Package org.opensaml.saml.saml2.testing

# Class SAML2ActionTestingSupport

java.lang.Object
org.opensaml.saml.saml2.testing.SAML2ActionTestingSupport

public class SAML2ActionTestingSupport extends Object
Helper methods for creating/testing SAML 2 objects within profile action tests. When methods herein refer to mock objects they are always objects that have been created via Mockito unless otherwise noted.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`ASSERTION_ID`
ID used for all generated `Assertion` objects.
`static final String`
`REQUEST_ID`
ID used for all generated `Response` objects.
`static final String`
`RESPONSE_ID`
ID used for all generated `Response` objects.

## Constructor Summary

Constructors
Constructor
Description
`SAML2ActionTestingSupport()`

## Method Summary

Modifier and Type
Method
Description
`static ArtifactResolve`
`buildArtifactResolve(String artifact)`
Builds a `ArtifactResolve`.
`static ArtifactResponse`
`buildArtifactResponse()`
Builds an empty artifact response.
`static Assertion`
`buildAssertion()`
Builds an empty assertion.
`static Attribute`
`buildAttribute(String name, String format, Collection<String> values)`
Builds an attribute and values.
`static AttributeQuery`
`buildAttributeQueryRequest(Subject subject)`
Builds an `AttributeQuery`.
`static AttributeStatement`
`buildAttributeStatement()`
Builds an empty attribute statement.
`static AuthnRequest`
`buildAuthnRequest()`
Builds an `AuthnRequest`.
`static AuthnStatement`
`buildAuthnStatement()`
Builds an authentication statement.
`static AuthnStatement`
`buildAuthnStatement(Instant ts, String address, String classRef)`
Builds an authentication statement with specified timestamp and subject locality data and context class ref.
`static Conditions`
`buildConditions(Instant notBefore, Instant notOnOrAfter, String audience)`
Builds a `Conditions`, with optional content.
`static Issuer`
`buildIssuer(String entityID)`
Builds a `Issuer`.
`static LogoutRequest`
`buildLogoutRequest(NameID name)`
Builds an `LogoutRequest`.
`static LogoutResponse`
`buildLogoutResponse()`
Builds an empty logout response.
`static NameID`
`buildNameID(String principalName)`
Builds a `NameID`.
`static Response`
`buildResponse()`
Builds an empty response.
`static Scoping`
`buildScoping(Integer count, Set<String> idplist)`
Build a `Scoping`.
`static Status`
`buildStatus(String codeString, String subcodeString)`
Builds a `Status`.
`static Subject`
`buildSubject(String principalName)`
Builds a `Subject`.
`static SubjectConfirmation`
`buildSubjectConfirmation(String method, String recipient, String address)`
Builds a `SubjectConfirmation`.

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

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

## Field Details

### REQUEST_ID

@Nonnull public static final String REQUEST_ID
ID used for all generated `Response` objects.

See Also:
  - Constant Field Values

### RESPONSE_ID

@Nonnull public static final String RESPONSE_ID
ID used for all generated `Response` objects.

See Also:
  - Constant Field Values

### ASSERTION_ID

@Nonnull public static final String ASSERTION_ID
ID used for all generated `Assertion` objects.

See Also:
  - Constant Field Values

## Constructor Details

### SAML2ActionTestingSupport

public SAML2ActionTestingSupport()

## Method Details

### buildResponse

@Nonnull public static Response buildResponse()
Builds an empty response. The ID of the message is `ActionTestingSupport.OUTBOUND_MSG_ID`, the issue instant is 1970-01-01T00:00:00Z and the SAML version is `SAMLVersion.VERSION_11`.

Returns:
  the constructed response

### buildArtifactResponse

@Nonnull public static ArtifactResponse buildArtifactResponse()
Builds an empty artifact response. The ID of the message is `ActionTestingSupport.OUTBOUND_MSG_ID`, the issue instant is 1970-01-01T00:00:00Z and the SAML version is `SAMLVersion.VERSION_11`.

Returns:
  the constructed response

### buildLogoutRequest

@Nonnull public static LogoutRequest buildLogoutRequest(@Nullable NameID name)
Builds an `LogoutRequest`. If a `NameID` is given, it will be added to the constructed `LogoutRequest`.

Parameters:
  `name` - the NameID to add to the request
Returns:
  the built request

### buildLogoutResponse

@Nonnull public static LogoutResponse buildLogoutResponse()
Builds an empty logout response. The ID of the message is `ActionTestingSupport.OUTBOUND_MSG_ID`, the issue instant is 1970-01-01T00:00:00Z and the SAML version is `SAMLVersion.VERSION_11`.

Returns:
  the constructed response

### buildAssertion

@Nonnull public static Assertion buildAssertion()
Builds an empty assertion. The ID of the message is `ASSERTION_ID`, the issue instant is 1970-01-01T00:00:00Z and the SAML version is `SAMLVersion.VERSION_11`.

Returns:
  the constructed assertion

### buildAuthnStatement

@Nonnull public static AuthnStatement buildAuthnStatement()
Builds an authentication statement. The authn instant is set to 1970-01-01T00:00:00Z.

Returns:
  the constructed statement

### buildAuthnStatement

@Nonnull public static AuthnStatement buildAuthnStatement(@Nonnull Instant ts, @Nonnull String address, @Nonnull String classRef)
Builds an authentication statement with specified timestamp and subject locality data and context class ref.

Parameters:
  `ts` - authn time
  `address` - client address
  `classRef` - authentication context class ref
Returns:
  the constructed statement
Since:
  5.2.0

### buildAttributeStatement

@Nonnull public static AttributeStatement buildAttributeStatement()
Builds an empty attribute statement.

Returns:
  the constructed statement

### buildAttribute

@Nonnull public static Attribute buildAttribute(@Nonnull String name, @Nullable String format, @Nonnull Collection<String> values)
Builds an attribute and values.

Parameters:
  `name` - attribute name
  `format` - name format
  `values` - value collection
Returns:
  the constructed attribute
Since:
  5.2.0

### buildSubject

@Nonnull public static Subject buildSubject(@Nullable String principalName)
Builds a `Subject`. If a principal name is given a `NameID`, whose value is the given principal name, will be created and added to the `Subject`.

Parameters:
  `principalName` - the principal name to add to the subject
Returns:
  the built subject

### buildNameID

@Nonnull public static NameID buildNameID(@Nonnull @NotEmpty String principalName)
Builds a `NameID`.

Parameters:
  `principalName` - the principal name to use in the NameID
Returns:
  the built NameID

### buildSubjectConfirmation

@Nonnull public static SubjectConfirmation buildSubjectConfirmation(@Nullable String method, @Nullable String recipient, @Nullable String address)
Builds a `SubjectConfirmation`.

Parameters:
  `method` - confirmation method
  `recipient` - recipient value
  `address` - confirmation address
Returns:
  the built subject confirmation
Since:
  5.2.0

### buildIssuer

@Nonnull public static Issuer buildIssuer(@Nonnull @NotEmpty String entityID)
Builds a `Issuer`.

Parameters:
  `entityID` - the entity ID to use in the Issuer
Returns:
  the built Issuer

### buildConditions

@Nonnull public static Conditions buildConditions(@Nullable Instant notBefore, @Nullable Instant notOnOrAfter, @Nullable String audience)
Builds a `Conditions`, with optional content.

Parameters:
  `notBefore` - the NotBefore to set
  `notOnOrAfter` - the NotOnOrAfter to set
  `audience` - audience to place into `AudienceRestriction`
Returns:
  the object
Since:
  5.2.0

### buildAttributeQueryRequest

@Nonnull public static AttributeQuery buildAttributeQueryRequest(@Nullable Subject subject)
Builds an `AttributeQuery`. If a `Subject` is given, it will be added to the constructed `AttributeQuery`.

Parameters:
  `subject` - the subject to add to the query
Returns:
  the built query

### buildAuthnRequest

@Nonnull public static AuthnRequest buildAuthnRequest()
Builds an `AuthnRequest`.

Returns:
  the built request

### buildScoping

@Nonnull public static Scoping buildScoping(@Nullable Integer count, @Nullable Set<String> idplist)
Build a `Scoping`.

Parameters:
  `count` - proxy count
  `idplist` - list of IdP entityIDs
Returns:
  populated `Scoping`
Since:
  4.0.0

### buildArtifactResolve

@Nonnull public static ArtifactResolve buildArtifactResolve(@Nullable String artifact)
Builds a `ArtifactResolve`.

Parameters:
  `artifact` - the artifact to add to the request
Returns:
  the built request

### buildStatus

@Nonnull public static Status buildStatus(@Nonnull String codeString, @Nullable String subcodeString)
Builds a `Status`.

Parameters:
  `codeString` - status code string
  `subcodeString` - subcode string if any
Returns:
  the object
Since:
  5.2.0