Search in sources :

Example 56 with AuthenticationResult

use of org.apache.qpid.server.security.auth.AuthenticationResult in project qpid-broker-j by apache.

the class PrincipalDatabaseAuthenticationManagerTest method testSaslAuthenticationNotCompleted.

/**
 * Tests that the authenticate method correctly interprets an
 * authentication not complete.
 */
public void testSaslAuthenticationNotCompleted() throws Exception {
    setupMocks();
    when(_saslNegotiator.handleResponse(any(byte[].class))).thenReturn(new AuthenticationResult(AuthenticationStatus.CONTINUE));
    AuthenticationResult result = _saslNegotiator.handleResponse("12345".getBytes());
    assertEquals("Principals was not expected size", 0, result.getPrincipals().size());
    assertEquals(AuthenticationStatus.CONTINUE, result.getStatus());
}
Also used : AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult)

Example 57 with AuthenticationResult

use of org.apache.qpid.server.security.auth.AuthenticationResult in project qpid-broker-j by apache.

the class PrincipalDatabaseAuthenticationManagerTest method testNonSaslAuthenticationSuccess.

public void testNonSaslAuthenticationSuccess() throws Exception {
    setupMocks();
    when(_principalDatabase.verifyPassword("guest", "guest".toCharArray())).thenReturn(true);
    AuthenticationResult result = _manager.authenticate("guest", "guest");
    UsernamePrincipal expectedPrincipal = new UsernamePrincipal("guest", _manager);
    assertOnlyContainsWrapped(expectedPrincipal, result.getPrincipals());
    assertEquals(AuthenticationStatus.SUCCESS, result.getStatus());
}
Also used : UsernamePrincipal(org.apache.qpid.server.security.auth.UsernamePrincipal) AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult)

Example 58 with AuthenticationResult

use of org.apache.qpid.server.security.auth.AuthenticationResult in project qpid-broker-j by apache.

the class SimpleAuthenticationManagerTest method testAuthenticateWithPlainSaslServerInvalidPassword.

public void testAuthenticateWithPlainSaslServerInvalidPassword() throws Exception {
    AuthenticationResult result = authenticatePlain(TEST_USER, "wrong-password");
    assertUnauthenticated(result);
}
Also used : AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult)

Example 59 with AuthenticationResult

use of org.apache.qpid.server.security.auth.AuthenticationResult in project qpid-broker-j by apache.

the class SimpleAuthenticationManagerTest method testAuthenticateWithPlainSaslServer.

public void testAuthenticateWithPlainSaslServer() throws Exception {
    AuthenticationResult result = authenticatePlain(TEST_USER, TEST_PASSWORD);
    assertAuthenticated(result);
}
Also used : AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult)

Example 60 with AuthenticationResult

use of org.apache.qpid.server.security.auth.AuthenticationResult in project qpid-broker-j by apache.

the class SimpleAuthenticationManagerTest method testAuthenticateInvalidUserName.

public void testAuthenticateInvalidUserName() {
    AuthenticationResult result = _authenticationManager.authenticate("invalid", TEST_PASSWORD);
    assertUnauthenticated(result);
}
Also used : AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult)

Aggregations

AuthenticationResult (org.apache.qpid.server.security.auth.AuthenticationResult)78 UsernamePrincipal (org.apache.qpid.server.security.auth.UsernamePrincipal)13 SaslNegotiator (org.apache.qpid.server.security.auth.sasl.SaslNegotiator)13 X500Principal (javax.security.auth.x500.X500Principal)12 SubjectAuthenticationResult (org.apache.qpid.server.security.auth.SubjectAuthenticationResult)9 HashMap (java.util.HashMap)6 SubjectCreator (org.apache.qpid.server.security.SubjectCreator)6 Subject (javax.security.auth.Subject)5 IOException (java.io.IOException)4 OAuth2AuthenticationProvider (org.apache.qpid.server.security.auth.manager.oauth2.OAuth2AuthenticationProvider)4 InetSocketAddress (java.net.InetSocketAddress)3 URISyntaxException (java.net.URISyntaxException)3 Principal (java.security.Principal)3 Broker (org.apache.qpid.server.model.Broker)3 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)3 AuthenticatedPrincipal (org.apache.qpid.server.security.auth.AuthenticatedPrincipal)3 URI (java.net.URI)2 AccessControlException (java.security.AccessControlException)2 EventLogger (org.apache.qpid.server.logging.EventLogger)2 User (org.apache.qpid.server.model.User)2