use of org.apache.qpid.server.security.auth.UsernamePrincipal in project qpid-broker-j by apache.
the class ExternalAuthenticationManagerTest method testAuthenticatePrincipalCn_OtherComponentsIgnored.
public void testAuthenticatePrincipalCn_OtherComponentsIgnored() throws Exception {
X500Principal principal = new X500Principal("CN=person, O=My Company Ltd, L=Newbury, ST=Berkshire, C=GB");
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.UsernamePrincipal in project qpid-broker-j by apache.
the class PrincipalDatabaseAuthenticationManagerTest method testNonSaslAuthenticationSuccess.
public void testNonSaslAuthenticationSuccess() throws Exception {
setupMocks();
when(_principalDatabase.verifyPassword("guest", "guest".toCharArray())).thenReturn(true);
AuthenticationResult result = _manager.authenticate("guest", "guest");
UsernamePrincipal expectedPrincipal = new UsernamePrincipal("guest", _manager);
assertOnlyContainsWrapped(expectedPrincipal, result.getPrincipals());
assertEquals(AuthenticationStatus.SUCCESS, result.getStatus());
}
use of org.apache.qpid.server.security.auth.UsernamePrincipal in project qpid-broker-j by apache.
the class GroupPrincipalTest method testAddRejected.
public void testAddRejected() {
final GroupPrincipal principal = new GroupPrincipal("group", (GroupProvider) null);
final UsernamePrincipal user = new UsernamePrincipal("name", null);
try {
principal.addMember(user);
fail("Exception not thrown");
} catch (UnsupportedOperationException uso) {
// PASS
}
}
Aggregations