Search in sources :

Example 61 with AuthenticationResult

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

the class SimpleAuthenticationManagerTest method authenticateCramMd5.

private AuthenticationResult authenticateCramMd5(String userName, String userPassword) throws Exception {
    SaslSettings saslSettings = mock(SaslSettings.class);
    when(saslSettings.getLocalFQDN()).thenReturn("testHost");
    SaslNegotiator saslNegotiator = _authenticationManager.createSaslNegotiator("CRAM-MD5", saslSettings, null);
    AuthenticationResult result = saslNegotiator.handleResponse(new byte[0]);
    assertEquals("Unexpected SASL status", AuthenticationStatus.CONTINUE, result.getStatus());
    byte[] challenge = result.getChallenge();
    byte[] response = SaslUtil.generateCramMD5ClientResponse(userName, userPassword, challenge);
    return saslNegotiator.handleResponse(response);
}
Also used : SaslSettings(org.apache.qpid.server.security.auth.sasl.SaslSettings) SaslNegotiator(org.apache.qpid.server.security.auth.sasl.SaslNegotiator) AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult)

Example 62 with AuthenticationResult

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

the class SimpleAuthenticationManagerTest method testAuthenticateWithCramMd5SaslServer.

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

Example 63 with AuthenticationResult

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

the class SimpleAuthenticationManagerTest method testAuthenticateInvalidPassword.

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

Example 64 with AuthenticationResult

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

the class OAuth2AuthenticationProviderImplTest method testFailAuthenticateViaInvalidAccessToken.

public void testFailAuthenticateViaInvalidAccessToken() throws Exception {
    OAuth2MockEndpoint mockIdentityResolverEndpoint = createMockIdentityResolverEndpoint();
    mockIdentityResolverEndpoint.putExpectedParameter("token", TEST_INVALID_ACCESS_TOKEN);
    mockIdentityResolverEndpoint.setResponse(400, "{\"error\":\"invalid_token\"}");
    _server.setEndpoints(Collections.singletonMap(TEST_IDENTITY_RESOLVER_ENDPOINT_PATH, mockIdentityResolverEndpoint));
    AuthenticationResult authenticationResult = _authProvider.authenticateViaAccessToken(TEST_INVALID_ACCESS_TOKEN, null);
    assertFailure(authenticationResult, "invalid_token");
}
Also used : AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult)

Example 65 with AuthenticationResult

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

the class OAuth2AuthenticationProviderImplTest method testFailAuthenticateViaSasl.

public void testFailAuthenticateViaSasl() throws Exception {
    OAuth2MockEndpoint mockIdentityResolverEndpoint = createMockIdentityResolverEndpoint();
    mockIdentityResolverEndpoint.putExpectedParameter("token", TEST_INVALID_ACCESS_TOKEN);
    mockIdentityResolverEndpoint.setResponse(400, "{\"error\":\"invalid_token\"}");
    _server.setEndpoints(Collections.singletonMap(TEST_IDENTITY_RESOLVER_ENDPOINT_PATH, mockIdentityResolverEndpoint));
    final SaslNegotiator negotiator = _authProvider.createSaslNegotiator(OAuth2Negotiator.MECHANISM, null, null);
    AuthenticationResult authenticationResult = negotiator.handleResponse(("auth=Bearer " + TEST_INVALID_ACCESS_TOKEN + "\1\1").getBytes(UTF8));
    assertFailure(authenticationResult, "invalid_token");
}
Also used : SaslNegotiator(org.apache.qpid.server.security.auth.sasl.SaslNegotiator) 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