Search in sources :

Example 11 with MasterAccessControlEntry

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

the class MasterAccessControlEntryManagerTest method testFindByUserIdAndIsEditable.

@Test
public void testFindByUserIdAndIsEditable() {
    String userId = "user";
    create(userId, "domain1", "interface1", TrustLevel.HIGH, new TrustLevel[] {}, TrustLevel.LOW, new TrustLevel[] {}, "operation1", Permission.YES, new Permission[] {});
    create(userId, "domain2", "interface2", TrustLevel.HIGH, new TrustLevel[] {}, TrustLevel.LOW, new TrustLevel[] {}, "operation2", Permission.YES, new Permission[] {});
    DomainRoleEntryEntity role1 = new DomainRoleEntryEntity();
    role1.setUserId(userId);
    role1.setRole(Role.MASTER);
    role1.setDomains(Sets.newHashSet("domain1", "domain4", "domain5"));
    entityManager.persist(role1);
    flushAndClear();
    MasterAccessControlEntry[] result = subject.findByUserIdThatAreEditable(userId, MASTER);
    assertNotNull(result);
    assertEquals(1, result.length);
    assertEquals("domain1", result[0].getDomain());
    assertEquals("interface1", result[0].getInterfaceName());
}
Also used : DomainRoleEntryEntity(io.joynr.accesscontrol.global.jee.persistence.DomainRoleEntryEntity) MasterAccessControlEntry(joynr.infrastructure.DacTypes.MasterAccessControlEntry) Test(org.junit.Test)

Example 12 with MasterAccessControlEntry

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

the class GlobalDomainAccessControlListEditorProviderImpl method removeMasterAccessControlEntry.

@Override
public Promise<RemoveMasterAccessControlEntryDeferred> removeMasterAccessControlEntry(String uid, String domain, String interfaceName, String operation) {
    RemoveMasterAccessControlEntryDeferred deferred = new RemoveMasterAccessControlEntryDeferred();
    boolean removeSuccess = domainAccessStore.removeMasterAccessControlEntry(uid, domain, interfaceName, operation);
    if (removeSuccess) {
        MasterAccessControlEntry removedEntry = new MasterAccessControlEntry(uid, domain, interfaceName, null, null, null, null, operation, null, null);
        domainAccessControllerProvider.fireMasterAccessControlEntryChanged(ChangeType.REMOVE, removedEntry);
    }
    deferred.resolve(removeSuccess);
    return new Promise<RemoveMasterAccessControlEntryDeferred>(deferred);
}
Also used : Promise(io.joynr.provider.Promise) MasterAccessControlEntry(joynr.infrastructure.DacTypes.MasterAccessControlEntry)

Example 13 with MasterAccessControlEntry

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

the class DomainAccessControlStoreEhCache method updateOwnerAccessControlEntry.

@Override
public Boolean updateOwnerAccessControlEntry(OwnerAccessControlEntry updatedOwnerAce) {
    boolean updateSuccess = false;
    MasterAccessControlEntry masterAce = getMasterAccessControlEntry(updatedOwnerAce.getUid(), updatedOwnerAce.getDomain(), updatedOwnerAce.getInterfaceName(), updatedOwnerAce.getOperation());
    MasterAccessControlEntry mediatorAce = getMediatorAccessControlEntry(updatedOwnerAce.getUid(), updatedOwnerAce.getDomain(), updatedOwnerAce.getInterfaceName(), updatedOwnerAce.getOperation());
    AceValidator aceValidator = new AceValidator(masterAce, mediatorAce, updatedOwnerAce);
    if (aceValidator.isOwnerValid()) {
        UserDomainInterfaceOperationKey aceKey = new UserDomainInterfaceOperationKey(updatedOwnerAce.getUid(), updatedOwnerAce.getDomain(), updatedOwnerAce.getInterfaceName(), updatedOwnerAce.getOperation());
        updateSuccess = updateAce(updatedOwnerAce, CacheId.OWNER_ACL, aceKey);
    }
    return updateSuccess;
}
Also used : MasterAccessControlEntry(joynr.infrastructure.DacTypes.MasterAccessControlEntry) UserDomainInterfaceOperationKey(io.joynr.accesscontrol.primarykey.UserDomainInterfaceOperationKey)

Example 14 with MasterAccessControlEntry

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

the class DomainAccessControlStoreEhCache method updateMediatorAccessControlEntry.

@Override
public Boolean updateMediatorAccessControlEntry(MasterAccessControlEntry updatedMediatorAce) {
    boolean updateSuccess = false;
    MasterAccessControlEntry masterAce = getMasterAccessControlEntry(updatedMediatorAce.getUid(), updatedMediatorAce.getDomain(), updatedMediatorAce.getInterfaceName(), updatedMediatorAce.getOperation());
    AceValidator aceValidator = new AceValidator(masterAce, updatedMediatorAce, null);
    if (aceValidator.isMediatorValid()) {
        UserDomainInterfaceOperationKey aceKey = new UserDomainInterfaceOperationKey(updatedMediatorAce.getUid(), updatedMediatorAce.getDomain(), updatedMediatorAce.getInterfaceName(), updatedMediatorAce.getOperation());
        updateSuccess = updateAce(updatedMediatorAce, CacheId.MASTER_ACL, aceKey);
    }
    return updateSuccess;
}
Also used : MasterAccessControlEntry(joynr.infrastructure.DacTypes.MasterAccessControlEntry) UserDomainInterfaceOperationKey(io.joynr.accesscontrol.primarykey.UserDomainInterfaceOperationKey)

Example 15 with MasterAccessControlEntry

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

the class DomainAccessControlStoreTest method testGetMasterAce.

@Test
public void testGetMasterAce() throws Exception {
    store.updateMasterAccessControlEntry(expectedMasterAccessControlEntry);
    assertEquals("Master ACE associated to UID1 from Master ACL should be the same as expectedMasterAccessControlEntry", expectedMasterAccessControlEntry, store.getMasterAccessControlEntries(UID1).get(0));
    assertEquals("Master ACE associated to DOMAIN1 and INTERFACE1 should be the same as expectedMasterAccessControlEntry", expectedMasterAccessControlEntry, store.getMasterAccessControlEntries(DOMAIN1, INTERFACE1).get(0));
    assertEquals("Master ACE associated to UID1, DOMAIN1 and INTERFACE1 should be the same as expectedMasterAccessControlEntry", expectedMasterAccessControlEntry, store.getMasterAccessControlEntries(UID1, DOMAIN1, INTERFACE1).get(0));
    MasterAccessControlEntry masterAceWithWildcardOperation = new MasterAccessControlEntry(expectedMasterAccessControlEntry);
    masterAceWithWildcardOperation.setOperation(WILDCARD);
    store.updateMasterAccessControlEntry(masterAceWithWildcardOperation);
    int expectedAceCount = 2;
    assertEquals("There are two (2) master ACEs associated to UID1, DOMAIN1 and INTERFACE1", expectedAceCount, store.getMasterAccessControlEntries(UID1, DOMAIN1, INTERFACE1).size());
    MasterAccessControlEntry returnedMasterAce = store.getMasterAccessControlEntry(UID1, DOMAIN1, INTERFACE1, OPERATION1);
    assertEquals("Master ACE associated to UID1, DOMAIN1, INTERFACE1 and OPERATION1 should be the same as expectedMasterAccessControlEntry", expectedMasterAccessControlEntry, returnedMasterAce);
}
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