public class LegacyWebSecurityManager
extends java.lang.Object
WebServiceHandler
SoapHandler
RestHandler
Using it through SecurityManager.legacyWebSm allows resetting SecurityManager instance.
| Modifier and Type | Class and Description |
|---|---|
private static class |
LegacyWebSecurityManager.WebServiceLogin
A thread inheriting the FWD server context, used to perform authentication and authorization work for
web requests.
|
| Modifier and Type | Field and Description |
|---|---|
private static CentralLogger |
LOG
Logger
|
private SecurityManager |
sm
SecurityManager instance.
|
private java.util.Map<java.lang.String,WebRequestContext> |
webRequestContexts
The map of currently active web requests, with their context data.
|
private java.lang.Thread |
webServiceContextCleaner
A thread used to cleanup the expired
webRequestContexts. |
private LegacyWebSecurityManager.WebServiceLogin |
webServiceLogin
The work which does the authentication and authorization requires a server context.
|
| Constructor and Description |
|---|
LegacyWebSecurityManager(SecurityManager sm)
Public constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
authWebRequest(java.lang.String account,
java.lang.String webServiceToken)
Check if the given credentials (user account and
token) is
allowed to access FWD web services. |
boolean |
checkAuthorization(java.lang.String token,
java.util.function.Supplier<java.lang.Boolean> task)
Execute the given task in the
webServiceLogin thread, so that it
can check if the web request identified with the given authentication token is authorized for that
web request. |
private void |
cleanExpiredWebRequestContexts()
The main work performed by
webServiceContextCleaner, it goes through the
webRequestContexts every 10 seconds and cleans any contexts which are not in use and are
expired. |
java.lang.String |
createWebRequestContext(java.lang.String account,
java.lang.String webServiceToken,
int timeout)
Authenticate and create the FWD context
|
boolean |
destroyWebRequestContext(java.lang.String token)
Destroy the context for the web request identified by the specified token.
|
void |
executeInContext(java.lang.String token,
java.lang.Runnable task)
Execute the specified task in the context associated with the web request identified via the specified
authentication token.
|
void |
executeInContext(java.lang.String token,
java.lang.Runnable task,
boolean useInitial)
Execute the specified task in the context associated with the web request identified via the specified
authentication token.
|
ContextSwitcher |
getContextSwitcher(java.lang.Runnable auth)
Given an authentication related code, return a
ContextSwitcher instance, if the
authentication was performed. |
boolean |
hasWebRequestContext(java.lang.String token)
Check if the specified token is associated with an active and not expired web request context.
|
void |
startWebServiceContextThreads()
Start the
webServiceContextCleaner and webServiceLogin threads, using the server
context. |
private static final CentralLogger LOG
private final SecurityManager sm
private java.util.Map<java.lang.String,WebRequestContext> webRequestContexts
private java.lang.Thread webServiceContextCleaner
webRequestContexts. Only contexts which are not active
being used will be cleaned.private LegacyWebSecurityManager.WebServiceLogin webServiceLogin
AssociatedThread will be started if any web services has enabled authentication, and this is
where the work will be performed.LegacyWebSecurityManager(SecurityManager sm)
sm - SecurityManager instance.public boolean authWebRequest(java.lang.String account,
java.lang.String webServiceToken)
throws RestrictedUseException
token) is
allowed to access FWD web services. Authorization will be done later, via checkAuthorization(java.lang.String, java.util.function.Supplier<java.lang.Boolean>).account - The FWD user account.webServiceToken - The web service token.true if there is a FWD user account with that name and web service token.RestrictedUseException - If this method is called from restricted contextpublic java.lang.String createWebRequestContext(java.lang.String account,
java.lang.String webServiceToken,
int timeout)
throws RestrictedUseException
account - The FWD user account.webServiceToken - The web service token.timeout - The timeout after which the FWD context will be destroyed.
If set to zero, the context will live until a logout operation is performed.RestrictedUseException - If this method is called from restricted contextpublic void startWebServiceContextThreads()
webServiceContextCleaner and webServiceLogin threads, using the server
context.public boolean destroyWebRequestContext(java.lang.String token)
token - The authentication token.true if webRequestContexts has this token and
the FWD session was terminated.public boolean hasWebRequestContext(java.lang.String token)
If the web request is expired, it will be destroyed.
token - The authentication token.true if the token exists and the web request is not expired.public void executeInContext(java.lang.String token,
java.lang.Runnable task)
token - The authentication token.task - The task to be performed.public void executeInContext(java.lang.String token,
java.lang.Runnable task,
boolean useInitial)
token - The authentication token.task - The task to be performed.useInitial - Flag indicating to create an initial security context.public boolean checkAuthorization(java.lang.String token,
java.util.function.Supplier<java.lang.Boolean> task)
webServiceLogin thread, so that it
can check if the web request identified with the given authentication token is authorized for that
web request.token - The authentication token.task - The authorization task.true if the web request token is authorized.public ContextSwitcher getContextSwitcher(java.lang.Runnable auth)
ContextSwitcher instance, if the
authentication was performed.
This switcher allows a thread to establish the context, if it knows a session ID.
auth - The authentication code.private void cleanExpiredWebRequestContexts()
webServiceContextCleaner, it goes through the
webRequestContexts every 10 seconds and cleans any contexts which are not in use and are
expired.