use of joynr.infrastructure.DacTypes.Permission in project joynr by bmwcarit.
the class AccessControlAlgorithmTest method testPermissionWithMasterAceOnly.
@Test
public void testPermissionWithMasterAceOnly() {
masterAce.setDefaultConsumerPermission(Permission.YES);
masterAce.setDefaultRequiredTrustLevel(TrustLevel.HIGH);
Permission consumerPermission = accessControlAlgorithm.getConsumerPermission(masterAce, null, null, TrustLevel.HIGH);
Assert.assertEquals(Permission.YES, consumerPermission);
}
use of joynr.infrastructure.DacTypes.Permission in project joynr by bmwcarit.
the class AccessControlAlgorithmTest method testPermissionWithAllAceNull.
@Test
public void testPermissionWithAllAceNull() {
Permission providerPermission = accessControlAlgorithm.getConsumerPermission(null, null, null, TrustLevel.HIGH);
Assert.assertEquals(Permission.NO, providerPermission);
}
use of joynr.infrastructure.DacTypes.Permission in project joynr by bmwcarit.
the class AccessControlAlgorithmTest method testPermissionWithMasterMediatorAndOwnerAce.
// ------ Owner overrides master and mediator ---------------------------------
@Test
public void testPermissionWithMasterMediatorAndOwnerAce() {
masterAce.setDefaultConsumerPermission(Permission.YES);
masterAce.setDefaultRequiredTrustLevel(TrustLevel.LOW);
mediatorAce.setDefaultConsumerPermission(Permission.ASK);
mediatorAce.setDefaultRequiredTrustLevel(TrustLevel.HIGH);
ownerAce.setConsumerPermission(Permission.YES);
ownerAce.setRequiredTrustLevel(TrustLevel.MID);
Permission consumerPermission = accessControlAlgorithm.getConsumerPermission(masterAce, mediatorAce, ownerAce, TrustLevel.MID);
Assert.assertEquals(Permission.YES, consumerPermission);
}
use of joynr.infrastructure.DacTypes.Permission in project joynr by bmwcarit.
the class GdacBroadcastListenerTest method setup.
@Before
public void setup() {
// instantiate some template objects
userDre = new DomainRoleEntry(UID1, new String[] { DOMAIN1 }, Role.OWNER);
masterAce = new MasterAccessControlEntry(UID1, DOMAIN1, INTERFACE1, TrustLevel.LOW, new TrustLevel[] { TrustLevel.MID, TrustLevel.LOW }, TrustLevel.LOW, new TrustLevel[] { TrustLevel.MID, TrustLevel.LOW }, OPEARATION1, Permission.NO, new Permission[] { Permission.ASK, Permission.NO });
ownerAce = new OwnerAccessControlEntry(UID1, DOMAIN1, INTERFACE1, TrustLevel.LOW, TrustLevel.LOW, OPEARATION1, Permission.YES);
}
use of joynr.infrastructure.DacTypes.Permission in project joynr by bmwcarit.
the class AccessControlAlgorithm method getPermission.
private Permission getPermission(PermissionType type, @Nullable MasterAccessControlEntry masterAce, @Nullable MasterAccessControlEntry mediatorAce, @Nullable OwnerAccessControlEntry ownerAce, TrustLevel trustLevel) {
AceValidator aceValidator = new AceValidator(masterAce, mediatorAce, ownerAce);
if (!aceValidator.isValid()) {
return Permission.NO;
}
Permission permission = Permission.NO;
if (ownerAce != null) {
if (TrustLevelComparator.compare(trustLevel, ownerAce.getRequiredTrustLevel()) >= 0) {
if (type == PermissionType.CONSUMER) {
permission = ownerAce.getConsumerPermission();
}
}
} else if (mediatorAce != null) {
if (TrustLevelComparator.compare(trustLevel, mediatorAce.getDefaultRequiredTrustLevel()) >= 0) {
if (type == PermissionType.CONSUMER) {
permission = mediatorAce.getDefaultConsumerPermission();
}
}
} else if (masterAce != null) {
if (TrustLevelComparator.compare(trustLevel, masterAce.getDefaultRequiredTrustLevel()) >= 0) {
if (type == PermissionType.CONSUMER) {
permission = masterAce.getDefaultConsumerPermission();
}
}
}
return permission;
}
Aggregations