use of joynr.infrastructure.DacTypes.Permission in project joynr by bmwcarit.
the class AccessControlAlgorithmTest method testPermissionWithOwnerAceOnly.
@Test
public void testPermissionWithOwnerAceOnly() {
ownerAce.setConsumerPermission(Permission.YES);
ownerAce.setRequiredTrustLevel(TrustLevel.HIGH);
Permission providerPermission = accessControlAlgorithm.getConsumerPermission(null, null, ownerAce, TrustLevel.HIGH);
Assert.assertEquals(Permission.YES, providerPermission);
}
use of joynr.infrastructure.DacTypes.Permission in project joynr by bmwcarit.
the class AccessControlAlgorithmTest method testPermissionWithMasterAndInvalidOwnerAce.
@Test
public void testPermissionWithMasterAndInvalidOwnerAce() {
masterAce.setPossibleConsumerPermissions(new Permission[] { Permission.NO });
ownerAce.setConsumerPermission(Permission.ASK);
Permission consumerPermission = accessControlAlgorithm.getConsumerPermission(masterAce, null, ownerAce, TrustLevel.HIGH);
Assert.assertEquals(Permission.NO, consumerPermission);
}
use of joynr.infrastructure.DacTypes.Permission in project joynr by bmwcarit.
the class LocalDomainAccessControllerImpl method getConsumerPermission.
@Override
@CheckForNull
public void getConsumerPermission(final String userId, final String domain, final String interfaceName, final TrustLevel trustLevel, final GetConsumerPermissionCallback callback) {
final UserDomainInterfaceOperationKey subscriptionKey = new UserDomainInterfaceOperationKey(null, domain, interfaceName, null);
LOG.debug("getConsumerPermission on domain {}, interface {}", domain, interfaceName);
// Handle special cases which should not require a lookup or a subscription
Permission specialPermission = handleSpecialCases(domain, interfaceName);
if (specialPermission != null) {
callback.getConsumerPermission(specialPermission);
return;
}
if (subscriptionsMap.get(subscriptionKey) == null) {
if (!ongoingSubscriptions.contains(subscriptionKey)) {
queryDomainRoles(userId);
queryAccessControlEntries(domain, interfaceName, new QueryAccessControlEntriesCallback() {
@Override
public void queryAccessControlEntriesSucceeded() {
subscriptionsMap.put(subscriptionKey, subscribeForAceChange(domain, interfaceName));
ongoingSubscriptions.remove(subscriptionKey);
getConsumerPermissionWithCachedEntries(userId, domain, interfaceName, trustLevel, callback);
}
@Override
public void queryAccessControlEntriesFailed() {
callback.getConsumerPermissionFailed();
}
});
}
} else {
getConsumerPermissionWithCachedEntries(userId, domain, interfaceName, trustLevel, callback);
}
}
use of joynr.infrastructure.DacTypes.Permission in project joynr by bmwcarit.
the class MasterAccessControlEntryManager method mapEntityToJoynrType.
private MasterAccessControlEntry mapEntityToJoynrType(MasterAccessControlEntryEntity entity) {
MasterAccessControlEntry result = new MasterAccessControlEntry();
result.setUid(entity.getUserId());
result.setDomain(entity.getDomain());
result.setInterfaceName(entity.getInterfaceName());
result.setDefaultRequiredTrustLevel(entity.getDefaultRequiredTrustLevel());
result.setPossibleRequiredTrustLevels(entity.getPossibleRequiredTrustLevels().toArray(new TrustLevel[entity.getPossibleRequiredTrustLevels().size()]));
result.setDefaultRequiredControlEntryChangeTrustLevel(entity.getDefaultRequiredControlEntryChangeTrustLevel());
result.setPossibleRequiredControlEntryChangeTrustLevels(entity.getPossibleRequiredControlEntryChangeTrustLevels().toArray(new TrustLevel[entity.getPossibleRequiredControlEntryChangeTrustLevels().size()]));
result.setOperation(entity.getOperation());
result.setDefaultConsumerPermission(entity.getDefaultConsumerPermission());
result.setPossibleConsumerPermissions(entity.getPossibleConsumerPermissions().toArray(new Permission[entity.getPossibleConsumerPermissions().size()]));
return result;
}
use of joynr.infrastructure.DacTypes.Permission in project joynr by bmwcarit.
the class DomainAccessControlStoreTest method setup.
@Before
public void setup() {
// instantiate some template objects
expectedUserDomainRoleEntry = new DomainRoleEntry(UID1, new String[0], Role.OWNER);
expectedMasterAccessControlEntry = new MasterAccessControlEntry(UID1, DOMAIN1, INTERFACE1, TrustLevel.LOW, new TrustLevel[] { TrustLevel.MID, TrustLevel.LOW }, TrustLevel.LOW, new TrustLevel[] { TrustLevel.MID, TrustLevel.LOW }, OPERATION1, Permission.NO, new Permission[] { Permission.ASK, Permission.NO });
expectedOwnerAccessControlEntry = new OwnerAccessControlEntry(UID1, DOMAIN1, INTERFACE1, TrustLevel.LOW, TrustLevel.LOW, OPERATION1, Permission.NO);
}
Aggregations