Search in sources :

Example 1 with DefaultMessageResolver

use of org.springframework.binding.message.DefaultMessageResolver in project head by mifos.

the class MessageMatcher method matchesSafely.

@Override
public boolean matchesSafely(MessageResolver messageResolver) {
    DefaultMessageResolver defaultMessageResolver = (DefaultMessageResolver) messageResolver;
    String[] codes = defaultMessageResolver.getCodes();
    for (String code : codes) {
        if (StringUtils.equals(code, errorCode))
            return true;
    }
    return false;
}
Also used : DefaultMessageResolver(org.springframework.binding.message.DefaultMessageResolver)

Example 2 with DefaultMessageResolver

use of org.springframework.binding.message.DefaultMessageResolver in project cas by apereo.

the class AuthenticationExceptionHandlerTests method handleUnsatisfiedAuthenticationPolicyExceptionByDefault.

@Test
public void handleUnsatisfiedAuthenticationPolicyExceptionByDefault() {
    final AuthenticationExceptionHandler handler = new AuthenticationExceptionHandler();
    final MessageContext ctx = mock(MessageContext.class);
    final ContextualAuthenticationPolicy<?> policy = new TestContextualAuthenticationPolicy();
    final String id = handler.handle(new UnsatisfiedAuthenticationPolicyException(policy), ctx);
    assertEquals(id, "UnsatisfiedAuthenticationPolicyException");
    final ArgumentCaptor<DefaultMessageResolver> message = ArgumentCaptor.forClass(DefaultMessageResolver.class);
    verify(ctx, times(1)).addMessage(message.capture());
    assertArrayEquals(new String[] { policy.getCode().get() }, message.getValue().getCodes());
}
Also used : UnsatisfiedAuthenticationPolicyException(org.apereo.cas.ticket.UnsatisfiedAuthenticationPolicyException) DefaultMessageResolver(org.springframework.binding.message.DefaultMessageResolver) MessageContext(org.springframework.binding.message.MessageContext) Test(org.junit.Test)

Aggregations

DefaultMessageResolver (org.springframework.binding.message.DefaultMessageResolver)2 UnsatisfiedAuthenticationPolicyException (org.apereo.cas.ticket.UnsatisfiedAuthenticationPolicyException)1 Test (org.junit.Test)1 MessageContext (org.springframework.binding.message.MessageContext)1