Class MockChallengeHttpSecuritySource
- All Implemented Interfaces:
HttpSecurity<MockAuthentication,,MockAccessControl, Void, None, None> HttpSecuritySource<MockAuthentication,MockAccessControl, Void, None, None>
Mock HttpSecuritySource to use for testing with challenges.
It provides a MockAuthentication and MockAccessControl by the
following Basic authentication scheme, except that:
- authentication is obtained by user name and password being the same
- the
MockAccessControlis provided the user name as a role (allows logging in with various roles for testing). Multiple roles can be specified by the user name being a comma separate list.
- Author:
- Daniel Sagenschneider
-
Nested Class Summary
Nested classes/interfaces inherited from class net.officefloor.web.spi.security.impl.AbstractHttpSecuritySource
AbstractHttpSecuritySource.DependencyLabeller, AbstractHttpSecuritySource.Labeller, AbstractHttpSecuritySource.MetaDataContext<A,AC extends Serializable, C, O extends Enum<O>, F extends Enum<F>>, AbstractHttpSecuritySource.SpecificationContext -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringAuthentication scheme reported to the application via theHttpAccessControl.static final StringName ofPropertyto configure the realm.Fields inherited from class net.officefloor.web.spi.security.impl.AbstractHttpSecuritySource
UTF_8 -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Instantiate with the realm. -
Method Summary
Modifier and TypeMethodDescriptionvoidauthenticate(Void credentials, AuthenticateContext<MockAccessControl, None, None> context) Undertakes authentication.voidchallenge(ChallengeContext<None, None> context) Triggers the authentication challenge to the client.Creates the custom authentication.static StringgetHeaderChallengeValue(String realm) Obtains theWWW-AuthenticateHttpHeadervalue.protected voidloadMetaData(AbstractHttpSecuritySource.MetaDataContext<MockAuthentication, MockAccessControl, Void, None, None> context) Overridden to load meta-data.protected voidOverridden to load specifications.voidlogout(LogoutContext<None, None> context) Logs out.booleanratify(Void credentials, RatifyContext<MockAccessControl> context) Ratifies whether enough information is available to undertake authentication.sourceHttpSecurity(HttpSecurityContext context) Sources theHttpSecurity.Methods inherited from class net.officefloor.web.spi.security.impl.AbstractHttpSecuritySource
getSpecification, init, start, stop
-
Field Details
-
PROPERTY_REALM
Name ofPropertyto configure the realm.- See Also:
-
AUTHENTICATION_SCHEME
Authentication scheme reported to the application via theHttpAccessControl.- See Also:
-
-
Constructor Details
-
MockChallengeHttpSecuritySource
Instantiate with the realm.- Parameters:
realm- Realm.
-
MockChallengeHttpSecuritySource
public MockChallengeHttpSecuritySource()Default constructor.
-
-
Method Details
-
getHeaderChallengeValue
Obtains theWWW-AuthenticateHttpHeadervalue.- Parameters:
realm- Realm.- Returns:
WWW-AuthenticateHttpHeadervalue.
-
loadSpecification
Description copied from class:AbstractHttpSecuritySourceOverridden to load specifications.- Specified by:
loadSpecificationin classAbstractHttpSecuritySource<MockAuthentication,MockAccessControl, Void, None, None> - Parameters:
context- Specifications.
-
loadMetaData
protected void loadMetaData(AbstractHttpSecuritySource.MetaDataContext<MockAuthentication, MockAccessControl, throws ExceptionVoid, None, None> context) Description copied from class:AbstractHttpSecuritySourceOverridden to load meta-data.- Specified by:
loadMetaDatain classAbstractHttpSecuritySource<MockAuthentication,MockAccessControl, Void, None, None> - Parameters:
context- Meta-data.- Throws:
Exception- If fails to load the meta-data.
-
sourceHttpSecurity
public HttpSecurity<MockAuthentication,MockAccessControl, sourceHttpSecurityVoid, None, None> (HttpSecurityContext context) throws HttpException Description copied from interface:HttpSecuritySourceSources theHttpSecurity.- Specified by:
sourceHttpSecurityin interfaceHttpSecuritySource<MockAuthentication,MockAccessControl, Void, None, None> - Parameters:
context-HttpSecurity.- Returns:
HttpSecurity.- Throws:
HttpException- If fails to source theHttpSecurity.
-
createAuthentication
public MockAuthentication createAuthentication(AuthenticationContext<MockAccessControl, Void> context) Description copied from interface:HttpSecurityCreates the custom authentication.- Specified by:
createAuthenticationin interfaceHttpSecurity<MockAuthentication,MockAccessControl, Void, None, None> - Parameters:
context-AuthenticateContext.- Returns:
- Custom authentication.
-
ratify
Description copied from interface:HttpSecurityRatifies whether enough information is available to undertake authentication.
As authentication will likely require communication with external services (LDAP store, database, etc), this method allows checking whether enough information is available to undertake the authentication. The purpose is to avoid the
ManagedFunctiondepending on dependencies of authentication subsequently causing execution by differentTeam. This is especially as the majority ofHttpRequestservicing will use theHttpSessionto cache details and not require the authentication dependencies causing the swap inTeam.- Specified by:
ratifyin interfaceHttpSecurity<MockAuthentication,MockAccessControl, Void, None, None> - Parameters:
credentials- Credentials.context-RatifyContext.- Returns:
trueshould enough information be available to undertake authentication.falseif not enough information is available for authentication.
-
authenticate
public void authenticate(Void credentials, AuthenticateContext<MockAccessControl, None, throws HttpExceptionNone> context) Description copied from interface:HttpSecurityUndertakes authentication.- Specified by:
authenticatein interfaceHttpSecurity<MockAuthentication,MockAccessControl, Void, None, None> - Parameters:
credentials- Credentials.context-AuthenticateContext.- Throws:
HttpException- If failure in communicating to necessary security services.
-
challenge
Description copied from interface:HttpSecurityTriggers the authentication challenge to the client.- Specified by:
challengein interfaceHttpSecurity<MockAuthentication,MockAccessControl, Void, None, None> - Parameters:
context-ChallengeContext.- Throws:
HttpException- If failure in communicating to necessary security services.
-
logout
Description copied from interface:HttpSecurityLogs out.- Specified by:
logoutin interfaceHttpSecurity<MockAuthentication,MockAccessControl, Void, None, None> - Parameters:
context-LogoutContext.- Throws:
HttpException- If failure in communicating to necessary security services.
-