Package net.shibboleth.idp.profile.testing

# Class RequestContextBuilder

java.lang.Object
net.shibboleth.idp.profile.testing.RequestContextBuilder

public class RequestContextBuilder extends Object
Builder used to construct `RequestContext` used in `Action` executions.

## Field Summary

Fields
Modifier and Type
Field
Description
`private HttpServletRequest`
`httpRequest`
The `HttpServletRequest` used when building the request context.
`private HttpServletResponse`
`httpResponse`
The `HttpServletResponse` used when building the request context.
`private Object`
`inboundMessage`
The inbound message.
`private String`
`inboundMessageId`
The ID of the inbound message.
`private Instant`
`inboundMessageIssueInstant`
The issue instant of the inbound message.
`private String`
`inboundMessageIssuer`
The issuer of the inbound message.
`private static final String`
`NO_VAL`
Value used to represent a string value that has not be set.
`private Object`
`outboundMessage`
The outbound message.
`private String`
`outboundMessageId`
The ID of the outbound message.
`private Instant`
`outboundMessageIssueInstant`
The issue instant of the outbound message.
`private String`
`outboundMessageIssuer`
The issuer of the outbound message.
`private Collection<ProfileConfiguration>`
`relyingPartyProfileConfigurations`
The profile configurations associated with the relying party.
`private ServletContext`
`servletContext`
The `ServletContext` used when building the request context.

## Constructor Summary

Constructors
Constructor
Description
`RequestContextBuilder()`
Constructor.
`RequestContextBuilder(RequestContextBuilder prototype)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected MessageContext`
`buildInboundMessageContext()`
Builds a inbound `MessageContext`.
`protected MessageContext`
`buildOutboundMessageContext()`
Builds a outbound `MessageContext`.
`ProfileRequestContext`
`buildProfileRequestContext()`
Builds a `ProfileRequestContext`.
`protected RelyingPartyConfiguration`
`buildRelyingPartyConfiguration()`
Builds a `RelyingPartyConfiguration`.
`protected RelyingPartyContext`
`buildRelyingPartyContext(ProfileRequestContext profileRequestContext)`
Builds `RelyingPartyContext`.
`RequestContext`
`buildRequestContext()`
Builds a `MockRequestContext`.
`ServletExternalContext`
`buildServletExternalContext()`
Builds a `ServletExternalContext`.
`protected ProfileConfiguration`
`selectProfileConfiguration(Map<String,ProfileConfiguration> rpProfileConfigs)`
Selects the active profile configurations from the set of registered profile configuration from the relying party configuration built by `buildRelyingPartyConfiguration()`.
`RequestContextBuilder`
`setHttpRequest(HttpServletRequest request)`
Sets the `HttpServletRequest` used when building the request context.
`RequestContextBuilder`
`setHttpResponse(HttpServletResponse response)`
Sets the `HttpServletResponse` used when building the request context.
`RequestContextBuilder`
`setInboundMessage(Object message)`
Sets the inbound message.
`RequestContextBuilder`
`setInboundMessageId(String id)`
Sets the ID of the inbound message.
`RequestContextBuilder`
`setInboundMessageIssueInstant(Instant instant)`
Sets the issue instant of the inbound message
`RequestContextBuilder`
`setInboundMessageIssuer(String issuer)`
Sets the issuer of the inbound message.
`RequestContextBuilder`
`setOutboundMessage(Object message)`
Sets the outbound message.
`RequestContextBuilder`
`setOutboundMessageId(String id)`
Sets the ID of the outbound message.
`RequestContextBuilder`
`setOutboundMessageIssueInstant(Instant instant)`
Sets the issue instant of the outbound message
`RequestContextBuilder`
`setOutboundMessageIssuer(String issuer)`
Sets the issuer of the outbound message.
`RequestContextBuilder`
`setRelyingPartyProfileConfigurations(Collection<ProfileConfiguration> configs)`
Sets the profile configurations associated with the relying party.
`RequestContextBuilder`
`setServletContext(ServletContext context)`
Sets the `ServletContext` used when building the request context.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### NO_VAL

@Nonnull @NotEmpty private static final String NO_VAL
Value used to represent a string value that has not be set.

See Also:
  - Constant Field Values

### servletContext

@Nullable private ServletContext servletContext
The `ServletContext` used when building the request context.

### httpRequest

@Nullable private HttpServletRequest httpRequest
The `HttpServletRequest` used when building the request context.

### httpResponse

@Nullable private HttpServletResponse httpResponse
The `HttpServletResponse` used when building the request context.

### inboundMessageId

@Nullable private String inboundMessageId
The ID of the inbound message.

### inboundMessageIssueInstant

@Nullable private Instant inboundMessageIssueInstant
The issue instant of the inbound message.

### inboundMessageIssuer

@Nullable private String inboundMessageIssuer
The issuer of the inbound message.

### inboundMessage

@Nullable private Object inboundMessage
The inbound message.

### outboundMessageId

@Nullable private String outboundMessageId
The ID of the outbound message.

### outboundMessageIssueInstant

@Nullable private Instant outboundMessageIssueInstant
The issue instant of the outbound message.

### outboundMessageIssuer

@Nullable private String outboundMessageIssuer
The issuer of the outbound message.

### outboundMessage

@Nullable private Object outboundMessage
The outbound message.

### relyingPartyProfileConfigurations

@Nullable private Collection<ProfileConfiguration> relyingPartyProfileConfigurations
The profile configurations associated with the relying party.

## Constructor Details

### RequestContextBuilder

public RequestContextBuilder()
Constructor.

### RequestContextBuilder

public RequestContextBuilder(@Nonnull RequestContextBuilder prototype)
Constructor.

Parameters:
  `prototype` - prototype whose properties are copied onto this builder

## Method Details

### setServletContext

@Nonnull public RequestContextBuilder setServletContext(@Nullable ServletContext context)
Sets the `ServletContext` used when building the request context.

Parameters:
  `context` - the `ServletContext` used when building the request context
Returns:
  this builder

### setHttpRequest

@Nonnull public RequestContextBuilder setHttpRequest(@Nullable HttpServletRequest request)
Sets the `HttpServletRequest` used when building the request context.

Parameters:
  `request` - the `HttpServletRequest` used when building the request context
Returns:
  this builder

### setHttpResponse

@Nonnull public RequestContextBuilder setHttpResponse(@Nullable HttpServletResponse response)
Sets the `HttpServletResponse` used when building the request context.

Parameters:
  `response` - the `HttpServletResponse` used when building the request context
Returns:
  this builder

### setInboundMessageId

@Nonnull public RequestContextBuilder setInboundMessageId(@Nullable String id)
Sets the ID of the inbound message.

Parameters:
  `id` - ID of the inbound message
Returns:
  this builder

### setInboundMessageIssueInstant

@Nonnull public RequestContextBuilder setInboundMessageIssueInstant(@Nullable Instant instant)
Sets the issue instant of the inbound message

Parameters:
  `instant` - issue instant of the inbound message
Returns:
  this builder

### setInboundMessageIssuer

@Nonnull public RequestContextBuilder setInboundMessageIssuer(@Nullable String issuer)
Sets the issuer of the inbound message.

Parameters:
  `issuer` - issuer of the inbound message
Returns:
  this builder

### setInboundMessage

@Nonnull public RequestContextBuilder setInboundMessage(@Nullable Object message)
Sets the inbound message.

Parameters:
  `message` - the inbound message
Returns:
  this builder

### setOutboundMessageId

@Nonnull public RequestContextBuilder setOutboundMessageId(@Nullable String id)
Sets the ID of the outbound message.

Parameters:
  `id` - ID of the outbound message
Returns:
  this builder

### setOutboundMessageIssueInstant

@Nonnull public RequestContextBuilder setOutboundMessageIssueInstant(@Nullable Instant instant)
Sets the issue instant of the outbound message

Parameters:
  `instant` - issue instant of the outbound message
Returns:
  this builder

### setOutboundMessageIssuer

public RequestContextBuilder setOutboundMessageIssuer(@Nullable String issuer)
Sets the issuer of the outbound message.

Parameters:
  `issuer` - issuer of the outbound message
Returns:
  this builder

### setOutboundMessage

@Nonnull public RequestContextBuilder setOutboundMessage(@Nullable Object message)
Sets the outbound message.

Parameters:
  `message` - the outbound message
Returns:
  this builder

### setRelyingPartyProfileConfigurations

@Nonnull public RequestContextBuilder setRelyingPartyProfileConfigurations(@Nullable Collection<ProfileConfiguration> configs)
Sets the profile configurations associated with the relying party.

Parameters:
  `configs` - profile configurations associated with the relying party
Returns:
  this builder

### buildRequestContext

@Nonnull public RequestContext buildRequestContext() throws ComponentInitializationException
Builds a `MockRequestContext`. The default implementation builds a `MockRequestContext` that contains a:

- `ServletExternalContext`, via `RequestContext.getExternalContext()`, created by `buildServletExternalContext()`
- `ProfileRequestContext` created by `buildProfileRequestContext()`

Returns:
  the constructed `MockRequestContext`
Throws:
  `ComponentInitializationException` - ...

### buildServletExternalContext

@Nonnull public ServletExternalContext buildServletExternalContext()
Builds a `ServletExternalContext`. The default implementations builds a `ServletExternalContext` that contains a:

- the `ServletContext` provided by `setServletContext(ServletContext)` or a `MockServletContext` if none was provided
- the `HttpServletRequest` provided by `setHttpRequest(HttpServletRequest)` or a `MockHttpServletRequest` if none was provided
- the `HttpServletResponse` provided by `setHttpResponse(HttpServletResponse)` or a `MockHttpServletResponse` if none was provided

Returns:
  the constructed `ServletContext`

### buildProfileRequestContext

@Nonnull public ProfileRequestContext buildProfileRequestContext() throws ComponentInitializationException
Builds a `ProfileRequestContext`. The default implementation builds a `ProfileRequestContext` that contains a:

- inbound message context created by `buildInboundMessageContext()`
- outbound message context created by `buildOutboundMessageContext()`
- `RelyingPartyContext` created by `buildRelyingPartyContext(ProfileRequestContext)`

Returns:
  the constructed {
Throws:
  `ComponentInitializationException` - @link ProfileRequestContext

### buildInboundMessageContext

@Nonnull protected MessageContext buildInboundMessageContext()
Builds a inbound `MessageContext`. The default implementation builds a `MessageContext` that contains:

- the message provided by `setInboundMessage(Object)`

Returns:
  the constructed `MessageContext`

### buildOutboundMessageContext

@Nonnull protected MessageContext buildOutboundMessageContext()
Builds a outbound `MessageContext`. The default implementation builds a `MessageContext` that contains:

- the message provided by `setOutboundMessage(Object)`

Returns:
  the constructed `MessageContext`

### buildRelyingPartyContext

@Nonnull protected RelyingPartyContext buildRelyingPartyContext(@Nonnull ProfileRequestContext profileRequestContext) throws ComponentInitializationException
Builds `RelyingPartyContext`. The default implementations builds a `RelyingPartyContext` with:

- a relying party ID provided by `setInboundMessageIssuer(String)` or `ActionTestingSupport.INBOUND_MSG_ISSUER` if none is given
- a relying party configuration built by `buildRelyingPartyConfiguration()`
- the active profile selected, out of the profiles registered with the built relying party configuration, by `selectProfileConfiguration(Map)`

Parameters:
  `profileRequestContext` - ...
Returns:
  the constructed `RelyingPartyContext`
Throws:
  `ComponentInitializationException` - ...

### buildRelyingPartyConfiguration

@Nonnull protected RelyingPartyConfiguration buildRelyingPartyConfiguration() throws ComponentInitializationException
Builds a `RelyingPartyConfiguration`. The default implementation of this method builds a `RelyingPartyConfiguration` such that:

- configuration ID is 'mock'
- the responder ID provided by `setOutboundMessageIssuer(String)` or `ActionTestingSupport.OUTBOUND_MSG_ISSUER` if none is given
- the activation criteria is `Predicates.alwaysTrue()`
- the profile configurations provided `setRelyingPartyProfileConfigurations(Collection)` or one `MockProfileConfiguration` if none is provided

Returns:
  the constructed `RelyingPartyConfiguration`
Throws:
  `ComponentInitializationException` - ...

### selectProfileConfiguration

@Nullable protected ProfileConfiguration selectProfileConfiguration(@Nonnull Map<String,ProfileConfiguration> rpProfileConfigs)
Selects the active profile configurations from the set of registered profile configuration from the relying party configuration built by `buildRelyingPartyConfiguration()`. The default implementation of this method simply returns the first value of the `Map.values()` collection.

Parameters:
  `rpProfileConfigs` - the set of profile configurations associated with the constructed relying party
Returns:
  the active `ProfileConfiguration`