Class SamlAssertionValidator.Builder

java.lang.Object
org.apache.juneau.rest.server.auth.saml.SamlAssertionValidator.Builder
Enclosing class:
SamlAssertionValidator

public static class SamlAssertionValidator.Builder extends Object
  • Constructor Details

    • Builder

      protected Builder()
      Constructor.
  • Method Details

    • metadataResolver

      public SamlAssertionValidator.Builder metadataResolver(org.opensaml.saml.metadata.resolver.MetadataResolver value)
      Sets the MetadataResolver used to resolve the IdP's signing credential at validation time.

      Mutually exclusive with signingCredential(Credential).

      The metadata supplies the trust anchor, so prefer a resolver whose metadata signature is verified against a pinned certificate, e.g. SamlMetadataResolvers.url(String, java.security.cert.X509Certificate). Unsigned metadata is only as trustworthy as the transport it was fetched over.

      Parameters:
      value - The metadata resolver. Must not be null.
      Returns:
      This object.
    • signingCredential

      public SamlAssertionValidator.Builder signingCredential(org.opensaml.security.credential.Credential value)
      Sets a static IdP signing credential. Useful when metadata is not available.

      Mutually exclusive with metadataResolver(MetadataResolver).

      Parameters:
      value - The IdP signing credential. Must not be null.
      Returns:
      This object.
    • decryptionCredential

      public SamlAssertionValidator.Builder decryptionCredential(org.opensaml.security.credential.Credential value)
      Sets the credential used to decrypt <EncryptedAssertion> elements.

      If the response contains encrypted assertions and no decryption credential is configured, validation fails with AuthenticationException.

      Parameters:
      value - The SP decryption credential. Must not be null.
      Returns:
      This object.
    • spEntityId

      Sets the Service Provider entity ID used to validate <AudienceRestriction>.
      Parameters:
      value - The SP entity ID. Must not be null or blank.
      Returns:
      This object.
    • expectedIssuer

      Sets the expected IdP issuer (the <Issuer> element). Required.
      Parameters:
      value - The expected IdP entity ID. Must not be null or blank.
      Returns:
      This object.
    • algorithms

      Replaces the default signature-algorithm allowlist with the supplied URIs.

      SHA-1 algorithms are silently filtered out (permanent rejection).

      Parameters:
      values - The XML-DSig algorithm URIs to allow. Must contain at least one non-SHA-1 entry.
      Returns:
      This object.
    • digestAlgorithms

      Replaces the default reference-digest allowlist with the supplied URIs.

      The reference DigestMethod of the enveloped signature must appear in this set. SHA-1 algorithms are silently filtered out (permanent rejection), mirroring algorithms(String...).

      Parameters:
      values - The XML-DSig digest algorithm URIs to allow. Must contain at least one non-SHA-1 entry.
      Returns:
      This object.
    • recipient

      Sets the expected Recipient (this SP's Assertion Consumer Service URL). Required.

      Every validated assertion must carry a bearer <SubjectConfirmation> whose <SubjectConfirmationData> names this exact Recipient, is within its NotBefore/NotOnOrAfter window, and satisfies the subjectAddress(String) expectation. A response carrying a Destination must name this URL as well.

      Parameters:
      value - The expected ACS URL. Must not be null or blank.
      Returns:
      This object.
    • expectedInResponseTo

      Pins the request ID a bearer <SubjectConfirmationData> must echo in its InResponseTo attribute.

      When set, the confirmation's InResponseTo must equal this value. When left unset (the default), a present InResponseTo must reference an ID registered with SamlAssertionValidator.rememberAuthnRequest(String).

      Parameters:
      value - The expected request ID. Must not be null or blank.
      Returns:
      This object.
    • subjectAddress

      Sets the client address a bearer <SubjectConfirmationData> must name in its Address attribute.

      When set, the confirmation's Address must equal this value; when unset (the default) the Address attribute is not checked.

      Parameters:
      value - The expected client address. Must not be null or blank.
      Returns:
      This object.
    • replayCache

      Overrides the ReplayCache used to enforce one-time use of each assertion ID.

      Defaults to a per-process InMemoryReplayCache, which enforces single-use within one JVM; a warning is logged when the default is used. Multi-node deployments should inject a ReplayCache backed by a store shared across every node so an assertion consumed against one node cannot be replayed against another. The check is always fail-closed: a cache that cannot answer causes the assertion to be rejected.

      Parameters:
      value - The replay cache. Must not be null.
      Returns:
      This object.
    • allowIdpInitiated

      Allows IdP-initiated responses, i.e. a bearer confirmation that carries no InResponseTo.

      Off by default. An unsolicited response cannot be bound to a request this SP made, so enable it only when the IdP starts the login flow.

      Returns:
      This object.
    • authnRequestStore

      Overrides the AuthnRequestStore that tracks outstanding authentication request IDs.

      Defaults to a per-process InMemoryAuthnRequestStore, which holds up to InMemoryAuthnRequestStore.DEFAULT_MAX_ENTRIES IDs and is not shared between nodes; a warning is logged when the default is used. Multi-node deployments should inject a store shared across every node.

      Parameters:
      value - The store. Must not be null.
      Returns:
      This object.
    • authnRequestTtl

      Sets how long a request ID registered with SamlAssertionValidator.rememberAuthnRequest(String) stays valid. Defaults to 10 minutes.
      Parameters:
      value - The lifetime. Must be positive.
      Returns:
      This object.
    • clockSkew

      Sets the clock-skew tolerance for NotBefore / NotOnOrAfter validation.
      Parameters:
      value - The tolerance. Must be non-negative and not exceed 5 minutes.
      Returns:
      This object.
    • clock

      Overrides the Clock used for timestamp validation. Useful in tests.
      Parameters:
      value - The clock. Must not be null.
      Returns:
      This object.
    • build

      Builds the validator.
      Returns:
      A new SamlAssertionValidator.