Top Description Inners Fields Constructors Methods
io.undertow.security.impl

public Class SecurityContextImpl

extends AbstractSecurityContext
implements AuthenticationMechanismContext
Class Inheritance
All Implemented Interfaces
io.undertow.security.api.AuthenticationMechanismContext, io.undertow.security.api.SecurityContext
Imports
io.undertow.UndertowLogger, .UndertowMessages, io.undertow.security.api.AuthenticationMechanism, .AuthenticationMechanism.AuthenticationMechanismOutcome, .AuthenticationMechanism.ChallengeResult, .AuthenticationMechanismContext, .AuthenticationMode, io.undertow.security.idm.Account, .IdentityManager, .PasswordCredential, io.undertow.server.HttpServerExchange, io.undertow.util.StatusCodes, java.security.AccessController, .PrivilegedAction, java.util.Collections, .LinkedList, .List

The internal SecurityContext used to hold the state of security for the current exchange.
Authors
Darran Lofthouse, Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
pack-priv static enum
SecurityContextImpl.AuthenticationState

Representation of the current authentication state of the SecurityContext.

private class
SecurityContextImpl.ChallengeSender

Class responsible for sending the authentication challenges.

private static class
SecurityContextImpl.Node<T>

To reduce allocations we use a custom linked list data structure

Field Summary

Modifier and TypeField and Description
private final AuthenticationMode
private SecurityContextImpl.AuthenticationState
private SecurityContextImpl.Node<AuthenticationMechanism>
authMechanisms

the authentication mechanisms.

private final IdentityManager
private static final RuntimePermission
private String
Inherited from io.undertow.security.impl.AbstractSecurityContext:
exchange

Constructor Summary

AccessConstructor and Description
public
SecurityContextImpl(final HttpServerExchange exchange, final IdentityManager identityManager)

public
SecurityContextImpl(final HttpServerExchange exchange, final AuthenticationMode authenticationMode, final IdentityManager identityManager)

Method Summary

Modifier and TypeMethod and Description
public void
private SecurityContextImpl.AuthenticationState
public boolean
authenticate()

Implements io.undertow.security.api.SecurityContext.authenticate.

Performs authentication on the request.

private boolean
private boolean
public List<AuthenticationMechanism>
public IdentityManager
getIdentityManager()

Implements io.undertow.security.api.SecurityContext.getIdentityManager.

Deprecated

Obtain the associated IdentityManager to use to make account verification decisions.

public boolean
login(final String
The username
username
,
final String
The password
password
)

Implements io.undertow.security.api.SecurityContext.login.

Attempts to log the user in using the provided credentials.

public void
private SecurityContextImpl.AuthenticationState
public void
setProgramaticMechName(final String programaticMechName)

Set the name of the mechanism used for authentication to be reported if authentication was handled programatically.

Inherited from io.undertow.security.impl.AbstractSecurityContext:
authenticationCompleteauthenticationCompleteauthenticationFailedgetAuthenticatedAccountgetMechanismNameisAuthenticatedisAuthenticationRequiredregisterNotificationReceiverremoveNotificationReceiversetAuthenticationRequired

Field Detail

authenticationModeback to summary
private final AuthenticationMode authenticationMode
authenticationStateback to summary
private SecurityContextImpl.AuthenticationState authenticationState
authMechanismsback to summary
private SecurityContextImpl.Node<AuthenticationMechanism> authMechanisms

the authentication mechanisms. Note that in order to reduce the allocation of list and iterator structures we use a custom linked list structure.

identityManagerback to summary
private final IdentityManager identityManager
PERMISSIONback to summary
private static final RuntimePermission PERMISSION
programaticMechNameback to summary
private String programaticMechName

Constructor Detail

SecurityContextImplback to summary
public SecurityContextImpl(final HttpServerExchange exchange, final IdentityManager identityManager)
SecurityContextImplback to summary
public SecurityContextImpl(final HttpServerExchange exchange, final AuthenticationMode authenticationMode, final IdentityManager identityManager)

Method Detail

addAuthenticationMechanismback to summary
public void addAuthenticationMechanism(final AuthenticationMechanism handler)

Implements io.undertow.security.api.AuthenticationMechanismContext.addAuthenticationMechanism, io.undertow.security.api.SecurityContext.addAuthenticationMechanism.

Doc from io.undertow.security.api.AuthenticationMechanismContext.addAuthenticationMechanism.

Adds an authentication mechanism to this context. When authenticate() is called mechanisms will be iterated over in the order they are added, and given a chance to authenticate the user.

Parameters
handler:AuthenticationMechanism

The mechanism to add

Annotations
@Override
attemptAuthenticationback to summary
private SecurityContextImpl.AuthenticationState attemptAuthentication()
authenticateback to summary
public boolean authenticate()

Implements io.undertow.security.api.SecurityContext.authenticate.

Doc from io.undertow.security.api.SecurityContext.authenticate.

Performs authentication on the request. If authentication is REQUIRED then setAuthenticationRequired() should be called before calling this method. If the result indicates that a response has been sent to the client then no further attempts should be made to modify the response. The caller of this method is responsible for ending the exchange. If this method returns true it can still have committed the response (e.g. form auth redirects back to the original page). Callers should check that the exchange has not been ended before proceeding.

Returns:boolean

true if either the request is successfully authenticated or if there is no failure validating the current request so that the request should continue to be processed, false if authentication was not completed and challenge has been prepared for the client.

Annotations
@Override
authTransitionback to summary
private boolean authTransition()
authTransitionRequiredback to summary
private boolean authTransitionRequired()
getAuthenticationMechanismsback to summary
public List<AuthenticationMechanism> getAuthenticationMechanisms()

Implements io.undertow.security.api.SecurityContext.getAuthenticationMechanisms.

Deprecated

Returns:List<AuthenticationMechanism>

Doc from io.undertow.security.api.SecurityContext.getAuthenticationMechanisms.

A list of all authentication mechanisms in this context

Annotations
@Override
@Deprecated
getIdentityManagerback to summary
public IdentityManager getIdentityManager()

Implements io.undertow.security.api.SecurityContext.getIdentityManager.

Doc from io.undertow.security.api.SecurityContext.getIdentityManager.

Deprecated

Obtain the associated IdentityManager to use to make account verification decisions.

Returns:IdentityManager

The associated IdentityManager

Annotations
@Override
@Deprecated
loginback to summary
public boolean login(final String username, final String password)

Implements io.undertow.security.api.SecurityContext.login.

Doc from io.undertow.security.api.SecurityContext.login.

Attempts to log the user in using the provided credentials. This result will be stored in the current AuthenticatedSessionManager (if any), so subsequent requests will automatically be authenticated as this user.

This operation may block

Parameters
username:String

The username

password:String

The password

Returns:boolean

true if the login succeeded, false otherwise

Annotations
@Override
logoutback to summary
public void logout()

Overrides io.undertow.security.impl.AbstractSecurityContext.logout.

Implements io.undertow.security.api.SecurityContext.logout.

Doc from io.undertow.security.api.SecurityContext.logout.

de-authenticates the current exchange.

Annotations
@Override
sendChallengesback to summary
private SecurityContextImpl.AuthenticationState sendChallenges()
setProgramaticMechNameback to summary
public void setProgramaticMechName(final String programaticMechName)

Set the name of the mechanism used for authentication to be reported if authentication was handled programatically.

io.undertow.security.impl back to summary

private Class SecurityContextImpl.AuthAttempter

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private SecurityContextImpl.Node<AuthenticationMechanism>
private final HttpServerExchange

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private SecurityContextImpl.AuthenticationState
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentMethodback to summary
private SecurityContextImpl.Node<AuthenticationMechanism> currentMethod
exchangeback to summary
private final HttpServerExchange exchange

Constructor Detail

AuthAttempterback to summary
private AuthAttempter(SecurityContextImpl.Node<AuthenticationMechanism> currentMethod, final HttpServerExchange exchange)

Method Detail

transitionback to summary
private SecurityContextImpl.AuthenticationState transition()
io.undertow.security.impl back to summary

pack-priv final Enum SecurityContextImpl.AuthenticationState

extends Enum<SecurityContextImpl.AuthenticationState>
Class Inheritance

Representation of the current authentication state of the SecurityContext.

Field Summary

Modifier and TypeField and Description
public static final SecurityContextImpl.AuthenticationState
public static final SecurityContextImpl.AuthenticationState
public static final SecurityContextImpl.AuthenticationState
public static final SecurityContextImpl.AuthenticationState

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static SecurityContextImpl.AuthenticationState
public static SecurityContextImpl.AuthenticationState[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ATTEMPTEDback to summary
public static final SecurityContextImpl.AuthenticationState ATTEMPTED
AUTHENTICATEDback to summary
public static final SecurityContextImpl.AuthenticationState AUTHENTICATED
CHALLENGE_SENTback to summary
public static final SecurityContextImpl.AuthenticationState CHALLENGE_SENT
NOT_ATTEMPTEDback to summary
public static final SecurityContextImpl.AuthenticationState NOT_ATTEMPTED

Constructor Detail

AuthenticationStateback to summary
private AuthenticationState()

Method Detail

valueOfback to summary
public static SecurityContextImpl.AuthenticationState valueOf(String name)
valuesback to summary
public static SecurityContextImpl.AuthenticationState[] values()
io.undertow.security.impl back to summary

private Class SecurityContextImpl.ChallengeSender

extends Object
Class Inheritance
  • java.lang.Object
  • io.undertow.security.impl.SecurityContextImpl.ChallengeSender

Class responsible for sending the authentication challenges.

Field Summary

Modifier and TypeField and Description
private boolean
private Integer
private SecurityContextImpl.Node<AuthenticationMechanism>
private final HttpServerExchange

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private SecurityContextImpl.AuthenticationState
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

challengeSentback to summary
private boolean challengeSent
chosenStatusCodeback to summary
private Integer chosenStatusCode
currentMethodback to summary
private SecurityContextImpl.Node<AuthenticationMechanism> currentMethod
exchangeback to summary
private final HttpServerExchange exchange

Constructor Detail

ChallengeSenderback to summary
private ChallengeSender(SecurityContextImpl.Node<AuthenticationMechanism> currentMethod, final HttpServerExchange exchange)

Method Detail

transitionback to summary
private SecurityContextImpl.AuthenticationState transition()
io.undertow.security.impl back to summary

private final Class SecurityContextImpl.Node<T>

extends Object
Class Inheritance

To reduce allocations we use a custom linked list data structure

Field Summary

Modifier and TypeField and Description
pack-priv final T
pack-priv SecurityContextImpl.Node<T>

Constructor Summary

AccessConstructor and Description
private
Node(T item)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

itemback to summary
pack-priv final T item
nextback to summary
pack-priv SecurityContextImpl.Node<T> next

Constructor Detail

Nodeback to summary
private Node(T item)