@ThreadSafe public abstract class AbstractIdPSession extends Object implements IdPSession
IdPSession, handles basic management of the
instance data without addressing persistence.
Data that can change post-construction can be modified using doSet/doAdd/doRemove methods that maintain the object state. Abstract methods defined here or left unimplemented from the interface should be implemented to call these methods and perform any additional work required to maintain the coherence of the underlying store, if any.
The checkAddress(String) method is implemented by calling into other abstract and defined
methods to check session state and update address information as required.
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractIdPSession.AddressFamily
Address syntaxes supported for address binding.
|
| Modifier and Type | Field and Description |
|---|---|
private ConcurrentMap<String,com.google.common.base.Optional<AuthenticationResult>> |
authenticationResults
Tracks authentication results that have occurred during this session.
|
private long |
creationInstant
Time, in milliseconds since the epoch, when this session was created.
|
private String |
id
Unique ID of this session.
|
private String |
ipV4Address
Addresses to which the session is bound.
|
private String |
ipV6Address
An IPv6 address to which the session is bound.
|
private long |
lastActivityInstant
Last activity instant, in milliseconds since the epoch, for this session.
|
private org.slf4j.Logger |
log
Class logger.
|
private String |
principalName
A canonical name for the subject of the session.
|
private ConcurrentMap<String,com.google.common.base.Optional<SPSession>> |
spSessions
Tracks services which have been issued authentication tokens during this session.
|
MDC_ATTRIBUTE| Constructor and Description |
|---|
AbstractIdPSession(String sessionId,
String canonicalName,
long creationTime)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
AuthenticationResult |
addAuthenticationResult(AuthenticationResult result)
Add a new
AuthenticationResult to this IdP session, replacing any
existing result of the same flow ID. |
SPSession |
addSPSession(SPSession spSession)
Add a new SP session to this IdP session, replacing any existing session for the same
service.
|
void |
bindToAddress(String address)
Associate an address with this session.
|
boolean |
checkAddress(String address)
Test the session's validity based on the supplied client address, possibly binding it
to the session if appropriate.
|
boolean |
checkTimeout()
Test the session's validity based on inactivity, while updating the last activity time.
|
AuthenticationResult |
doAddAuthenticationResult(AuthenticationResult result)
Add a new
AuthenticationResult to this IdP session, replacing any
existing result of the same flow ID. |
SPSession |
doAddSPSession(SPSession spSession)
Add a new SP session to this IdP session, replacing any existing session for the same
service.
|
void |
doBindToAddress(String address)
Associate an address with this session.
|
boolean |
doRemoveAuthenticationResult(AuthenticationResult result)
Disassociate an
AuthenticationResult from this IdP session. |
boolean |
doRemoveSPSession(SPSession spSession)
Disassociate the given SP session from this IdP session.
|
void |
doSetLastActivityInstant(long instant)
Set the last activity instant, in milliseconds since the epoch, for the session.
|
boolean |
equals(Object obj) |
String |
getAddress(AbstractIdPSession.AddressFamily family)
Get an address to which this session is bound.
|
protected static AbstractIdPSession.AddressFamily |
getAddressFamily(String address)
Returns the address family for an input address.
|
AuthenticationResult |
getAuthenticationResult(String flowId)
Get an associated
AuthenticationResult given its flow ID. |
protected Map<String,com.google.common.base.Optional<AuthenticationResult>> |
getAuthenticationResultMap()
Accessor for the underlying
AuthenticationResult map maintained with the IdP session. |
Set<AuthenticationResult> |
getAuthenticationResults()
Get the unmodifiable set of
AuthenticationResults associated with this session. |
long |
getCreationInstant()
Get the time, in milliseconds since the epoch, when this session was created.
|
String |
getId() |
long |
getLastActivityInstant()
Get the last activity instant, in milliseconds since the epoch, for the session.
|
String |
getPrincipalName()
Get the canonical principal name for the session.
|
SPSession |
getSPSession(String serviceId)
Get the SPSession for a given service.
|
protected Map<String,com.google.common.base.Optional<SPSession>> |
getSPSessionMap()
Accessor for the underlying
SPSession map maintained with the IdP session. |
Set<SPSession> |
getSPSessions()
Gets the unmodifiable collection of service sessions associated with this session.
|
int |
hashCode() |
boolean |
removeAuthenticationResult(AuthenticationResult result)
Disassociate an
AuthenticationResult from this IdP session. |
boolean |
removeSPSession(SPSession spSession)
Disassociate the given SP session from this IdP session.
|
void |
setLastActivityInstant(long instant)
Set the last activity instant, in milliseconds since the epoch, for the session.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitupdateAuthenticationResultActivity@Nonnull private final org.slf4j.Logger log
@Nonnull @NotEmpty private final String principalName
@Duration private final long creationInstant
@Duration private long lastActivityInstant
@Nonnull private final ConcurrentMap<String,com.google.common.base.Optional<AuthenticationResult>> authenticationResults
@Nonnull private final ConcurrentMap<String,com.google.common.base.Optional<SPSession>> spSessions
public AbstractIdPSession(@Nonnull@NotEmpty String sessionId, @Nonnull@NotEmpty String canonicalName, @Positive long creationTime)
sessionId - identifier for this sessioncanonicalName - canonical name of subjectcreationTime - creation time of session in milliseconds@Nonnull @NotEmpty public String getId()
getId in interface IdentifiedComponent@Nonnull @NotEmpty public String getPrincipalName()
getPrincipalName in interface IdPSessionpublic long getCreationInstant()
getCreationInstant in interface IdPSession@Duration public long getLastActivityInstant()
getLastActivityInstant in interface IdPSession@Duration public void setLastActivityInstant(@Duration@Positive long instant) throws SessionException
instant - last activity instant, in milliseconds since the epoch, for the session, must be greater than 0SessionException - if an error occurs updating the session@Duration public void doSetLastActivityInstant(@Duration@Positive long instant)
This manipulates only the internal state of the object. The setLastActivityInstant(long)
method must be overridden to support other persistence requirements.
instant - last activity instant, in milliseconds since the epoch, for the session, must be greater than 0@Nullable public String getAddress(@Nonnull AbstractIdPSession.AddressFamily family)
family - the address family to inquirepublic void bindToAddress(@Nonnull@NotEmpty String address) throws SessionException
address - the address to associateSessionException - if an error occurs binding the address to the sessionpublic void doBindToAddress(@Nonnull@NotEmpty String address)
This manipulates only the internal state of the object. The bindToAddress(String)
method must be overridden to support other persistence requirements.
address - the address to associate@Nonnull @NonnullElements @NotLive @Unmodifiable public Set<AuthenticationResult> getAuthenticationResults()
AuthenticationResults associated with this session.getAuthenticationResults in interface IdPSession@Nullable public AuthenticationResult getAuthenticationResult(@Nonnull@NotEmpty String flowId)
AuthenticationResult given its flow ID.getAuthenticationResult in interface IdPSessionflowId - the ID of the AuthenticationResult@Nullable public AuthenticationResult addAuthenticationResult(@Nonnull AuthenticationResult result) throws SessionException
AuthenticationResult to this IdP session, replacing any
existing result of the same flow ID.addAuthenticationResult in interface IdPSessionresult - the result to addSessionException - if an error occurs updating the sessionpublic boolean removeAuthenticationResult(@Nonnull AuthenticationResult result) throws SessionException
AuthenticationResult from this IdP session.removeAuthenticationResult in interface IdPSessionresult - the result to disassociateSessionException - if an error occurs accessing the session@Nullable public AuthenticationResult doAddAuthenticationResult(@Nonnull AuthenticationResult result)
AuthenticationResult to this IdP session, replacing any
existing result of the same flow ID.
This manipulates only the internal state of the object. The
addAuthenticationResult(AuthenticationResult) method must be implemented to support
other persistence requirements.
result - the result to addpublic boolean doRemoveAuthenticationResult(@Nonnull AuthenticationResult result)
AuthenticationResult from this IdP session.
This manipulates only the internal state of the object. The
removeAuthenticationResult(AuthenticationResult) method must be implemented to support
other persistence requirements.
result - the result to disassociate@Nonnull @NonnullElements @NotLive @Unmodifiable public Set<SPSession> getSPSessions()
getSPSessions in interface IdPSession@Nullable public SPSession getSPSession(@Nonnull@NotEmpty String serviceId)
getSPSession in interface IdPSessionserviceId - ID of the service@Nullable public SPSession addSPSession(@Nonnull SPSession spSession) throws SessionException
addSPSession in interface IdPSessionspSession - the SP sessionSessionException - if an error occurs accessing the sessionpublic boolean removeSPSession(@Nonnull SPSession spSession) throws SessionException
removeSPSession in interface IdPSessionspSession - the SP sessionSessionException - if an error occurs accessing the SP session@Nullable public SPSession doAddSPSession(@Nonnull SPSession spSession)
This manipulates only the internal state of the object. The addSPSession(SPSession)
method must be implemented to support other persistence requirements.
spSession - the SP sessionpublic boolean doRemoveSPSession(@Nonnull SPSession spSession)
This manipulates only the internal state of the object. The removeSPSession(SPSession)
method must be implemented to support other persistence requirements.
spSession - the SP sessionpublic boolean checkAddress(@Nonnull@NotEmpty String address) throws SessionException
checkAddress in interface IdPSessionaddress - client address for validationSessionException - if an error occurs binding the address to the sessionpublic boolean checkTimeout()
throws SessionException
checkTimeout in interface IdPSessionSessionException - if an error occurs updating the activity time@Nonnull @NonnullElements @Live protected Map<String,com.google.common.base.Optional<AuthenticationResult>> getAuthenticationResultMap()
AuthenticationResult map maintained with the IdP session.@Nonnull @NonnullElements @Live protected Map<String,com.google.common.base.Optional<SPSession>> getSPSessionMap()
SPSession map maintained with the IdP session.@Nonnull protected static AbstractIdPSession.AddressFamily getAddressFamily(@Nonnull@NotEmpty String address)
address - the string to checkCopyright © 1999–2018 Shibboleth Consortium. All rights reserved.