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