use of org.apache.qpid.server.security.auth.sasl.SaslNegotiator in project qpid-broker-j by apache.
the class AnonymousAuthenticationManagerTest method testCreateSaslNegotiator.
public void testCreateSaslNegotiator() throws Exception {
SaslNegotiator negotiator = _manager.createSaslNegotiator("ANONYMOUS", null, null);
assertNotNull("Could not create SASL negotiator for mechanism 'ANONYMOUS'", negotiator);
negotiator = _manager.createSaslNegotiator("PLAIN", null, null);
assertNull("Should not be able to create SASL negotiator for mechanism 'PLAIN'", negotiator);
}
use of org.apache.qpid.server.security.auth.sasl.SaslNegotiator in project qpid-broker-j by apache.
the class ExternalAuthenticationManagerTest method testFullDNMode_Authenticate.
public void testFullDNMode_Authenticate() throws Exception {
X500Principal principal = new X500Principal("CN=person, DC=example, DC=com");
when(_saslSettings.getExternalPrincipal()).thenReturn(principal);
SaslNegotiator negotiator = _managerUsingFullDN.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(principal, result.getPrincipals());
assertEquals("CN=person,DC=example,DC=com", result.getMainPrincipal().getName());
}
use of org.apache.qpid.server.security.auth.sasl.SaslNegotiator in project qpid-broker-j by apache.
the class ExternalAuthenticationManagerTest method createSaslNegotiatorTestImpl.
private void createSaslNegotiatorTestImpl(AuthenticationProvider<?> manager) throws Exception {
SaslNegotiator negotiator = manager.createSaslNegotiator("EXTERNAL", _saslSettings, null);
assertNotNull("Could not create SASL negotiator for 'EXTERNAL' mechanism.", negotiator);
negotiator = manager.createSaslNegotiator("PLAIN", _saslSettings, null);
assertNull("Should not be able to create SASL negotiator with incorrect mechanism.", negotiator);
}
use of org.apache.qpid.server.security.auth.sasl.SaslNegotiator in project qpid-broker-j by apache.
the class ExternalAuthenticationManagerTest method testAuthenticatePrincipalCnDc_OtherComponentsIgnored.
public void testAuthenticatePrincipalCnDc_OtherComponentsIgnored() throws Exception {
X500Principal principal = new X500Principal("CN=person, DC=example, DC=com, O=My Company Ltd, L=Newbury, ST=Berkshire, C=GB");
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.sasl.SaslNegotiator in project qpid-broker-j by apache.
the class ExternalAuthenticationManagerTest method testAuthenticatePrincipalNoCn_CausesAuthError.
public void testAuthenticatePrincipalNoCn_CausesAuthError() throws Exception {
X500Principal principal = new X500Principal("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