Search in sources :

Example 21 with MasterAccessControlEntry

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

the class ProviderApplication method provisionAccessControl.

private static void provisionAccessControl(Properties properties, String domain) throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    MasterAccessControlEntry newMasterAccessControlEntry = new MasterAccessControlEntry("*", domain, ProviderAnnotations.getInterfaceName(Provider.class), TrustLevel.LOW, new TrustLevel[] { TrustLevel.LOW }, TrustLevel.LOW, new TrustLevel[] { TrustLevel.LOW }, "*", Permission.YES, new Permission[] { Permission.YES });
    MasterAccessControlEntry[] provisionedAccessControlEntries = { newMasterAccessControlEntry };
    String provisionedAccessControlEntriesAsJson = objectMapper.writeValueAsString(provisionedAccessControlEntries);
    properties.setProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES, provisionedAccessControlEntriesAsJson);
}
Also used : MasterAccessControlEntry(joynr.infrastructure.DacTypes.MasterAccessControlEntry) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 22 with MasterAccessControlEntry

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

the class JoynrEnd2EndTest method provisionPermissiveAccessControlEntry.

protected static void provisionPermissiveAccessControlEntry(String domain, String interfaceName) throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    List<MasterAccessControlEntry> provisionedAccessControlEntries = new ArrayList<MasterAccessControlEntry>();
    String existingAccessControlEntriesJson = System.getProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES);
    if (existingAccessControlEntriesJson != null) {
        provisionedAccessControlEntries.addAll(Arrays.asList(objectMapper.readValue(existingAccessControlEntriesJson, MasterAccessControlEntry[].class)));
    }
    MasterAccessControlEntry newMasterAccessControlEntry = new MasterAccessControlEntry("*", domain, interfaceName, TrustLevel.LOW, new TrustLevel[] { TrustLevel.LOW }, TrustLevel.LOW, new TrustLevel[] { TrustLevel.LOW }, "*", Permission.YES, new Permission[] { Permission.YES });
    provisionedAccessControlEntries.add(newMasterAccessControlEntry);
    String provisionedAccessControlEntriesAsJson = objectMapper.writeValueAsString(provisionedAccessControlEntries.toArray());
    System.setProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES, provisionedAccessControlEntriesAsJson);
}
Also used : MasterAccessControlEntry(joynr.infrastructure.DacTypes.MasterAccessControlEntry) ArrayList(java.util.ArrayList) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 23 with MasterAccessControlEntry

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

the class AccessControllerEnd2EndTest method sendProvisionedEntriesToGDAC.

private void sendProvisionedEntriesToGDAC(List<DomainRoleEntry> domainRoleEntries, List<MasterAccessControlEntry> masterAccessControlEntries, List<MasterAccessControlEntry> mediatorAccessControlEntries, List<OwnerAccessControlEntry> ownerAccessControlEntries) {
    DiscoveryQos discoveryQos = new DiscoveryQos();
    discoveryQos.setDiscoveryScope(DiscoveryScope.GLOBAL_ONLY);
    discoveryQos.setArbitrationStrategy(ArbitrationStrategy.HighestPriority);
    discoveryQos.setDiscoveryTimeoutMs(DISCOVERY_TIMEOUT);
    MessagingQos messagingQos = new MessagingQos();
    messagingQos.setTtl_ms(MESSAGING_TTL);
    GlobalDomainAccessControlListEditorProxy gdacListEditorProxy = runtime.getProxyBuilder(GDAC_DOMAIN, GlobalDomainAccessControlListEditorProxy.class).setDiscoveryQos(discoveryQos).setMessagingQos(messagingQos).build();
    GlobalDomainRoleControllerProxy gdrcProxy = runtime.getProxyBuilder(GDAC_DOMAIN, GlobalDomainRoleControllerProxy.class).setDiscoveryQos(discoveryQos).setMessagingQos(messagingQos).build();
    for (DomainRoleEntry entry : domainRoleEntries) {
        assertTrue(gdrcProxy.updateDomainRole(entry));
    }
    for (MasterAccessControlEntry entry : masterAccessControlEntries) {
        assertTrue(gdacListEditorProxy.updateMasterAccessControlEntry(entry));
    }
    for (MasterAccessControlEntry entry : mediatorAccessControlEntries) {
        assertTrue(gdacListEditorProxy.updateMediatorAccessControlEntry(entry));
    }
    for (OwnerAccessControlEntry entry : ownerAccessControlEntries) {
        assertTrue(gdacListEditorProxy.updateOwnerAccessControlEntry(entry));
    }
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) GlobalDomainAccessControlListEditorProxy(joynr.infrastructure.GlobalDomainAccessControlListEditorProxy) MasterAccessControlEntry(joynr.infrastructure.DacTypes.MasterAccessControlEntry) OwnerAccessControlEntry(joynr.infrastructure.DacTypes.OwnerAccessControlEntry) DomainRoleEntry(joynr.infrastructure.DacTypes.DomainRoleEntry) GlobalDomainRoleControllerProxy(joynr.infrastructure.GlobalDomainRoleControllerProxy) DiscoveryQos(io.joynr.arbitration.DiscoveryQos)

Example 24 with MasterAccessControlEntry

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

the class AccessControllerEnd2EndTest method createDefaultGDACEntries.

private void createDefaultGDACEntries(String domainName, String interfaceName, String operationName, String userId, Permission permission) {
    MasterAccessControlEntry testEntry = new MasterAccessControlEntry();
    testEntry.setUid(userId);
    testEntry.setDomain(domainName);
    testEntry.setInterfaceName(interfaceName);
    testEntry.setDefaultConsumerPermission(permission);
    testEntry.setOperation(operationName);
    List<MasterAccessControlEntry> provisionedACEs = new ArrayList<MasterAccessControlEntry>();
    provisionedACEs.add(testEntry);
    DomainRoleEntry domainMasterRoleEntry = new DomainRoleEntry();
    domainMasterRoleEntry.setDomains(new String[] { domainName });
    domainMasterRoleEntry.setRole(Role.MASTER);
    domainMasterRoleEntry.setUid(userId);
    DomainRoleEntry domainOwnerRoleEntry = new DomainRoleEntry();
    domainOwnerRoleEntry.setDomains(new String[] { domainName });
    domainOwnerRoleEntry.setRole(Role.OWNER);
    domainOwnerRoleEntry.setUid(userId);
    List<DomainRoleEntry> domainRoleEntries = new ArrayList<DomainRoleEntry>();
    domainRoleEntries.add(domainMasterRoleEntry);
    domainRoleEntries.add(domainOwnerRoleEntry);
    OwnerAccessControlEntry ownerControlEntry = new OwnerAccessControlEntry();
    ownerControlEntry.setDomain(domainName);
    ownerControlEntry.setInterfaceName(interfaceName);
    ownerControlEntry.setUid(userId);
    ownerControlEntry.setConsumerPermission(Permission.YES);
    List<OwnerAccessControlEntry> ownerEntries = new ArrayList<OwnerAccessControlEntry>();
    ownerEntries.add(ownerControlEntry);
    sendProvisionedEntriesToGDAC(domainRoleEntries, provisionedACEs, provisionedACEs, ownerEntries);
}
Also used : MasterAccessControlEntry(joynr.infrastructure.DacTypes.MasterAccessControlEntry) OwnerAccessControlEntry(joynr.infrastructure.DacTypes.OwnerAccessControlEntry) ArrayList(java.util.ArrayList) DomainRoleEntry(joynr.infrastructure.DacTypes.DomainRoleEntry)

Example 25 with MasterAccessControlEntry

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

the class GlobalDomainAccessControlListEditorBeanTest method testUpdateMediatorAccessControlEntry.

@Test
public void testUpdateMediatorAccessControlEntry() {
    MasterAccessControlEntry mace = new MasterAccessControlEntry(USER_ID, DOMAIN, INTERFACE_NAME, TrustLevel.LOW, new TrustLevel[0], TrustLevel.HIGH, new TrustLevel[0], OPERATION, Permission.ASK, new Permission[0]);
    CreateOrUpdateResult<MasterAccessControlEntry> updateResult = new CreateOrUpdateResult<>(mace, ChangeType.UPDATE);
    when(masterAccessControlEntryManagerMock.createOrUpdate(mace, ControlEntryType.MEDIATOR)).thenReturn(updateResult);
    Boolean result = globalDomainAccessControlListEditorSubject.updateMediatorAccessControlEntry(mace);
    assertEquals(Boolean.TRUE, result);
    verify(masterAccessControlEntryManagerMock).createOrUpdate(mace, ControlEntryType.MEDIATOR);
    verify(globalDomainAccessControllerBeanMock).doFireMediatorAccessControlEntryChanged(ChangeType.UPDATE, mace);
}
Also used : MasterAccessControlEntry(joynr.infrastructure.DacTypes.MasterAccessControlEntry) Test(org.junit.Test)

Aggregations

MasterAccessControlEntry (joynr.infrastructure.DacTypes.MasterAccessControlEntry)41 Test (org.junit.Test)14 OwnerAccessControlEntry (joynr.infrastructure.DacTypes.OwnerAccessControlEntry)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 DomainRoleEntry (joynr.infrastructure.DacTypes.DomainRoleEntry)7 Permission (joynr.infrastructure.DacTypes.Permission)6 TrustLevel (joynr.infrastructure.DacTypes.TrustLevel)6 Before (org.junit.Before)6 MasterAccessControlEntryEntity (io.joynr.accesscontrol.global.jee.persistence.MasterAccessControlEntryEntity)5 ArrayList (java.util.ArrayList)4 Query (javax.persistence.Query)3 DomainRoleEntryEntity (io.joynr.accesscontrol.global.jee.persistence.DomainRoleEntryEntity)2 UserDomainInterfaceOperationKey (io.joynr.accesscontrol.primarykey.UserDomainInterfaceOperationKey)2 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)2 MessagingQos (io.joynr.messaging.MessagingQos)2 Promise (io.joynr.provider.Promise)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 DomainAccessControlStoreEhCache (io.joynr.accesscontrol.DomainAccessControlStoreEhCache)1 ControlEntryType (io.joynr.accesscontrol.global.jee.persistence.ControlEntryType)1 ProxyBuilderFactoryImpl (io.joynr.proxy.ProxyBuilderFactoryImpl)1