Class AuthenticationUtils
java.lang.Object
com.foreach.across.modules.spring.security.AuthenticationUtils
Utility methods for authentication and authority checking.
Mainly for internal use within the Across framework.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanhasAuthority(SecurityPrincipal securityPrincipal, String authority) Check if aSecurityPrincipalhas as given authority string.static booleanhasAuthority(Collection<? extends org.springframework.security.core.GrantedAuthority> authorities, String authority) Check if a collection ofGrantedAuthoritycontains a specific authority string.static booleanhasAuthority(org.springframework.security.core.Authentication authentication, String authority) Check if an authentication has as given authority string.
-
Method Details
-
hasAuthority
Check if aSecurityPrincipalhas as given authority string. This assumes the call toSecurityPrincipal.getAuthorities()to be complete: all possible authorities should be present.- Parameters:
securityPrincipal- to checkauthority- to check for- Returns:
trueif 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 toAuthentication.getAuthorities()to be complete: all possible authorities should be present.- Parameters:
authentication- to checkauthority- to check for- Returns:
trueif authority was present
-
hasAuthority
public static boolean hasAuthority(Collection<? extends org.springframework.security.core.GrantedAuthority> authorities, String authority) Check if a collection ofGrantedAuthoritycontains a specific authority string.- Parameters:
authorities- collection of authoritiesauthority- string to check for- Returns:
trueif authority was present
-