Search in sources :

Example 6 with SaslNegotiator

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

the class ExternalAuthenticationManagerTest method testAuthenticatePrincipalCnOnly.

public void testAuthenticatePrincipalCnOnly() throws Exception {
    X500Principal principal = new X500Principal("CN=person");
    UsernamePrincipal expectedPrincipal = new UsernamePrincipal("person", _manager);
    when(_saslSettings.getExternalPrincipal()).thenReturn(principal);
    SaslNegotiator negotiator = _manager.createSaslNegotiator("EXTERNAL", _saslSettings, null);
    AuthenticationResult result = negotiator.handleResponse(new byte[0]);
    assertNotNull(result);
    assertEquals("Expected authentication to be successful", AuthenticationResult.AuthenticationStatus.SUCCESS, result.getStatus());
    assertOnlyContainsWrapped(expectedPrincipal, result.getPrincipals());
    assertEquals("person", result.getMainPrincipal().getName());
}
Also used : UsernamePrincipal(org.apache.qpid.server.security.auth.UsernamePrincipal) X500Principal(javax.security.auth.x500.X500Principal) SaslNegotiator(org.apache.qpid.server.security.auth.sasl.SaslNegotiator) AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult)

Example 7 with SaslNegotiator

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

the class PrincipalDatabaseAuthenticationManagerTest method testSaslMechanismCreation.

public void testSaslMechanismCreation() throws Exception {
    setupMocks();
    SaslSettings saslSettings = mock(SaslSettings.class);
    SaslNegotiator saslNegotiator = _manager.createSaslNegotiator(MOCK_MECH_NAME, saslSettings, null);
    assertNotNull(saslNegotiator);
}
Also used : SaslSettings(org.apache.qpid.server.security.auth.sasl.SaslSettings) SaslNegotiator(org.apache.qpid.server.security.auth.sasl.SaslNegotiator)

Example 8 with SaslNegotiator

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

the class SimpleAuthenticationManagerTest method authenticatePlain.

private AuthenticationResult authenticatePlain(String userName, String userPassword) throws Exception {
    SaslSettings saslSettings = mock(SaslSettings.class);
    SaslNegotiator saslNegotiator = _authenticationManager.createSaslNegotiator("PLAIN", saslSettings, null);
    byte[] response = SaslUtil.generatePlainClientResponse(userName, userPassword);
    return saslNegotiator.handleResponse(response);
}
Also used : SaslSettings(org.apache.qpid.server.security.auth.sasl.SaslSettings) SaslNegotiator(org.apache.qpid.server.security.auth.sasl.SaslNegotiator)

Example 9 with SaslNegotiator

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

the class SimpleAuthenticationManagerTest method testCreateSaslNegotiatorForUnsupportedMechanisms.

public void testCreateSaslNegotiatorForUnsupportedMechanisms() throws Exception {
    String[] unsupported = new String[] { "EXTERNAL", "CRAM-MD5-HEX", "CRAM-MD5-HASHED", "ANONYMOUS", "GSSAPI" };
    for (int i = 0; i < unsupported.length; i++) {
        String mechanism = unsupported[i];
        SaslNegotiator negotiator = _authenticationManager.createSaslNegotiator(mechanism, null, null);
        assertNull("Mechanism " + mechanism + " should not be supported by SimpleAuthenticationManager", negotiator);
    }
}
Also used : SaslNegotiator(org.apache.qpid.server.security.auth.sasl.SaslNegotiator)

Example 10 with SaslNegotiator

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

the class OAuth2AuthenticationProviderImplTest method testAuthenticateViaSasl.

public void testAuthenticateViaSasl() throws Exception {
    _server.setEndpoints(Collections.singletonMap(TEST_IDENTITY_RESOLVER_ENDPOINT_PATH, createMockIdentityResolverEndpoint()));
    final SaslNegotiator negotiator = _authProvider.createSaslNegotiator(OAuth2Negotiator.MECHANISM, null, null);
    AuthenticationResult authenticationResult = negotiator.handleResponse(("auth=Bearer " + TEST_VALID_ACCESS_TOKEN + "\1\1").getBytes(UTF8));
    assertSuccess(authenticationResult);
}
Also used : SaslNegotiator(org.apache.qpid.server.security.auth.sasl.SaslNegotiator) AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult)

Aggregations

SaslNegotiator (org.apache.qpid.server.security.auth.sasl.SaslNegotiator)22 AuthenticationResult (org.apache.qpid.server.security.auth.AuthenticationResult)13 X500Principal (javax.security.auth.x500.X500Principal)7 SaslSettings (org.apache.qpid.server.security.auth.sasl.SaslSettings)7 UsernamePrincipal (org.apache.qpid.server.security.auth.UsernamePrincipal)5 SubjectCreator (org.apache.qpid.server.security.SubjectCreator)2 InetSocketAddress (java.net.InetSocketAddress)1 Subject (javax.security.auth.Subject)1 HttpSession (javax.servlet.http.HttpSession)1 TaskExecutorImpl (org.apache.qpid.server.configuration.updater.TaskExecutorImpl)1 EventLogger (org.apache.qpid.server.logging.EventLogger)1 SessionInvalidatedException (org.apache.qpid.server.management.plugin.SessionInvalidatedException)1 AuthenticationProvider (org.apache.qpid.server.model.AuthenticationProvider)1 Broker (org.apache.qpid.server.model.Broker)1 BrokerModel (org.apache.qpid.server.model.BrokerModel)1 Model (org.apache.qpid.server.model.Model)1 SystemConfig (org.apache.qpid.server.model.SystemConfig)1 VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)1 AmqpPort (org.apache.qpid.server.model.port.AmqpPort)1 AuthenticatedPrincipal (org.apache.qpid.server.security.auth.AuthenticatedPrincipal)1