Top Description Inners Methods
io.undertow.security.api

public Interface AuthenticationMechanism

Known Direct Implementers
io.undertow.security.impl.BasicAuthenticationMechanism, io.undertow.security.impl.CachedAuthenticatedSessionMechanism, io.undertow.security.impl.ClientCertAuthenticationMechanism, io.undertow.security.impl.DigestAuthenticationMechanism, io.undertow.security.impl.ExternalAuthenticationMechanism, io.undertow.security.impl.FormAuthenticationMechanism, io.undertow.security.impl.GenericHeaderAuthenticationMechanism, io.undertow.security.impl.GSSAPIAuthenticationMechanism, io.undertow.security.impl.SingleSignOnAuthenticationMechanism
Imports
io.undertow.server.HttpServerExchange

The interface to be implemented by a single authentication mechanism.

The implementation of this interface are assumed to be stateless, if there is a need to share state between the authenticate and handleComplete calls then it should be held in the HttpServerExchange.

As an in-bound request is received the authenticate method is called on each mechanism in turn until one of the following occurs: - - A mechanism successfully authenticates the incoming request. - A mechanism attempts but fails to authenticate the request. - The list of mechanisms is exhausted.

This means that if the authenticate method is called on a mechanism it should assume it is required to check if it can actually authenticate the incoming request, anything that would prevent it from performing the check would have already stopped the authenticate method from being called.

Authentication is allowed to proceed if either authentication was required AND one handler authenticated the request or it is allowed to proceed if it is not required AND no handler failed to authenticate the request.

The handleComplete methods are used as the request processing is returning up the chain, primarily these are used to challenge the client to authenticate but where supported by the mechanism they could also be used to send mechanism specific updates back with a request.

If a mechanism successfully authenticated the incoming request then only the handleComplete method on that mechanism is called.

If any mechanism failed or if authentication was required and no mechanism succeeded in authenticating the request then handleComplete will be called for all mechanisms.

Finally if authentication was not required handleComplete will not be called for any of the mechanisms.

The mechanisms will need to double check why handleComplete is being called, if the request was authenticated then they should do nothing unless the mechanism has intermediate state to send back. If the request was not authenticated then a challenge should be sent.

Authors
Stuart Douglas, Darran Lofthouse

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
AuthenticationMechanism.AuthenticationMechanismOutcome

The AuthenticationOutcome is used by an AuthenticationMechanism to indicate the outcome of the call to authenticate, the overall authentication process will then used this along with the current AuthenticationState to decide how to proceed with the current request.

public static class
AuthenticationMechanism.ChallengeResult

Simple class to wrap the result of requesting a mechanism sends it's challenge.

Method Summary

Modifier and TypeMethod and Description
public AuthenticationMechanism.AuthenticationMechanismOutcome
authenticate(final HttpServerExchange
The exchange
exchange
,
final SecurityContext securityContext)

Perform authentication of the request.

public AuthenticationMechanism.ChallengeResult

Returns:

A ChallengeResult indicating if a challenge was sent and the desired response code.
sendChallenge
(final HttpServerExchange
The exchange
exchange
,
final SecurityContext
The security context
securityContext
)

Send an authentication challenge to the remote client.

Method Detail

authenticateback to summary
public AuthenticationMechanism.AuthenticationMechanismOutcome authenticate(final HttpServerExchange exchange, final SecurityContext securityContext)

Perform authentication of the request. Any potentially blocking work should be performed in the handoff executor provided

Parameters
exchange:HttpServerExchange

The exchange

sendChallengeback to summary
public AuthenticationMechanism.ChallengeResult sendChallenge(final HttpServerExchange exchange, final SecurityContext securityContext)

Send an authentication challenge to the remote client.

The individual mechanisms should update the response headers and body of the message as appropriate however they should not set the response code, instead that should be indicated in the ChallengeResult and the most appropriate overall response code will be selected. This method should not return null.

Parameters
exchange:HttpServerExchange

The exchange

securityContext:SecurityContext

The security context

Returns:AuthenticationMechanism.ChallengeResult

A ChallengeResult indicating if a challenge was sent and the desired response code.

io.undertow.security.api back to summary

public final Enum AuthenticationMechanism.AuthenticationMechanismOutcome

extends Enum<AuthenticationMechanism.AuthenticationMechanismOutcome>
Class Inheritance

The AuthenticationOutcome is used by an AuthenticationMechanism to indicate the outcome of the call to authenticate, the overall authentication process will then used this along with the current AuthenticationState to decide how to proceed with the current request.

Field Summary

Modifier and TypeField and Description
public static final AuthenticationMechanism.AuthenticationMechanismOutcome
AUTHENTICATED

Based on the current request the mechanism has successfully performed authentication.

public static final AuthenticationMechanism.AuthenticationMechanismOutcome
NOT_ATTEMPTED

The mechanism did not attempt authentication on this request, most likely due to not discovering any applicable security tokens for this mechanisms in the request.

public static final AuthenticationMechanism.AuthenticationMechanismOutcome
NOT_AUTHENTICATED

The mechanism attempted authentication but it did not complete, this could either be due to a failure validating the tokens from the client or it could be due to the mechanism requiring at least one additional round trip with the client - either way the request will return challenges to the client.

Constructor Summary

AccessConstructor and Description
private

Method Summary

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

Field Detail

AUTHENTICATEDback to summary
public static final AuthenticationMechanism.AuthenticationMechanismOutcome AUTHENTICATED

Based on the current request the mechanism has successfully performed authentication.

NOT_ATTEMPTEDback to summary
public static final AuthenticationMechanism.AuthenticationMechanismOutcome NOT_ATTEMPTED

The mechanism did not attempt authentication on this request, most likely due to not discovering any applicable security tokens for this mechanisms in the request.

NOT_AUTHENTICATEDback to summary
public static final AuthenticationMechanism.AuthenticationMechanismOutcome NOT_AUTHENTICATED

The mechanism attempted authentication but it did not complete, this could either be due to a failure validating the tokens from the client or it could be due to the mechanism requiring at least one additional round trip with the client - either way the request will return challenges to the client.

Constructor Detail

AuthenticationMechanismOutcomeback to summary
private AuthenticationMechanismOutcome()

Method Detail

valueOfback to summary
public static AuthenticationMechanism.AuthenticationMechanismOutcome valueOf(String name)
valuesback to summary
public static AuthenticationMechanism.AuthenticationMechanismOutcome[] values()
io.undertow.security.api back to summary

public Class AuthenticationMechanism.ChallengeResult

extends Object
Class Inheritance
  • java.lang.Object
  • io.undertow.security.api.AuthenticationMechanism.ChallengeResult

Simple class to wrap the result of requesting a mechanism sends it's challenge.

Field Summary

Modifier and TypeField and Description
private final boolean
public static final AuthenticationMechanism.ChallengeResult
private final Integer

Constructor Summary

AccessConstructor and Description
public
ChallengeResult(final boolean challengeSent, final Integer statusCode)

public
ChallengeResult(final boolean challengeSent)

Method Summary

Modifier and TypeMethod and Description
public Integer

Returns:

The desired response code or null if no code specified.
getDesiredResponseCode
()

Obtain the response code desired by this mechanism for the challenge.

public boolean

Returns:

true if a challenge was sent, false otherwise.
isChallengeSent
()

Check if the mechanism did send a challenge.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

challengeSentback to summary
private final boolean challengeSent
NOT_SENTback to summary
public static final AuthenticationMechanism.ChallengeResult NOT_SENT
statusCodeback to summary
private final Integer statusCode

Constructor Detail

ChallengeResultback to summary
public ChallengeResult(final boolean challengeSent, final Integer statusCode)
ChallengeResultback to summary
public ChallengeResult(final boolean challengeSent)

Method Detail

getDesiredResponseCodeback to summary
public Integer getDesiredResponseCode()

Obtain the response code desired by this mechanism for the challenge.

Where multiple mechanisms are in use concurrently all of the requested response codes will be checked and the most suitable one selected. If no specific response code is required any value less than 0 can be set.

Returns:Integer

The desired response code or null if no code specified.

isChallengeSentback to summary
public boolean isChallengeSent()

Check if the mechanism did send a challenge.

Some mechanisms do not send a challenge and just rely on the correct information to authenticate a user being available in the request, in that case it would be normal for the mechanism to set this to false.

Returns:boolean

true if a challenge was sent, false otherwise.