Class GenericUserAuthentication<A extends Identity>
- Type Parameters:
A- the type of identity
- All Implemented Interfaces:
Authentication,GroupAwareAuthentication,PrincipalAuthentication,UserAuthentication<A>
Generic UserAuthentication implementation.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Constructor Summary
ConstructorsConstructorDescriptionGenericUserAuthentication(String username, A identity, Set<String> groups, boolean authenticated) Creates a generic user authentication with the specified username, identity and set of groups. -
Method Summary
Modifier and TypeMethodDescriptionbooleangetCause()Returns the cause of a failed authentication.Returns the groups to which the authenticated entity belongs to.Returns the user's identity.Returns the unique username of the authenticated entity.inthashCode()booleanDetermine whether the authentication is authenticated.voidsetCause(SecurityException cause) Sets the cause of the failed authentication.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.inverno.mod.security.authentication.Authentication
isAnonymous
-
Constructor Details
-
GenericUserAuthentication
public GenericUserAuthentication(String username, A identity, Set<String> groups, boolean authenticated) Creates a generic user authentication with the specified username, identity and set of groups.
- Parameters:
username- a usernameidentity- an identitygroups- a set of groupsauthenticated- true to create an authenticated authentication, false otherwise
-
-
Method Details
-
setCause
Sets the cause of the failed authentication.
This also sets the authenticated flag to false when the specified cause is not null.
- Parameters:
cause- a security exception resulting from the failed authentication
-
getUsername
Description copied from interface:PrincipalAuthenticationReturns the unique username of the authenticated entity.
- Specified by:
getUsernamein interfacePrincipalAuthentication- Returns:
- a username
-
getGroups
Description copied from interface:GroupAwareAuthenticationReturns the groups to which the authenticated entity belongs to.
- Specified by:
getGroupsin interfaceGroupAwareAuthentication- Returns:
- a sets of groups
-
getIdentity
Description copied from interface:UserAuthenticationReturns the user's identity.
- Specified by:
getIdentityin interfaceUserAuthentication<A extends Identity>- Returns:
- the user identity or null if none was resolved during the authentication process.
-
isAuthenticated
public boolean isAuthenticated()Description copied from interface:AuthenticationDetermine whether the authentication is authenticated.
A non-authenticated authentication might indicates that no authentication took place (i.e. anonymous access) or that the authentication failed. In case of a failed authentication, the cause is exposed by
Authentication.getCause().- Specified by:
isAuthenticatedin interfaceAuthentication- Returns:
- true if the the authentication is authenticated, false otherwise
-
getCause
Description copied from interface:AuthenticationReturns the cause of a failed authentication.
A non-authenticated authentication with no cause indicates that no authentication took place (i.e. anonymous access).
A non-authenticated authentication with a cause indicates a failed authentication.
- Specified by:
getCausein interfaceAuthentication- Returns:
- an optional returning the cause of the failed authentication, or an empty optional if there was no authentication or if the authentication was successful
-
hashCode
public int hashCode() -
equals
-