public class ComputedPersistentIdGenerationStrategy extends AbstractInitializableComponent implements PersistentIdGenerationStrategy
PersistentIdGenerationStrategy that generates a unique ID by computing the hash of
a given attribute value, the entity ID of the inbound message issuer, and a provided salt.
The original implementation and values in common use relied on base64 encoding of the result, but due to discovery of the lack of appropriate case handling of identifiers by applications, the ability to use base32 has been added to eliminate the possibility of case conflicts.
| Modifier and Type | Class and Description |
|---|---|
static class |
ComputedPersistentIdGenerationStrategy.Encoding
Post-digest encoding types.
|
| Modifier and Type | Field and Description |
|---|---|
private String |
algorithm
JCE digest algorithm name to use.
|
private ComputedPersistentIdGenerationStrategy.Encoding |
encoding
The encoding to apply to the digest.
|
private Map<String,Map<String,String>> |
exceptionMap
Override map to block or re-issue identifiers.
|
private org.slf4j.Logger |
log
Class logger.
|
private byte[] |
salt
Salt used when computing the ID.
|
static String |
WILDCARD_OVERRIDE
An override trigger to apply to all relying parties.
|
| Constructor and Description |
|---|
ComputedPersistentIdGenerationStrategy()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
doInitialize() |
String |
generate(String assertingPartyId,
String relyingPartyId,
String principalName,
String sourceId)
Get a Persistent ID that corresponds to the inputs.
|
String |
getAlgorithm()
Get the JCE algorithm name of the digest algorithm to use (default is SHA).
|
private byte[] |
getEffectiveSalt(String principalName,
String relyingPartyId)
Get the effective salt to apply for a particular principal/RP pair, or null to refuse to generate one.
|
ComputedPersistentIdGenerationStrategy.Encoding |
getEncoding()
Get the post-digest encoding to use.
|
byte[] |
getSalt()
Get the salt used when computing the ID.
|
void |
setAlgorithm(String alg)
Set the JCE algorithm name of the digest algorithm to use (default is SHA).
|
void |
setEncodedSalt(String newValue)
Set the base64-encoded salt used when computing the ID.
|
void |
setEncoding(ComputedPersistentIdGenerationStrategy.Encoding enc)
Set the post-digest encoding to use.
|
void |
setExceptionMap(Map<String,Map<String,String>> map)
Install map of exceptions that override standard generation.
|
void |
setSalt(byte[] newValue)
Set the salt used when computing the ID.
|
destroy, doDestroy, initialize, isDestroyed, isInitialized@Nonnull @NotEmpty public static final String WILDCARD_OVERRIDE
@Nonnull private final org.slf4j.Logger log
@NonnullAfterInit private byte[] salt
@Nonnull private ComputedPersistentIdGenerationStrategy.Encoding encoding
public ComputedPersistentIdGenerationStrategy()
@NonnullAfterInit public byte[] getSalt()
public void setSalt(@Nullable byte[] newValue)
An empty/null input is ignored.
newValue - used when computing the IDpublic void setEncodedSalt(@Nullable String newValue)
An empty/null input is ignored.
newValue - used when computing the ID@Nonnull @NotEmpty public String getAlgorithm()
public void setAlgorithm(@Nonnull@NotEmpty String alg)
alg - JCE message digest algorithm@Nonnull public ComputedPersistentIdGenerationStrategy.Encoding getEncoding()
public void setEncoding(@Nonnull ComputedPersistentIdGenerationStrategy.Encoding enc)
enc - encodingpublic void setExceptionMap(@Nullable@NotEmpty Map<String,Map<String,String>> map)
The map is keyed by principal name (or '*' for all), and the values are a map of relying party to salt overrides. A relying party of '*' applies to all parties. A null mapped value implies that no value should be generated, while a string value is fed into the computation in place of the default salt. Specific rules trump wildcarded rules.
map - exceptions to applyprotected void doInitialize()
throws ComponentInitializationException
doInitialize in class AbstractInitializableComponentComponentInitializationException@Nonnull @NotEmpty public String generate(@Nonnull@NotEmpty String assertingPartyId, @Nonnull@NotEmpty String relyingPartyId, @Nonnull@NotEmpty String principalName, @Nonnull@NotEmpty String sourceId) throws SAMLException
This may be generated directly from the inputs or retrieved from some other source.
generate in interface PersistentIdGenerationStrategyassertingPartyId - the asserting party providing the identifierrelyingPartyId - the relying party for whom we're obtaining the identifierprincipalName - name of the subjectsourceId - an underlying identifier for the subjectSAMLException - if an error occurs generating the identifier@Nullable private byte[] getEffectiveSalt(@Nonnull@NotEmpty String principalName, @Nonnull@NotEmpty String relyingPartyId)
principalName - name of subjectrelyingPartyId - name of relying party scopeCopyright © 1999–2018 Shibboleth Consortium. All rights reserved.