public class LifecycleAwareSessionManager extends Object implements SessionManager, 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 | Field and Description |
---|---|
static int |
REFRESH_PERIOD_BEFORE_EXPIRY |
Constructor and Description |
---|
LifecycleAwareSessionManager(ClientAuthentication clientAuthentication,
AsyncTaskExecutor taskExecutor,
VaultClient vaultClient)
Create a
LifecycleAwareSessionManager given ClientAuthentication ,
AsyncTaskExecutor and VaultClient . |
Modifier and Type | Method and Description |
---|---|
void |
destroy() |
VaultToken |
getSessionToken()
Obtain a session token.
|
protected boolean |
renewToken()
Performs a token refresh.
|
public static final int REFRESH_PERIOD_BEFORE_EXPIRY
public LifecycleAwareSessionManager(ClientAuthentication clientAuthentication, AsyncTaskExecutor taskExecutor, VaultClient vaultClient)
LifecycleAwareSessionManager
given ClientAuthentication
,
AsyncTaskExecutor
and VaultClient
.clientAuthentication
- must not be null.taskExecutor
- must not be null.vaultClient
- must not be null.public void destroy()
destroy
in interface DisposableBean
protected boolean renewToken()
public VaultToken getSessionToken()
SessionManager
getSessionToken
in interface SessionManager
Copyright © 2016–2017 Pivotal Software, Inc.. All rights reserved.