use of org.apache.qpid.server.security.auth.AuthenticationResult 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());
}
use of org.apache.qpid.server.security.auth.AuthenticationResult in project qpid-broker-j by apache.
the class ManagedAuthenticationManagerTestBase method testAuthenticateInvalidCredentials.
public void testAuthenticateInvalidCredentials() throws Exception {
_authManager.createUser(TEST_USER_NAME, TEST_USER_PASSWORD, Collections.<String, String>emptyMap());
AuthenticationResult result = _authManager.authenticate(TEST_USER_NAME, TEST_USER_PASSWORD + "1");
assertEquals("Unexpected result status", AuthenticationResult.AuthenticationStatus.ERROR, result.getStatus());
assertNull("Unexpected result principal", result.getMainPrincipal());
}
use of org.apache.qpid.server.security.auth.AuthenticationResult in project qpid-broker-j by apache.
the class PlainPasswordDatabaseAuthenticationManagerTest method testAuthenticate.
public void testAuthenticate() {
_passwordFile = TestFileUtils.createTempFile(this, ".user.password", "user:password");
String file = _passwordFile.getAbsolutePath();
Map<String, Object> providerAttrs = new HashMap<>();
providerAttrs.put(PlainPasswordDatabaseAuthenticationManager.TYPE, PROVIDER_TYPE);
providerAttrs.put(PlainPasswordDatabaseAuthenticationManager.PATH, file);
providerAttrs.put(PlainPasswordDatabaseAuthenticationManager.NAME, getTestName());
PasswordCredentialManagingAuthenticationProvider provider = ((PasswordCredentialManagingAuthenticationProvider) _objectFactory.create(AuthenticationProvider.class, providerAttrs, _broker));
{
AuthenticationResult result = provider.authenticate("user", "password");
assertThat(result.getStatus(), is(equalTo(SUCCESS)));
}
{
AuthenticationResult result = provider.authenticate("user", "badpassword");
assertThat(result.getStatus(), is(equalTo(AuthenticationResult.AuthenticationStatus.ERROR)));
}
{
AuthenticationResult result = provider.authenticate("unknownuser", "badpassword");
assertThat(result.getStatus(), is(equalTo(AuthenticationResult.AuthenticationStatus.ERROR)));
}
}
use of org.apache.qpid.server.security.auth.AuthenticationResult in project qpid-broker-j by apache.
the class PrincipalDatabaseAuthenticationManagerTest method testSaslAuthenticationSuccess.
/**
* Tests that the authenticate method correctly interprets an
* authentication success.
*/
public void testSaslAuthenticationSuccess() throws Exception {
setupMocks();
UsernamePrincipal expectedPrincipal = new UsernamePrincipal("guest", _manager);
when(_saslNegotiator.handleResponse(any(byte[].class))).thenReturn(new AuthenticationResult(expectedPrincipal));
AuthenticationResult result = _saslNegotiator.handleResponse("12345".getBytes());
assertOnlyContainsWrapped(expectedPrincipal, result.getPrincipals());
assertEquals(AuthenticationStatus.SUCCESS, result.getStatus());
}
use of org.apache.qpid.server.security.auth.AuthenticationResult in project qpid-broker-j by apache.
the class SimpleAuthenticationManagerTest method testAuthenticateWithPlainSaslServerInvalidUsername.
public void testAuthenticateWithPlainSaslServerInvalidUsername() throws Exception {
AuthenticationResult result = authenticatePlain("wrong-user", TEST_PASSWORD);
assertUnauthenticated(result);
}
Aggregations