use of org.apache.activemq.jaas.GroupPrincipal in project activemq-artemis by apache.
the class JaasDualAuthenticationBrokerTest method testInsecureConnector.
public void testInsecureConnector() {
Connector connector = new TransportConnector(nonSslTransportServer);
connectionContext.setConnector(connector);
connectionInfo.setUserName(INSECURE_USERNAME);
try {
authBroker.addConnection(connectionContext, connectionInfo);
} catch (Exception e) {
fail("Call to addConnection failed: " + e.getMessage());
}
assertEquals("Number of addConnection calls to underlying Broker must match number of calls made to " + "AuthenticationBroker.", 1, receiveBroker.addConnectionData.size());
ConnectionContext receivedContext = receiveBroker.addConnectionData.getFirst().connectionContext;
assertEquals("The SecurityContext's userName must be set to that of the UserPrincipal.", INSECURE_USERNAME, receivedContext.getSecurityContext().getUserName());
Set<Principal> receivedPrincipals = receivedContext.getSecurityContext().getPrincipals();
assertEquals("2 Principals received", 2, receivedPrincipals.size());
for (Iterator<Principal> iter = receivedPrincipals.iterator(); iter.hasNext(); ) {
Principal currentPrincipal = iter.next();
if (currentPrincipal instanceof UserPrincipal) {
assertEquals("UserPrincipal is '" + INSECURE_USERNAME + "'", INSECURE_USERNAME, currentPrincipal.getName());
} else if (currentPrincipal instanceof GroupPrincipal) {
assertEquals("GroupPrincipal is '" + INSECURE_GROUP + "'", INSECURE_GROUP, currentPrincipal.getName());
} else {
fail("Unexpected Principal subclass found.");
}
}
try {
authBroker.removeConnection(connectionContext, connectionInfo, null);
} catch (Exception e) {
fail("Call to removeConnection failed: " + e.getMessage());
}
assertEquals("Number of removeConnection calls to underlying Broker must match number of calls made to " + "AuthenticationBroker.", 1, receiveBroker.removeConnectionData.size());
}
use of org.apache.activemq.jaas.GroupPrincipal in project activemq-artemis by apache.
the class LDAPAuthorizationMapTest method testComposite.
@Test
public void testComposite() {
ActiveMQDestination q1 = new ActiveMQQueue("queue1,topic://topic1");
Set<GroupPrincipal> aclsq1 = authMap.getWriteACLs(q1);
assertEquals(0, aclsq1.size());
}
use of org.apache.activemq.jaas.GroupPrincipal in project activemq-artemis by apache.
the class LDAPAuthorizationMapTest method testGetAdminACLs.
/*
* Test method for 'org.apache.activemq.security.LDAPAuthorizationMap.getAdminACLs(ActiveMQDestination)'
*/
@Test
public void testGetAdminACLs() {
ActiveMQDestination q1 = new ActiveMQQueue("queue1");
Set<GroupPrincipal> aclsq1 = authMap.getAdminACLs(q1);
assertEquals(1, aclsq1.size());
assertTrue(aclsq1.contains(new GroupPrincipal("role1")));
ActiveMQDestination t1 = new ActiveMQTopic("topic1");
Set<GroupPrincipal> aclst1 = authMap.getAdminACLs(t1);
assertEquals(1, aclst1.size());
assertTrue(aclst1.contains(new GroupPrincipal("role1")));
}
use of org.apache.activemq.jaas.GroupPrincipal in project activemq-artemis by apache.
the class LDAPAuthorizationMapTest method testAdvisory.
@Test
public void testAdvisory() {
ActiveMQDestination dest = AdvisorySupport.getConnectionAdvisoryTopic();
Set<GroupPrincipal> acls = authMap.getWriteACLs(dest);
assertEquals(1, acls.size());
assertTrue(acls.contains(new GroupPrincipal("role3")));
}
use of org.apache.activemq.jaas.GroupPrincipal in project activemq-artemis by apache.
the class LDAPAuthorizationMapTest method testGetReadACLs.
/*
* Test method for 'org.apache.activemq.security.LDAPAuthorizationMap.getReadACLs(ActiveMQDestination)'
*/
@Test
public void testGetReadACLs() {
ActiveMQDestination q1 = new ActiveMQQueue("queue1");
Set<GroupPrincipal> aclsq1 = authMap.getReadACLs(q1);
assertEquals(1, aclsq1.size());
assertTrue(aclsq1.contains(new GroupPrincipal("role1")));
ActiveMQDestination t1 = new ActiveMQTopic("topic1");
Set<GroupPrincipal> aclst1 = authMap.getReadACLs(t1);
assertEquals(1, aclst1.size());
assertTrue(aclst1.contains(new GroupPrincipal("role2")));
}
Aggregations