Search in sources :

Example 6 with Permission

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);
}
Also used : Permission(joynr.infrastructure.DacTypes.Permission) Test(org.junit.Test)

Example 7 with Permission

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);
}
Also used : Permission(joynr.infrastructure.DacTypes.Permission) Test(org.junit.Test)

Example 8 with Permission

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);
    }
}
Also used : Permission(joynr.infrastructure.DacTypes.Permission) UserDomainInterfaceOperationKey(io.joynr.accesscontrol.primarykey.UserDomainInterfaceOperationKey) CheckForNull(javax.annotation.CheckForNull)

Example 9 with Permission

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;
}
Also used : MasterAccessControlEntry(joynr.infrastructure.DacTypes.MasterAccessControlEntry) TrustLevel(joynr.infrastructure.DacTypes.TrustLevel) Permission(joynr.infrastructure.DacTypes.Permission)

Example 10 with Permission

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);
}
Also used : MasterAccessControlEntry(joynr.infrastructure.DacTypes.MasterAccessControlEntry) TrustLevel(joynr.infrastructure.DacTypes.TrustLevel) OwnerAccessControlEntry(joynr.infrastructure.DacTypes.OwnerAccessControlEntry) DomainRoleEntry(joynr.infrastructure.DacTypes.DomainRoleEntry) Permission(joynr.infrastructure.DacTypes.Permission) Before(org.junit.Before)

Aggregations

Permission (joynr.infrastructure.DacTypes.Permission)20 Test (org.junit.Test)11 TrustLevel (joynr.infrastructure.DacTypes.TrustLevel)7 MasterAccessControlEntry (joynr.infrastructure.DacTypes.MasterAccessControlEntry)6 Before (org.junit.Before)5 DomainRoleEntry (joynr.infrastructure.DacTypes.DomainRoleEntry)4 OwnerAccessControlEntry (joynr.infrastructure.DacTypes.OwnerAccessControlEntry)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 UserDomainInterfaceOperationKey (io.joynr.accesscontrol.primarykey.UserDomainInterfaceOperationKey)1 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)1 MessagingQos (io.joynr.messaging.MessagingQos)1 ProxyBuilderFactoryImpl (io.joynr.proxy.ProxyBuilderFactoryImpl)1 Set (java.util.Set)1 CheckForNull (javax.annotation.CheckForNull)1 MasterRegistrationControlEntry (joynr.infrastructure.DacTypes.MasterRegistrationControlEntry)1 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)1