Search in sources :

Example 61 with RepositoryFileAcl

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);
}
Also used : RepositoryFileAce(org.pentaho.platform.api.repository2.unified.RepositoryFileAce) RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl) Test(org.junit.Test)

Example 62 with RepositoryFileAcl

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)));
}
Also used : RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl) Test(org.junit.Test)

Example 63 with RepositoryFileAcl

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;
}
Also used : SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) RepositoryFileAce(org.pentaho.platform.api.repository2.unified.RepositoryFileAce) ArrayList(java.util.ArrayList) RepositoryFilePermission(org.pentaho.platform.api.repository2.unified.RepositoryFilePermission) IPentahoAclEntry(org.pentaho.platform.api.engine.IPentahoAclEntry) PentahoAclEntry(org.pentaho.platform.engine.security.acls.PentahoAclEntry) IPentahoAclEntry(org.pentaho.platform.api.engine.IPentahoAclEntry)

Example 64 with RepositoryFileAcl

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));
}
Also used : InputStream(java.io.InputStream) RepositoryFileAclDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto) Matchers.anyString(org.mockito.Matchers.anyString) RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl) RepositoryFileAclAdapter(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclAdapter) Test(org.junit.Test)

Example 65 with RepositoryFileAcl

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();
}
Also used : RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl)

Aggregations

RepositoryFileAcl (org.pentaho.platform.api.repository2.unified.RepositoryFileAcl)99 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)73 Test (org.junit.Test)50 ITenant (org.pentaho.platform.api.mt.ITenant)25 RepositoryFileSid (org.pentaho.platform.api.repository2.unified.RepositoryFileSid)23 RepositoryFileAce (org.pentaho.platform.api.repository2.unified.RepositoryFileAce)15 Node (javax.jcr.Node)13 Matchers.anyString (org.mockito.Matchers.anyString)13 UnifiedRepositoryException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryException)13 Serializable (java.io.Serializable)12 Session (javax.jcr.Session)12 JcrCallback (org.springframework.extensions.jcr.JcrCallback)12 ArrayList (java.util.ArrayList)11 RepositoryException (javax.jcr.RepositoryException)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 IOException (java.io.IOException)9 DataNode (org.pentaho.platform.api.repository2.unified.data.node.DataNode)9 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)8 RepositoryFilePermission (org.pentaho.platform.api.repository2.unified.RepositoryFilePermission)8 InputStream (java.io.InputStream)7