Class AddStatusToResponse

All Implemented Interfaces:
Component, DestructableComponent, InitializableComponent, ProfileAction

public class AddStatusToResponse extends AbstractProfileAction
Action that sets Status content in a Response 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
  • Field Details

    • log

      @Nonnull private org.slf4j.Logger log
      Class logger.
    • responseLookupStrategy

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

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

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

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

      @Nonnull @NonnullElements private List<QName> defaultStatusCodes
      One or more default 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

      @Nullable private Response response
      Response to modify.
  • Constructor Details

    • AddStatusToResponse

      public AddStatusToResponse()
      Constructor.
  • Method Details

    • 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<QName>> 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
    • 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
    • setStatusCodes

      public void setStatusCodes(@Nonnull @NonnullElements List<QName> codes)
      Set the default 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 @NonnullElements List<QName> 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