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

public Class BasicAuthenticationMechanism

extends Object
implements AuthenticationMechanism
Class Inheritance
All Implemented Interfaces
io.undertow.security.api.AuthenticationMechanism
Static Imports
io.undertow.UndertowMessages.MESSAGES, io.undertow.util.Headers.AUTHORIZATION, .Headers.BASIC, .Headers.WWW_AUTHENTICATE, .StatusCodes.UNAUTHORIZED

The authentication handler responsible for BASIC authentication as described by RFC2617
Author
Darran Lofthouse

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private static final String
private final String
public static final String
private final Charset
private static final String
public static final AuthenticationMechanismFactory
private final IdentityManager
private static final String
private final String
private static final int
public static final String
private final boolean
silent

If silent is true then this mechanism will only take effect if there is an Authorization header.

public static final String
USER_AGENT_CHARSETS

A comma separated list of patterns and charsets.

private final Map<Pattern, Charset>

Constructor Summary

AccessConstructor and Description
public
public
BasicAuthenticationMechanism(final String realmName, final String mechanismName)

public
BasicAuthenticationMechanism(final String realmName, final String mechanismName, final boolean silent)

public
BasicAuthenticationMechanism(final String realmName, final String mechanismName, final boolean silent, final IdentityManager identityManager)

public
BasicAuthenticationMechanism(final String realmName, final String mechanismName, final boolean silent, final IdentityManager identityManager, Charset charset, Map<Pattern, Charset> userAgentCharsets)

Method Summary

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

Implements io.undertow.security.api.AuthenticationMechanism.authenticate.

Perform authentication of the request.

private static void
clear(final char[] array)

private IdentityManager
public AuthenticationMechanism.ChallengeResult
sendChallenge(HttpServerExchange
The exchange
exchange
,
SecurityContext
The security context
securityContext
)

Implements io.undertow.security.api.AuthenticationMechanism.sendChallenge.

Send an authentication challenge to the remote client.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BASIC_PREFIXback to summary
private static final String BASIC_PREFIX
challengeback to summary
private final String challenge
CHARSETback to summary
public static final String CHARSET
charsetback to summary
private final Charset charset
COLONback to summary
private static final String COLON
FACTORYback to summary
public static final AuthenticationMechanismFactory FACTORY
identityManagerback to summary
private final IdentityManager identityManager
LOWERCASE_BASIC_PREFIXback to summary
private static final String LOWERCASE_BASIC_PREFIX
nameback to summary
private final String name
PREFIX_LENGTHback to summary
private static final int PREFIX_LENGTH
SILENTback to summary
public static final String SILENT
silentback to summary
private final boolean silent

If silent is true then this mechanism will only take effect if there is an Authorization header. This allows you to combine basic auth with form auth, so human users will use form based auth, but allows programmatic clients to login using basic auth.

USER_AGENT_CHARSETSback to summary
public static final String USER_AGENT_CHARSETS

A comma separated list of patterns and charsets. The pattern is a regular expression. Because different browsers user different encodings this allows for the correct encoding to be selected based on the current browser. In general though it is recommended that BASIC auth not be used when passwords contain characters outside ASCII, as some browsers use the current locate to determine encoding. This list must have an even number of elements, as it is interpreted as pattern,charset,pattern,charset,...

userAgentCharsetsback to summary
private final Map<Pattern, Charset> userAgentCharsets

Constructor Detail

BasicAuthenticationMechanismback to summary
public BasicAuthenticationMechanism(final String realmName)
BasicAuthenticationMechanismback to summary
public BasicAuthenticationMechanism(final String realmName, final String mechanismName)
BasicAuthenticationMechanismback to summary
public BasicAuthenticationMechanism(final String realmName, final String mechanismName, final boolean silent)
BasicAuthenticationMechanismback to summary
public BasicAuthenticationMechanism(final String realmName, final String mechanismName, final boolean silent, final IdentityManager identityManager)
BasicAuthenticationMechanismback to summary
public BasicAuthenticationMechanism(final String realmName, final String mechanismName, final boolean silent, final IdentityManager identityManager, Charset charset, Map<Pattern, Charset> userAgentCharsets)

Method Detail

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

Implements io.undertow.security.api.AuthenticationMechanism.authenticate.

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

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

Parameters
exchange:HttpServerExchange

The exchange

Annotations
@Override
See Also
io.undertow.server.HttpHandler#handleRequest(io.undertow.server.HttpServerExchange)
clearback to summary
private static void clear(final char[] array)
getIdentityManagerback to summary
private IdentityManager getIdentityManager(SecurityContext securityContext)
Annotations
@SuppressWarnings:deprecation
sendChallengeback to summary
public AuthenticationMechanism.ChallengeResult sendChallenge(HttpServerExchange exchange, SecurityContext securityContext)

Implements io.undertow.security.api.AuthenticationMechanism.sendChallenge.

Doc from io.undertow.security.api.AuthenticationMechanism.sendChallenge.

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.

Annotations
@Override
io.undertow.security.impl back to summary

public Class BasicAuthenticationMechanism.Factory

extends Object
implements AuthenticationMechanismFactory
Class Inheritance
  • java.lang.Object
  • io.undertow.security.impl.BasicAuthenticationMechanism.Factory
All Implemented Interfaces
io.undertow.security.api.AuthenticationMechanismFactory

Constructor Summary

AccessConstructor and Description
public
Factory(IdentityManager identityManager)
Deprecated

public

Method Summary

Modifier and TypeMethod and Description
public AuthenticationMechanism
create(String
The name under which this factory was registered
mechanismName
,
IdentityManager
the IdentityManager instance asscociated with the deployment
identityManager
,
FormParserFactory
Parser to create a form data parser for a given request.
formParserFactory
,
Map<String, String>
The properties
properties
)

Overrides default io.undertow.security.api.AuthenticationMechanismFactory.create.

Creates an authentication mechanism that needs access to the deployment IdentityManager and specified properties

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Factoryback to summary
public Factory(IdentityManager identityManager)

Deprecated

Annotations
@Deprecated
Factoryback to summary
public Factory()

Method Detail

createback to summary
public AuthenticationMechanism create(String mechanismName, IdentityManager identityManager, FormParserFactory formParserFactory, Map<String, String> properties)

Overrides default io.undertow.security.api.AuthenticationMechanismFactory.create.

Doc from io.undertow.security.api.AuthenticationMechanismFactory.create.

Creates an authentication mechanism that needs access to the deployment IdentityManager and specified properties

Parameters
mechanismName:String

The name under which this factory was registered

identityManager:IdentityManager

the IdentityManager instance asscociated with the deployment

formParserFactory:FormParserFactory

Parser to create a form data parser for a given request.

properties:Map<String, String>

The properties

Returns:AuthenticationMechanism

The mechanism

Annotations
@Override