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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations