use of joynr.infrastructure.DacTypes.OwnerAccessControlEntry 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.OwnerAccessControlEntry in project joynr by bmwcarit.
the class OwnerAccessControlEntryManagerTest method testCreate.
@Test
public void testCreate() {
String userId = "user";
String domain = "domain";
String interfaceName = "interfaceName";
String operation = "operation";
OwnerAccessControlEntry data = new OwnerAccessControlEntry(userId, domain, interfaceName, TrustLevel.HIGH, TrustLevel.LOW, operation, Permission.ASK);
CreateOrUpdateResult<OwnerAccessControlEntry> result = subject.createOrUpdate(data);
assertNotNull(result);
assertEquals(ChangeType.ADD, result.getChangeType());
assertNotNull(result.getEntry());
assertEquals(userId, result.getEntry().getUid());
flushAndClear();
OwnerAccessControlEntry persisted = subject.findByUserId(userId)[0];
assertEquals(userId, persisted.getUid());
assertEquals(domain, persisted.getDomain());
assertEquals(interfaceName, persisted.getInterfaceName());
assertEquals(operation, persisted.getOperation());
assertEquals(TrustLevel.HIGH, persisted.getRequiredTrustLevel());
assertEquals(TrustLevel.LOW, persisted.getRequiredAceChangeTrustLevel());
assertEquals(Permission.ASK, persisted.getConsumerPermission());
}
use of joynr.infrastructure.DacTypes.OwnerAccessControlEntry in project joynr by bmwcarit.
the class OwnerAccessControlEntryManagerTest method testFindByUserIdAndAreEditable.
@Test
public void testFindByUserIdAndAreEditable() {
String userId = "user1";
String domain = "domain1";
String interfaceName = "interfaceName1";
String operation = "operation1";
create(userId, domain, interfaceName, TrustLevel.HIGH, TrustLevel.HIGH, operation, Permission.ASK);
create(userId, "otherdomain", "interfaceName", TrustLevel.LOW, TrustLevel.HIGH, "operation2", Permission.NO);
DomainRoleEntryEntity domainRoleEntryEntity = new DomainRoleEntryEntity();
domainRoleEntryEntity.setUserId(userId);
domainRoleEntryEntity.setRole(Role.OWNER);
domainRoleEntryEntity.setDomains(Sets.newHashSet(domain));
entityManager.persist(domainRoleEntryEntity);
flushAndClear();
OwnerAccessControlEntry[] result = subject.findByUserIdThatAreEditable(userId);
assertNotNull(result);
assertEquals(1, result.length);
assertEquals(interfaceName, result[0].getInterfaceName());
assertEquals(operation, result[0].getOperation());
}
use of joynr.infrastructure.DacTypes.OwnerAccessControlEntry in project joynr by bmwcarit.
the class OwnerAccessControlEntryManagerTest method testCreateNotAllowedWithoutOwnerRole.
@Test
public void testCreateNotAllowedWithoutOwnerRole() {
String userId = "user";
String domain = "domain";
String interfaceName = "interfaceName";
String operation = "operation";
DomainRoleEntryEntity domainRoleEntryEntity = new DomainRoleEntryEntity();
domainRoleEntryEntity.setUserId(userId);
domainRoleEntryEntity.setRole(Role.MASTER);
domainRoleEntryEntity.setDomains(Sets.newHashSet(domain));
entityManager.persist(domainRoleEntryEntity);
flushAndClear();
OwnerAccessControlEntry data = new OwnerAccessControlEntry(userId, domain, interfaceName, TrustLevel.HIGH, TrustLevel.LOW, operation, Permission.ASK);
CreateOrUpdateResult<OwnerAccessControlEntry> result = null;
JoynrJeeMessageContext.getInstance().activate();
try {
joynrCallingPrincipal.setUsername(userId);
result = subject.createOrUpdate(data);
} finally {
JoynrJeeMessageContext.getInstance().deactivate();
}
assertNull(result);
flushAndClear();
assertEquals(0, subject.findByUserId(userId).length);
}
use of joynr.infrastructure.DacTypes.OwnerAccessControlEntry in project joynr by bmwcarit.
the class GlobalDomainAccessControlListEditorProviderImpl method removeOwnerAccessControlEntry.
@Override
public Promise<RemoveOwnerAccessControlEntryDeferred> removeOwnerAccessControlEntry(String uid, String domain, String interfaceName, String operation) {
RemoveOwnerAccessControlEntryDeferred deferred = new RemoveOwnerAccessControlEntryDeferred();
boolean removeSuccess = domainAccessStore.removeOwnerAccessControlEntry(uid, domain, interfaceName, operation);
if (removeSuccess) {
OwnerAccessControlEntry removedEntry = new OwnerAccessControlEntry(uid, domain, interfaceName, null, null, operation, null);
domainAccessControllerProvider.fireOwnerAccessControlEntryChanged(ChangeType.REMOVE, removedEntry);
}
deferred.resolve(removeSuccess);
return new Promise<RemoveOwnerAccessControlEntryDeferred>(deferred);
}
Aggregations