Search in sources :

Example 71 with AuthenticationResult

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

the class ExternalNegotiatorTest method testHandleResponseFailsWithoutExternalPrincipal.

public void testHandleResponseFailsWithoutExternalPrincipal() throws Exception {
    ExternalAuthenticationManager<?> externalAuthenticationManager = mock(ExternalAuthenticationManager.class);
    when(externalAuthenticationManager.getUseFullDN()).thenReturn(true);
    ExternalNegotiator negotiator = new ExternalNegotiator(externalAuthenticationManager, null);
    AuthenticationResult firstResult = negotiator.handleResponse(new byte[0]);
    assertEquals("Unexpected first result status", AuthenticationResult.AuthenticationStatus.ERROR, firstResult.getStatus());
    assertNull("Unexpected first result principal", firstResult.getMainPrincipal());
}
Also used : AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult)

Example 72 with AuthenticationResult

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

the class ExternalNegotiatorTest method testHandleResponseNotUseFullDN_No_CN_DC_In_ExternalPrincipal.

public void testHandleResponseNotUseFullDN_No_CN_DC_In_ExternalPrincipal() throws Exception {
    ExternalAuthenticationManager<?> externalAuthenticationManager = mock(ExternalAuthenticationManager.class);
    when(externalAuthenticationManager.getUseFullDN()).thenReturn(false);
    X500Principal externalPrincipal = new X500Principal(USERNAME_NO_CN_DC);
    ExternalNegotiator negotiator = new ExternalNegotiator(externalAuthenticationManager, externalPrincipal);
    AuthenticationResult firstResult = negotiator.handleResponse(new byte[0]);
    assertEquals("Unexpected first result status", AuthenticationResult.AuthenticationStatus.ERROR, firstResult.getStatus());
    assertNull("Unexpected first result principal", firstResult.getMainPrincipal());
}
Also used : X500Principal(javax.security.auth.x500.X500Principal) AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult)

Example 73 with AuthenticationResult

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

the class ExternalNegotiatorTest method testHandleResponseSucceedsForNonX500Principal.

public void testHandleResponseSucceedsForNonX500Principal() throws Exception {
    ExternalAuthenticationManager<?> externalAuthenticationManager = mock(ExternalAuthenticationManager.class);
    when(externalAuthenticationManager.getUseFullDN()).thenReturn(true);
    Principal principal = mock(Principal.class);
    ExternalNegotiator negotiator = new ExternalNegotiator(externalAuthenticationManager, principal);
    AuthenticationResult firstResult = negotiator.handleResponse(new byte[0]);
    assertEquals("Unexpected first result status", AuthenticationResult.AuthenticationStatus.SUCCESS, firstResult.getStatus());
    assertEquals("Unexpected first result principal", principal, firstResult.getMainPrincipal());
    AuthenticationResult secondResult = negotiator.handleResponse(new byte[0]);
    assertEquals("Unexpected second result status", AuthenticationResult.AuthenticationStatus.ERROR, secondResult.getStatus());
}
Also used : Principal(java.security.Principal) X500Principal(javax.security.auth.x500.X500Principal) AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult)

Example 74 with AuthenticationResult

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

the class OAuth2NegotiatorTest method testHandleResponse_ResponseAuthAbsent.

public void testHandleResponse_ResponseAuthAbsent() throws Exception {
    AuthenticationResult actualResult = _negotiator.handleResponse(RESPONSE_WITH_NO_TOKEN);
    assertEquals("Unexpected result status", AuthenticationResult.AuthenticationStatus.ERROR, actualResult.getStatus());
    assertNull("Unexpected result principal", actualResult.getMainPrincipal());
}
Also used : AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult)

Example 75 with AuthenticationResult

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

the class OAuth2NegotiatorTest 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());
}
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