Class MessageSourceConsentFunction

java.lang.Object
net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
net.shibboleth.idp.consent.logic.impl.MessageSourceConsentFunction
All Implemented Interfaces:
Function<ProfileRequestContext,​Map<String,​Consent>>, Component, DestructableComponent, InitializableComponent, Aware, MessageSourceAware

public class MessageSourceConsentFunction
extends AbstractInitializableComponent
implements Function<ProfileRequestContext,​Map<String,​Consent>>, MessageSourceAware
Function that returns a consent object whose id and value are resolved from a lookup function and MessageSource.

The lookup function's return value is a key, mapped via the MessageSource to an ID. A suffix is attached to the ID to obtain the message key of the value.

  • Field Details

  • Constructor Details

    • MessageSourceConsentFunction

      public MessageSourceConsentFunction()
      Constructor.
  • Method Details

    • setMessageSource

      public void setMessageSource​(MessageSource source)
      Specified by:
      setMessageSource in interface MessageSourceAware
    • setConsentKeyLookupStrategy

      public void setConsentKeyLookupStrategy​(@Nonnull Function<ProfileRequestContext,​String> strategy)
      Set the lookup strategy for the consent message key.
      Parameters:
      strategy - lookup strategy
    • setConsentValueMessageCodeSuffix

      public void setConsentValueMessageCodeSuffix​(@Nonnull @NotEmpty String suffix)
      Set the consent value message code suffix.
      Parameters:
      suffix - suffix of message code for the consent value
    • setConsentFlowDescriptorLookupStrategy

      public void setConsentFlowDescriptorLookupStrategy​(@Nonnull Function<ProfileRequestContext,​ConsentFlowDescriptor> strategy)
      Set the consent flow descriptor lookup strategy.
      Parameters:
      strategy - consent flow descriptor lookup strategy
    • getHashFunction

      @NonnullAfterInit Function<String,​String> getHashFunction()
      Get the hash function.
      Returns:
      hash function
      Since:
      4.1.0
    • setHashFunction

      public void setHashFunction​(@Nonnull Function<String,​String> function)
      Set the hash function.
      Parameters:
      function - hash function
    • setLocaleLookupStrategy

      public void setLocaleLookupStrategy​(@Nonnull Function<ProfileRequestContext,​Locale> strategy)
      Set the locale lookup strategy.
      Parameters:
      strategy - The localeLookupStrategy to set.
    • doInitialize

      protected void doInitialize() throws ComponentInitializationException
      Overrides:
      doInitialize in class AbstractInitializableComponent
      Throws:
      ComponentInitializationException
    • apply

      @Nullable public Map<String,​Consent> apply​(@Nullable ProfileRequestContext input)
      Specified by:
      apply in interface Function<ProfileRequestContext,​Map<String,​Consent>>
    • getConsentId

      @Nullable protected String getConsentId​(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull Locale locale)
      Get the consent id.
      Parameters:
      profileRequestContext - profile request context
      locale - locale to use
      Returns:
      consent id
    • getConsentValue

      @Nullable protected String getConsentValue​(@Nonnull @NotEmpty String consentId, @Nonnull Locale locale)
      Get the consent value.
      Parameters:
      consentId - consent ID
      locale - locale to use
      Returns:
      consent value
    • getConsentValueHash

      @Nullable protected String getConsentValueHash​(@Nonnull @NotEmpty String consentId, @Nonnull Locale locale)
      Get the consent value hash.
      Parameters:
      consentId - consent ID
      locale - locale to use
      Returns:
      consent value hash
    • getLocale

      @Nullable protected Locale getLocale​(@Nonnull ProfileRequestContext profileRequestContext)
      Get the locale.
      Parameters:
      profileRequestContext - profile request context
      Returns:
      locale
    • isCompareValues

      protected boolean isCompareValues​(@Nonnull ProfileRequestContext profileRequestContext)
      Whether consent equality includes comparing consent values.
      Parameters:
      profileRequestContext - profile request context
      Returns:
      true if consent equality includes comparing consent values