Class JwtHttpSecuritySource<C>
- All Implemented Interfaces:
HttpSecurity<HttpAuthentication<Void>,,JwtHttpAccessControl<C>, Void, None, JwtHttpSecuritySource.Flows> HttpSecuritySource<HttpAuthentication<Void>,JwtHttpAccessControl<C>, Void, None, JwtHttpSecuritySource.Flows>
HttpSecuritySource for JWT.- Author:
- Daniel Sagenschneider
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumFlow keys.static classJWT claims.static classJWT header.static interfaceAllows overriding the creation ofJwtValidateKeyinstances.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 Bearer.static final longDefault value forPROPERTY_CLOCK_SKEW.static final longDefault value forPROEPRTY_STARTUP_TIMEOUT.static final StringPropertyname for the startup timeout in milliseconds.static final Stringstatic final StringPropertyname for the clock skew in seconds.Fields inherited from class net.officefloor.web.spi.security.impl.AbstractHttpSecuritySource
UTF_8 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidauthenticate(Void credentials, AuthenticateContext<JwtHttpAccessControl<C>, None, JwtHttpSecuritySource.Flows> context) Undertakes authentication.voidTriggers the authentication challenge to the client.Creates the custom authentication.protected voidloadMetaData(AbstractHttpSecuritySource.MetaDataContext<HttpAuthentication<Void>, JwtHttpAccessControl<C>, Void, None, JwtHttpSecuritySource.Flows> context) Overridden to load meta-data.protected voidOverridden to load specifications.voidlogout(LogoutContext<None, JwtHttpSecuritySource.Flows> context) Logs out.booleanratify(Void credentials, RatifyContext<JwtHttpAccessControl<C>> context) Ratifies whether enough information is available to undertake authentication.static voidsetOverrideKeys(JwtHttpSecuritySource.JwtValidateKeysFactory validateKeysFactory) Uses theJwtHttpSecuritySource.JwtValidateKeysFactoryfor keys.HttpSecurity<HttpAuthentication<Void>,JwtHttpAccessControl<C>, Void, None, JwtHttpSecuritySource.Flows> sourceHttpSecurity(HttpSecurityContext context) Sources theHttpSecurity.voidCalled once afterHttpSecuritySource.init(HttpSecuritySourceContext)to indicate thisHttpSecuritySourceshould start execution.Methods inherited from class net.officefloor.web.spi.security.impl.AbstractHttpSecuritySource
getSpecification, init, stop
-
Field Details
-
AUTHENTICATION_SCHEME_BEARER
Authentication scheme Bearer.- See Also:
-
PROPERTY_CLAIMS_CLASS
- See Also:
-
PROEPRTY_STARTUP_TIMEOUT
Propertyname for the startup timeout in milliseconds.This is the time that
HttpRequestinstances are held up waiting the for the initialJwtValidateKeyinstances to be loaded.- See Also:
-
DEFAULT_STARTUP_TIMEOUT
public static final long DEFAULT_STARTUP_TIMEOUTDefault value forPROEPRTY_STARTUP_TIMEOUT.- See Also:
-
PROPERTY_CLOCK_SKEW
Propertyname for the clock skew in seconds.- See Also:
-
DEFAULT_CLOCK_SKEW
public static final long DEFAULT_CLOCK_SKEWDefault value forPROPERTY_CLOCK_SKEW.- See Also:
-
-
Constructor Details
-
JwtHttpSecuritySource
public JwtHttpSecuritySource()
-
-
Method Details
-
setOverrideKeys
public static void setOverrideKeys(JwtHttpSecuritySource.JwtValidateKeysFactory validateKeysFactory) Uses the
JwtHttpSecuritySource.JwtValidateKeysFactoryfor keys.This is typically used for testing to allow overriding the
JwtValidateKeyinstances being used.- Parameters:
validateKeysFactory-JwtHttpSecuritySource.JwtValidateKeysFactory. May benullto not override.
-
loadSpecification
Description copied from class:AbstractHttpSecuritySourceOverridden to load specifications.- Specified by:
loadSpecificationin classAbstractHttpSecuritySource<HttpAuthentication<Void>,JwtHttpAccessControl<C>, Void, None, JwtHttpSecuritySource.Flows> - Parameters:
context- Specifications.
-
loadMetaData
protected void loadMetaData(AbstractHttpSecuritySource.MetaDataContext<HttpAuthentication<Void>, JwtHttpAccessControl<C>, throws ExceptionVoid, None, JwtHttpSecuritySource.Flows> context) Description copied from class:AbstractHttpSecuritySourceOverridden to load meta-data.- Specified by:
loadMetaDatain classAbstractHttpSecuritySource<HttpAuthentication<Void>,JwtHttpAccessControl<C>, Void, None, JwtHttpSecuritySource.Flows> - Parameters:
context- Meta-data.- Throws:
Exception- If fails to load the meta-data.
-
sourceHttpSecurity
public HttpSecurity<HttpAuthentication<Void>,JwtHttpAccessControl<C>, sourceHttpSecurityVoid, None, JwtHttpSecuritySource.Flows> (HttpSecurityContext context) throws HttpException Description copied from interface:HttpSecuritySourceSources theHttpSecurity.- Specified by:
sourceHttpSecurityin interfaceHttpSecuritySource<HttpAuthentication<Void>,JwtHttpAccessControl<C>, Void, None, JwtHttpSecuritySource.Flows> - Parameters:
context-HttpSecurity.- Returns:
HttpSecurity.- Throws:
HttpException- If fails to source theHttpSecurity.
-
start
Description copied from interface:HttpSecuritySourceCalled once after
HttpSecuritySource.init(HttpSecuritySourceContext)to indicate thisHttpSecuritySourceshould start execution.On invocation of this method,
ProcessStateinstances may be invoked via theHttpSecurityExecuteContext.- Specified by:
startin interfaceHttpSecuritySource<HttpAuthentication<Void>,JwtHttpAccessControl<C>, Void, None, JwtHttpSecuritySource.Flows> - Overrides:
startin classAbstractHttpSecuritySource<HttpAuthentication<Void>,JwtHttpAccessControl<C>, Void, None, JwtHttpSecuritySource.Flows> - Parameters:
context-HttpSecurityExecuteContextto use in starting thisHttpSecuritySource.- Throws:
Exception- Should theHttpSecuritySourcefail to start execution.
-
createAuthentication
public HttpAuthentication<Void> createAuthentication(AuthenticationContext<JwtHttpAccessControl<C>, Void> context) Description copied from interface:HttpSecurityCreates the custom authentication.- Specified by:
createAuthenticationin interfaceHttpSecurity<HttpAuthentication<Void>,JwtHttpAccessControl<C>, Void, None, JwtHttpSecuritySource.Flows> - 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<HttpAuthentication<Void>,JwtHttpAccessControl<C>, Void, None, JwtHttpSecuritySource.Flows> - 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<JwtHttpAccessControl<C>, None, throws HttpExceptionJwtHttpSecuritySource.Flows> context) Description copied from interface:HttpSecurityUndertakes authentication.- Specified by:
authenticatein interfaceHttpSecurity<HttpAuthentication<Void>,JwtHttpAccessControl<C>, Void, None, JwtHttpSecuritySource.Flows> - Parameters:
credentials- Credentials.context-AuthenticateContext.- Throws:
HttpException- If failure in communicating to necessary security services.
-
challenge
public void challenge(ChallengeContext<None, JwtHttpSecuritySource.Flows> context) throws HttpExceptionDescription copied from interface:HttpSecurityTriggers the authentication challenge to the client.- Specified by:
challengein interfaceHttpSecurity<HttpAuthentication<Void>,JwtHttpAccessControl<C>, Void, None, JwtHttpSecuritySource.Flows> - Parameters:
context-ChallengeContext.- Throws:
HttpException- If failure in communicating to necessary security services.
-
logout
Description copied from interface:HttpSecurityLogs out.- Specified by:
logoutin interfaceHttpSecurity<HttpAuthentication<Void>,JwtHttpAccessControl<C>, Void, None, JwtHttpSecuritySource.Flows> - Parameters:
context-LogoutContext.- Throws:
HttpException- If failure in communicating to necessary security services.
-