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

# Class AddStatusToResponse

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

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

public class AddStatusToResponse extends AbstractProfileAction
Action that sets `Status` content in a `StatusResponseType` obtained from a lookup strategy, typically from the outbound message context.

If the message already contains status information, this action will overwrite it.

Options allows for the creation of a `StatusMessage` either explicitly, or via lookup strategy.

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

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`AddStatusToResponse.StatusCodeMappingFunction`
A default method to map event IDs to SAML 2 StatusCode URIs based on `EventContext`.

## Field Summary

Fields
Modifier and Type
Field
Description
`private List<String>`
`defaultStatusCodes`
One or more status codes to insert.
`private boolean`
`detailedErrors`
Whether to include detailed status information.
`private Predicate<ProfileRequestContext>`
`detailedErrorsCondition`
Predicate determining whether detailed error information is permitted.
`private org.slf4j.Logger`
`log`
Class logger.
`private StatusResponseType`
`response`
Response to modify.
`private Function<ProfileRequestContext,StatusResponseType>`
`responseLookupStrategy`
Strategy used to locate the `StatusResponseType` to operate on.
`private Function<ProfileRequestContext,List<String>>`
`statusCodesLookupStrategy`
Optional method to obtain status codes.
`private String`
`statusMessage`
A default status message to include.
`private Function<ProfileRequestContext,String>`
`statusMessageLookupStrategy`
Optional method to obtain a status message.

## Constructor Summary

Constructors
Constructor
Description
`AddStatusToResponse()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`private void`
`buildStatusCode(Status status, List<String> codes)`
Build and attach `StatusCode` element.
`private void`
`buildStatusMessage(Status status, String message)`
Build and attach `StatusMessage` element.
`protected void`
`doExecute(ProfileRequestContext profileRequestContext)`
Performs this action.
`protected boolean`
`doPreExecute(ProfileRequestContext profileRequestContext)`
Called prior to execution, actions may override this method to perform pre-processing for a request.
`void`
`setDetailedErrorsCondition(Predicate<ProfileRequestContext> condition)`
Set the predicate used to determine the detailed errors condition.
`void`
`setResponseLookupStrategy(Function<ProfileRequestContext,StatusResponseType> strategy)`
Set the strategy used to locate the `StatusResponseType` to operate on.
`void`
`setStatusCodes(List<String> codes)`
Set the list of status code values to insert, ordered such that the top level code is first and every other code will be nested inside the previous one.
`void`
`setStatusCodesLookupStrategy(Function<ProfileRequestContext,List<String>> strategy)`
Set the optional strategy used to obtain status codes to include.
`void`
`setStatusMessage(String message)`
Set a default status message to use in the event that error detail is off, or no specific message is obtained.
`void`
`setStatusMessageLookupStrategy(Function<ProfileRequestContext,String> strategy)`
Set the optional strategy used to obtain a status message to include.

### 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, doInitialize, 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 org.slf4j.Logger log
Class logger.

### responseLookupStrategy

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

### detailedErrorsCondition

@Nonnull private Predicate<ProfileRequestContext> detailedErrorsCondition
Predicate determining whether detailed error information is permitted.

### statusCodesLookupStrategy

@Nullable private Function<ProfileRequestContext,List<String>> statusCodesLookupStrategy
Optional method to obtain status codes.

### statusMessageLookupStrategy

@Nullable private Function<ProfileRequestContext,String> statusMessageLookupStrategy
Optional method to obtain a status message.

### defaultStatusCodes

@Nonnull private List<String> defaultStatusCodes
One or more status codes to insert.

### statusMessage

@Nullable private String statusMessage
A default status message to include.

### detailedErrors

private boolean detailedErrors
Whether to include detailed status information.

### response

@NonnullBeforeExec private StatusResponseType response
Response to modify.

## Constructor Details

### AddStatusToResponse

public AddStatusToResponse()
Constructor.

## Method Details

### setResponseLookupStrategy

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

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

### setDetailedErrorsCondition

public void setDetailedErrorsCondition(@Nonnull Predicate<ProfileRequestContext> condition)
Set the predicate used to determine the detailed errors condition.

Parameters:
  `condition` - predicate for detailed errors condition

### setStatusCodesLookupStrategy

public void setStatusCodesLookupStrategy(@Nullable Function<ProfileRequestContext,List<String>> strategy)
Set the optional strategy used to obtain status codes to include.

Parameters:
  `strategy` - strategy used to obtain status codes

### setStatusMessageLookupStrategy

public void setStatusMessageLookupStrategy(@Nullable Function<ProfileRequestContext,String> strategy)
Set the optional strategy used to obtain a status message to include.

Parameters:
  `strategy` - strategy used to obtain a status message

### setStatusCodes

public void setStatusCodes(@Nonnull List<String> codes)
Set the list of status code values to insert, ordered such that the top level code is first and every other code will be nested inside the previous one.

Parameters:
  `codes` - list of status code values to insert

### setStatusMessage

public void setStatusMessage(@Nullable String message)
Set a default status message to use in the event that error detail is off, or no specific message is obtained.

Parameters:
  `message` - default status message

### 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

### buildStatusCode

private void buildStatusCode(@Nonnull Status status, @Nonnull List<String> codes)
Build and attach `StatusCode` element.

Parameters:
  `status` - the element to attach to
  `codes` - the status codes to use

### buildStatusMessage

private void buildStatusMessage(@Nonnull Status status, @Nonnull @NotEmpty String message)
Build and attach `StatusMessage` element.

Parameters:
  `status` - the element to attach to
  `message` - the message to set