Search in sources :

Example 26 with AuthenticationResult

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

the class OAuth2NegotiatorTest method doHandleResponseWithValidResponse.

private void doHandleResponseWithValidResponse(final byte[] validResponse) {
    final AuthenticationResult expectedResult = mock(AuthenticationResult.class);
    when(_authenticationProvider.authenticateViaAccessToken(eq(VALID_TOKEN), any())).thenReturn(expectedResult);
    AuthenticationResult actualResult = _negotiator.handleResponse(validResponse);
    assertEquals("Unexpected result", expectedResult, actualResult);
    verify(_authenticationProvider).authenticateViaAccessToken(eq(VALID_TOKEN), any());
    AuthenticationResult secondResult = _negotiator.handleResponse(validResponse);
    assertEquals("Unexpected second result status", AuthenticationResult.AuthenticationStatus.ERROR, secondResult.getStatus());
}
Also used : AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult)

Example 27 with AuthenticationResult

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

the class OAuth2NegotiatorTest method testHandleNoInitialResponse.

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

Example 28 with AuthenticationResult

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

the class PlainNegotiatorTest method testHandleNoInitialResponseNull.

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

Example 29 with AuthenticationResult

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

the class PlainNegotiatorTest method testHandleNoInitialResponse.

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

Example 30 with AuthenticationResult

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

the class PlainNegotiatorTest method testMultipleAuthenticationAttempts.

public void testMultipleAuthenticationAttempts() throws Exception {
    final AuthenticationResult firstResult = _negotiator.handleResponse(VALID_RESPONSE.getBytes(US_ASCII));
    assertEquals("Unexpected first authentication result", _successfulResult, firstResult);
    final AuthenticationResult secondResult = _negotiator.handleResponse(VALID_RESPONSE.getBytes(US_ASCII));
    assertEquals("Unexpected second authentication result", AuthenticationResult.AuthenticationStatus.ERROR, secondResult.getStatus());
}
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