Search in sources :

Example 16 with Permission

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

Example 17 with Permission

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

Example 18 with Permission

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

Example 19 with Permission

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);
}
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)

Example 20 with Permission

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

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