Class GenericPrincipalAuthentication
- All Implemented Interfaces:
Authentication,PrincipalAuthentication
Generic PrincipalAuthentication implementation.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Constructor Summary
ConstructorsConstructorDescriptionGenericPrincipalAuthentication(String username, boolean authenticated) Creates a generic principal authentication with the specified username. -
Method Summary
Modifier and TypeMethodDescriptionbooleangetCause()Returns the cause of a failed authentication.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
-
GenericPrincipalAuthentication
Creates a generic principal authentication with the specified username.
- Parameters:
username- the usernameauthenticated- 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
-
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
-