Package org.opensaml.saml.common.profile
Class AbstractNameIdentifierGenerator<NameIdType extends SAMLObject>
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
-
- net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
-
- org.opensaml.saml.common.profile.AbstractNameIdentifierGenerator<NameIdType>
-
- Type Parameters:
NameIdType
- type of object produced
- All Implemented Interfaces:
Predicate<org.opensaml.profile.context.ProfileRequestContext>
,net.shibboleth.utilities.java.support.component.Component
,net.shibboleth.utilities.java.support.component.DestructableComponent
,net.shibboleth.utilities.java.support.component.IdentifiableComponent
,net.shibboleth.utilities.java.support.component.IdentifiedComponent
,net.shibboleth.utilities.java.support.component.InitializableComponent
,FormatSpecificNameIdentifierGenerator<NameIdType>
,NameIdentifierGenerator<NameIdType>
- Direct Known Subclasses:
AbstractSAML1NameIdentifierGenerator
,AbstractSAML2NameIDGenerator
public abstract class AbstractNameIdentifierGenerator<NameIdType extends SAMLObject> extends net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent implements FormatSpecificNameIdentifierGenerator<NameIdType>, Predicate<org.opensaml.profile.context.ProfileRequestContext>
Abstract base class for simple implementations ofNameIdentifierGenerator
.This class is suitable for implementing generators that produce simple kinds of identifiers. It supports various options controlling the inclusion of qualifier attributes.
Subclasses must override one of
doGenerate(ProfileRequestContext)
orgetIdentifier(ProfileRequestContext)
.
-
-
Field Summary
Fields Modifier and Type Field Description private Predicate<org.opensaml.profile.context.ProfileRequestContext>
activationCondition
A predicate indicating whether the component applies to a request.private Function<org.opensaml.profile.context.ProfileRequestContext,String>
defaultIdPNameQualifierLookupStrategy
Optional lookup function for obtaining default NameQualifier.private Function<org.opensaml.profile.context.ProfileRequestContext,String>
defaultSPNameQualifierLookupStrategy
Optional lookup function for obtaining default SPNameQualifier.private String
format
The identifier Format supported.private String
idpNameQualifier
Explicit NameQualifier, if any.private boolean
omitQualifiers
Flag allowing qualifier(s) to be omitted when they would match defaults or are not set.private String
spNameQualifier
Explicit SPNameQualifier, if any.private String
spProvidedId
SPProvidedID, if any.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractNameIdentifierGenerator()
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract NameIdType
doGenerate(org.opensaml.profile.context.ProfileRequestContext profileRequestContext)
Override this method to fully control the generation process.protected void
doInitialize()
NameIdType
generate(org.opensaml.profile.context.ProfileRequestContext profileRequestContext, String theFormat)
Generate an identifier object.Function<org.opensaml.profile.context.ProfileRequestContext,String>
getDefaultIdPNameQualifierLookupStrategy()
Get the lookup strategy to obtain the default IdP NameQualifier.Function<org.opensaml.profile.context.ProfileRequestContext,String>
getDefaultSPNameQualifierLookupStrategy()
Get the lookup strategy to obtain the default SPNameQualifier.protected String
getEffectiveIdPNameQualifier(org.opensaml.profile.context.ProfileRequestContext profileRequestContext)
Get the effective NameQualifier to apply based on the properties set and the current request.protected String
getEffectiveSPNameQualifier(org.opensaml.profile.context.ProfileRequestContext profileRequestContext)
Get the effective SPNameQualifier to apply based on the properties set and the current request.String
getFormat()
Get the identifier format associated with this component.protected String
getIdentifier(org.opensaml.profile.context.ProfileRequestContext profileRequestContext)
Override this method to reuse this implementation ofdoGenerate(ProfileRequestContext)
, and return the identifier to be included as the value of the eventual element.String
getIdPNameQualifier()
Get the NameQualifier attribute.String
getSPNameQualifier()
Get the SPNameQualifier attribute.String
getSPProvidedID()
Get the SPProvidedID attribute.boolean
isOmitQualifiers()
Get whether to omit NameQualifier/SPNameQualifier attributes if the qualifiers are not explicitly set or are set to values matching the IdP and relying party names respectively.void
setActivationCondition(Predicate<org.opensaml.profile.context.ProfileRequestContext> condition)
Set an activation condition that determines whether to run or not.void
setDefaultIdPNameQualifierLookupStrategy(Function<org.opensaml.profile.context.ProfileRequestContext,String> strategy)
Set the lookup strategy to obtain the default IdP NameQualifier.void
setDefaultSPNameQualifierLookupStrategy(Function<org.opensaml.profile.context.ProfileRequestContext,String> strategy)
Set the lookup strategy to obtain the default SPNameQualifier.void
setFormat(String f)
Set the Format attribute supported.void
setIdPNameQualifier(String qualifier)
Set the NameQualifier attribute.void
setOmitQualifiers(boolean flag)
Set whether to omit NameQualifier/SPNameQualifier attributes if the qualifiers are not explicitly set or are set to values matching the IdP and relying party names respectively.void
setSPNameQualifier(String qualifier)
Set the SPNameQualifier attribute.void
setSPProvidedId(String id)
Set the SPProvidedID attribute.boolean
test(org.opensaml.profile.context.ProfileRequestContext input)
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
setId
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
getId
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitialized
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
activationCondition
@Nonnull private Predicate<org.opensaml.profile.context.ProfileRequestContext> activationCondition
A predicate indicating whether the component applies to a request.
-
defaultIdPNameQualifierLookupStrategy
@Nullable private Function<org.opensaml.profile.context.ProfileRequestContext,String> defaultIdPNameQualifierLookupStrategy
Optional lookup function for obtaining default NameQualifier.
-
defaultSPNameQualifierLookupStrategy
@Nullable private Function<org.opensaml.profile.context.ProfileRequestContext,String> defaultSPNameQualifierLookupStrategy
Optional lookup function for obtaining default SPNameQualifier.
-
omitQualifiers
private boolean omitQualifiers
Flag allowing qualifier(s) to be omitted when they would match defaults or are not set.
-
format
@NonnullAfterInit @NotEmpty private String format
The identifier Format supported.
-
idpNameQualifier
@Nullable private String idpNameQualifier
Explicit NameQualifier, if any.
-
spNameQualifier
@Nullable private String spNameQualifier
Explicit SPNameQualifier, if any.
-
spProvidedId
@Nullable private String spProvidedId
SPProvidedID, if any.
-
-
Method Detail
-
setActivationCondition
public void setActivationCondition(@Nonnull Predicate<org.opensaml.profile.context.ProfileRequestContext> condition)
Set an activation condition that determines whether to run or not.- Parameters:
condition
- an activation condition
-
getDefaultIdPNameQualifierLookupStrategy
@Nullable public Function<org.opensaml.profile.context.ProfileRequestContext,String> getDefaultIdPNameQualifierLookupStrategy()
Get the lookup strategy to obtain the default IdP NameQualifier.- Returns:
- lookup strategy
-
setDefaultIdPNameQualifierLookupStrategy
public void setDefaultIdPNameQualifierLookupStrategy(@Nullable Function<org.opensaml.profile.context.ProfileRequestContext,String> strategy)
Set the lookup strategy to obtain the default IdP NameQualifier.- Parameters:
strategy
- lookup strategy
-
getDefaultSPNameQualifierLookupStrategy
@Nullable public Function<org.opensaml.profile.context.ProfileRequestContext,String> getDefaultSPNameQualifierLookupStrategy()
Get the lookup strategy to obtain the default SPNameQualifier.- Returns:
- lookup strategy
-
setDefaultSPNameQualifierLookupStrategy
public void setDefaultSPNameQualifierLookupStrategy(@Nullable Function<org.opensaml.profile.context.ProfileRequestContext,String> strategy)
Set the lookup strategy to obtain the default SPNameQualifier.- Parameters:
strategy
- lookup strategy
-
isOmitQualifiers
public boolean isOmitQualifiers()
Get whether to omit NameQualifier/SPNameQualifier attributes if the qualifiers are not explicitly set or are set to values matching the IdP and relying party names respectively.- Returns:
- whether to omit qualifiers
-
setOmitQualifiers
public void setOmitQualifiers(boolean flag)
Set whether to omit NameQualifier/SPNameQualifier attributes if the qualifiers are not explicitly set or are set to values matching the IdP and relying party names respectively.- Parameters:
flag
- flag to set
-
getFormat
@NonnullAfterInit @NotEmpty public String getFormat()
Get the identifier format associated with this component.- Specified by:
getFormat
in interfaceFormatSpecificNameIdentifierGenerator<NameIdType extends SAMLObject>
- Returns:
- identifier format
-
setFormat
public void setFormat(@Nonnull @NotEmpty String f)
Set the Format attribute supported.- Parameters:
f
- format to set
-
getIdPNameQualifier
@Nullable public String getIdPNameQualifier()
Get the NameQualifier attribute.- Returns:
- the qualifier attribute
-
setIdPNameQualifier
public void setIdPNameQualifier(@Nullable String qualifier)
Set the NameQualifier attribute.If not set, and
isOmitQualifiers()
is false, then the value used will be derived from the IdP identity.- Parameters:
qualifier
- qualifier to set
-
getSPNameQualifier
@Nullable public String getSPNameQualifier()
Get the SPNameQualifier attribute.- Returns:
- the qualifier attribute
-
setSPNameQualifier
public void setSPNameQualifier(@Nullable String qualifier)
Set the SPNameQualifier attribute.If not set, and
isOmitQualifiers()
is false, then the value used will be derived from the relying party identity.- Parameters:
qualifier
- qualifier to set
-
getSPProvidedID
@Nullable public String getSPProvidedID()
Get the SPProvidedID attribute.- Returns:
- the secondary ID attribute
-
setSPProvidedId
public void setSPProvidedId(@Nullable String id)
Set the SPProvidedID attribute.- Parameters:
id
- value to set
-
doInitialize
protected void doInitialize() throws net.shibboleth.utilities.java.support.component.ComponentInitializationException
- Overrides:
doInitialize
in classnet.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
- Throws:
net.shibboleth.utilities.java.support.component.ComponentInitializationException
-
test
public boolean test(@Nullable org.opensaml.profile.context.ProfileRequestContext input)
- Specified by:
test
in interfacePredicate<NameIdType extends SAMLObject>
-
generate
@Nullable public NameIdType generate(@Nonnull org.opensaml.profile.context.ProfileRequestContext profileRequestContext, @Nonnull @NotEmpty String theFormat) throws SAMLException
Generate an identifier object.- Specified by:
generate
in interfaceNameIdentifierGenerator<NameIdType extends SAMLObject>
- Parameters:
profileRequestContext
- the current profile request contexttheFormat
- the identifier format to generate- Returns:
- the identifier object, or null
- Throws:
SAMLException
- if an error occurs generating an identifier
-
doGenerate
@Nullable protected abstract NameIdType doGenerate(@Nonnull org.opensaml.profile.context.ProfileRequestContext profileRequestContext) throws SAMLException
Override this method to fully control the generation process.- Parameters:
profileRequestContext
- current profile request context- Returns:
- the generated object
- Throws:
SAMLException
- if an error occurs
-
getIdentifier
@Nullable protected String getIdentifier(@Nonnull org.opensaml.profile.context.ProfileRequestContext profileRequestContext) throws SAMLException
Override this method to reuse this implementation ofdoGenerate(ProfileRequestContext)
, and return the identifier to be included as the value of the eventual element.- Parameters:
profileRequestContext
- current profile request context- Returns:
- the generated identifier
- Throws:
SAMLException
- if an error occurs
-
getEffectiveIdPNameQualifier
@Nullable protected String getEffectiveIdPNameQualifier(@Nonnull org.opensaml.profile.context.ProfileRequestContext profileRequestContext)
Get the effective NameQualifier to apply based on the properties set and the current request.- Parameters:
profileRequestContext
- current profile context- Returns:
- the effective NameQualifier to set, or null
-
getEffectiveSPNameQualifier
@Nullable protected String getEffectiveSPNameQualifier(@Nonnull org.opensaml.profile.context.ProfileRequestContext profileRequestContext)
Get the effective SPNameQualifier to apply based on the properties set and the current request.- Parameters:
profileRequestContext
- current profile context- Returns:
- the effective NameQualifier to set, or null
-
-