use of org.apache.qpid.server.security.auth.AuthenticationResult in project qpid-broker-j by apache.
the class AnonymousAuthenticationManagerTest method testAuthenticate.
public void testAuthenticate() throws Exception {
SaslNegotiator negotiator = _manager.createSaslNegotiator("ANONYMOUS", null, null);
AuthenticationResult result = negotiator.handleResponse(new byte[0]);
assertNotNull(result);
assertEquals("Expected authentication to be successful", AuthenticationResult.AuthenticationStatus.SUCCESS, result.getStatus());
assertOnlyContainsWrapped(_manager.getAnonymousPrincipal(), result.getPrincipals());
}
use of org.apache.qpid.server.security.auth.AuthenticationResult in project qpid-broker-j by apache.
the class ExternalAuthenticationManagerTest method testAuthenticatePrincipalNull_CausesAuthError.
public void testAuthenticatePrincipalNull_CausesAuthError() throws Exception {
SaslNegotiator negotiator = _manager.createSaslNegotiator("EXTERNAL", _saslSettings, null);
AuthenticationResult result = negotiator.handleResponse(new byte[0]);
assertNotNull(result);
assertEquals("Expected authentication to be unsuccessful", AuthenticationResult.AuthenticationStatus.ERROR, result.getStatus());
assertNull(result.getMainPrincipal());
}
use of org.apache.qpid.server.security.auth.AuthenticationResult in project qpid-broker-j by apache.
the class ExternalAuthenticationManagerTest method testAuthenticatePrincipalCnAndDc.
public void testAuthenticatePrincipalCnAndDc() throws Exception {
X500Principal principal = new X500Principal("CN=person, DC=example, DC=com");
UsernamePrincipal expectedPrincipal = new UsernamePrincipal("person@example.com", _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@example.com", result.getMainPrincipal().getName());
}
use of org.apache.qpid.server.security.auth.AuthenticationResult 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.AuthenticationResult in project qpid-broker-j by apache.
the class ExternalAuthenticationManagerTest method testAuthenticatePrincipalEmptyCn_CausesAuthError.
public void testAuthenticatePrincipalEmptyCn_CausesAuthError() throws Exception {
X500Principal principal = new X500Principal("CN=, DC=example, DC=com, O=My Company Ltd, L=Newbury, ST=Berkshire, C=GB");
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 unsuccessful", AuthenticationResult.AuthenticationStatus.ERROR, result.getStatus());
assertNull(result.getMainPrincipal());
}
Aggregations