Search in sources :

Example 11 with OwnerAccessControlEntry

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);
}
Also used : MasterAccessControlEntry(joynr.infrastructure.DacTypes.MasterAccessControlEntry) OwnerAccessControlEntry(joynr.infrastructure.DacTypes.OwnerAccessControlEntry) ArrayList(java.util.ArrayList) DomainRoleEntry(joynr.infrastructure.DacTypes.DomainRoleEntry)

Example 12 with OwnerAccessControlEntry

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

Example 13 with OwnerAccessControlEntry

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());
}
Also used : DomainRoleEntryEntity(io.joynr.accesscontrol.global.jee.persistence.DomainRoleEntryEntity) OwnerAccessControlEntry(joynr.infrastructure.DacTypes.OwnerAccessControlEntry) Test(org.junit.Test)

Example 14 with OwnerAccessControlEntry

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);
}
Also used : DomainRoleEntryEntity(io.joynr.accesscontrol.global.jee.persistence.DomainRoleEntryEntity) OwnerAccessControlEntry(joynr.infrastructure.DacTypes.OwnerAccessControlEntry) Test(org.junit.Test)

Example 15 with OwnerAccessControlEntry

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);
}
Also used : Promise(io.joynr.provider.Promise) OwnerAccessControlEntry(joynr.infrastructure.DacTypes.OwnerAccessControlEntry)

Aggregations

OwnerAccessControlEntry (joynr.infrastructure.DacTypes.OwnerAccessControlEntry)21 MasterAccessControlEntry (joynr.infrastructure.DacTypes.MasterAccessControlEntry)9 Test (org.junit.Test)9 DomainRoleEntry (joynr.infrastructure.DacTypes.DomainRoleEntry)6 Before (org.junit.Before)5 Permission (joynr.infrastructure.DacTypes.Permission)4 TrustLevel (joynr.infrastructure.DacTypes.TrustLevel)4 OwnerAccessControlEntryEntity (io.joynr.accesscontrol.global.jee.persistence.OwnerAccessControlEntryEntity)3 DomainRoleEntryEntity (io.joynr.accesscontrol.global.jee.persistence.DomainRoleEntryEntity)2 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)2 MessagingQos (io.joynr.messaging.MessagingQos)2 ArrayList (java.util.ArrayList)2 DomainAccessControlStoreEhCache (io.joynr.accesscontrol.DomainAccessControlStoreEhCache)1 Promise (io.joynr.provider.Promise)1 ProxyBuilderFactoryImpl (io.joynr.proxy.ProxyBuilderFactoryImpl)1 Map (java.util.Map)1 Set (java.util.Set)1 GlobalDomainAccessControlListEditorProxy (joynr.infrastructure.GlobalDomainAccessControlListEditorProxy)1 GlobalDomainRoleControllerProxy (joynr.infrastructure.GlobalDomainRoleControllerProxy)1 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)1