use of org.apache.qpid.server.security.auth.AuthenticationResult in project qpid-broker-j by apache.
the class PlainNegotiatorTest method testHandleResponse.
public void testHandleResponse() throws Exception {
final AuthenticationResult result = _negotiator.handleResponse(VALID_RESPONSE.getBytes(US_ASCII));
verify(_authenticationProvider).authenticate(eq(VALID_USERNAME), eq(VALID_PASSWORD));
assertEquals("Unexpected authentication result", _successfulResult, result);
}
use of org.apache.qpid.server.security.auth.AuthenticationResult in project qpid-broker-j by apache.
the class PlainNegotiatorTest method testHandleNeverSendAResponse.
public void testHandleNeverSendAResponse() throws Exception {
final AuthenticationResult firstResult = _negotiator.handleResponse(new byte[0]);
assertEquals("Unexpected authentication status", AuthenticationResult.AuthenticationStatus.CONTINUE, firstResult.getStatus());
assertArrayEquals("Unexpected authentication challenge", new byte[0], firstResult.getChallenge());
final AuthenticationResult secondResult = _negotiator.handleResponse(new byte[0]);
assertEquals("Unexpected first authentication result", AuthenticationResult.AuthenticationStatus.ERROR, secondResult.getStatus());
}
use of org.apache.qpid.server.security.auth.AuthenticationResult in project qpid-broker-j by apache.
the class ScramNegotiatorTest method doSaslNegotiationTestInvalidCredentials.
private void doSaslNegotiationTestInvalidCredentials(final String userName, final String userPassword, final String mechanism, final AuthenticationProvider<?> authenticationProvider, final ScramSaslServerSource scramSaslServerSource) throws Exception {
ScramNegotiator scramNegotiator = new ScramNegotiator(authenticationProvider, scramSaslServerSource, mechanism);
byte[] initialResponse = createInitialResponse(userName);
AuthenticationResult firstResult = scramNegotiator.handleResponse(initialResponse);
assertEquals("Unexpected first result status", AuthenticationResult.AuthenticationStatus.CONTINUE, firstResult.getStatus());
assertNotNull("Unexpected first result challenge", firstResult.getChallenge());
byte[] response = calculateClientProof(firstResult.getChallenge(), scramSaslServerSource.getHmacName(), scramSaslServerSource.getDigestName(), userPassword);
AuthenticationResult secondResult = scramNegotiator.handleResponse(response);
assertEquals("Unexpected second result status", AuthenticationResult.AuthenticationStatus.ERROR, secondResult.getStatus());
assertNull("Unexpected second result challenge", secondResult.getChallenge());
assertNull("Unexpected second result principal", secondResult.getMainPrincipal());
}
Aggregations