Class JwtHttpSecuritySource<C>
- java.lang.Object
-
- net.officefloor.web.spi.security.impl.AbstractHttpSecuritySource<HttpAuthentication<java.lang.Void>,JwtHttpAccessControl<C>,java.lang.Void,None,JwtHttpSecuritySource.Flows>
-
- net.officefloor.web.jwt.JwtHttpSecuritySource<C>
-
- All Implemented Interfaces:
HttpSecurity<HttpAuthentication<java.lang.Void>,JwtHttpAccessControl<C>,java.lang.Void,None,JwtHttpSecuritySource.Flows>,HttpSecuritySource<HttpAuthentication<java.lang.Void>,JwtHttpAccessControl<C>,java.lang.Void,None,JwtHttpSecuritySource.Flows>
public class JwtHttpSecuritySource<C> extends AbstractHttpSecuritySource<HttpAuthentication<java.lang.Void>,JwtHttpAccessControl<C>,java.lang.Void,None,JwtHttpSecuritySource.Flows> implements HttpSecurity<HttpAuthentication<java.lang.Void>,JwtHttpAccessControl<C>,java.lang.Void,None,JwtHttpSecuritySource.Flows>
HttpSecuritySourcefor JWT.- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJwtHttpSecuritySource.FlowsFlow keys.static classJwtHttpSecuritySource.JwtClaimsJWT claims.static classJwtHttpSecuritySource.JwtHeaderJWT header.static interfaceJwtHttpSecuritySource.JwtValidateKeysFactoryAllows 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 java.io.Serializable,C,O extends java.lang.Enum<O>,F extends java.lang.Enum<F>>, AbstractHttpSecuritySource.SpecificationContext
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAUTHENTICATION_SCHEME_BEARERAuthentication scheme Bearer.static longDEFAULT_CLOCK_SKEWDefault value forPROPERTY_CLOCK_SKEW.static longDEFAULT_STARTUP_TIMEOUTDefault value forPROEPRTY_STARTUP_TIMEOUT.static java.lang.StringPROEPRTY_STARTUP_TIMEOUTPropertyname for the startup timeout in milliseconds.static java.lang.StringPROPERTY_CLAIMS_CLASSPropertyname for the claimsClassto be loaded with claim information of JWT.static java.lang.StringPROPERTY_CLOCK_SKEWPropertyname for the clock skew in seconds.-
Fields inherited from class net.officefloor.web.spi.security.impl.AbstractHttpSecuritySource
UTF_8
-
-
Constructor Summary
Constructors Constructor Description JwtHttpSecuritySource()
-
Method Summary
-
Methods inherited from class net.officefloor.web.spi.security.impl.AbstractHttpSecuritySource
getSpecification, init, stop
-
-
-
-
Field Detail
-
AUTHENTICATION_SCHEME_BEARER
public static final java.lang.String AUTHENTICATION_SCHEME_BEARER
Authentication scheme Bearer.- See Also:
- Constant Field Values
-
PROPERTY_CLAIMS_CLASS
public static final java.lang.String PROPERTY_CLAIMS_CLASS
Propertyname for the claimsClassto be loaded with claim information of JWT.- See Also:
- Constant Field Values
-
PROEPRTY_STARTUP_TIMEOUT
public static final java.lang.String 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:
- Constant Field Values
-
DEFAULT_STARTUP_TIMEOUT
public static final long DEFAULT_STARTUP_TIMEOUT
Default value forPROEPRTY_STARTUP_TIMEOUT.- See Also:
- Constant Field Values
-
PROPERTY_CLOCK_SKEW
public static final java.lang.String PROPERTY_CLOCK_SKEW
Propertyname for the clock skew in seconds.- See Also:
- Constant Field Values
-
DEFAULT_CLOCK_SKEW
public static final long DEFAULT_CLOCK_SKEW
Default value forPROPERTY_CLOCK_SKEW.- See Also:
- Constant Field Values
-
-
Method Detail
-
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.- Throws:
T- If failure inAbstractExternalOverride.ContextRunnable.
-
loadSpecification
protected void loadSpecification(AbstractHttpSecuritySource.SpecificationContext context)
Description copied from class:AbstractHttpSecuritySourceOverridden to load specifications.- Specified by:
loadSpecificationin classAbstractHttpSecuritySource<HttpAuthentication<java.lang.Void>,JwtHttpAccessControl<C>,java.lang.Void,None,JwtHttpSecuritySource.Flows>- Parameters:
context- Specifications.
-
loadMetaData
protected void loadMetaData(AbstractHttpSecuritySource.MetaDataContext<HttpAuthentication<java.lang.Void>,JwtHttpAccessControl<C>,java.lang.Void,None,JwtHttpSecuritySource.Flows> context) throws java.lang.Exception
Description copied from class:AbstractHttpSecuritySourceOverridden to load meta-data.- Specified by:
loadMetaDatain classAbstractHttpSecuritySource<HttpAuthentication<java.lang.Void>,JwtHttpAccessControl<C>,java.lang.Void,None,JwtHttpSecuritySource.Flows>- Parameters:
context- Meta-data.- Throws:
java.lang.Exception- If fails to load the meta-data.
-
sourceHttpSecurity
public HttpSecurity<HttpAuthentication<java.lang.Void>,JwtHttpAccessControl<C>,java.lang.Void,None,JwtHttpSecuritySource.Flows> sourceHttpSecurity(HttpSecurityContext context) throws HttpException
Description copied from interface:HttpSecuritySourceSources theHttpSecurity.- Specified by:
sourceHttpSecurityin interfaceHttpSecuritySource<HttpAuthentication<java.lang.Void>,JwtHttpAccessControl<C>,java.lang.Void,None,JwtHttpSecuritySource.Flows>- Parameters:
context-HttpSecurity.- Returns:
HttpSecurity.- Throws:
HttpException- If fails to source theHttpSecurity.
-
start
public void start(HttpSecurityExecuteContext<JwtHttpSecuritySource.Flows> context) throws java.lang.Exception
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<java.lang.Void>,JwtHttpAccessControl<C>,java.lang.Void,None,JwtHttpSecuritySource.Flows>- Overrides:
startin classAbstractHttpSecuritySource<HttpAuthentication<java.lang.Void>,JwtHttpAccessControl<C>,java.lang.Void,None,JwtHttpSecuritySource.Flows>- Parameters:
context-HttpSecurityExecuteContextto use in starting thisHttpSecuritySource.- Throws:
java.lang.Exception- Should theHttpSecuritySourcefail to start execution.
-
createAuthentication
public HttpAuthentication<java.lang.Void> createAuthentication(AuthenticationContext<JwtHttpAccessControl<C>,java.lang.Void> context)
Description copied from interface:HttpSecurityCreates the custom authentication.- Specified by:
createAuthenticationin interfaceHttpSecurity<HttpAuthentication<java.lang.Void>,JwtHttpAccessControl<C>,java.lang.Void,None,JwtHttpSecuritySource.Flows>- Parameters:
context-AuthenticateContext.- Returns:
- Custom authentication.
-
ratify
public boolean ratify(java.lang.Void credentials, RatifyContext<JwtHttpAccessControl<C>> context)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<java.lang.Void>,JwtHttpAccessControl<C>,java.lang.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(java.lang.Void credentials, AuthenticateContext<JwtHttpAccessControl<C>,None,JwtHttpSecuritySource.Flows> context) throws HttpExceptionDescription copied from interface:HttpSecurityUndertakes authentication.- Specified by:
authenticatein interfaceHttpSecurity<HttpAuthentication<java.lang.Void>,JwtHttpAccessControl<C>,java.lang.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 HttpException
Description copied from interface:HttpSecurityTriggers the authentication challenge to the client.- Specified by:
challengein interfaceHttpSecurity<HttpAuthentication<java.lang.Void>,JwtHttpAccessControl<C>,java.lang.Void,None,JwtHttpSecuritySource.Flows>- Parameters:
context-ChallengeContext.- Throws:
HttpException- If failure in communicating to necessary security services.
-
logout
public void logout(LogoutContext<None,JwtHttpSecuritySource.Flows> context) throws HttpException
Description copied from interface:HttpSecurityLogs out.- Specified by:
logoutin interfaceHttpSecurity<HttpAuthentication<java.lang.Void>,JwtHttpAccessControl<C>,java.lang.Void,None,JwtHttpSecuritySource.Flows>- Parameters:
context-LogoutContext.- Throws:
HttpException- If failure in communicating to necessary security services.
-
-