Class AbstractIdPSession
- All Implemented Interfaces:
IdPSession
,Component
,IdentifiedComponent
- Direct Known Subclasses:
StorageBackedIdPSession
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Address syntaxes supported for address binding. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentMap<String,
Optional<AuthenticationResult>> Tracks authentication results that have occurred during this session.private final Instant
Time when this session was created.private final String
Unique ID of this session.private String
An IPv4 address to which the session is bound.private String
An IPv6 address to which the session is bound.private Instant
Last activity instant for this session.private final org.slf4j.Logger
Class logger.private final String
A canonical name for the subject of the session.private final ConcurrentMap<String,
Optional<SPSession>> Tracks services which have been issued authentication tokens during this session.private String
An "unknown" address to which the session is bound.Fields inherited from interface net.shibboleth.idp.session.IdPSession
MDC_ATTRIBUTE
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractIdPSession
(String sessionId, String canonicalName, Instant creationTime) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionAdd a newAuthenticationResult
to this IdP session, replacing any existing result of the same flow ID.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
Test the session's validity based on inactivity, while updating the last activity time.Add a newAuthenticationResult
to this IdP session, replacing any existing result of the same flow ID.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
Disassociate anAuthenticationResult
from this IdP session.boolean
doRemoveSPSession
(SPSession spSession) Disassociate the given SP session from this IdP session.void
doSetLastActivityInstant
(Instant instant) Set the last activity instant for the session.boolean
Get an address to which this session is bound.protected static AbstractIdPSession.AddressFamily
getAddressFamily
(String address) Returns the address family for an input address.getAuthenticationResult
(String flowId) Get an associatedAuthenticationResult
given its flow ID.protected Map<String,
Optional<AuthenticationResult>> Accessor for the underlyingAuthenticationResult
map maintained with the IdP session.Get the unmodifiable set ofAuthenticationResult
s associated with this session.Get the time when this session was created.getId()
Get the last activity instant for the session.Get the canonical principal name for the session.getSPSession
(String serviceId) Get the SPSession for a given service.Accessor for the underlyingSPSession
map maintained with the IdP session.Gets the unmodifiable collection of service sessions associated with this session.int
hashCode()
boolean
Disassociate anAuthenticationResult
from this IdP session.boolean
removeSPSession
(SPSession spSession) Disassociate the given SP session from this IdP session.void
setLastActivityInstant
(Instant instant) Set the last activity instant for the session.toString()
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 Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
id
Unique ID of this session. -
principalName
A canonical name for the subject of the session. -
creationInstant
Time when this session was created. -
lastActivityInstant
Last activity instant for this session. -
ipV4Address
An IPv4 address to which the session is bound. -
ipV6Address
An IPv6 address to which the session is bound. -
unknownAddress
An "unknown" address to which the session is bound. -
authenticationResults
Tracks authentication results that have occurred during this session. -
spSessions
Tracks services which have been issued authentication tokens during this session.
-
-
Constructor Details
-
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 Details
-
getId
- Specified by:
getId
in interfaceIdentifiedComponent
-
getPrincipalName
Get the canonical principal name for the session.- Specified by:
getPrincipalName
in interfaceIdPSession
- Returns:
- the principal name
-
getCreationInstant
Get the time when this session was created.- Specified by:
getCreationInstant
in interfaceIdPSession
- Returns:
- time this session was created
-
getLastActivityInstant
Get the last activity instant for the session.- Specified by:
getLastActivityInstant
in interfaceIdPSession
- Returns:
- last activity instant for the session
-
setLastActivityInstant
Set 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
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
Test the session's validity based on the supplied client address, possibly binding it to the session if appropriate.- Specified by:
checkAddress
in 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
Get an address to which this session is bound.- Parameters:
family
- the address family to inquire- Returns:
- bound address or null
-
bindToAddress
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
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
Test the session's validity based on inactivity, while updating the last activity time.- Specified by:
checkTimeout
in 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 ofAuthenticationResult
s associated with this session.- Specified by:
getAuthenticationResults
in interfaceIdPSession
- Returns:
- unmodifiable set of results
-
getAuthenticationResult
Get an associatedAuthenticationResult
given its flow ID.- Specified by:
getAuthenticationResult
in 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 newAuthenticationResult
to this IdP session, replacing any existing result of the same flow ID.- Specified by:
addAuthenticationResult
in 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 SessionException Disassociate anAuthenticationResult
from this IdP session.- Specified by:
removeAuthenticationResult
in 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 newAuthenticationResult
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.- Parameters:
result
- the result to add- Returns:
- a previously existing result replaced by the new one, if any
-
doRemoveAuthenticationResult
Disassociate anAuthenticationResult
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.- Parameters:
result
- the result to disassociate- Returns:
- true iff the given result had been associated with this IdP session and now is not
-
getSPSessions
Gets the unmodifiable collection of service sessions associated with this session.- Specified by:
getSPSessions
in interfaceIdPSession
- Returns:
- unmodifiable collection of service sessions associated with this session
-
getSPSession
Get the SPSession for a given service.- Specified by:
getSPSession
in interfaceIdPSession
- Parameters:
serviceId
- ID of the service- Returns:
- the session service or null if no session exists for that service, may be null
-
addSPSession
Add a new SP session to this IdP session, replacing any existing session for the same service.- Specified by:
addSPSession
in 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
Disassociate the given SP session from this IdP session.- Specified by:
removeSPSession
in 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
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
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
-
equals
-
hashCode
public int hashCode() -
toString
-
getAuthenticationResultMap
@Nonnull @NonnullElements @Live protected Map<String,Optional<AuthenticationResult>> getAuthenticationResultMap()Accessor for the underlyingAuthenticationResult
map maintained with the IdP session.- Returns:
- direct access to the result map
-
getSPSessionMap
Accessor for the underlyingSPSession
map 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
-