Package io.undertow.security.impl
Class AbstractSecurityContext
java.lang.Object
io.undertow.security.impl.AbstractSecurityContext
- All Implemented Interfaces:
SecurityContext
- Direct Known Subclasses:
SecurityContextImpl
A base class for
SecurityContext implementations predominantly focusing on the notification handling allowing the
specific implementation for focus on authentication.- Author:
- Darran Lofthouse
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classTo reduce allocations we use a custom linked list data structure -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidauthenticationComplete(Account account, String mechanism, boolean cachingRequired) Called by theAuthenticationMechanismto indicate that an account has been successfully authenticated.protected voidauthenticationComplete(Account account, String mechanism, boolean programatic, boolean cachingRequired) voidauthenticationFailed(String message, String mechanism) Called by theAuthenticationMechanismto indicate that an authentication attempt has failed.Obtain theAccountfor the currently authenticated identity.booleanbooleanReturns true if authentication is requiredvoidlogout()de-authenticates the current exchange.voidRegister aNotificationReceiverinterested in receiving notifications for security events that happen on this SecurityContext.voidRemove a previously registeredNotificationReceiverfrom this SecurityContext.voidMarks this request as requiring authentication.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.undertow.security.api.SecurityContext
addAuthenticationMechanism, authenticate, getAuthenticationMechanisms, getIdentityManager, login
-
Field Details
-
exchange
-
-
Constructor Details
-
AbstractSecurityContext
-
-
Method Details
-
setAuthenticationRequired
public void setAuthenticationRequired()Description copied from interface:SecurityContextMarks this request as requiring authentication. Authentication challenge headers will only be sent if this method has been called. IfSecurityContext.authenticate()is called without first calling this method then the request will continue as normal even if the authentication was not successful.- Specified by:
setAuthenticationRequiredin interfaceSecurityContext
-
isAuthenticationRequired
public boolean isAuthenticationRequired()Description copied from interface:SecurityContextReturns true if authentication is required- Specified by:
isAuthenticationRequiredin interfaceSecurityContext- Returns:
trueIf authentication is required
-
isAuthenticated
public boolean isAuthenticated()- Specified by:
isAuthenticatedin interfaceSecurityContext- Returns:
- true if a user has been authenticated for this request, false otherwise.
-
getAuthenticatedAccount
Description copied from interface:SecurityContextObtain theAccountfor the currently authenticated identity.- Specified by:
getAuthenticatedAccountin interfaceSecurityContext- Returns:
- The
Accountfor the currently authenticated identity ornullif no account is currently authenticated.
-
getMechanismName
- Specified by:
getMechanismNamein interfaceSecurityContext- Returns:
- The name of the mechanism used to authenticate the request.
-
authenticationComplete
Description copied from interface:SecurityContextCalled by theAuthenticationMechanismto indicate that an account has been successfully authenticated. Note: A successful verification of an account using theIdentityManageris not the same as a successful authentication decision, other factors could be taken into account to make the final decision.- Specified by:
authenticationCompletein interfaceSecurityContext- Parameters:
account- - The authenticatedAccountmechanism- - The name of the mechanism used to authenticate the account.cachingRequired- - If this mechanism requires caching
-
authenticationComplete
-
authenticationFailed
Description copied from interface:SecurityContextCalled by theAuthenticationMechanismto indicate that an authentication attempt has failed. This should only be called where an authentication attempt has truly failed, for authentication mechanisms where an additional round trip with the client is expected this should not be called. Where possible the failure message should contain the name of the identity that authentication was being attempted for, however as this is not always possible to identify in advance a generic message may be all that can be reported.- Specified by:
authenticationFailedin interfaceSecurityContext- Parameters:
message- - The message describing the failure.mechanism- - The name of the mechanism reporting the failure.
-
registerNotificationReceiver
Description copied from interface:SecurityContextRegister aNotificationReceiverinterested in receiving notifications for security events that happen on this SecurityContext.- Specified by:
registerNotificationReceiverin interfaceSecurityContext- Parameters:
receiver- - TheNotificationReceiverto register.
-
removeNotificationReceiver
Description copied from interface:SecurityContextRemove a previously registeredNotificationReceiverfrom this SecurityContext. If the supplied receiver has not been previously registered this method will fail silently.- Specified by:
removeNotificationReceiverin interfaceSecurityContext- Parameters:
receiver- - TheNotificationReceiverto remove.
-
logout
public void logout()Description copied from interface:SecurityContextde-authenticates the current exchange.- Specified by:
logoutin interfaceSecurityContext
-