Search in sources :

Example 76 with AuthenticationResult

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

the class PlainNegotiatorTest method testHandleResponse.

public void testHandleResponse() throws Exception {
    final AuthenticationResult result = _negotiator.handleResponse(VALID_RESPONSE.getBytes(US_ASCII));
    verify(_authenticationProvider).authenticate(eq(VALID_USERNAME), eq(VALID_PASSWORD));
    assertEquals("Unexpected authentication result", _successfulResult, result);
}
Also used : AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult)

Example 77 with AuthenticationResult

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

the class PlainNegotiatorTest method testHandleNeverSendAResponse.

public void testHandleNeverSendAResponse() throws Exception {
    final AuthenticationResult firstResult = _negotiator.handleResponse(new byte[0]);
    assertEquals("Unexpected authentication status", AuthenticationResult.AuthenticationStatus.CONTINUE, firstResult.getStatus());
    assertArrayEquals("Unexpected authentication challenge", new byte[0], firstResult.getChallenge());
    final AuthenticationResult secondResult = _negotiator.handleResponse(new byte[0]);
    assertEquals("Unexpected first authentication result", AuthenticationResult.AuthenticationStatus.ERROR, secondResult.getStatus());
}
Also used : AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult)

Example 78 with AuthenticationResult

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

the class ScramNegotiatorTest method doSaslNegotiationTestInvalidCredentials.

private void doSaslNegotiationTestInvalidCredentials(final String userName, final String userPassword, final String mechanism, final AuthenticationProvider<?> authenticationProvider, final ScramSaslServerSource scramSaslServerSource) throws Exception {
    ScramNegotiator scramNegotiator = new ScramNegotiator(authenticationProvider, scramSaslServerSource, mechanism);
    byte[] initialResponse = createInitialResponse(userName);
    AuthenticationResult firstResult = scramNegotiator.handleResponse(initialResponse);
    assertEquals("Unexpected first result status", AuthenticationResult.AuthenticationStatus.CONTINUE, firstResult.getStatus());
    assertNotNull("Unexpected first result challenge", firstResult.getChallenge());
    byte[] response = calculateClientProof(firstResult.getChallenge(), scramSaslServerSource.getHmacName(), scramSaslServerSource.getDigestName(), userPassword);
    AuthenticationResult secondResult = scramNegotiator.handleResponse(response);
    assertEquals("Unexpected second result status", AuthenticationResult.AuthenticationStatus.ERROR, secondResult.getStatus());
    assertNull("Unexpected second result challenge", secondResult.getChallenge());
    assertNull("Unexpected second result principal", secondResult.getMainPrincipal());
}
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