use of org.springframework.binding.message.MessageContext in project cas by apereo.
the class AuthenticationExceptionHandlerAction method handle.
/**
* Maps an authentication exception onto a state name.
* Also sets an ERROR severity message in the message context.
*
* @param e Authentication error to handle.
* @param requestContext the spring context
* @return Name of next flow state to transition to or {@value #UNKNOWN}
*/
public String handle(final Exception e, final RequestContext requestContext) {
final MessageContext messageContext = requestContext.getMessageContext();
if (e instanceof AuthenticationException) {
return handleAuthenticationException((AuthenticationException) e, requestContext);
}
if (e instanceof AbstractTicketException) {
return handleAbstractTicketException((AbstractTicketException) e, requestContext);
}
LOGGER.trace("Unable to translate errors of the authentication exception [{}]. Returning [{}]", e, UNKNOWN);
final String messageCode = this.messageBundlePrefix + UNKNOWN;
messageContext.addMessage(new MessageBuilder().error().code(messageCode).build());
return UNKNOWN;
}
Aggregations