Class WebAuthRequestCollection
- java.lang.Object
-
- com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
-
- com.inductiveautomation.ignition.gateway.auth.web.WebAuthRequestCollection
-
- All Implemented Interfaces:
java.util.EventListener
,javax.servlet.http.HttpSessionBindingListener
public class WebAuthRequestCollection extends AbstractLifecycle implements javax.servlet.http.HttpSessionBindingListener
A collection of web auth requests represented as relay state ->
WebAuthRequestCollection.WebAuthCallback
pairs.Each
HttpSession
may have at most one collection.The internal collection supports high-concurrency and is thread-safe.
When a collection is bound to an
HttpSession
, it is started up, which schedules the first reaper.A reaper is scheduled every 2 minutes to clear out any expired web auth requests.
When a collection is unbound from an
HttpSession
, it is shut down, which clears the internal collection .
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
WebAuthRequestCollection.BaseWebAuthResponseHandler
class
WebAuthRequestCollection.LoginRequestBuilder
static interface
WebAuthRequestCollection.LoginResponseHandler
class
WebAuthRequestCollection.LogoutRequestBuilder
static interface
WebAuthRequestCollection.LogoutResponseHandler
static class
WebAuthRequestCollection.WebAuthCallback
Wraps a web auth request's creation timestamp, state to be carried from request to response, and a web auth response handler for handling the web auth response associated with the request.class
WebAuthRequestCollection.WebAuthRequestBuilder<T extends WebAuthRequestCollection.WebAuthRequestBuilder<T>>
static interface
WebAuthRequestCollection.WebAuthResponseHandler
Handler for web auth responses
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description WebAuthRequestCollection.LoginRequestBuilder
createLoginRequest()
WebAuthRequestCollection.LogoutRequestBuilder
createLogoutRequest()
java.util.Optional<WebAuthRequestCollection.WebAuthCallback>
get(java.lang.String state)
Fetch theWebAuthRequestCollection.WebAuthCallback
associated with the given relay state valuestatic WebAuthRequestCollection
getOrCreate(RequestContext req)
static WebAuthRequestCollection
getOrCreate(GatewayContext gatewayContext, javax.servlet.http.HttpServletRequest httpServletRequest)
static WebAuthRequestCollection
getOrCreate(GatewayContext gatewayContext, javax.servlet.http.HttpSession httpSession)
Gets theWebAuthRequestCollection
associated with the givenHttpSession
.protected void
onShutdown()
protected void
onStartup()
void
registerHandler(java.lang.String state, java.lang.String app, WebAuthRequestCollection.WebAuthResponseHandler handler)
Allows you to manually register a state key to a given handler.java.util.Optional<WebAuthRequestCollection.WebAuthCallback>
remove(java.lang.String state)
Remove theWebAuthRequestCollection.WebAuthCallback
associated with the given relay state valuevoid
valueBound(javax.servlet.http.HttpSessionBindingEvent event)
void
valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
-
Methods inherited from class com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
isRunning, shutdown, startup
-
-
-
-
Method Detail
-
getOrCreate
@Nonnull public static WebAuthRequestCollection getOrCreate(@Nonnull GatewayContext gatewayContext, @Nonnull javax.servlet.http.HttpSession httpSession)
Gets theWebAuthRequestCollection
associated with the givenHttpSession
. If aWebAuthRequestCollection
does not exist on the session, a new instance is created, set on the session, and returned.- Parameters:
gatewayContext
- the currently executingGatewayContext
httpSession
- theHttpSession
holding theWebAuthRequestCollection
- Returns:
- the
WebAuthRequestCollection
associated with the givenHttpSession
-
getOrCreate
@Nonnull public static WebAuthRequestCollection getOrCreate(@Nonnull GatewayContext gatewayContext, @Nonnull javax.servlet.http.HttpServletRequest httpServletRequest)
Gets theWebAuthRequestCollection
associated with theHttpSession
on the givenHttpServletRequest
. If aWebAuthRequestCollection
does not exist on the session, a new instance is created, set on the session, and returned.- Parameters:
gatewayContext
- the currently executingGatewayContext
httpServletRequest
- theHttpServletRequest
which contains theHttpSession
holding theWebAuthRequestCollection
- Returns:
- the
WebAuthRequestCollection
associated with the givenHttpServletRequest's
HttpSession
- See Also:
getOrCreate(GatewayContext, HttpSession)
-
getOrCreate
@Nonnull public static WebAuthRequestCollection getOrCreate(@Nonnull RequestContext req)
Gets theWebAuthRequestCollection
associated with theHttpSession
on the givenRequestContext
. If aWebAuthRequestCollection
does not exist on the session, a new instance is created, set on the session, and returned.- Parameters:
req
- theRequestContext
which contains theHttpSession
holding theWebAuthRequestCollection
- Returns:
- the
WebAuthRequestCollection
associated with the givenRequestContext's
HttpSession
- See Also:
getOrCreate(GatewayContext, HttpServletRequest)
-
get
@Nonnull public java.util.Optional<WebAuthRequestCollection.WebAuthCallback> get(@Nonnull java.lang.String state)
Fetch theWebAuthRequestCollection.WebAuthCallback
associated with the given relay state value- Parameters:
state
- the relay state value- Returns:
- an
Optional
containing theWebAuthRequestCollection.WebAuthCallback
associated with the given relay state or an emptyOptional
if there is noWebAuthRequestCollection.WebAuthCallback
associated with the given relay state
-
remove
@Nonnull public java.util.Optional<WebAuthRequestCollection.WebAuthCallback> remove(@Nonnull java.lang.String state)
Remove theWebAuthRequestCollection.WebAuthCallback
associated with the given relay state value- Parameters:
state
- the relay state value- Returns:
- an
Optional
containing theWebAuthRequestCollection.WebAuthCallback
associated with the given relay state or an emptyOptional
if there is noWebAuthRequestCollection.WebAuthCallback
associated with the given relay state
-
valueBound
public void valueBound(javax.servlet.http.HttpSessionBindingEvent event)
- Specified by:
valueBound
in interfacejavax.servlet.http.HttpSessionBindingListener
-
valueUnbound
public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
- Specified by:
valueUnbound
in interfacejavax.servlet.http.HttpSessionBindingListener
-
onStartup
protected void onStartup()
- Specified by:
onStartup
in classAbstractLifecycle
-
onShutdown
protected void onShutdown()
- Specified by:
onShutdown
in classAbstractLifecycle
-
registerHandler
public void registerHandler(java.lang.String state, java.lang.String app, WebAuthRequestCollection.WebAuthResponseHandler handler)
Allows you to manually register a state key to a given handler.- Parameters:
state
- the state key used to retrieveWebAuthRequestCollection.WebAuthCallback
instead of using the state key generated from theWebAuthState
app
- the app's namehandler
- theWebAuthRequestCollection.WebAuthResponseHandler
to handle the web auth response for this request
-
createLoginRequest
@Nonnull public WebAuthRequestCollection.LoginRequestBuilder createLoginRequest()
- Returns:
- a new
WebAuthRequestCollection.LoginRequestBuilder
instance
-
createLogoutRequest
@Nonnull public WebAuthRequestCollection.LogoutRequestBuilder createLogoutRequest()
- Returns:
- a new
WebAuthRequestCollection.LogoutRequestBuilder
instance
-
-