Class MessageSourceConsentFunction

  • All Implemented Interfaces:
    Function<org.opensaml.profile.context.ProfileRequestContext,​Map<String,​net.shibboleth.idp.consent.Consent>>, net.shibboleth.utilities.java.support.component.Component, net.shibboleth.utilities.java.support.component.DestructableComponent, net.shibboleth.utilities.java.support.component.InitializableComponent, Aware, MessageSourceAware

    public class MessageSourceConsentFunction
    extends net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
    implements Function<org.opensaml.profile.context.ProfileRequestContext,​Map<String,​net.shibboleth.idp.consent.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 master key, mapped via the MessageSource to an ID. A suffix is attached to the ID to obtain the message key of the value.

    • Field Detail

      • consentKeyLookupStrategy

        @Nonnull
        private Function<org.opensaml.profile.context.ProfileRequestContext,​String> consentKeyLookupStrategy
        Lookup strategy for the consent message key to use.
      • consentValueMessageCodeSuffix

        @Nonnull
        @NotEmpty
        private String consentValueMessageCodeSuffix
        Message code suffix used to resolve the consent value.
      • consentFlowDescriptorLookupStrategy

        @Nonnull
        private Function<org.opensaml.profile.context.ProfileRequestContext,​ConsentFlowDescriptor> consentFlowDescriptorLookupStrategy
        Consent flow descriptor lookup strategy.
      • hashFunction

        @Nonnull
        private Function<String,​String> hashFunction
        Function used to create a hash of the consent value.
      • localeLookupStrategy

        @Nonnull
        private Function<org.opensaml.profile.context.ProfileRequestContext,​Locale> localeLookupStrategy
        Locale lookup strategy.
      • messageSource

        @Nonnull
        private MessageSource messageSource
        MessageSource injected by Spring, typically the parent ApplicationContext itself.
    • Constructor Detail

      • MessageSourceConsentFunction

        public MessageSourceConsentFunction()
        Constructor.
    • Method Detail

      • setConsentKeyLookupStrategy

        public void setConsentKeyLookupStrategy​(@Nonnull
                                                Function<org.opensaml.profile.context.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<org.opensaml.profile.context.ProfileRequestContext,​ConsentFlowDescriptor> strategy)
        Set the consent flow descriptor lookup strategy.
        Parameters:
        strategy - consent flow descriptor lookup strategy
      • setHashFunction

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

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

        @Nullable
        public Map<String,​net.shibboleth.idp.consent.Consent> apply​(@Nullable
                                                                          org.opensaml.profile.context.ProfileRequestContext input)
        Specified by:
        apply in interface Function<org.opensaml.profile.context.ProfileRequestContext,​Map<String,​net.shibboleth.idp.consent.Consent>>
      • getConsentId

        @Nullable
        protected String getConsentId​(@Nonnull
                                      org.opensaml.profile.context.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
                                   org.opensaml.profile.context.ProfileRequestContext profileRequestContext)
        Get the locale.
        Parameters:
        profileRequestContext - profile request context
        Returns:
        locale
      • isCompareValues

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