public class LifecycleAwareSessionManager extends Object implements SessionManager, org.springframework.beans.factory.DisposableBean
SessionManager
obtains tokens from a
ClientAuthentication
upon request
. Tokens are
renewed asynchronously if a token has a lease duration. This happens 5 seconds before
the token expires, see REFRESH_PERIOD_BEFORE_EXPIRY
.
This SessionManager
also implements DisposableBean
to revoke the
LoginToken
once it's not required anymore. Token revocation will stop regular
token refresh.
If Token renewal runs into a client-side error, it assumes the token was revoked/expired and discards the token state so the next attempt will lead to another login attempt.
LoginToken
,
SessionManager
,
AsyncTaskExecutor
Modifier and Type | Class and Description |
---|---|
static class |
LifecycleAwareSessionManager.FixedTimeoutRefreshTrigger
LifecycleAwareSessionManager.RefreshTrigger implementation using a fixed timeout to schedule renewal
before a LoginToken expires. |
static interface |
LifecycleAwareSessionManager.RefreshTrigger
Common interface for trigger objects that determine the next execution time of a
refresh task that they get associated with.
|
Modifier and Type | Field and Description |
---|---|
static int |
REFRESH_PERIOD_BEFORE_EXPIRY
Refresh 5 seconds before the token expires.
|
Constructor and Description |
---|
LifecycleAwareSessionManager(ClientAuthentication clientAuthentication,
org.springframework.scheduling.TaskScheduler taskScheduler,
org.springframework.web.client.RestOperations restOperations)
Create a
LifecycleAwareSessionManager given ClientAuthentication ,
AsyncTaskExecutor and RestOperations . |
LifecycleAwareSessionManager(ClientAuthentication clientAuthentication,
org.springframework.scheduling.TaskScheduler taskScheduler,
org.springframework.web.client.RestOperations restOperations,
LifecycleAwareSessionManager.RefreshTrigger refreshTrigger)
Create a
LifecycleAwareSessionManager given ClientAuthentication ,
AsyncTaskExecutor and RestOperations . |
Modifier and Type | Method and Description |
---|---|
void |
destroy() |
VaultToken |
getSessionToken()
Obtain a session token.
|
protected boolean |
isTokenRenewable() |
protected VaultToken |
login() |
protected boolean |
renewToken()
Performs a token refresh.
|
public static final int REFRESH_PERIOD_BEFORE_EXPIRY
public LifecycleAwareSessionManager(ClientAuthentication clientAuthentication, org.springframework.scheduling.TaskScheduler taskScheduler, org.springframework.web.client.RestOperations restOperations)
LifecycleAwareSessionManager
given ClientAuthentication
,
AsyncTaskExecutor
and RestOperations
.clientAuthentication
- must not be null.taskScheduler
- must not be null.restOperations
- must not be null.public LifecycleAwareSessionManager(ClientAuthentication clientAuthentication, org.springframework.scheduling.TaskScheduler taskScheduler, org.springframework.web.client.RestOperations restOperations, LifecycleAwareSessionManager.RefreshTrigger refreshTrigger)
LifecycleAwareSessionManager
given ClientAuthentication
,
AsyncTaskExecutor
and RestOperations
.clientAuthentication
- must not be null.taskScheduler
- must not be null.restOperations
- must not be null.refreshTrigger
- must not be null.public void destroy()
destroy
in interface org.springframework.beans.factory.DisposableBean
protected boolean renewToken()
public VaultToken getSessionToken()
SessionManager
getSessionToken
in interface SessionManager
protected VaultToken login()
protected boolean isTokenRenewable()
Copyright © 2016–2017 Pivotal Software, Inc.. All rights reserved.