use of org.pentaho.di.repository.pur.model.ObjectAce in project pentaho-kettle by pentaho.
the class UIRepositoryObjectAclModelTest method createRoleAce.
private ObjectAce createRoleAce(String recipientName) {
ObjectRecipient objectRecipient = new RepositoryObjectRecipient(recipientName, ObjectRecipient.Type.ROLE);
ObjectAce objectAce = new RepositoryObjectAce(objectRecipient, EnumSet.of(RepositoryFilePermission.READ, RepositoryFilePermission.WRITE));
return objectAce;
}
use of org.pentaho.di.repository.pur.model.ObjectAce 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));
}
use of org.pentaho.di.repository.pur.model.ObjectAce in project pentaho-kettle by pentaho.
the class UIRepositoryObjectAcls method updateAcl.
public void updateAcl(UIRepositoryObjectAcl aclToUpdate) {
List<ObjectAce> aces = obj.getAces();
for (ObjectAce ace : aces) {
if (ace.getRecipient().getName().equals(aclToUpdate.getRecipientName())) {
ace.setPermissions(aclToUpdate.getPermissionSet());
}
}
UIRepositoryObjectAcl acl = getAcl(aclToUpdate.getRecipientName());
acl.setPermissionSet(aclToUpdate.getPermissionSet());
// $NON-NLS-1$
this.firePropertyChange("acls", null, getAcls());
// above firePropertyChange replaces all elements in the listBox and therefore clears any selected elements;
// however, the selectedAclList field is never updated because no selectedIndices event is ever called; manually
// update it to reflect the selected state of the user/role list now (no selection)
selectedAclList.clear();
// Setting the selected index
List<UIRepositoryObjectAcl> aclList = new ArrayList<UIRepositoryObjectAcl>();
aclList.add(aclToUpdate);
setSelectedAclList(aclList);
setModelDirty(true);
}
use of org.pentaho.di.repository.pur.model.ObjectAce 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;
}
use of org.pentaho.di.repository.pur.model.ObjectAce 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);
}
}
Aggregations