Search in sources :

Example 51 with MessageContext

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;
}
Also used : MessageBuilder(org.springframework.binding.message.MessageBuilder) AuthenticationException(org.apereo.cas.authentication.AuthenticationException) MessageContext(org.springframework.binding.message.MessageContext) AbstractTicketException(org.apereo.cas.ticket.AbstractTicketException)

Aggregations

MessageContext (org.springframework.binding.message.MessageContext)51 Test (org.junit.Test)18 Message (org.springframework.binding.message.Message)16 MessageBuilder (org.springframework.binding.message.MessageBuilder)9 ArrayList (java.util.ArrayList)5 AuthenticationException (org.apereo.cas.authentication.AuthenticationException)5 InvalidTicketException (org.apereo.cas.ticket.InvalidTicketException)4 UnsatisfiedAuthenticationPolicyException (org.apereo.cas.ticket.UnsatisfiedAuthenticationPolicyException)4 LocalDate (org.joda.time.LocalDate)4 BigDecimal (java.math.BigDecimal)3 GeneralSecurityException (java.security.GeneralSecurityException)3 HashMap (java.util.HashMap)3 AccountLockedException (javax.security.auth.login.AccountLockedException)3 AccountNotFoundException (javax.security.auth.login.AccountNotFoundException)3 PreventedException (org.apereo.cas.authentication.PreventedException)3 DateTime (org.joda.time.DateTime)3 LoanCreationInstallmentDto (org.mifos.dto.domain.LoanCreationInstallmentDto)2 LoanScheduleDto (org.mifos.dto.screen.LoanScheduleDto)2 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)2 ErrorEntry (org.mifos.platform.validations.ErrorEntry)2