use of org.apache.qpid.server.security.auth.sasl.SaslNegotiator 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);
}
use of org.apache.qpid.server.security.auth.sasl.SaslNegotiator 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");
}
Aggregations