Class AbstractIdPSession
- java.lang.Object
-
- net.shibboleth.idp.session.AbstractIdPSession
-
- All Implemented Interfaces:
IdPSession,Component,IdentifiedComponent
@ThreadSafe public abstract class AbstractIdPSession extends Object implements IdPSession
Abstract base for implementations ofIdPSession, 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractIdPSession.AddressFamilyAddress syntaxes supported for address binding.
-
Field Summary
Fields Modifier and Type Field Description private ConcurrentMap<String,Optional<AuthenticationResult>>authenticationResultsTracks authentication results that have occurred during this session.private InstantcreationInstantTime when this session was created.private StringidUnique ID of this session.private StringipV4AddressAddresses to which the session is bound.private StringipV6AddressAn IPv6 address to which the session is bound.private InstantlastActivityInstantLast activity instant for this session.private org.slf4j.LoggerlogClass logger.private StringprincipalNameA canonical name for the subject of the session.private ConcurrentMap<String,Optional<SPSession>>spSessionsTracks services which have been issued authentication tokens during this session.-
Fields inherited from interface net.shibboleth.idp.session.IdPSession
MDC_ATTRIBUTE
-
-
Constructor Summary
Constructors Constructor Description AbstractIdPSession(String sessionId, String canonicalName, Instant creationTime)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AuthenticationResultaddAuthenticationResult(AuthenticationResult result)Add a newAuthenticationResultto this IdP session, replacing any existing result of the same flow ID.SPSessionaddSPSession(SPSession spSession)Add a new SP session to this IdP session, replacing any existing session for the same service.voidbindToAddress(String address)Associate an address with this session.booleancheckAddress(String address)Test the session's validity based on the supplied client address, possibly binding it to the session if appropriate.booleancheckTimeout()Test the session's validity based on inactivity, while updating the last activity time.AuthenticationResultdoAddAuthenticationResult(AuthenticationResult result)Add a newAuthenticationResultto this IdP session, replacing any existing result of the same flow ID.SPSessiondoAddSPSession(SPSession spSession)Add a new SP session to this IdP session, replacing any existing session for the same service.voiddoBindToAddress(String address)Associate an address with this session.booleandoRemoveAuthenticationResult(AuthenticationResult result)Disassociate anAuthenticationResultfrom this IdP session.booleandoRemoveSPSession(SPSession spSession)Disassociate the given SP session from this IdP session.voiddoSetLastActivityInstant(Instant instant)Set the last activity instant for the session.booleanequals(Object obj)StringgetAddress(AbstractIdPSession.AddressFamily family)Get an address to which this session is bound.protected static AbstractIdPSession.AddressFamilygetAddressFamily(String address)Returns the address family for an input address.AuthenticationResultgetAuthenticationResult(String flowId)Get an associatedAuthenticationResultgiven its flow ID.protected Map<String,Optional<AuthenticationResult>>getAuthenticationResultMap()Accessor for the underlyingAuthenticationResultmap maintained with the IdP session.Set<AuthenticationResult>getAuthenticationResults()Get the unmodifiable set ofAuthenticationResults associated with this session.InstantgetCreationInstant()Get the time when this session was created.StringgetId()InstantgetLastActivityInstant()Get the last activity instant for the session.StringgetPrincipalName()Get the canonical principal name for the session.SPSessiongetSPSession(String serviceId)Get the SPSession for a given service.protected Map<String,Optional<SPSession>>getSPSessionMap()Accessor for the underlyingSPSessionmap maintained with the IdP session.Set<SPSession>getSPSessions()Gets the unmodifiable collection of service sessions associated with this session.inthashCode()booleanremoveAuthenticationResult(AuthenticationResult result)Disassociate anAuthenticationResultfrom this IdP session.booleanremoveSPSession(SPSession spSession)Disassociate the given SP session from this IdP session.voidsetLastActivityInstant(Instant instant)Set the last activity instant for the session.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.shibboleth.idp.session.IdPSession
updateAuthenticationResultActivity
-
-
-
-
Field Detail
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
principalName
@Nonnull @NotEmpty private final String principalName
A canonical name for the subject of the session.
-
creationInstant
@Nonnull private final Instant creationInstant
Time when this session was created.
-
lastActivityInstant
@Nonnull private Instant lastActivityInstant
Last activity instant for this session.
-
ipV4Address
@Nullable private String ipV4Address
Addresses to which the session is bound.
-
ipV6Address
@Nullable private String ipV6Address
An IPv6 address to which the session is bound.
-
authenticationResults
@Nonnull private final ConcurrentMap<String,Optional<AuthenticationResult>> authenticationResults
Tracks authentication results that have occurred during this session.
-
spSessions
@Nonnull private final ConcurrentMap<String,Optional<SPSession>> spSessions
Tracks services which have been issued authentication tokens during this session.
-
-
Constructor Detail
-
AbstractIdPSession
public AbstractIdPSession(@Nonnull @NotEmpty String sessionId, @Nonnull @NotEmpty String canonicalName, @Nonnull Instant creationTime)
Constructor.- Parameters:
sessionId- identifier for this sessioncanonicalName- canonical name of subjectcreationTime- creation time of session
-
-
Method Detail
-
getId
@Nonnull @NotEmpty public String getId()
- Specified by:
getIdin interfaceIdentifiedComponent
-
getPrincipalName
@Nonnull @NotEmpty public String getPrincipalName()
Get the canonical principal name for the session.- Specified by:
getPrincipalNamein interfaceIdPSession- Returns:
- the principal name
-
getCreationInstant
@Nonnull public Instant getCreationInstant()
Get the time when this session was created.- Specified by:
getCreationInstantin interfaceIdPSession- Returns:
- time this session was created
-
getLastActivityInstant
@Nonnull public Instant getLastActivityInstant()
Get the last activity instant for the session.- Specified by:
getLastActivityInstantin interfaceIdPSession- Returns:
- last activity instant for the session
-
setLastActivityInstant
public void setLastActivityInstant(@Nonnull Instant instant) throws SessionExceptionSet the last activity instant for the session.- Parameters:
instant- last activity instant for the session- Throws:
SessionException- if an error occurs updating the session
-
doSetLastActivityInstant
public void doSetLastActivityInstant(@Nonnull Instant instant)Set the last activity instant for the session.This manipulates only the internal state of the object. The
setLastActivityInstant(Instant)method must be overridden to support other persistence requirements.- Parameters:
instant- last activity instant for the session
-
checkAddress
public boolean checkAddress(@Nonnull @NotEmpty String address) throws SessionException
Test the session's validity based on the supplied client address, possibly binding it to the session if appropriate.- Specified by:
checkAddressin interfaceIdPSession- Parameters:
address- client address for validation- Returns:
- true iff the session is valid for the specified client address
- Throws:
SessionException- if an error occurs binding the address to the session
-
getAddress
@Nullable public String getAddress(@Nonnull AbstractIdPSession.AddressFamily family)
Get an address to which this session is bound.- Parameters:
family- the address family to inquire- Returns:
- bound address or null
-
bindToAddress
public void bindToAddress(@Nonnull @NotEmpty String address) throws SessionException
Associate an address with this session.- Parameters:
address- the address to associate- Throws:
SessionException- if an error occurs binding the address to the session
-
doBindToAddress
public void doBindToAddress(@Nonnull @NotEmpty String address)
Associate an address with this session.This manipulates only the internal state of the object. The
bindToAddress(String)method must be overridden to support other persistence requirements.- Parameters:
address- the address to associate
-
checkTimeout
public boolean checkTimeout() throws SessionExceptionTest the session's validity based on inactivity, while updating the last activity time.- Specified by:
checkTimeoutin interfaceIdPSession- Returns:
- true iff the session is still valid
- Throws:
SessionException- if an error occurs updating the activity time
-
getAuthenticationResults
@Nonnull @NonnullElements @NotLive @Unmodifiable public Set<AuthenticationResult> getAuthenticationResults()
Get the unmodifiable set ofAuthenticationResults associated with this session.- Specified by:
getAuthenticationResultsin interfaceIdPSession- Returns:
- unmodifiable set of results
-
getAuthenticationResult
@Nullable public AuthenticationResult getAuthenticationResult(@Nonnull @NotEmpty String flowId)
Get an associatedAuthenticationResultgiven its flow ID.- Specified by:
getAuthenticationResultin interfaceIdPSession- Parameters:
flowId- the ID of theAuthenticationResult- Returns:
- the authentication result, or null
-
addAuthenticationResult
@Nullable public AuthenticationResult addAuthenticationResult(@Nonnull AuthenticationResult result) throws SessionException
Add a newAuthenticationResultto this IdP session, replacing any existing result of the same flow ID.- Specified by:
addAuthenticationResultin interfaceIdPSession- Parameters:
result- the result to add- Returns:
- a previously existing result replaced by the new one, if any
- Throws:
SessionException- if an error occurs updating the session
-
removeAuthenticationResult
public boolean removeAuthenticationResult(@Nonnull AuthenticationResult result) throws SessionExceptionDisassociate anAuthenticationResultfrom this IdP session.- Specified by:
removeAuthenticationResultin interfaceIdPSession- Parameters:
result- the result to disassociate- Returns:
- true iff the given result had been associated with this IdP session and now is not
- Throws:
SessionException- if an error occurs accessing the session
-
doAddAuthenticationResult
@Nullable public AuthenticationResult doAddAuthenticationResult(@Nonnull AuthenticationResult result)
Add a newAuthenticationResultto 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.- Parameters:
result- the result to add- Returns:
- a previously existing result replaced by the new one, if any
-
doRemoveAuthenticationResult
public boolean doRemoveAuthenticationResult(@Nonnull AuthenticationResult result)Disassociate anAuthenticationResultfrom this IdP session.This manipulates only the internal state of the object. The
removeAuthenticationResult(AuthenticationResult)method must be implemented to support other persistence requirements.- Parameters:
result- the result to disassociate- Returns:
- true iff the given result had been associated with this IdP session and now is not
-
getSPSessions
@Nonnull @NonnullElements @NotLive @Unmodifiable public Set<SPSession> getSPSessions()
Gets the unmodifiable collection of service sessions associated with this session.- Specified by:
getSPSessionsin interfaceIdPSession- Returns:
- unmodifiable collection of service sessions associated with this session
-
getSPSession
@Nullable public SPSession getSPSession(@Nonnull @NotEmpty String serviceId)
Get the SPSession for a given service.- Specified by:
getSPSessionin interfaceIdPSession- Parameters:
serviceId- ID of the service- Returns:
- the session service or null if no session exists for that service, may be null
-
addSPSession
@Nullable public SPSession addSPSession(@Nonnull SPSession spSession) throws SessionException
Add a new SP session to this IdP session, replacing any existing session for the same service.- Specified by:
addSPSessionin interfaceIdPSession- Parameters:
spSession- the SP session- Returns:
- a previously existing SPSession replaced by the new one, if any
- Throws:
SessionException- if an error occurs accessing the session
-
removeSPSession
public boolean removeSPSession(@Nonnull SPSession spSession) throws SessionExceptionDisassociate the given SP session from this IdP session.- Specified by:
removeSPSessionin interfaceIdPSession- Parameters:
spSession- the SP session- Returns:
- true iff the given SP session had been associated with this IdP session and now is not
- Throws:
SessionException- if an error occurs accessing the SP session
-
doAddSPSession
@Nullable public SPSession doAddSPSession(@Nonnull SPSession spSession)
Add a new SP session to this IdP session, replacing any existing session for the same service.This manipulates only the internal state of the object. The
addSPSession(SPSession)method must be implemented to support other persistence requirements.- Parameters:
spSession- the SP session- Returns:
- a previously existing SPSession replaced by the new one, if any
-
doRemoveSPSession
public boolean doRemoveSPSession(@Nonnull SPSession spSession)Disassociate the given SP session from this IdP session.This manipulates only the internal state of the object. The
removeSPSession(SPSession)method must be implemented to support other persistence requirements.- Parameters:
spSession- the SP session- Returns:
- true iff the given SP session had been associated with this IdP session and now is not
-
getAuthenticationResultMap
@Nonnull @NonnullElements @Live protected Map<String,Optional<AuthenticationResult>> getAuthenticationResultMap()
Accessor for the underlyingAuthenticationResultmap maintained with the IdP session.- Returns:
- direct access to the result map
-
getSPSessionMap
@Nonnull @NonnullElements @Live protected Map<String,Optional<SPSession>> getSPSessionMap()
Accessor for the underlyingSPSessionmap maintained with the IdP session.- Returns:
- direct access to the service session map
-
getAddressFamily
@Nonnull protected static AbstractIdPSession.AddressFamily getAddressFamily(@Nonnull @NotEmpty String address)
Returns the address family for an input address.- Parameters:
address- the string to check- Returns:
- the address family
-
-