Package org.opensaml.saml.common.binding.artifact.impl

# Class BasicSAMLArtifactMap

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.saml.common.binding.artifact.impl.BasicSAMLArtifactMap

All Implemented Interfaces:
  `Component`, `DestructableComponent`, `InitializableComponent`, `SAMLArtifactMap`

public class BasicSAMLArtifactMap extends AbstractInitializableComponent implements SAMLArtifactMap
Basic artifact map implementation.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`protected class`
`BasicSAMLArtifactMap.Cleanup`
A cleanup task that relies on the weakly consistent iterator support in the map implementation.

## Nested classes/interfaces inherited from interface org.opensaml.saml.common.binding.artifact.SAMLArtifactMap

`SAMLArtifactMap.SAMLArtifactMapEntry, SAMLArtifactMap.SAMLArtifactMapEntryFactory`

## Field Summary

Fields
Modifier and Type
Field
Description
`private Duration`
`artifactLifetime`
Lifetime of an artifact.
`private Map<String,ExpiringSAMLArtifactMapEntry>`
`artifactStore`
Artifact mapping storage.
`private Duration`
`cleanupInterval`
Time between cleanup checks.
`private TimerTask`
`cleanupTask`
Task that cleans up expired records.
`private Timer`
`cleanupTaskTimer`
Timer used to schedule cleanup tasks.
`private SAMLArtifactMap.SAMLArtifactMapEntryFactory`
`entryFactory`
Factory for SAMLArtifactMapEntry instances.
`private final org.slf4j.Logger`
`log`
Class Logger.

## Constructor Summary

Constructors
Constructor
Description
`BasicSAMLArtifactMap()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`contains(String artifact)`
Checks if a given artifact has a map entry.
`protected void`
`doDestroy()`
`protected void`
`doInitialize()`
`SAMLArtifactMap.SAMLArtifactMapEntry`
`get(String artifact)`
Gets the artifact entry for the given artifact.
`Duration`
`getArtifactLifetime()`
Get the artifact entry lifetime.
`SAMLArtifactMap.SAMLArtifactMapEntryFactory`
`getEntryFactory()`
Get the map entry factory.
`void`
`put(String artifact, String relyingPartyId, String issuerId, SAMLObject samlMessage)`
Creates a mapping between a given artifact and the SAML message to which it maps.
`void`
`remove(String artifact)`
Removes the artifact from this map.
`void`
`setArtifactLifetime(Duration lifetime)`
Set the artifact entry lifetime.
`void`
`setCleanupInterval(Duration interval)`
Set the cleanup interval, or 0 for none.
`void`
`setEntryFactory(SAMLArtifactMap.SAMLArtifactMapEntryFactory factory)`
Set the map entry factory.

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, destroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitialized`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### log

@Nonnull private final org.slf4j.Logger log
Class Logger.

### artifactStore

@NonnullAfterInit private Map<String,ExpiringSAMLArtifactMapEntry> artifactStore
Artifact mapping storage.

### artifactLifetime

@Nonnull private Duration artifactLifetime
Lifetime of an artifact.

### entryFactory

@Nonnull private SAMLArtifactMap.SAMLArtifactMapEntryFactory entryFactory
Factory for SAMLArtifactMapEntry instances.

### cleanupInterval

@Nonnull private Duration cleanupInterval
Time between cleanup checks. Default value: (5 mins)

### cleanupTaskTimer

@NonnullAfterInit private Timer cleanupTaskTimer
Timer used to schedule cleanup tasks.

### cleanupTask

@Nullable private TimerTask cleanupTask
Task that cleans up expired records.

## Constructor Details

### BasicSAMLArtifactMap

public BasicSAMLArtifactMap()
Constructor.

## Method Details

### doInitialize

protected void doInitialize() throws ComponentInitializationException

Overrides:
  `doInitialize` in class `AbstractInitializableComponent`
Throws:
  `ComponentInitializationException`

### doDestroy

protected void doDestroy()

Overrides:
  `doDestroy` in class `AbstractInitializableComponent`

### getArtifactLifetime

@Nonnull public Duration getArtifactLifetime()
Get the artifact entry lifetime.

Returns:
  the artifact entry lifetime

### getEntryFactory

@Nonnull public SAMLArtifactMap.SAMLArtifactMapEntryFactory getEntryFactory()
Get the map entry factory.

Returns:
  the map entry factory

### setArtifactLifetime

public void setArtifactLifetime(@Nonnull Duration lifetime)
Set the artifact entry lifetime.

Parameters:
  `lifetime` - artifact entry lifetime

### setCleanupInterval

public void setCleanupInterval(@Nonnull Duration interval)
Set the cleanup interval, or 0 for none.

Parameters:
  `interval` - cleanup interval

### setEntryFactory

public void setEntryFactory(@Nonnull SAMLArtifactMap.SAMLArtifactMapEntryFactory factory)
Set the map entry factory.

Parameters:
  `factory` - map entry factory

### contains

public boolean contains(@Nonnull @NotEmpty String artifact) throws IOException
Checks if a given artifact has a map entry.

Specified by:
  `contains` in interface `SAMLArtifactMap`
Parameters:
  `artifact` - the artifact to check
Returns:
  true iff this map has an entry for the given artifact
Throws:
  `IOException` - if an error occurs retrieving the information

### get

@Nullable public SAMLArtifactMap.SAMLArtifactMapEntry get(@Nonnull @NotEmpty String artifact) throws IOException
Gets the artifact entry for the given artifact.

Specified by:
  `get` in interface `SAMLArtifactMap`
Parameters:
  `artifact` - the artifact to retrieve the entry for
Returns:
  the entry, or null if the artifact has already expired or did not exist
Throws:
  `IOException` - if an error occurs retrieving the information

### put

public void put(@Nonnull @NotEmpty String artifact, @Nonnull @NotEmpty String relyingPartyId, @Nonnull @NotEmpty String issuerId, @Nonnull SAMLObject samlMessage) throws IOException
Creates a mapping between a given artifact and the SAML message to which it maps.

Specified by:
  `put` in interface `SAMLArtifactMap`
Parameters:
  `artifact` - the artifact
  `relyingPartyId` - ID of the party the artifact was sent to
  `issuerId` - ID of the issuer of the artifact
  `samlMessage` - the SAML message
Throws:
  `IOException` - if an error occurs storing the information

### remove

public void remove(@Nonnull @NotEmpty String artifact) throws IOException
Removes the artifact from this map.

Specified by:
  `remove` in interface `SAMLArtifactMap`
Parameters:
  `artifact` - artifact to be removed
Throws:
  `IOException` - if an error occurs retrieving the information