Package org.opensaml.profile.action

# Class AbstractProfileAction

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.profile.action.AbstractProfileAction

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

Direct Known Subclasses:
  `AbstractConditionalProfileAction`, `AbstractDecryptAction`, `AbstractMessageChannelSecurity`, `AbstractResponseShellAction`, `AddNameIdentifierToSubjects`, `AddNameIDToSubjects`, `AddResponseShell`, `AddSOAPFault`, `AddStatusResponseShell`, `AddStatusToResponse`, `AddStatusToResponse`, `AddSubjectConfirmationToSubjects`, `AddSubjectConfirmationToSubjects`, `CheckAccess`, `CopyNameIdentifierFromRequest`, `CopyNameIDFromRequest`, `DecodeMessage`, `EncodeMessage`, `LoadClientStorageServices`, `LogEvent`, `LogLocalStorageSaveResults`, `PopulateClientStorageLoadContext`, `PopulateClientStorageSaveContext`, `PopulateClientTLSValidationParameters`, `PopulateMetricContext`, `ResolveArtifact`, `ResolveArtifacts`, `SaveCookieBackedClientStorageServices`, `SetProfileId`, `SignAssertions`, `ValidateAssertions`, `VerifyChannelBindings`

@Prototype public abstract class AbstractProfileAction extends AbstractInitializableComponent implements ProfileAction
Base class for profile actions. This base class is annotated with `Prototype` to indicate that it is stateful.

## Field Summary

Fields
Modifier and Type
Field
Description
`private NonnullSupplier<HttpServletRequest>`
`httpServletRequestSupplier`
Supplier for the Current HTTP request, if available.
`private NonnullSupplier<HttpServletResponse>`
`httpServletResponseSupplier`
Current HTTP response, if available.
`private String`
`logPrefix`
Cached log prefix.
`private boolean`
`preExecuted`
Has `doPreExecute(ProfileRequestContext)` been called?.

## Constructor Summary

Constructors
Constructor
Description
`AbstractProfileAction()`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`doExecute(ProfileRequestContext profileRequestContext)`
Performs this action.
`protected void`
`doPostExecute(ProfileRequestContext profileRequestContext)`
Called after execution, actions may override this method to perform post-processing for a request.
`protected void`
`doPostExecute(ProfileRequestContext profileRequestContext, Exception e)`
Called after execution, actions may override this method to perform post-processing for a request.
`protected boolean`
`doPreExecute(ProfileRequestContext profileRequestContext)`
Called prior to execution, actions may override this method to perform pre-processing for a request.
`HttpServletRequest`
`ensureHttpServletRequest()`
Get the current HTTP request if available, raising an `IllegalStateException` if absent.
`HttpServletResponse`
`ensureHttpServletResponse()`
Get the current HTTP response if available, raising an `IllegalStateException` if absent.
`void`
`execute(ProfileRequestContext profileRequestContext)`
Performs this action.
`HttpServletRequest`
`getHttpServletRequest()`
Get the current HTTP request if available.
`NonnullSupplier<HttpServletRequest>`
`getHttpServletRequestSupplier()`
Get the supplier for HTTP request if available.
`HttpServletResponse`
`getHttpServletResponse()`
Get the current HTTP response if available.
`NonnullSupplier<HttpServletResponse>`
`getHttpServletResponseSupplier()`
Get the current HTTP response supplier if available.
`protected String`
`getLogPrefix()`
Return a prefix for logging messages for this component.
`protected boolean`
`isPreExecuteCalled()`
Has the `doPreExecute(ProfileRequestContext)` method been entirely called? Note the unsynchronized access.
`void`
`setHttpServletRequestSupplier(NonnullSupplier<HttpServletRequest> requestSupplier)`
Set the current HTTP request Supplier.
`void`
`setHttpServletResponseSupplier(NonnullSupplier<HttpServletResponse> supplier)`
Set the supplier of the current HTTP response.

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

### logPrefix

@Nullable private String logPrefix
Cached log prefix.

### httpServletRequestSupplier

@Nullable private NonnullSupplier<HttpServletRequest> httpServletRequestSupplier
Supplier for the Current HTTP request, if available.

### httpServletResponseSupplier

@Nullable private NonnullSupplier<HttpServletResponse> httpServletResponseSupplier
Current HTTP response, if available.

### preExecuted

private boolean preExecuted
Has `doPreExecute(ProfileRequestContext)` been called?. Only ever set to true

## Constructor Details

### AbstractProfileAction

public AbstractProfileAction()

## Method Details

### getHttpServletRequest

@Nullable public HttpServletRequest getHttpServletRequest()
Get the current HTTP request if available.

Returns:
  current HTTP request

### ensureHttpServletRequest

@Nonnull public HttpServletRequest ensureHttpServletRequest()
Get the current HTTP request if available, raising an `IllegalStateException` if absent.

Returns:
  current HTTP request
Since:
  5.0.0

### getHttpServletRequestSupplier

@Nullable public NonnullSupplier<HttpServletRequest> getHttpServletRequestSupplier()
Get the supplier for HTTP request if available.

Returns:
  current HTTP request

### setHttpServletRequestSupplier

public void setHttpServletRequestSupplier(@Nullable NonnullSupplier<HttpServletRequest> requestSupplier)
Set the current HTTP request Supplier.

Parameters:
  `requestSupplier` - Supplier for the current HTTP request

### getHttpServletResponse

@Nullable public HttpServletResponse getHttpServletResponse()
Get the current HTTP response if available.

Returns:
  current HTTP response or null

### ensureHttpServletResponse

@Nonnull public HttpServletResponse ensureHttpServletResponse()
Get the current HTTP response if available, raising an `IllegalStateException` if absent.

Returns:
  current HTTP response
Since:
  5.0.0

### getHttpServletResponseSupplier

@Nullable public NonnullSupplier<HttpServletResponse> getHttpServletResponseSupplier()
Get the current HTTP response supplier if available.

Returns:
  current HTTP response supplier or null

### setHttpServletResponseSupplier

public void setHttpServletResponseSupplier(@Nullable NonnullSupplier<HttpServletResponse> supplier)
Set the supplier of the current HTTP response.

Parameters:
  `supplier` - what to set

### execute

public void execute(@Nonnull ProfileRequestContext profileRequestContext)
Performs this action.

Specified by:
  `execute` in interface `ProfileAction`
Parameters:
  `profileRequestContext` - the current IdP profile request context

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

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.

Parameters:
  `profileRequestContext` - the current IdP profile request context

### doPostExecute

protected void doPostExecute(@Nonnull ProfileRequestContext profileRequestContext)
Called after execution, actions may override this method to perform post-processing for a request.

Actions must not "fail" during this step and will not have the opportunity to signal events at this stage. This method will not be called if `doPreExecute(org.opensaml.profile.context.ProfileRequestContext)` fails, but is called if an exception is raised by `doExecute(org.opensaml.profile.context.ProfileRequestContext)`.

Parameters:
  `profileRequestContext` - the current IdP profile request context

### doPostExecute

protected void doPostExecute(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull Exception e)
Called after execution, actions may override this method to perform post-processing for a request.

Actions must not "fail" during this step and will not have the opportunity to signal events at this stage. This method will not be called if `doPreExecute(org.opensaml.profile.context.ProfileRequestContext)` fails, but is called if an exception is raised by `doExecute(org.opensaml.profile.context.ProfileRequestContext)`.

This version of the method will be called if an exception is raised during execution of the action. The overall action result will be to raise this error, so any errors inadvertently raised by this method will be logged and superseded.

The default implementation simply calls the error-less version of this method.

Parameters:
  `profileRequestContext` - the current IdP profile request context
  `e` - an exception raised by the `doExecute(org.opensaml.profile.context.ProfileRequestContext)` method

### isPreExecuteCalled

protected boolean isPreExecuteCalled()
Has the `doPreExecute(ProfileRequestContext)` method been entirely called? Note the unsynchronized access. The underlying field is only ever set true, so if true is returned it is correct, if false is returned is is not safe to make any assumptions (even if there was an call in flight.

Returns:
  whether the preExecute hook was called
Since:
  5.0.0

### getLogPrefix

@Nonnull @NotEmpty protected String getLogPrefix()
Return a prefix for logging messages for this component.

Returns:
  a string for insertion at the beginning of any log messages