public class MockHttpSecuritySource extends AbstractHttpSecuritySource<HttpSecurity,Void,None,None>
Mock HttpSecuritySource
to use for testing.
It provides a HttpSecurity
by the following Basic
authentication scheme, except that:
HttpSecurity
is provided the username as a role (allows
logging in with various roles for testing). Multiple roles can be specified
by the username being a comma separate list.AbstractHttpSecuritySource.DependencyLabeller, AbstractHttpSecuritySource.Labeller, AbstractHttpSecuritySource.MetaDataContext<S,C,D extends Enum<D>,F extends Enum<F>>, AbstractHttpSecuritySource.SpecificationContext
Modifier and Type | Field and Description |
---|---|
static String |
AUTHENTICATION_SCHEME_MOCK
Authentication scheme reported to the application via the
HttpSecurity . |
Constructor and Description |
---|
MockHttpSecuritySource() |
Modifier and Type | Method and Description |
---|---|
void |
authenticate(HttpAuthenticateContext<HttpSecurity,Void,None> context)
Undertakes authentication.
|
void |
challenge(HttpChallengeContext<None,None> context)
Triggers the authentication challenge to the client.
|
protected void |
loadMetaData(AbstractHttpSecuritySource.MetaDataContext<HttpSecurity,Void,None,None> context)
Overridden to load meta-data.
|
protected void |
loadSpecification(AbstractHttpSecuritySource.SpecificationContext context)
Overridden to load specifications.
|
void |
logout(HttpLogoutContext<None> context)
Logs out.
|
boolean |
ratify(HttpRatifyContext<HttpSecurity,Void> context)
Ratifies whether enough information is available to undertake
authentication.
|
getMetaData, getSpecification, init
public static final String AUTHENTICATION_SCHEME_MOCK
HttpSecurity
.protected void loadSpecification(AbstractHttpSecuritySource.SpecificationContext context)
AbstractHttpSecuritySource
loadSpecification
in class AbstractHttpSecuritySource<HttpSecurity,Void,None,None>
context
- Specifications.protected void loadMetaData(AbstractHttpSecuritySource.MetaDataContext<HttpSecurity,Void,None,None> context) throws Exception
AbstractHttpSecuritySource
loadMetaData
in class AbstractHttpSecuritySource<HttpSecurity,Void,None,None>
context
- Meta-data.Exception
- If fails to load the meta-data.public boolean ratify(HttpRatifyContext<HttpSecurity,Void> context)
HttpSecuritySource
Ratifies 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 Job
depending on
HttpAuthentication
and inherit the dependencies of authentication
subsequently causing execution by the authentication Team
-
especially as the majority of HttpRequest
servicing will have the
HTTP security cached in the HttpSession
and not require the
authentication dependencies causing the swap in Team
.
context
- HttpRatifyContext
.true
should enough information be available to
undertake authentication. false
if not enough
information is available for authentication.public void authenticate(HttpAuthenticateContext<HttpSecurity,Void,None> context) throws IOException
HttpSecuritySource
context
- HttpAuthenticateContext
.IOException
- If failure in communicating to necessary security services.public void challenge(HttpChallengeContext<None,None> context) throws IOException
HttpSecuritySource
context
- HttpChallengeContext
.IOException
- If failure in communicating to necessary security services.public void logout(HttpLogoutContext<None> context) throws IOException
HttpSecuritySource
context
- HttpLogoutContext
.IOException
- If failure in communicating to necessary security services.Copyright © 2005–2016. All rights reserved.