Search in sources :

Example 6 with RepositoryObjectRecipient

use of org.pentaho.di.repository.pur.model.RepositoryObjectRecipient in project pentaho-kettle by pentaho.

the class RepositoryTestBase method testSetAcl.

@Test
@Ignore
public void testSetAcl() throws Exception {
    RepositoryDirectoryInterface rootDir = initRepo();
    JobMeta jobMeta = createJobMeta(EXP_JOB_NAME);
    RepositoryDirectoryInterface jobsDir = rootDir.findDirectory(DIR_JOBS);
    repository.save(jobMeta, VERSION_COMMENT_V1, null);
    deleteStack.push(jobMeta);
    assertNotNull(jobMeta.getObjectId());
    ObjectRevision version = jobMeta.getObjectRevision();
    assertNotNull(version);
    assertTrue(hasVersionWithComment(jobMeta, VERSION_COMMENT_V1));
    assertTrue(repository.exists(EXP_JOB_NAME, jobsDir, RepositoryObjectType.JOB));
    ObjectAcl acl = ((IAclService) repository).getAcl(jobMeta.getObjectId(), false);
    assertNotNull(acl);
    acl.setEntriesInheriting(false);
    ObjectAce ace = new RepositoryObjectAce(new RepositoryObjectRecipient("suzy", Type.USER), EnumSet.of(RepositoryFilePermission.READ));
    List<ObjectAce> aceList = new ArrayList<ObjectAce>();
    aceList.add(ace);
    acl.setAces(aceList);
    ((IAclService) repository).setAcl(jobMeta.getObjectId(), acl);
    ObjectAcl acl1 = ((IAclService) repository).getAcl(jobMeta.getObjectId(), false);
    assertEquals(Boolean.FALSE, acl1.isEntriesInheriting());
    assertEquals(1, acl1.getAces().size());
    ObjectAce ace1 = acl1.getAces().get(0);
    assertEquals(ace1.getRecipient().getName(), "suzy");
    assertTrue(ace1.getPermissions().contains(RepositoryFilePermission.READ));
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) ObjectAcl(org.pentaho.di.repository.pur.model.ObjectAcl) RepositoryObjectRecipient(org.pentaho.di.repository.pur.model.RepositoryObjectRecipient) ArrayList(java.util.ArrayList) IAclService(org.pentaho.di.ui.repository.pur.services.IAclService) ObjectAce(org.pentaho.di.repository.pur.model.ObjectAce) RepositoryObjectAce(org.pentaho.di.repository.pur.model.RepositoryObjectAce) RepositoryObjectAce(org.pentaho.di.repository.pur.model.RepositoryObjectAce) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with RepositoryObjectRecipient

use of org.pentaho.di.repository.pur.model.RepositoryObjectRecipient in project pentaho-kettle by pentaho.

the class UnifiedRepositoryConnectionAclService method getAcl.

@Override
public ObjectAcl getAcl(ObjectId fileId, boolean forceParentInheriting) throws KettleException {
    RepositoryFileAcl acl = null;
    try {
        acl = pur.getAcl(fileId.getId());
    } catch (Exception drfe) {
        // The user does not have rights to view the acl information.
        throw new KettleException(drfe);
    }
    RepositoryFileSid sid = acl.getOwner();
    ObjectRecipient owner = new RepositoryObjectRecipient(sid.getName());
    if (sid.getType().equals(RepositoryFileSid.Type.USER)) {
        owner.setType(Type.USER);
    } else {
        owner.setType(Type.ROLE);
    }
    ObjectAcl objectAcl = new RepositoryObjectAcl(owner);
    List<RepositoryFileAce> aces;
    if (forceParentInheriting) {
        objectAcl.setEntriesInheriting(true);
        aces = pur.getEffectiveAces(acl.getId(), true);
    } else {
        objectAcl.setEntriesInheriting(acl.isEntriesInheriting());
        aces = (acl.isEntriesInheriting()) ? pur.getEffectiveAces(acl.getId()) : acl.getAces();
    }
    List<ObjectAce> objectAces = new ArrayList<ObjectAce>();
    for (RepositoryFileAce ace : aces) {
        EnumSet<RepositoryFilePermission> permissions = ace.getPermissions();
        EnumSet<RepositoryFilePermission> permissionSet = EnumSet.noneOf(RepositoryFilePermission.class);
        RepositoryFileSid aceSid = ace.getSid();
        ObjectRecipient recipient = new RepositoryObjectRecipient(aceSid.getName());
        if (aceSid.getType().equals(RepositoryFileSid.Type.USER)) {
            recipient.setType(Type.USER);
        } else {
            recipient.setType(Type.ROLE);
        }
        permissionSet.addAll(permissions);
        objectAces.add(new RepositoryObjectAce(recipient, permissionSet));
    }
    objectAcl.setAces(objectAces);
    return objectAcl;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObjectAcl(org.pentaho.di.repository.pur.model.RepositoryObjectAcl) ObjectAcl(org.pentaho.di.repository.pur.model.ObjectAcl) RepositoryFileAce(org.pentaho.platform.api.repository2.unified.RepositoryFileAce) ObjectRecipient(org.pentaho.di.repository.ObjectRecipient) RepositoryObjectRecipient(org.pentaho.di.repository.pur.model.RepositoryObjectRecipient) ArrayList(java.util.ArrayList) ObjectAce(org.pentaho.di.repository.pur.model.ObjectAce) RepositoryObjectAce(org.pentaho.di.repository.pur.model.RepositoryObjectAce) RepositoryObjectAce(org.pentaho.di.repository.pur.model.RepositoryObjectAce) KettleException(org.pentaho.di.core.exception.KettleException) RepositoryFileSid(org.pentaho.platform.api.repository2.unified.RepositoryFileSid) RepositoryObjectAcl(org.pentaho.di.repository.pur.model.RepositoryObjectAcl) RepositoryObjectRecipient(org.pentaho.di.repository.pur.model.RepositoryObjectRecipient) RepositoryFilePermission(org.pentaho.platform.api.repository2.unified.RepositoryFilePermission) RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl)

Example 8 with RepositoryObjectRecipient

use of org.pentaho.di.repository.pur.model.RepositoryObjectRecipient in project pentaho-kettle by pentaho.

the class UIRepositoryObjectAclModelTest method createUserAce.

private ObjectAce createUserAce(String recipientName) {
    ObjectRecipient objectRecipient = new RepositoryObjectRecipient(recipientName, ObjectRecipient.Type.USER);
    ObjectAce objectAce = new RepositoryObjectAce(objectRecipient, EnumSet.of(RepositoryFilePermission.READ, RepositoryFilePermission.WRITE));
    return objectAce;
}
Also used : ObjectRecipient(org.pentaho.di.repository.ObjectRecipient) RepositoryObjectRecipient(org.pentaho.di.repository.pur.model.RepositoryObjectRecipient) RepositoryObjectRecipient(org.pentaho.di.repository.pur.model.RepositoryObjectRecipient) ObjectAce(org.pentaho.di.repository.pur.model.ObjectAce) RepositoryObjectAce(org.pentaho.di.repository.pur.model.RepositoryObjectAce) RepositoryObjectAce(org.pentaho.di.repository.pur.model.RepositoryObjectAce)

Example 9 with RepositoryObjectRecipient

use of org.pentaho.di.repository.pur.model.RepositoryObjectRecipient in project pentaho-kettle by pentaho.

the class UIRepositoryObjectAclTest method testEquals.

@Test
public void testEquals() {
    UIRepositoryObjectAcl uiAcl1 = new UIRepositoryObjectAcl(createObjectAce());
    UIRepositoryObjectAcl uiAcl2 = new UIRepositoryObjectAcl(new RepositoryObjectAce(new RepositoryObjectRecipient(RECIPIENT1, ObjectRecipient.Type.USER), EnumSet.of(RepositoryFilePermission.ALL)));
    assertTrue(uiAcl1.equals(uiAcl2));
    uiAcl2 = new UIRepositoryObjectAcl(new RepositoryObjectAce(new RepositoryObjectRecipient(RECIPIENT1, ObjectRecipient.Type.SYSTEM_ROLE), EnumSet.of(RepositoryFilePermission.ALL)));
    assertFalse(uiAcl1.equals(uiAcl2));
    uiAcl2 = new UIRepositoryObjectAcl(new RepositoryObjectAce(new RepositoryObjectRecipient(RECIPIENT1, ObjectRecipient.Type.USER), EnumSet.of(RepositoryFilePermission.READ, RepositoryFilePermission.ALL)));
    assertFalse(uiAcl1.equals(uiAcl2));
    uiAcl2 = new UIRepositoryObjectAcl(new RepositoryObjectAce(new RepositoryObjectRecipient(RECIPIENT2, ObjectRecipient.Type.USER), EnumSet.of(RepositoryFilePermission.ALL)));
    assertFalse(uiAcl1.equals(uiAcl2));
    assertFalse(uiAcl1.equals(null));
}
Also used : RepositoryObjectRecipient(org.pentaho.di.repository.pur.model.RepositoryObjectRecipient) RepositoryObjectAce(org.pentaho.di.repository.pur.model.RepositoryObjectAce) Test(org.junit.Test)

Example 10 with RepositoryObjectRecipient

use of org.pentaho.di.repository.pur.model.RepositoryObjectRecipient in project pentaho-kettle by pentaho.

the class UIRepositoryObjectAclTest method createObjectAce.

private ObjectAce createObjectAce() {
    ObjectRecipient objectRecipient = new RepositoryObjectRecipient(RECIPIENT1, ObjectRecipient.Type.USER);
    ObjectAce objectAce = new RepositoryObjectAce(objectRecipient, EnumSet.of(RepositoryFilePermission.ALL));
    return objectAce;
}
Also used : ObjectRecipient(org.pentaho.di.repository.ObjectRecipient) RepositoryObjectRecipient(org.pentaho.di.repository.pur.model.RepositoryObjectRecipient) RepositoryObjectRecipient(org.pentaho.di.repository.pur.model.RepositoryObjectRecipient) ObjectAce(org.pentaho.di.repository.pur.model.ObjectAce) RepositoryObjectAce(org.pentaho.di.repository.pur.model.RepositoryObjectAce) RepositoryObjectAce(org.pentaho.di.repository.pur.model.RepositoryObjectAce)

Aggregations

RepositoryObjectRecipient (org.pentaho.di.repository.pur.model.RepositoryObjectRecipient)13 ObjectRecipient (org.pentaho.di.repository.ObjectRecipient)8 RepositoryObjectAce (org.pentaho.di.repository.pur.model.RepositoryObjectAce)7 RepositoryObjectAcl (org.pentaho.di.repository.pur.model.RepositoryObjectAcl)7 Test (org.junit.Test)6 ObjectAce (org.pentaho.di.repository.pur.model.ObjectAce)6 ObjectAcl (org.pentaho.di.repository.pur.model.ObjectAcl)5 KettleException (org.pentaho.di.core.exception.KettleException)4 ObjectId (org.pentaho.di.repository.ObjectId)3 AccessDeniedException (org.pentaho.di.ui.repository.repositoryexplorer.AccessDeniedException)3 ArrayList (java.util.ArrayList)2 Before (org.junit.Before)2 Ignore (org.junit.Ignore)1 JobMeta (org.pentaho.di.job.JobMeta)1 IAclService (org.pentaho.di.ui.repository.pur.services.IAclService)1 RepositoryFileAce (org.pentaho.platform.api.repository2.unified.RepositoryFileAce)1 RepositoryFileAcl (org.pentaho.platform.api.repository2.unified.RepositoryFileAcl)1 RepositoryFilePermission (org.pentaho.platform.api.repository2.unified.RepositoryFilePermission)1 RepositoryFileSid (org.pentaho.platform.api.repository2.unified.RepositoryFileSid)1