Package net.shibboleth.idp.consent.logic.impl

# Class MessageSourceConsentFunction

java.lang.Object
net.shibboleth.shared.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 Summary

Fields
Modifier and Type
Field
Description
`private Function<ProfileRequestContext,ConsentFlowDescriptor>`
`consentFlowDescriptorLookupStrategy`
Consent flow descriptor lookup strategy.
`private Function<ProfileRequestContext,String>`
`consentKeyLookupStrategy`
Lookup strategy for the consent message key to use.
`private String`
`consentValueMessageCodeSuffix`
Message code suffix used to resolve the consent value.
`private Function<String,String>`
`hashFunction`
Function used to create a hash of the consent value.
`private Function<ProfileRequestContext,Locale>`
`localeLookupStrategy`
Locale lookup strategy.
`private MessageSource`
`messageSource`
MessageSource injected by Spring, typically the parent ApplicationContext itself.

## Constructor Summary

Constructors
Constructor
Description
`MessageSourceConsentFunction()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`Map<String,Consent>`
`apply(ProfileRequestContext input)`
`protected void`
`doInitialize()`
`protected String`
`getConsentId(ProfileRequestContext profileRequestContext, Locale locale)`
Get the consent id.
`protected String`
`getConsentValue(String consentId, Locale locale)`
Get the consent value.
`protected String`
`getConsentValueHash(String consentId, Locale locale)`
Get the consent value hash.
`(package private) Function<String,String>`
`getHashFunction()`
Get the hash function.
`(package private) Locale`
`getLocale(ProfileRequestContext profileRequestContext)`
Get the locale.
`protected boolean`
`isCompareValues(ProfileRequestContext profileRequestContext)`
Whether consent equality includes comparing consent values.
`void`
`setConsentFlowDescriptorLookupStrategy(Function<ProfileRequestContext,ConsentFlowDescriptor> strategy)`
Set the consent flow descriptor lookup strategy.
`void`
`setConsentKeyLookupStrategy(Function<ProfileRequestContext,String> strategy)`
Set the lookup strategy for the consent message key.
`void`
`setConsentValueMessageCodeSuffix(String suffix)`
Set the consent value message code suffix.
`void`
`setHashFunction(Function<String,String> function)`
Set the hash function.
`void`
`setLocaleLookupStrategy(Function<ProfileRequestContext,Locale> strategy)`
Set the locale lookup strategy.
`void`
`setMessageSource(MessageSource source)`

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitialized`

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

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

### Methods inherited from interface java.util.function.Function

`andThen, compose`

## Field Details

### consentKeyLookupStrategy

@Nonnull private Function<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<ProfileRequestContext,ConsentFlowDescriptor> consentFlowDescriptorLookupStrategy
Consent flow descriptor lookup strategy.

### hashFunction

@NonnullAfterInit private Function<String,String> hashFunction
Function used to create a hash of the consent value.

### localeLookupStrategy

@Nonnull private Function<ProfileRequestContext,Locale> localeLookupStrategy
Locale lookup strategy.

### messageSource

@NonnullAfterInit private MessageSource messageSource
MessageSource injected by Spring, typically the parent ApplicationContext itself.

## Constructor Details

### MessageSourceConsentFunction

public MessageSourceConsentFunction()
Constructor.

## Method Details

### setMessageSource

public void setMessageSource(@Nonnull 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 @Unmodifiable @NotLive 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 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