Class AddNameIdentifierToSubjects
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- org.opensaml.profile.action.AbstractProfileAction
-
- org.opensaml.saml.saml1.profile.impl.AddNameIdentifierToSubjects
-
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,ProfileAction
public class AddNameIdentifierToSubjects extends AbstractProfileAction
Action that builds aNameIdentifierand adds it to theSubjectof all the statements in all the assertions found via a lookup strategy, by default from the outbound message context.No assertions or statements will be created by this action, but if no
Subjectexists in the statements found, it will be created.The source of the
NameIdentifieris one of a set of candidateSAML1NameIdentifierGeneratorplugins injected into the action. The plugin(s) to attempt to use are derived from the Format value, which is established by a lookup strategy.- Event:
EventIds.PROCEED_EVENT_ID
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classAddNameIdentifierToSubjects.AssertionStrategyDefault strategy for obtaining assertions to modify.
-
Field Summary
Fields Modifier and Type Field Description private List<Assertion>assertionsAssertions to modify.private Function<ProfileRequestContext,List<Assertion>>assertionsLookupStrategyStrategy used to locate theAssertions to operate on.private Function<ProfileRequestContext,List<String>>formatLookupStrategyStrategy used to determine the formats to try.private List<String>formatsFormats to try.private SAML1NameIdentifierGeneratorgeneratorGenerator to use.private org.slf4j.LoggerlogClass logger.private SAMLObjectBuilder<NameIdentifier>nameIdentifierBuilderBuilder for NameIdentifier objects.private booleanoverwriteExistingFlag controlling whether to overwrite an existing NameIdentifier.private SAMLObjectBuilder<Subject>subjectBuilderBuilder for Subject objects.
-
Constructor Summary
Constructors Constructor Description AddNameIdentifierToSubjects()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private NameIdentifiercloneNameIdentifier(NameIdentifier nameIdentifier)Create an efficient field-wise copy of aNameIdentifier.protected voiddoExecute(ProfileRequestContext profileRequestContext)protected voiddoInitialize()protected booleandoPreExecute(ProfileRequestContext profileRequestContext)private NameIdentifiergenerateNameIdentifier(ProfileRequestContext profileRequestContext)Attempt to generate aNameIdentifierusing each of the candidate Formats and plugins.private SubjectgetStatementSubject(SubjectStatement statement)Get the subject to which the name identifier will be added.voidsetAssertionsLookupStrategy(Function<ProfileRequestContext,List<Assertion>> strategy)Set the strategy used to locate theAssertions to operate on.voidsetFormatLookupStrategy(Function<ProfileRequestContext,List<String>> strategy)Set the strategy function to use to obtain the formats to try.voidsetNameIdentifierGenerator(SAML1NameIdentifierGenerator theGenerator)Set the generator to use.voidsetOverwriteExisting(boolean flag)Set whether to overwrite any existingNameIdentifierobjects found.-
Methods inherited from class org.opensaml.profile.action.AbstractProfileAction
doPostExecute, doPostExecute, execute, getHttpServletRequest, getHttpServletResponse, getLogPrefix, setHttpServletRequest, setHttpServletResponse
-
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
-
Methods inherited from interface net.shibboleth.utilities.java.support.component.InitializableComponent
initialize, isInitialized
-
-
-
-
Field Detail
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
subjectBuilder
@Nonnull private final SAMLObjectBuilder<Subject> subjectBuilder
Builder for Subject objects.
-
nameIdentifierBuilder
@Nonnull private final SAMLObjectBuilder<NameIdentifier> nameIdentifierBuilder
Builder for NameIdentifier objects.
-
overwriteExisting
private boolean overwriteExisting
Flag controlling whether to overwrite an existing NameIdentifier.
-
assertionsLookupStrategy
@Nonnull private Function<ProfileRequestContext,List<Assertion>> assertionsLookupStrategy
Strategy used to locate theAssertions to operate on.
-
formatLookupStrategy
@Nonnull private Function<ProfileRequestContext,List<String>> formatLookupStrategy
Strategy used to determine the formats to try.
-
generator
@NonnullAfterInit private SAML1NameIdentifierGenerator generator
Generator to use.
-
formats
@Nonnull @NonnullElements private List<String> formats
Formats to try.
-
assertions
@Nonnull @NonnullElements private List<Assertion> assertions
Assertions to modify.
-
-
Method Detail
-
setOverwriteExisting
public void setOverwriteExisting(boolean flag)
Set whether to overwrite any existingNameIdentifierobjects found.- Parameters:
flag- true iff the action should overwrite any existing objects
-
setAssertionsLookupStrategy
public void setAssertionsLookupStrategy(@Nonnull Function<ProfileRequestContext,List<Assertion>> strategy)Set the strategy used to locate theAssertions to operate on.- Parameters:
strategy- lookup strategy
-
setFormatLookupStrategy
public void setFormatLookupStrategy(@Nonnull Function<ProfileRequestContext,List<String>> strategy)Set the strategy function to use to obtain the formats to try.- Parameters:
strategy- format lookup strategy
-
setNameIdentifierGenerator
public void setNameIdentifierGenerator(@Nonnull SAML1NameIdentifierGenerator theGenerator)Set the generator to use.- Parameters:
theGenerator- the generator to use
-
doInitialize
protected void doInitialize() throws ComponentInitializationException- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
doPreExecute
protected boolean doPreExecute(@Nonnull ProfileRequestContext profileRequestContext)- Overrides:
doPreExecutein classAbstractProfileAction
-
doExecute
protected void doExecute(@Nonnull ProfileRequestContext profileRequestContext)- Overrides:
doExecutein classAbstractProfileAction
-
generateNameIdentifier
@Nullable private NameIdentifier generateNameIdentifier(@Nonnull ProfileRequestContext profileRequestContext)
Attempt to generate aNameIdentifierusing each of the candidate Formats and plugins.- Parameters:
profileRequestContext- current profile request context- Returns:
- a generated
NameIdentifieror null
-
getStatementSubject
@Nonnull private Subject getStatementSubject(@Nonnull SubjectStatement statement)
Get the subject to which the name identifier will be added.- Parameters:
statement- the statement being modified- Returns:
- the subject to which the name identifier will be added
-
cloneNameIdentifier
@Nonnull private NameIdentifier cloneNameIdentifier(@Nonnull NameIdentifier nameIdentifier)
Create an efficient field-wise copy of aNameIdentifier.- Parameters:
nameIdentifier- the object to clone- Returns:
- the copy
-
-