Class DefaultAuthentication
- java.lang.Object
-
- org.springframework.security.authentication.AbstractAuthenticationToken
-
- org.springframework.security.authentication.UsernamePasswordAuthenticationToken
-
- com.devonfw.module.security.common.api.authentication.DefaultAuthentication
-
- All Implemented Interfaces:
AdvancedAuthentication,Serializable,Principal,org.springframework.security.core.Authentication,org.springframework.security.core.CredentialsContainer
public class DefaultAuthentication extends org.springframework.security.authentication.UsernamePasswordAuthenticationToken implements AdvancedAuthentication
Implementation ofAdvancedAuthenticationto be used by default in devon4j apps after successful authentication.- Since:
- 2020.04.001
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DefaultAuthentication(Object principal, Object credentials, Collection<? extends org.springframework.security.core.GrantedAuthority> authorities)The constructor.DefaultAuthentication(Object principal, Object credentials, Collection<? extends org.springframework.security.core.GrantedAuthority> authorities, Map<String,Object> attributes)The constructor.DefaultAuthentication(Object principal, Object credentials, Set<String> permissions)The constructor.DefaultAuthentication(Object principal, Object credentials, Set<String> permissions, Map<String,Object> attributes)The constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TgetAttribute(String key)Map<String,Object>getAttributes()Set<String>getPermissions()static DefaultAuthenticationofAccessControls(Object principal, Object credentials, Collection<? extends AccessControl> accessControls, Map<String,Object> attributes)Creates a newDefaultAuthenticationinstance for the provided values.voidsetAttribute(String key, Object value)-
Methods inherited from class org.springframework.security.authentication.UsernamePasswordAuthenticationToken
eraseCredentials, getCredentials, getPrincipal, setAuthenticated
-
Methods inherited from class org.springframework.security.authentication.AbstractAuthenticationToken
equals, getAuthorities, getDetails, getName, hashCode, isAuthenticated, setDetails, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.devonfw.module.security.common.api.authentication.AdvancedAuthentication
hasPermission
-
-
-
-
Constructor Detail
-
DefaultAuthentication
public DefaultAuthentication(Object principal, Object credentials, Collection<? extends org.springframework.security.core.GrantedAuthority> authorities)
The constructor.- Parameters:
principal- theprincipal.credentials- the optionalcredentials.authorities- theauthorities.
-
DefaultAuthentication
public DefaultAuthentication(Object principal, Object credentials, Collection<? extends org.springframework.security.core.GrantedAuthority> authorities, Map<String,Object> attributes)
The constructor.- Parameters:
principal- theprincipal.credentials- the optionalcredentials.authorities- theauthorities.attributes- theMapofattributes. UseCollections.unmodifiableMap(Map)to preventmutation.
-
DefaultAuthentication
public DefaultAuthentication(Object principal, Object credentials, Set<String> permissions)
The constructor.- Parameters:
principal- theprincipal.credentials- the optionalcredentials.permissions- thepermissions.
-
DefaultAuthentication
public DefaultAuthentication(Object principal, Object credentials, Set<String> permissions, Map<String,Object> attributes)
The constructor.- Parameters:
principal- theprincipal.credentials- the optionalcredentials.permissions- thepermissions.attributes- theMapofattributes. UseCollections.unmodifiableMap(Map)to preventmutation.
-
-
Method Detail
-
ofAccessControls
public static DefaultAuthentication ofAccessControls(Object principal, Object credentials, Collection<? extends AccessControl> accessControls, Map<String,Object> attributes)
Creates a newDefaultAuthenticationinstance for the provided values.- Parameters:
principal- theprincipal.credentials- the optionalcredentials.accessControls- thepermissions.attributes- theMapofattributes. UseCollections.unmodifiableMap(Map)to preventmutation.- Returns:
- New
DefaultAuthentication.
-
getPermissions
public Set<String> getPermissions()
- Specified by:
getPermissionsin interfaceAdvancedAuthentication- Returns:
- the
authoritiesas aSetof flatStrings. Allows to improve performance of of checks if permissions are present or not. - See Also:
AdvancedAuthentication.hasPermission(String)
-
getAttribute
public <T> T getAttribute(String key)
- Specified by:
getAttributein interfaceAdvancedAuthentication- Type Parameters:
T- type of the expected return type.- Parameters:
key- thekeyof the requested attribute.- Returns:
- the attribute for the given
keyornullif not present.
-
setAttribute
public void setAttribute(String key, Object value)
- Specified by:
setAttributein interfaceAdvancedAuthentication- Parameters:
key- thekeyto set. May not benull.value- thevalueto set. May not benull.
-
-