Interface AdvancedAuthentication
-
- All Superinterfaces:
org.springframework.security.core.Authentication,Principal,Serializable
- All Known Implementing Classes:
DefaultAuthentication
public interface AdvancedAuthentication extends org.springframework.security.core.AuthenticationExtendsAuthenticationwith advanced features.- Since:
- 2020.04.001
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static AdvancedAuthenticationget()default <T> TgetAttribute(String key)Set<String>getPermissions()static Set<String>getPermissions(org.springframework.security.core.Authentication authentication)default booleanhasPermission(String permission)static booleanhasPermission(org.springframework.security.core.Authentication authentication, String permission)default voidsetAttribute(String key, Object value)
-
-
-
Method Detail
-
getAttribute
default <T> T getAttribute(String key)
- Type Parameters:
T- type of the expected return type.- Parameters:
key- thekeyof the requested attribute.- Returns:
- the attribute for the given
keyornullif not present.
-
getPermissions
Set<String> getPermissions()
- Returns:
- the
authoritiesas aSetof flatStrings. Allows to improve performance of of checks if permissions are present or not. - See Also:
hasPermission(String)
-
hasPermission
default boolean hasPermission(String permission)
- Parameters:
permission- the identifier of the permission to check.- Returns:
trueif the current user represented by thisAuthenticationhasthe givenpermission,falseotherwise.
-
hasPermission
static boolean hasPermission(org.springframework.security.core.Authentication authentication, String permission)- Parameters:
authentication- theAuthenticationto check.permission- the identifier of the permission to check.- Returns:
trueif the current user represented by the givenAuthenticationhasthe givenpermission,falseotherwise.
-
get
static AdvancedAuthentication get()
- Returns:
- the
AdvancedAuthenticationof the user currently authenticated as associated with this thread.
-
getPermissions
static Set<String> getPermissions(org.springframework.security.core.Authentication authentication)
- Parameters:
authentication- theAuthentication.- Returns:
- the
permissions.
-
-