use of org.apache.qpid.server.security.access.config.Rule.Builder in project qpid-broker-j by apache.
the class RuleSetTest method testList_Arrays.
@Test
public void testList_Arrays() {
_ruleCollector.addRule(1, new Builder().withIdentity(TEST_USER).withOutcome(RuleOutcome.ALLOW).withOperation(LegacyOperation.PUBLISH).withObject(ObjectType.EXCHANGE).withPredicate(Property.NAME, "broadcast").build());
_ruleCollector.addRule(3, new Builder().withIdentity(TEST_USER).withOutcome(RuleOutcome.ALLOW).withOperation(LegacyOperation.ACCESS).withObject(ObjectType.VIRTUALHOST).build());
_ruleCollector.addRule(17, new Builder().withIdentity(Rule.ALL).withOutcome(RuleOutcome.DENY).withOperation(LegacyOperation.ALL).withObject(ObjectType.ALL).build());
final RuleSet ruleSet = createRuleSet();
assertNotNull(ruleSet);
Object[] array = ruleSet.toArray();
Rule[] ruleArray = ruleSet.toArray(new Rule[0]);
assertEquals(3, array.length);
assertEquals(3, ruleArray.length);
for (int i = 0; i < array.length; i++) {
assertEquals(ruleSet.get(i), array[i]);
assertEquals(ruleSet.get(i), ruleArray[i]);
}
}
use of org.apache.qpid.server.security.access.config.Rule.Builder in project qpid-broker-j by apache.
the class RuleSetTest method testVirtualHostAccessDenyPermissionWithNameSetToWildCard.
@Test
public void testVirtualHostAccessDenyPermissionWithNameSetToWildCard() {
_ruleCollector.addRule(0, new Builder().withIdentity(TEST_USER).withOutcome(RuleOutcome.DENY).withOperation(LegacyOperation.ACCESS).withObject(ObjectType.VIRTUALHOST).withPredicate(Property.NAME, AclRulePredicatesBuilder.WILD_CARD).build());
final RuleSet ruleSet = createRuleSet();
assertEquals(Result.DENIED, ruleSet.check(_testSubject, LegacyOperation.ACCESS, ObjectType.VIRTUALHOST, new ObjectProperties(ALLOWED_VH)));
assertEquals(Result.DENIED, ruleSet.check(_testSubject, LegacyOperation.ACCESS, ObjectType.VIRTUALHOST, new ObjectProperties(DENIED_VH)));
}
use of org.apache.qpid.server.security.access.config.Rule.Builder in project qpid-broker-j by apache.
the class RuleSetTest method testTemporaryQueueLastConsume.
/**
* Test that temporary queue permissions after queue perms in the ACL config work correctly
*/
@Test
public void testTemporaryQueueLastConsume() {
final ObjectProperties temporary = new ObjectProperties(_queueName);
temporary.put(Property.AUTO_DELETE, Boolean.TRUE);
final ObjectProperties normal = new ObjectProperties(_queueName);
normal.put(Property.AUTO_DELETE, Boolean.FALSE);
RuleSet ruleSet = createRuleSet();
assertEquals(Result.DENIED, ruleSet.check(_testSubject, LegacyOperation.CONSUME, ObjectType.QUEUE, temporary));
// should not matter if the temporary permission is processed first or last
_ruleCollector.addRule(1, new Builder().withIdentity(TEST_USER).withOutcome(RuleOutcome.ALLOW).withOperation(LegacyOperation.CONSUME).withObject(ObjectType.QUEUE).withPredicates(temporary).build());
_ruleCollector.addRule(2, new Builder().withIdentity(TEST_USER).withOutcome(RuleOutcome.ALLOW).withOperation(LegacyOperation.CONSUME).withObject(ObjectType.QUEUE).withPredicates(normal).build());
ruleSet = createRuleSet();
assertEquals(2, ruleSet.size());
assertEquals(Result.ALLOWED, ruleSet.check(_testSubject, LegacyOperation.CONSUME, ObjectType.QUEUE, normal));
assertEquals(Result.ALLOWED, ruleSet.check(_testSubject, LegacyOperation.CONSUME, ObjectType.QUEUE, temporary));
}
use of org.apache.qpid.server.security.access.config.Rule.Builder in project qpid-broker-j by apache.
the class RuleSetTest method testNamedTemporaryQueueAllowed.
@Test
public void testNamedTemporaryQueueAllowed() {
final ObjectProperties named = new ObjectProperties(_queueName);
final ObjectProperties namedTemporary = new ObjectProperties(_queueName);
namedTemporary.put(Property.AUTO_DELETE, Boolean.TRUE);
RuleSet ruleSet = createRuleSet();
assertEquals(Result.DENIED, ruleSet.check(_testSubject, LegacyOperation.CREATE, ObjectType.QUEUE, named));
assertEquals(Result.DENIED, ruleSet.check(_testSubject, LegacyOperation.CREATE, ObjectType.QUEUE, namedTemporary));
_ruleCollector.addRule(1, new Builder().withIdentity(TEST_USER).withOutcome(RuleOutcome.ALLOW).withOperation(LegacyOperation.CREATE).withObject(ObjectType.QUEUE).withPredicates(namedTemporary).build());
_ruleCollector.addRule(2, new Builder().withIdentity(TEST_USER).withOutcome(RuleOutcome.ALLOW).withOperation(LegacyOperation.CREATE).withObject(ObjectType.QUEUE).withPredicates(named).build());
ruleSet = createRuleSet();
assertEquals(2, ruleSet.size());
assertEquals(Result.ALLOWED, ruleSet.check(_testSubject, LegacyOperation.CREATE, ObjectType.QUEUE, named));
assertEquals(Result.ALLOWED, ruleSet.check(_testSubject, LegacyOperation.CREATE, ObjectType.QUEUE, namedTemporary));
}
use of org.apache.qpid.server.security.access.config.Rule.Builder in project qpid-broker-j by apache.
the class RuleSetTest method testTemporaryQueueFirstConsume.
/**
* Test that temporary queue permissions before queue perms in the ACL config work correctly
*/
@Test
public void testTemporaryQueueFirstConsume() {
final ObjectProperties temporary = new ObjectProperties(_queueName);
temporary.put(Property.AUTO_DELETE, Boolean.TRUE);
final ObjectProperties normal = new ObjectProperties(_queueName);
normal.put(Property.AUTO_DELETE, Boolean.FALSE);
RuleSet ruleSet = createRuleSet();
assertEquals(Result.DENIED, ruleSet.check(_testSubject, LegacyOperation.CONSUME, ObjectType.QUEUE, temporary));
// should not matter if the temporary permission is processed first or last
_ruleCollector.addRule(1, new Builder().withIdentity(TEST_USER).withOutcome(RuleOutcome.ALLOW).withOperation(LegacyOperation.CONSUME).withObject(ObjectType.QUEUE).withPredicates(normal).build());
_ruleCollector.addRule(2, new Builder().withIdentity(TEST_USER).withOutcome(RuleOutcome.ALLOW).withOperation(LegacyOperation.CONSUME).withObject(ObjectType.QUEUE).withPredicates(temporary).build());
ruleSet = createRuleSet();
assertEquals(2, ruleSet.size());
assertEquals(Result.ALLOWED, ruleSet.check(_testSubject, LegacyOperation.CONSUME, ObjectType.QUEUE, normal));
assertEquals(Result.ALLOWED, ruleSet.check(_testSubject, LegacyOperation.CONSUME, ObjectType.QUEUE, temporary));
}
Aggregations