Search in sources :

Example 6 with ObjectRecipient

use of org.pentaho.di.repository.ObjectRecipient in project pentaho-kettle by pentaho.

the class UnifiedRepositoryConnectionAclService method setAcl.

@Override
public void setAcl(ObjectId fileId, ObjectAcl objectAcl) throws KettleException {
    try {
        RepositoryFileAcl acl = pur.getAcl(fileId.getId());
        RepositoryFileAcl.Builder newAclBuilder = new RepositoryFileAcl.Builder(acl).entriesInheriting(objectAcl.isEntriesInheriting()).clearAces();
        if (!objectAcl.isEntriesInheriting()) {
            List<ObjectAce> aces = objectAcl.getAces();
            for (ObjectAce objectAce : aces) {
                EnumSet<RepositoryFilePermission> permissions = objectAce.getPermissions();
                EnumSet<RepositoryFilePermission> permissionSet = EnumSet.noneOf(RepositoryFilePermission.class);
                ObjectRecipient recipient = objectAce.getRecipient();
                RepositoryFileSid sid;
                if (recipient.getType().equals(Type.ROLE)) {
                    sid = new RepositoryFileSid(recipient.getName(), RepositoryFileSid.Type.ROLE);
                } else {
                    sid = new RepositoryFileSid(recipient.getName());
                }
                if (permissions != null) {
                    permissionSet.addAll(permissions);
                }
                newAclBuilder.ace(sid, permissionSet);
            }
        }
        pur.updateAcl(newAclBuilder.build());
    } catch (Exception drfe) {
        // The user does not have rights to view or set the acl information.
        throw new KettleException(drfe);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryFileSid(org.pentaho.platform.api.repository2.unified.RepositoryFileSid) ObjectRecipient(org.pentaho.di.repository.ObjectRecipient) RepositoryObjectRecipient(org.pentaho.di.repository.pur.model.RepositoryObjectRecipient) RepositoryFilePermission(org.pentaho.platform.api.repository2.unified.RepositoryFilePermission) ObjectAce(org.pentaho.di.repository.pur.model.ObjectAce) RepositoryObjectAce(org.pentaho.di.repository.pur.model.RepositoryObjectAce) RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl) KettleException(org.pentaho.di.core.exception.KettleException)

Example 7 with ObjectRecipient

use of org.pentaho.di.repository.ObjectRecipient 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 8 with ObjectRecipient

use of org.pentaho.di.repository.ObjectRecipient 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)

Example 9 with ObjectRecipient

use of org.pentaho.di.repository.ObjectRecipient in project pentaho-kettle by pentaho.

the class UIRepositoryObjectAclsTest method createObjectAce.

private ObjectAce createObjectAce(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)

Aggregations

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