Class AuthenticationUtils

java.lang.Object
com.foreach.across.modules.spring.security.AuthenticationUtils

public final class AuthenticationUtils extends Object
Utility methods for authentication and authority checking. Mainly for internal use within the Across framework.
  • Method Details

    • hasAuthority

      public static boolean hasAuthority(SecurityPrincipal securityPrincipal, String authority)
      Check if a SecurityPrincipal has as given authority string. This assumes the call to SecurityPrincipal.getAuthorities() to be complete: all possible authorities should be present.
      Parameters:
      securityPrincipal - to check
      authority - to check for
      Returns:
      true if authority was present
    • hasAuthority

      public static boolean hasAuthority(org.springframework.security.core.Authentication authentication, String authority)
      Check if an authentication has as given authority string. This assumes the call to Authentication.getAuthorities() to be complete: all possible authorities should be present.
      Parameters:
      authentication - to check
      authority - to check for
      Returns:
      true if authority was present
    • hasAuthority

      public static boolean hasAuthority(Collection<? extends org.springframework.security.core.GrantedAuthority> authorities, String authority)
      Check if a collection of GrantedAuthority contains a specific authority string.
      Parameters:
      authorities - collection of authorities
      authority - string to check for
      Returns:
      true if authority was present