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 class
To reduce allocations we use a custom linked list data structure -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
authenticationComplete
(Account account, String mechanism, boolean cachingRequired) Called by theAuthenticationMechanism
to indicate that an account has been successfully authenticated.protected void
authenticationComplete
(Account account, String mechanism, boolean programatic, boolean cachingRequired) void
authenticationFailed
(String message, String mechanism) Called by theAuthenticationMechanism
to indicate that an authentication attempt has failed.Obtain theAccount
for the currently authenticated identity.boolean
boolean
Returns true if authentication is requiredvoid
logout()
de-authenticates the current exchange.void
Register aNotificationReceiver
interested in receiving notifications for security events that happen on this SecurityContext.void
Remove a previously registeredNotificationReceiver
from this SecurityContext.void
Marks this request as requiring authentication.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:SecurityContext
Marks 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:
setAuthenticationRequired
in interfaceSecurityContext
-
isAuthenticationRequired
public boolean isAuthenticationRequired()Description copied from interface:SecurityContext
Returns true if authentication is required- Specified by:
isAuthenticationRequired
in interfaceSecurityContext
- Returns:
true
If authentication is required
-
isAuthenticated
public boolean isAuthenticated()- Specified by:
isAuthenticated
in interfaceSecurityContext
- Returns:
- true if a user has been authenticated for this request, false otherwise.
-
getAuthenticatedAccount
Description copied from interface:SecurityContext
Obtain theAccount
for the currently authenticated identity.- Specified by:
getAuthenticatedAccount
in interfaceSecurityContext
- Returns:
- The
Account
for the currently authenticated identity ornull
if no account is currently authenticated.
-
getMechanismName
- Specified by:
getMechanismName
in interfaceSecurityContext
- Returns:
- The name of the mechanism used to authenticate the request.
-
authenticationComplete
Description copied from interface:SecurityContext
Called by theAuthenticationMechanism
to indicate that an account has been successfully authenticated. Note: A successful verification of an account using theIdentityManager
is not the same as a successful authentication decision, other factors could be taken into account to make the final decision.- Specified by:
authenticationComplete
in interfaceSecurityContext
- Parameters:
account
- - The authenticatedAccount
mechanism
- - The name of the mechanism used to authenticate the account.cachingRequired
- - If this mechanism requires caching
-
authenticationComplete
-
authenticationFailed
Description copied from interface:SecurityContext
Called by theAuthenticationMechanism
to 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:
authenticationFailed
in interfaceSecurityContext
- Parameters:
message
- - The message describing the failure.mechanism
- - The name of the mechanism reporting the failure.
-
registerNotificationReceiver
Description copied from interface:SecurityContext
Register aNotificationReceiver
interested in receiving notifications for security events that happen on this SecurityContext.- Specified by:
registerNotificationReceiver
in interfaceSecurityContext
- Parameters:
receiver
- - TheNotificationReceiver
to register.
-
removeNotificationReceiver
Description copied from interface:SecurityContext
Remove a previously registeredNotificationReceiver
from this SecurityContext. If the supplied receiver has not been previously registered this method will fail silently.- Specified by:
removeNotificationReceiver
in interfaceSecurityContext
- Parameters:
receiver
- - TheNotificationReceiver
to remove.
-
logout
public void logout()Description copied from interface:SecurityContext
de-authenticates the current exchange.- Specified by:
logout
in interfaceSecurityContext
-