Package org.opensaml.saml.saml2.profile.impl

# Class AddSubjectConfirmationToSubjects

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.profile.action.AbstractProfileAction
org.opensaml.saml.saml2.profile.impl.AddSubjectConfirmationToSubjects

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

public class AddSubjectConfirmationToSubjects extends AbstractProfileAction
Action that builds `SubjectConfirmation` and adds it to the `Subject` of all the assertions found in a `Response`. The message to update is returned by a lookup strategy, by default the message returned by `InOutOperationContext.getOutboundMessageContext()`.

No assertions will be created by this action, but if no `Subject` exists in the assertions found, it will be cretaed.

An associated `SubjectConfirmationData` will be built to spec based on a set of lookup functions that optionally provide various attributes. They have appropriate defaults for the simple use case of a bearer SSO assertion but need to be overridden for other cases.

Event:
  `EventIds.PROCEED_EVENT_ID`, `EventIds.INVALID_MSG_CTX`

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`private class`
`AddSubjectConfirmationToSubjects.RemoteAddressStrategy`
Default strategy for obtaining client address from servlet layer.

## Field Summary

Fields
Modifier and Type
Field
Description
`private Function<ProfileRequestContext,String>`
`addressLookupStrategy`
Strategy to obtain value for `SubjectConfirmationData.getAddress()`.
`private final SAMLObjectBuilder<SubjectConfirmation>`
`confirmationBuilder`
Builder for SubjectConfirmation objects.
`private final SAMLObjectBuilder<SubjectConfirmationData>`
`confirmationDataBuilder`
Builder for SubjectConfirmation objects.
`private String`
`confirmationMethod`
Method to add.
`private Function<ProfileRequestContext,String>`
`inResponseToLookupStrategy`
Optional strategy to obtain value for `SubjectConfirmationData.getInResponseTo()`.
`private Function<ProfileRequestContext,Long>`
`lifetimeLookupStrategy`
Optional strategy to obtain value for `SubjectConfirmationData.getNotOnOrAfter()`.
`private final org.slf4j.Logger`
`log`
Class logger.
`private boolean`
`overwriteExisting`
Flag controlling whether to overwrite existing confirmations.
`private Function<ProfileRequestContext,String>`
`recipientLookupStrategy`
Optional strategy to obtain value for `SubjectConfirmationData.getRecipient()`.
`private Response`
`response`
Response to modify.
`private Function<ProfileRequestContext,Response>`
`responseLookupStrategy`
Strategy used to locate the `Response` to operate on.
`private final SAMLObjectBuilder<Subject>`
`subjectBuilder`
Builder for Subject objects.

## Constructor Summary

Constructors
Constructor
Description
`AddSubjectConfirmationToSubjects()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`private SubjectConfirmation`
`cloneConfirmation(SubjectConfirmation confirmation)`
Create an efficient field-wise copy of a `SubjectConfirmation`.
`protected void`
`doExecute(ProfileRequestContext profileRequestContext)`
Performs this action.
`protected void`
`doInitialize()`
`protected boolean`
`doPreExecute(ProfileRequestContext profileRequestContext)`
Called prior to execution, actions may override this method to perform pre-processing for a request.
`private Subject`
`getAssertionSubject(Assertion assertion)`
Get the subject to which the confirmation will be added.
`void`
`setAddressLookupStrategy(Function<ProfileRequestContext,String> strategy)`
Set the strategy used to obtain value for `SubjectConfirmationData.getAddress()`.
`void`
`setInResponseToLookupStrategy(Function<ProfileRequestContext,String> strategy)`
Set the strategy used to obtain value for `SubjectConfirmationData.getInResponseTo()`.
`void`
`setLifetimeLookupStrategy(Function<ProfileRequestContext,Long> strategy)`
Set the strategy used to obtain value for `SubjectConfirmationData.getNotOnOrAfter()`.
`void`
`setMethod(String method)`
Set the confirmation method to use.
`void`
`setOverwriteExisting(boolean flag)`
Set whether to overwrite any existing `SubjectConfirmation` objects found.
`void`
`setRecipientLookupStrategy(Function<ProfileRequestContext,String> strategy)`
Set the strategy used to obtain value for `SubjectConfirmationData.getRecipient()`.
`void`
`setResponseLookupStrategy(Function<ProfileRequestContext,Response> strategy)`
Set the strategy used to locate the `Response` to operate on.

### Methods inherited from class org.opensaml.profile.action.AbstractProfileAction

`doPostExecute, doPostExecute, ensureHttpServletRequest, ensureHttpServletResponse, execute, getHttpServletRequest, getHttpServletRequestSupplier, getHttpServletResponse, getHttpServletResponseSupplier, getLogPrefix, isPreExecuteCalled, setHttpServletRequestSupplier, setHttpServletResponseSupplier`

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

`checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, 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.shared.component.InitializableComponent

`initialize, isInitialized`

## Field Details

### log

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

### subjectBuilder

@Nonnull private final SAMLObjectBuilder<Subject> subjectBuilder
Builder for Subject objects.

### confirmationBuilder

@Nonnull private final SAMLObjectBuilder<SubjectConfirmation> confirmationBuilder
Builder for SubjectConfirmation objects.

### confirmationDataBuilder

@Nonnull private final SAMLObjectBuilder<SubjectConfirmationData> confirmationDataBuilder
Builder for SubjectConfirmation objects.

### overwriteExisting

private boolean overwriteExisting
Flag controlling whether to overwrite existing confirmations.

### responseLookupStrategy

@Nonnull private Function<ProfileRequestContext,Response> responseLookupStrategy
Strategy used to locate the `Response` to operate on.

### addressLookupStrategy

@NonnullAfterInit private Function<ProfileRequestContext,String> addressLookupStrategy
Strategy to obtain value for `SubjectConfirmationData.getAddress()`.

### inResponseToLookupStrategy

@Nullable private Function<ProfileRequestContext,String> inResponseToLookupStrategy
Optional strategy to obtain value for `SubjectConfirmationData.getInResponseTo()`.

### recipientLookupStrategy

@Nullable private Function<ProfileRequestContext,String> recipientLookupStrategy
Optional strategy to obtain value for `SubjectConfirmationData.getRecipient()`.

### lifetimeLookupStrategy

@Nullable private Function<ProfileRequestContext,Long> lifetimeLookupStrategy
Optional strategy to obtain value for `SubjectConfirmationData.getNotOnOrAfter()`.

### confirmationMethod

@NonnullAfterInit private String confirmationMethod
Method to add.

### response

@NonnullBeforeExec private Response response
Response to modify.

## Constructor Details

### AddSubjectConfirmationToSubjects

public AddSubjectConfirmationToSubjects()
Constructor.

## Method Details

### setOverwriteExisting

public void setOverwriteExisting(boolean flag)
Set whether to overwrite any existing `SubjectConfirmation` objects found.

Parameters:
  `flag` - true iff the action should overwrite any existing objects

### setResponseLookupStrategy

public void setResponseLookupStrategy(@Nonnull Function<ProfileRequestContext,Response> strategy)
Set the strategy used to locate the `Response` to operate on.

Parameters:
  `strategy` - strategy used to locate the `Response` to operate on

### setAddressLookupStrategy

public void setAddressLookupStrategy(@Nullable Function<ProfileRequestContext,String> strategy)
Set the strategy used to obtain value for `SubjectConfirmationData.getAddress()`.

Parameters:
  `strategy` - lookup strategy

### setInResponseToLookupStrategy

public void setInResponseToLookupStrategy(@Nullable Function<ProfileRequestContext,String> strategy)
Set the strategy used to obtain value for `SubjectConfirmationData.getInResponseTo()`.

Parameters:
  `strategy` - lookup strategy

### setRecipientLookupStrategy

public void setRecipientLookupStrategy(@Nullable Function<ProfileRequestContext,String> strategy)
Set the strategy used to obtain value for `SubjectConfirmationData.getRecipient()`.

Parameters:
  `strategy` - lookup strategy

### setLifetimeLookupStrategy

public void setLifetimeLookupStrategy(@Nullable Function<ProfileRequestContext,Long> strategy)
Set the strategy used to obtain value for `SubjectConfirmationData.getNotOnOrAfter()`.

Parameters:
  `strategy` - lookup strategy

### setMethod

public void setMethod(@Nonnull @NotEmpty String method)
Set the confirmation method to use.

Parameters:
  `method` - confirmation method to use

### doInitialize

protected void doInitialize() throws ComponentInitializationException

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

### doPreExecute

protected boolean doPreExecute(@Nonnull ProfileRequestContext profileRequestContext)
Called prior to execution, actions may override this method to perform pre-processing for a request.

If false is returned, execution will not proceed, and the action should attach an `EventContext` to the context tree to signal how to continue with overall workflow processing.

If returning successfully, the last step should be to return the result of the superclass version of this method.

Overrides:
  `doPreExecute` in class `AbstractProfileAction`
Parameters:
  `profileRequestContext` - the current IdP profile request context
Returns:
  true iff execution should proceed

### doExecute

protected void doExecute(@Nonnull ProfileRequestContext profileRequestContext)
Performs this action. Actions must override this method to perform their work.

Overrides:
  `doExecute` in class `AbstractProfileAction`
Parameters:
  `profileRequestContext` - the current IdP profile request context

### getAssertionSubject

@Nonnull private Subject getAssertionSubject(@Nonnull Assertion assertion)
Get the subject to which the confirmation will be added.

Parameters:
  `assertion` - the assertion being modified
Returns:
  the subject to which the confirmation will be added

### cloneConfirmation

@Nonnull private SubjectConfirmation cloneConfirmation(@Nonnull SubjectConfirmation confirmation)
Create an efficient field-wise copy of a `SubjectConfirmation`.

Parameters:
  `confirmation` - the object to clone
Returns:
  the copy