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 boolean
hasAuthority
(SecurityPrincipal securityPrincipal, String authority) Check if aSecurityPrincipal
has as given authority string.static boolean
hasAuthority
(Collection<? extends org.springframework.security.core.GrantedAuthority> authorities, String authority) Check if a collection ofGrantedAuthority
contains a specific authority string.static boolean
hasAuthority
(org.springframework.security.core.Authentication authentication, String authority) Check if an authentication has as given authority string.
-
Method Details
-
hasAuthority
Check if aSecurityPrincipal
has 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:
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 toAuthentication.getAuthorities()
to be complete: all possible authorities should be present.- Parameters:
authentication
- to checkauthority
- 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 ofGrantedAuthority
contains a specific authority string.- Parameters:
authorities
- collection of authoritiesauthority
- string to check for- Returns:
true
if authority was present
-