Package net.shibboleth.idp.authn.context.navigate

# Class PasswordErrorMessageLookupFunction

java.lang.Object
org.springframework.context.support.ApplicationObjectSupport
net.shibboleth.idp.authn.context.navigate.PasswordErrorMessageLookupFunction

All Implemented Interfaces:
  `Function<ProfileRequestContext,String>`, `ContextDataLookupFunction<ProfileRequestContext,String>`, `Aware`, `ApplicationContextAware`

public class PasswordErrorMessageLookupFunction extends ApplicationObjectSupport implements ContextDataLookupFunction<ProfileRequestContext,String>
A function that examines the state of a request and produces an appropriate error message for the Password login flow.

NOTE: The result of this function is NOT HTML-encoded in any way and must be encoded for safety if used.

This implements the pre-existing default behavior in Velocity for determining an error to display.

Since:
  5.1.0

## Field Summary

Fields
Modifier and Type
Field
Description
`private String`
`genericMessageID`
Message ID to use for generic, unclassified errors or exceptions.

### Fields inherited from class org.springframework.context.support.ApplicationObjectSupport

`logger`

## Constructor Summary

Constructors
Constructor
Description
`PasswordErrorMessageLookupFunction()`

## Method Summary

Modifier and Type
Method
Description
`String`
`apply(ProfileRequestContext input)`
`private String`
`getClassifiedMessage(MessageSourceAccessor messageSource, String classifiedError)`
Get classified message.
`private String`
`getExceptionMessage(MessageSourceAccessor messageSource, Exception e)`
Get generic error message or exception message.
`void`
`setGenericMessageID(String id)`
Sets whether non-message-based error messages should be exposed or turned into a more generic value.

### Methods inherited from class org.springframework.context.support.ApplicationObjectSupport

`getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, isContextRequired, obtainApplicationContext, requiredContextClass, setApplicationContext`

### 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

### genericMessageID

private String genericMessageID
Message ID to use for generic, unclassified errors or exceptions.

## Constructor Details

### PasswordErrorMessageLookupFunction

public PasswordErrorMessageLookupFunction()

## Method Details

### setGenericMessageID

public void setGenericMessageID(@Nullable String id)
Sets whether non-message-based error messages should be exposed or turned into a more generic value.

Parameters:
  `id` - message ID

### apply

@Nullable public String apply(@Nullable ProfileRequestContext input)

Specified by:
  `apply` in interface `Function<ProfileRequestContext,String>`

### getClassifiedMessage

@Nullable private String getClassifiedMessage(@Nonnull MessageSourceAccessor messageSource, @Nonnull String classifiedError)
Get classified message.

Parameters:
  `messageSource` - Spring message source
  `classifiedError` - classified error event
Returns:
  mapped message, or null

### getExceptionMessage

@Nullable private String getExceptionMessage(@Nonnull MessageSourceAccessor messageSource, @Nonnull Exception e)
Get generic error message or exception message.

Parameters:
  `messageSource` - Spring message source
  `e` - exception
Returns:
  the exception message or the generic message as appropriate