use of org.pentaho.platform.api.repository2.unified.RepositoryFileAcl in project pentaho-platform by pentaho.
the class JcrAclNodeHelperIT method administratorRoleIsAdded.
@Test
public void administratorRoleIsAdded() {
makeDsPrivate();
loginAsSuzy();
helper.resetAclNodeCallCounter();
RepositoryFileAcl aclReturned = helper.getAclFor(targetFile);
// This tests that getAclFor doesn't make redundant calls to getAclNode - BISERVER-12780
assertEquals(1, helper.getAclNodeCallCounter());
boolean adminPresent = false;
for (RepositoryFileAce ace : aclReturned.getAces()) {
if (ace.getSid().getName() == tenantAdminRoleName) {
adminPresent = true;
break;
}
}
assertFalse(adminPresent);
loginAsRepositoryAdmin();
aclReturned = helper.getAclFor(targetFile);
adminPresent = false;
for (RepositoryFileAce ace : aclReturned.getAces()) {
if (ace.getSid().getName() == tenantAdminRoleName) {
adminPresent = true;
break;
}
}
assertTrue(adminPresent);
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFileAcl in project pentaho-platform by pentaho.
the class JcrAclNodeHelperIT method aclIsReplaced.
@Test
public void aclIsReplaced() throws InterruptedException {
loginAsRepositoryAdmin();
RepositoryFileAcl acl = createAclFor(USERNAME_TIFFANY);
helper.setAclFor(targetFile, acl);
loginAsTiffany();
assertTrue(helper.canAccess(targetFile, EnumSet.of(RepositoryFilePermission.READ)));
loginAsSuzy();
assertFalse(helper.canAccess(targetFile, EnumSet.of(RepositoryFilePermission.READ)));
loginAsRepositoryAdmin();
acl = createAclFor(USERNAME_SUZY);
helper.setAclFor(targetFile, acl);
loginAsSuzy();
// This is failing most of the time in this integration test. ACL is set properly yet Suzy can still see ACL node.
// If execution is paused long enough, it does work properly.
assertTrue(helper.canAccess(targetFile, EnumSet.of(RepositoryFilePermission.READ)));
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFileAcl in project pentaho-platform by pentaho.
the class AccessVoterToLegacyAcl method convert.
private LegacyRepositoryFile convert(RepositoryFile file, RepositoryFileAcl acl) {
LegacyRepositoryFile legacy = new LegacyRepositoryFile(file.getName(), file.getPath(), file.isFolder());
legacy.setId(file.getId());
if (file.getLastModifiedDate() != null) {
legacy.setLastModified(file.getLastModifiedDate().getTime());
}
List<IPentahoAclEntry> legacyAcls = new ArrayList<IPentahoAclEntry>();
for (RepositoryFileAce fileAce : acl.getAces()) {
if (fileAce != null && fileAce.getSid() != null && fileAce.getPermissions() != null) {
for (RepositoryFilePermission filePermission : fileAce.getPermissions()) {
PentahoAclEntry fileAcl = new PentahoAclEntry();
if (RepositoryFileSid.Type.USER == fileAce.getSid().getType()) {
// user
fileAcl.setRecipient(fileAce.getSid().getName());
} else {
// role
fileAcl.setRecipient(new SimpleGrantedAuthority(fileAce.getSid().getName()));
}
fileAcl.setMask(mask(filePermission));
legacyAcls.add(fileAcl);
}
}
}
legacy.setAccessControls(legacyAcls);
return legacy;
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFileAcl in project data-access by pentaho.
the class DataSourceWizardServiceTest method testSetMetadataDatasourceAcl.
@Test
public void testSetMetadataDatasourceAcl() throws Exception {
String domainId = DOMAIN_ID;
String domainIdWithoutExt = "domainId";
final RepositoryFileAclDto aclDto = new RepositoryFileAclDto();
aclDto.setOwner("owner");
aclDto.setOwnerType(RepositoryFileSid.Type.USER.ordinal());
doReturn(true).when(dataSourceWizardService).canManageACL();
doReturn(new HashMap<String, InputStream>()).when(dataSourceWizardService).doGetDSWFilesAsDownload(domainId);
dataSourceWizardService.setDSWAcl(domainId, aclDto);
final RepositoryFileAcl acl = new RepositoryFileAclAdapter().unmarshal(aclDto);
verify(dataSourceWizardService.aclAwarePentahoMetadataDomainRepositoryImporter).setAclFor(eq(domainId), eq(acl));
verify(dataSourceWizardService.aclAwareMondrianCatalogService).setAclFor(eq(domainIdWithoutExt), eq(acl));
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFileAcl in project data-access by pentaho.
the class AnalysisService method setAnalysisDatasourceAcl.
public void setAnalysisDatasourceAcl(String analysisId, RepositoryFileAclDto aclDto) throws PentahoAccessControlException, FileNotFoundException {
checkAnalysisExists(analysisId);
final RepositoryFileAcl acl = aclDto == null ? null : repositoryFileAclAdapter.unmarshal(aclDto);
if (aclAwareMondrianCatalogService != null) {
aclAwareMondrianCatalogService.setAclFor(analysisId, acl);
}
flushDataSources();
}
Aggregations