Search in sources :

Example 11 with DisabledException

use of org.springframework.security.authentication.DisabledException in project midpoint by Evolveum.

the class TestAbstractAuthenticationEvaluator method loginJackGoodPasswordExpectDenied.

private void loginJackGoodPasswordExpectDenied(final String TEST_NAME, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    display("now", clock.currentTimeXMLGregorianCalendar());
    ConnectionEnvironment connEnv = createConnectionEnvironment();
    XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    try {
        getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getGoodPasswordJack()));
        AssertJUnit.fail("Unexpected success");
    } catch (DisabledException e) {
        // This is expected
        // THEN
        TestUtil.displayThen(TEST_NAME);
        display("expected exception", e);
        // this is important. The exception should give no indication whether the password is
        // good or bad
        assertDisabledException(e, USER_JACK_USERNAME);
    }
    PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
    display("user after", userAfter);
    assertFailedLogins(userAfter, 0);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DisabledException(org.springframework.security.authentication.DisabledException) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Aggregations

DisabledException (org.springframework.security.authentication.DisabledException)11 Test (org.junit.Test)5 AuthenticationException (org.springframework.security.core.AuthenticationException)3 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)2 UnclaimedProfileExistsException (org.orcid.core.security.UnclaimedProfileExistsException)2 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)2 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)2 Authentication (org.springframework.security.core.Authentication)2 UsernameNotFoundException (org.springframework.security.core.userdetails.UsernameNotFoundException)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 ConnectionEnvironment (com.evolveum.midpoint.security.api.ConnectionEnvironment)1 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)1 Task (com.evolveum.midpoint.task.api.Task)1 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)1 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)1 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)1