Search in sources :

Example 11 with Permission

use of joynr.infrastructure.DacTypes.Permission in project joynr by bmwcarit.

the class ProvisionedDomainAccessControlStoreTest method setup.

@Before
public void setup() throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    // instantiate some template objects
    expectedUserDomainRoleEntry = new DomainRoleEntry(UID1, new String[0], Role.OWNER);
    DomainRoleEntry[] provisionedDomainRoles = { expectedUserDomainRoleEntry };
    domainRoleEntryString = objectMapper.writeValueAsString(provisionedDomainRoles);
    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 });
    MasterAccessControlEntry[] provisionedMasterAccessControlEntries = { expectedMasterAccessControlEntry };
    masterAccessControlEntryString = objectMapper.writeValueAsString(provisionedMasterAccessControlEntries);
}
Also used : MasterAccessControlEntry(joynr.infrastructure.DacTypes.MasterAccessControlEntry) TrustLevel(joynr.infrastructure.DacTypes.TrustLevel) DomainRoleEntry(joynr.infrastructure.DacTypes.DomainRoleEntry) Permission(joynr.infrastructure.DacTypes.Permission) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 12 with Permission

use of joynr.infrastructure.DacTypes.Permission in project joynr by bmwcarit.

the class MasterRegistrationControlEntryManager method mapEntityToJoynrType.

private MasterRegistrationControlEntry mapEntityToJoynrType(MasterRegistrationControlEntryEntity entity) {
    Set<TrustLevel> possibleRequiredTrustLevels = Sets.newHashSet(entity.getPossibleRequiredTrustLevels());
    Set<TrustLevel> possibleRequiredControlEntryChangeTrustLevels = Sets.newHashSet(entity.getPossibleRequiredControlEntryChangeTrustLevels());
    Set<Permission> possibleProviderPermissions = Sets.newHashSet(entity.getDefaultProviderPermission());
    MasterRegistrationControlEntry entry = new MasterRegistrationControlEntry(entity.getUserId(), entity.getDomain(), entity.getInterfaceName(), entity.getDefaultRequiredTrustLevel(), possibleRequiredTrustLevels.toArray(new TrustLevel[possibleRequiredTrustLevels.size()]), entity.getDefaultRequiredControlEntryChangeTrustLevel(), possibleRequiredControlEntryChangeTrustLevels.toArray(new TrustLevel[possibleRequiredControlEntryChangeTrustLevels.size()]), entity.getDefaultProviderPermission(), possibleProviderPermissions.toArray(new Permission[possibleProviderPermissions.size()]));
    return entry;
}
Also used : TrustLevel(joynr.infrastructure.DacTypes.TrustLevel) Permission(joynr.infrastructure.DacTypes.Permission) MasterRegistrationControlEntry(joynr.infrastructure.DacTypes.MasterRegistrationControlEntry)

Example 13 with Permission

use of joynr.infrastructure.DacTypes.Permission in project joynr by bmwcarit.

the class AceValidatorTest method setup.

@Before
public void setup() {
    masterAce = new MasterAccessControlEntry(null, null, null, TrustLevel.LOW, new TrustLevel[] { TrustLevel.MID, TrustLevel.LOW }, TrustLevel.LOW, new TrustLevel[] { TrustLevel.MID, TrustLevel.HIGH }, null, Permission.NO, new Permission[] { Permission.ASK, Permission.NO });
    mediatorAce = new MasterAccessControlEntry(null, null, null, TrustLevel.LOW, new TrustLevel[] { TrustLevel.MID, TrustLevel.LOW }, TrustLevel.LOW, new TrustLevel[] { TrustLevel.MID, TrustLevel.HIGH }, null, Permission.NO, new Permission[] { Permission.ASK, Permission.NO });
    ownerAce = new OwnerAccessControlEntry(null, null, null, TrustLevel.MID, TrustLevel.HIGH, null, Permission.ASK);
}
Also used : MasterAccessControlEntry(joynr.infrastructure.DacTypes.MasterAccessControlEntry) TrustLevel(joynr.infrastructure.DacTypes.TrustLevel) OwnerAccessControlEntry(joynr.infrastructure.DacTypes.OwnerAccessControlEntry) Permission(joynr.infrastructure.DacTypes.Permission) Before(org.junit.Before)

Example 14 with Permission

use of joynr.infrastructure.DacTypes.Permission in project joynr by bmwcarit.

the class LocalDomainAccessControllerTest method setup.

@SuppressWarnings("unchecked")
@Before
public void setup() {
    cacheManager = CacheManager.create();
    domainAccessControlStore = new DomainAccessControlStoreEhCache(cacheManager, new DefaultDomainAccessControlProvisioning());
    when(proxyInvocationHandlerFactoryMock.create(any(Set.class), any(String.class), any(String.class), any(DiscoveryQos.class), any(MessagingQos.class))).thenReturn(proxyInvocationHandlerMock);
    GlobalDiscoveryEntry accessControlDomain = mock(GlobalDiscoveryEntry.class);
    when(accessControlDomain.getDomain()).thenReturn("accessControlDomain");
    localDomainAccessController = new LocalDomainAccessControllerImpl(accessControlDomain, domainAccessControlStore, new ProxyBuilderFactoryImpl(localDiscoveryAggregator, proxyInvocationHandlerFactoryMock, MAX_TTL, DISCOVERY_TIMEOUT_MS, RETRY_INTERVAL_MS), "systemServiceDomain");
    // 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 : Set(java.util.Set) ProxyBuilderFactoryImpl(io.joynr.proxy.ProxyBuilderFactoryImpl) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) DomainRoleEntry(joynr.infrastructure.DacTypes.DomainRoleEntry) DiscoveryQos(io.joynr.arbitration.DiscoveryQos) MessagingQos(io.joynr.messaging.MessagingQos) MasterAccessControlEntry(joynr.infrastructure.DacTypes.MasterAccessControlEntry) TrustLevel(joynr.infrastructure.DacTypes.TrustLevel) OwnerAccessControlEntry(joynr.infrastructure.DacTypes.OwnerAccessControlEntry) Permission(joynr.infrastructure.DacTypes.Permission) Before(org.junit.Before)

Example 15 with Permission

use of joynr.infrastructure.DacTypes.Permission in project joynr by bmwcarit.

the class AccessControlAlgorithmTest method testPermissionWithMasterAndInvalidMediatorAce.

@Test
public void testPermissionWithMasterAndInvalidMediatorAce() {
    masterAce.setPossibleConsumerPermissions(new Permission[] { Permission.NO });
    mediatorAce.setPossibleConsumerPermissions(new Permission[] { Permission.ASK, Permission.YES });
    mediatorAce.setDefaultConsumerPermission(Permission.YES);
    mediatorAce.setDefaultRequiredTrustLevel(TrustLevel.MID);
    Permission consumerPermission = accessControlAlgorithm.getConsumerPermission(masterAce, mediatorAce, null, TrustLevel.HIGH);
    Assert.assertEquals(Permission.NO, consumerPermission);
}
Also used : Permission(joynr.infrastructure.DacTypes.Permission) Test(org.junit.Test)

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