Class MetadataPublishingProfileConfiguration

All Implemented Interfaces:
ConditionalProfileConfiguration, ProfileConfiguration, Component, DestructableComponent, IdentifiableComponent, IdentifiedComponent, InitializableComponent, MetadataPublishingProfileConfiguration

public class MetadataPublishingProfileConfiguration extends AbstractConditionalProfileConfiguration implements MetadataPublishingProfileConfiguration
Configuration support for publishing SAML 2.0 Metadata.
  • Field Details

  • Constructor Details

    • MetadataPublishingProfileConfiguration

      public MetadataPublishingProfileConfiguration()
      Constructor.
    • MetadataPublishingProfileConfiguration

      protected MetadataPublishingProfileConfiguration(@Nonnull @NotEmpty String profileId)
      Constructor.
      Parameters:
      profileId - unique ID for this profile
  • Method Details

    • getTemplatePath

      @Nullable @NotEmpty public String getTemplatePath(@Nullable ProfileRequestContext profileRequestContext)
      Gets the path to a template XML resource to source for the metadata.

      Defaults to null, resulting in a query to the configured MetadataResolver service for the configured "issuer" value as entityID to obtain metadata loaded into the Hub.

      If set, the path is evaluated as a Velocity template with the following variables populated:

      • agentID
      • applicationID
      • issuer
      • entityID
      Specified by:
      getTemplatePath in interface MetadataPublishingProfileConfiguration
      Parameters:
      profileRequestContext - profile request context
      Returns:
      templated path to XML resource to serve
    • setTemplatePath

      public void setTemplatePath(@Nullable @NotEmpty String path)
      Sets the path to a template XML file to source for the metadata.
      Parameters:
      path - template path
    • setTemplatePathLookupStrategy

      public void setTemplatePathLookupStrategy(@Nonnull Function<ProfileRequestContext,String> strategy)
      Sets the lookup strategy for the path to a template XML file to source for the metadata.
      Parameters:
      strategy - lookup strategy
    • isUseVelocity

      public boolean isUseVelocity(@Nullable ProfileRequestContext profileRequestContext)
      Gets whether the template returned by MetadataPublishingProfileConfiguration.getTemplatePath(ProfileRequestContext) is evaluated by Velocity or returned directly.

      Defaults to false; only relevant if a template path is used. The same variables are populated in evaluating the template as described for MetadataPublishingProfileConfiguration.getTemplatePath(ProfileRequestContext).

      Specified by:
      isUseVelocity in interface MetadataPublishingProfileConfiguration
      Parameters:
      profileRequestContext - profile request context
      Returns:
      true iff Velocity should be applied to the template
    • setUseVelocity

      public void setUseVelocity(boolean flag)
      Sets whether the template returned by getTemplatePath(ProfileRequestContext) is evaluated by Velocity or returned directly.
      Parameters:
      flag - flag to set
    • setUseVelocityPredicate

      public void setUseVelocityPredicate(@Nonnull Predicate<ProfileRequestContext> condition)
      Sets a condition to determine whether the template returned by getTemplatePath(ProfileRequestContext) is evaluated by Velocity or returned directly.
      Parameters:
      condition - condition to set
    • isSignMetadata

      public boolean isSignMetadata(@Nullable ProfileRequestContext profileRequestContext)
      Gets whether to sign the metadata being published dynamically.

      Defaults to false.

      Specified by:
      isSignMetadata in interface MetadataPublishingProfileConfiguration
      Parameters:
      profileRequestContext - profile request context
      Returns:
      true iff the metadata should be signed in real time
    • setSignMetadata

      public void setSignMetadata(boolean flag)
      Sets whether to sign the metadata being published dynamically.
      Parameters:
      flag - flag to set
    • setSignMetadataPredicate

      public void setSignMetadataPredicate(@Nonnull Predicate<ProfileRequestContext> condition)
      Sets a condition to determine whether to sign the metadata being published dynamically.
      Parameters:
      condition - condition to set
    • getSigningCredential

      @Nullable public Credential getSigningCredential(@Nullable ProfileRequestContext profileRequestContext)
      Gets an optional Credential to use to sign the metadata if MetadataPublishingProfileConfiguration.isSignMetadata(ProfileRequestContext) is true.

      If unset, the default configured service is used, resulting in effectively self-signed metadata using the same key used for SAML messages.

      Specified by:
      getSigningCredential in interface MetadataPublishingProfileConfiguration
      Parameters:
      profileRequestContext - profile request context
      Returns:
      a signing credential or null
    • setSigningCredential

      public void setSigningCredential(@Nullable Credential credential)
      Sets an optional Credential to use to sign the metadata if isSignMetadata(ProfileRequestContext) is true.
      Parameters:
      credential - credential to set
    • setSigningCredentialLookupStrategy

      public void setSigningCredentialLookupStrategy(@Nonnull Function<ProfileRequestContext,Credential> strategy)
      Sets a lookup strategy for an optional Credential to use to sign the metadata if isSignMetadata(ProfileRequestContext) is true.
      Parameters:
      strategy - lookup strategy
    • isResolveKeys

      public boolean isResolveKeys(@Nullable ProfileRequestContext profileRequestContext)
      Gets whether to resolve signing and encryption keys from the configured CredentialResolver to publish into the Velocity context if that feature is enabled.

      Defaults to false.

      If true, this does not automatically remove any existing KeyDescriptor elements nor add any automatically, but provides the information to help do so.

      Specified by:
      isResolveKeys in interface MetadataPublishingProfileConfiguration
      Returns:
      true iff the credentials should be resolved for Velocity to access
    • setResolveKeys

      public void setResolveKeys(boolean flag)
      Sets whether to resolve signing and encryption keys from the configured CredentialResolver to publish into the Velocity context if that feature is enabled.
      Parameters:
      flag - flag to set
    • setResolveKeysPredicate

      public void setResolveKeysPredicate(@Nonnull Predicate<ProfileRequestContext> condition)
      Sets a condition to determine whether to resolve signing and encryption keys from the configured CredentialResolver to publish into the Velocity context if that feature is enabled.
      Parameters:
      condition - condition to set
    • getLifetime

      @Nullable @NonNegative public Duration getLifetime(@Nullable ProfileRequestContext profileRequestContext)
      Gets the optional lifetime from which to compute and set the root element's validUntil attribute.

      Defaults to null.

      Only applied if the root element's existing value would be longer.

      Specified by:
      getLifetime in interface MetadataPublishingProfileConfiguration
      Parameters:
      profileRequestContext - profile request context
      Returns:
      the time added to the current timestamp to set, or null to leave as is
    • setLifetime

      public void setLifetime(@Nullable @NonNegative Duration lifetime)
      Sets the optional lifetime from which to compute and set the root element's validUntil attribute.

      Passing zero is equivalent to null and will not alter the source value.

      Parameters:
      lifetime - metadata lifetime
    • setLifetimeLookupStrategy

      public void setLifetimeLookupStrategy(@Nonnull Function<ProfileRequestContext,Duration> strategy)
      Sets the lookup strategy for the optional lifetime from which to compute and set the root element's validUntil attribute.
      Parameters:
      strategy - lookup strategy
    • getCacheDuration

      @Nullable @NonNegative public Duration getCacheDuration(@Nullable ProfileRequestContext profileRequestContext)
      Gets the optional value to set in the root element's cacehDuration attribute.

      Defaults to null.

      Specified by:
      getCacheDuration in interface MetadataPublishingProfileConfiguration
      Parameters:
      profileRequestContext - profile request context
      Returns:
      the cache duration, or null to leave as is
    • setCacheDuration

      public void setCacheDuration(@Nullable @NonNegative Duration cacheDuration)
      Sets the optional value to set in the root element's cacheDuration attribute.

      Passing zero is equivalent to null and will not alter the source value.

      Parameters:
      cacheDuration - metadata cache duration
    • setCacheDurationLookupStrategy

      public void setCacheDurationLookupStrategy(@Nonnull Function<ProfileRequestContext,Duration> strategy)
      Sets the lookup strategy for the optional value to set in the root element's cacheDuration attribute.
      Parameters:
      strategy - lookup strategy