use of org.springframework.binding.message.MessageContext in project cas by apereo.
the class AuthenticationExceptionHandlerTests method handleUnknownExceptionByDefault.
@Test
public void handleUnknownExceptionByDefault() {
final AuthenticationExceptionHandler handler = new AuthenticationExceptionHandler();
final MessageContext ctx = mock(MessageContext.class);
final Map<String, Class<? extends Exception>> map = new HashMap<>();
map.put("unknown", GeneralSecurityException.class);
final String id = handler.handle(new AuthenticationException(map), ctx);
assertEquals(id, "UNKNOWN");
}
use of org.springframework.binding.message.MessageContext in project cas by apereo.
the class AuthenticationExceptionHandlerTests method correctHandlersOrder.
@Test
public void correctHandlersOrder() {
final AuthenticationExceptionHandler handler = new AuthenticationExceptionHandler();
final MessageContext ctx = mock(MessageContext.class);
final Map<String, Class<? extends Exception>> map = new HashMap<>();
map.put("accountLocked", AccountLockedException.class);
map.put("accountNotFound", AccountNotFoundException.class);
final String id = handler.handle(new AuthenticationException(map), ctx);
assertEquals(id, AccountLockedException.class.getSimpleName());
}
use of org.springframework.binding.message.MessageContext in project cas by apereo.
the class AuthenticationExceptionHandlerTests method handleAccountNotFoundExceptionByDefault.
@Test
public void handleAccountNotFoundExceptionByDefault() {
final AuthenticationExceptionHandler handler = new AuthenticationExceptionHandler();
final MessageContext ctx = mock(MessageContext.class);
final Map<String, Class<? extends Exception>> map = new HashMap<>();
map.put("notFound", AccountNotFoundException.class);
final String id = handler.handle(new AuthenticationException(map), ctx);
assertEquals(id, AccountNotFoundException.class.getSimpleName());
}
use of org.springframework.binding.message.MessageContext in project cas by apereo.
the class AbstractCasWebflowEventResolver method handleAuthenticationTransactionAndGrantTicketGrantingTicket.
/**
* Handle authentication transaction and grant ticket granting ticket set.
*
* @param context the context
* @return the set
*/
protected Set<Event> handleAuthenticationTransactionAndGrantTicketGrantingTicket(final RequestContext context) {
try {
final Credential credential = getCredentialFromContext(context);
AuthenticationResultBuilder builder = WebUtils.getAuthenticationResultBuilder(context);
LOGGER.debug("Handling authentication transaction for credential [{}]", credential);
final Service service = WebUtils.getService(context);
builder = this.authenticationSystemSupport.handleAuthenticationTransaction(service, builder, credential);
LOGGER.debug("Issuing ticket-granting tickets for service [{}]", service);
return Collections.singleton(grantTicketGrantingTicketToAuthenticationResult(context, builder, service));
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
final MessageContext messageContext = context.getMessageContext();
messageContext.addMessage(new MessageBuilder().error().code(DEFAULT_MESSAGE_BUNDLE_PREFIX.concat(e.getClass().getSimpleName())).build());
return Collections.singleton(new EventFactorySupport().error(this));
}
}
use of org.springframework.binding.message.MessageContext in project head by mifos.
the class QuestionController method addSmartChoiceTag.
public String addSmartChoiceTag(QuestionForm questionForm, RequestContext requestContext, int choiceIndex) {
MessageContext context = requestContext.getMessageContext();
boolean result = validateSmartChoice(questionForm, context, choiceIndex);
if (result) {
questionForm.getCurrentQuestion().addSmartChoiceTag(choiceIndex);
}
return result ? "success" : "failure";
}
Aggregations