Package net.shibboleth.idp.session.impl
Class StorageBackedIdPSession
- java.lang.Object
-
- net.shibboleth.idp.session.AbstractIdPSession
-
- net.shibboleth.idp.session.impl.StorageBackedIdPSession
-
- All Implemented Interfaces:
IdPSession,Component,IdentifiedComponent
public class StorageBackedIdPSession extends AbstractIdPSession
Implementation ofIdPSessionfor use withStorageBackedSessionManager.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.shibboleth.idp.session.AbstractIdPSession
AbstractIdPSession.AddressFamily
-
-
Field Summary
Fields Modifier and Type Field Description private org.slf4j.LoggerlogClass logger.private StorageBackedSessionManagersessionManagerBack-reference to parent instance.private longversionStorage version used to synchronize changes.-
Fields inherited from interface net.shibboleth.idp.session.IdPSession
MDC_ATTRIBUTE
-
-
Constructor Summary
Constructors Constructor Description StorageBackedIdPSession(StorageBackedSessionManager manager, String sessionId, String canonicalName, Instant creationTime)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AuthenticationResultaddAuthenticationResult(AuthenticationResult result)SPSessionaddSPSession(SPSession spSession)voidbindToAddress(String address)booleancheckAddress(String address)booleancheckTimeout()AuthenticationResultgetAuthenticationResult(String flowId)protected Map<String,Optional<AuthenticationResult>>getAuthenticationResultMap()Set<AuthenticationResult>getAuthenticationResults()SPSessiongetSPSession(String serviceId)protected Map<String,Optional<SPSession>>getSPSessionMap()Set<SPSession>getSPSessions()private StringgetSPSessionStorageKey(String serviceId)Convert a service identifier into a suitable key for the underlying storage service.protected longgetVersion()Get the record version.private AuthenticationResultloadAuthenticationResultFromStorage(String flowId)Loads anAuthenticationResultrecord from storage and deserializes it using the object attached to the correspondingAuthenticationFlowDescriptor.private SPSessionloadSPSessionFromStorage(String serviceId)Loads aSPSessionrecord from storage and deserializes it using the object registered in the attachedSPSessionSerializerRegistry.booleanremoveAuthenticationResult(AuthenticationResult result)booleanremoveSPSession(SPSession spSession)private booleansaveAuthenticationResultToStorage(AuthenticationResult result)Saves anAuthenticationResultrecord to storage, serializing it using the object attached to the correspondingAuthenticationFlowDescriptor.private booleansaveSPSessionToStorage(SPSession session)Saves aSPSessionrecord to storage.voidsetLastActivityInstant(Instant instant)protected voidsetVersion(long ver)Set the record version.voidupdateAuthenticationResultActivity(AuthenticationResult result)private booleanwriteToStorage()Update the primary session record based on the current contents of this object.-
Methods inherited from class net.shibboleth.idp.session.AbstractIdPSession
doAddAuthenticationResult, doAddSPSession, doBindToAddress, doRemoveAuthenticationResult, doRemoveSPSession, doSetLastActivityInstant, equals, getAddress, getAddressFamily, getCreationInstant, getId, getLastActivityInstant, getPrincipalName, hashCode, toString
-
-
-
-
Field Detail
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
sessionManager
@Nonnull private final StorageBackedSessionManager sessionManager
Back-reference to parent instance.
-
version
private long version
Storage version used to synchronize changes.
-
-
Constructor Detail
-
StorageBackedIdPSession
public StorageBackedIdPSession(@Nonnull StorageBackedSessionManager manager, @Nonnull @NotEmpty String sessionId, @Nonnull @NotEmpty String canonicalName, @Nonnull Instant creationTime)Constructor.- Parameters:
manager- parent SessionManager instancesessionId- unique ID of sessioncanonicalName- canonical name of session subjectcreationTime- creation time of session
-
-
Method Detail
-
setLastActivityInstant
public void setLastActivityInstant(@Nonnull Instant instant) throws SessionException- Overrides:
setLastActivityInstantin classAbstractIdPSession- Throws:
SessionException
-
checkAddress
public boolean checkAddress(@Nonnull @NotEmpty String address) throws SessionException
- Specified by:
checkAddressin interfaceIdPSession- Overrides:
checkAddressin classAbstractIdPSession- Throws:
SessionException
-
bindToAddress
public void bindToAddress(@Nonnull @NotEmpty String address) throws SessionException
- Overrides:
bindToAddressin classAbstractIdPSession- Throws:
SessionException
-
getAuthenticationResults
@Nonnull @NonnullElements @NotLive @Unmodifiable public Set<AuthenticationResult> getAuthenticationResults()
- Specified by:
getAuthenticationResultsin interfaceIdPSession- Overrides:
getAuthenticationResultsin classAbstractIdPSession
-
getAuthenticationResult
@Nullable public AuthenticationResult getAuthenticationResult(@Nonnull @NotEmpty String flowId)
- Specified by:
getAuthenticationResultin interfaceIdPSession- Overrides:
getAuthenticationResultin classAbstractIdPSession
-
addAuthenticationResult
@Nullable public AuthenticationResult addAuthenticationResult(@Nonnull AuthenticationResult result) throws SessionException
- Specified by:
addAuthenticationResultin interfaceIdPSession- Overrides:
addAuthenticationResultin classAbstractIdPSession- Throws:
SessionException
-
updateAuthenticationResultActivity
public void updateAuthenticationResultActivity(@Nonnull AuthenticationResult result) throws SessionException- Throws:
SessionException
-
removeAuthenticationResult
public boolean removeAuthenticationResult(@Nonnull AuthenticationResult result) throws SessionException- Specified by:
removeAuthenticationResultin interfaceIdPSession- Overrides:
removeAuthenticationResultin classAbstractIdPSession- Throws:
SessionException
-
getSPSessions
@Nonnull @NonnullElements @NotLive @Unmodifiable public Set<SPSession> getSPSessions()
- Specified by:
getSPSessionsin interfaceIdPSession- Overrides:
getSPSessionsin classAbstractIdPSession
-
getSPSession
@Nullable public SPSession getSPSession(@Nonnull @NotEmpty String serviceId)
- Specified by:
getSPSessionin interfaceIdPSession- Overrides:
getSPSessionin classAbstractIdPSession
-
addSPSession
@Nullable public SPSession addSPSession(@Nonnull SPSession spSession) throws SessionException
- Specified by:
addSPSessionin interfaceIdPSession- Overrides:
addSPSessionin classAbstractIdPSession- Throws:
SessionException
-
removeSPSession
public boolean removeSPSession(@Nonnull SPSession spSession) throws SessionException- Specified by:
removeSPSessionin interfaceIdPSession- Overrides:
removeSPSessionin classAbstractIdPSession- Throws:
SessionException
-
checkTimeout
public boolean checkTimeout() throws SessionException- Specified by:
checkTimeoutin interfaceIdPSession- Overrides:
checkTimeoutin classAbstractIdPSession- Throws:
SessionException
-
getVersion
protected long getVersion()
Get the record version.- Returns:
- current version of the storage record
-
setVersion
protected void setVersion(long ver)
Set the record version.- Parameters:
ver- version to set
-
getAuthenticationResultMap
@Nonnull @NonnullElements @Live protected Map<String,Optional<AuthenticationResult>> getAuthenticationResultMap()
- Overrides:
getAuthenticationResultMapin classAbstractIdPSession
-
getSPSessionMap
@Nonnull @NonnullElements @Live protected Map<String,Optional<SPSession>> getSPSessionMap()
- Overrides:
getSPSessionMapin classAbstractIdPSession
-
loadAuthenticationResultFromStorage
@Nullable private AuthenticationResult loadAuthenticationResultFromStorage(@Nonnull @NotEmpty String flowId) throws IOException
Loads anAuthenticationResultrecord from storage and deserializes it using the object attached to the correspondingAuthenticationFlowDescriptor.- Parameters:
flowId- ID of result/flow to load- Returns:
- the stored result, or null if the record is missing or unusable
- Throws:
IOException- if a possibly transitory storage-related error occurs
-
saveAuthenticationResultToStorage
private boolean saveAuthenticationResultToStorage(@Nonnull AuthenticationResult result) throws IOExceptionSaves anAuthenticationResultrecord to storage, serializing it using the object attached to the correspondingAuthenticationFlowDescriptor.- Parameters:
result- the object to store- Returns:
- true iff the record was successfully saved
- Throws:
IOException- if a possibly transitory storage-related error occurs
-
loadSPSessionFromStorage
@Nullable private SPSession loadSPSessionFromStorage(@Nonnull @NotEmpty String serviceId) throws IOException
Loads aSPSessionrecord from storage and deserializes it using the object registered in the attachedSPSessionSerializerRegistry.- Parameters:
serviceId- ID of service for session to load- Returns:
- the stored session, or null if the record is missing or unusable
- Throws:
IOException- if a possibly transitory storage-related error occurs
-
saveSPSessionToStorage
private boolean saveSPSessionToStorage(@Nonnull SPSession session) throws IOExceptionSaves aSPSessionrecord to storage.- Parameters:
session- the object to store- Returns:
- true iff the record was successfully saved
- Throws:
IOException- if a possibly transitory storage-related error occurs
-
getSPSessionStorageKey
@Nonnull @NotEmpty private String getSPSessionStorageKey(@Nonnull @NotEmpty String serviceId)
Convert a service identifier into a suitable key for the underlying storage service.- Parameters:
serviceId- the service identifier- Returns:
- an appropriately sized storage key
-
writeToStorage
private boolean writeToStorage() throws IOExceptionUpdate the primary session record based on the current contents of this object.- Returns:
- true iff the update succeeds, false iff a version mismatch resulted in overwrite of this object
- Throws:
IOException- if an error occurs trying to perform an update
-
-