Package org.pentaho.platform.api.repository2.unified

Examples of org.pentaho.platform.api.repository2.unified.RepositoryFileAcl$Builder


    RepositoryFile parentFolder =
        repo.getFile( ClientRepositoryPaths.getUserHomeFolderPath( PentahoSessionHolder.getSession().getName() ) );
    RepositoryFile newFolder = new RepositoryFile.Builder( "test" ).folder( true ).versioned( true ).build();
    newFolder = repo.createFolder( parentFolder.getId(), newFolder, null );

    RepositoryFileAcl acl = repo.getAcl( newFolder.getId() );
    assertEquals( true, acl.isEntriesInheriting() );
    assertEquals( new RepositoryFileSid( USERNAME_SUZY ), acl.getOwner() );
    assertEquals( newFolder.getId(), acl.getId() );
    assertTrue( acl.getAces().isEmpty() );
    RepositoryFileAcl newAcl =
        new RepositoryFileAcl.Builder( acl ).ace( userNameUtils.getPrincipleId( tenantAcme, USERNAME_TIFFANY ),
            RepositoryFileSid.Type.USER, RepositoryFilePermission.READ ).entriesInheriting( true ).build();
    RepositoryFileAcl fetchedAcl = repo.updateAcl( newAcl );
    // since isEntriesInheriting is true, ace addition should not have taken
    assertTrue( fetchedAcl.getAces().isEmpty() );
    newAcl =
        new RepositoryFileAcl.Builder( acl ).ace( userNameUtils.getPrincipleId( tenantAcme, USERNAME_TIFFANY ),
            RepositoryFileSid.Type.USER, RepositoryFilePermission.READ ).build(); // calling ace sets
    // entriesInheriting to false
    fetchedAcl = repo.updateAcl( newAcl );
    // since isEntriesInheriting is false, ace addition should have taken
    assertFalse( fetchedAcl.getAces().isEmpty() );
  }
View Full Code Here


    RepositoryFile parentFolder =
        repo.getFile( ClientRepositoryPaths.getUserHomeFolderPath( PentahoSessionHolder.getSession().getName() ) );
    RepositoryFile newFolder = new RepositoryFile.Builder( "test" ).folder( true ).versioned( true ).build();
    newFolder = repo.createFolder( parentFolder.getId(), newFolder, null );
    RepositoryFileAcl acl = repo.getAcl( newFolder.getId() );
    RepositoryFileAcl newAcl =
        new RepositoryFileAcl.Builder( acl ).entriesInheriting( false ).ace(
            new RepositoryFileSid( userNameUtils.getPrincipleId( tenantAcme, USERNAME_SUZY ) ),
            RepositoryFilePermission.ALL ).build();
    repo.updateAcl( newAcl );
    RepositoryFileAcl fetchedAcl = repo.getAcl( newFolder.getId() );
    assertEquals( 1, fetchedAcl.getAces().size() );
  }
View Full Code Here

    List<RepositoryFileAce> expectedEffectiveAces1 = repo.getEffectiveAces( acmePublicFolder.getId() );
    RepositoryFile newFolder = new RepositoryFile.Builder( "test" ).folder( true ).versioned( true ).build();
    newFolder = repo.createFolder( acmePublicFolder.getId(), newFolder, null );
    assertEquals( expectedEffectiveAces1, repo.getEffectiveAces( newFolder.getId() ) );

    RepositoryFileAcl acl = repo.getAcl( newFolder.getId() );
    RepositoryFileAcl newAcl =
        new RepositoryFileAcl.Builder( acl ).entriesInheriting( false ).ace(
            new RepositoryFileSid( userNameUtils.getPrincipleId( tenantAcme, USERNAME_SUZY ) ),
            RepositoryFilePermission.ALL ).ace(
            new RepositoryFileSid( userNameUtils.getPrincipleId( tenantAcme, USERNAME_TIFFANY ) ),
            RepositoryFilePermission.READ ).build();
View Full Code Here

    RepositoryFile parentFolder =
        repo.getFile( ClientRepositoryPaths.getUserHomeFolderPath( PentahoSessionHolder.getSession().getName() ) );
    RepositoryFile newFolder = new RepositoryFile.Builder( "test" ).folder( true ).versioned( true ).build();
    newFolder = repo.createFolder( parentFolder.getId(), newFolder, null );
    RepositoryFileAcl acl = repo.getAcl( newFolder.getId() );

    RepositoryFileAcl.Builder newAclBuilder = new RepositoryFileAcl.Builder( acl );
    RepositoryFileSid tiffanySid = new RepositoryFileSid(
        userNameUtils.getPrincipleId( tenantAcme, USERNAME_TIFFANY ) );
    newAclBuilder.owner( tiffanySid );
    repo.updateAcl( newAclBuilder.build() );
    RepositoryFileAcl fetchedAcl = repo.getAcl( newFolder.getId() );
    assertEquals( new RepositoryFileSid( USERNAME_TIFFANY ), fetchedAcl.getOwner() );
  }
View Full Code Here

    // tiffany owns it but suzy is creating it
    RepositoryFileAcl.Builder aclBuilder = new RepositoryFileAcl.Builder( tiffanySid );
    // need this to be able to fetch acl as suzy
    aclBuilder.ace( suzySid, RepositoryFilePermission.READ );
    newFolder = repo.createFolder( parentFolder.getId(), newFolder, aclBuilder.build(), null );
    RepositoryFileAcl fetchedAcl = repo.getAcl( newFolder.getId() );
    assertEquals( new RepositoryFileSid( USERNAME_TIFFANY ), fetchedAcl.getOwner() );
    assertLocalAceExists( newFolder, new RepositoryFileSid( USERNAME_SUZY ),
        EnumSet.of( RepositoryFilePermission.READ ) );
  }
View Full Code Here

    login( USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName } );

    RepositoryFile newFile =
        createSampleFile( repo.getFile( ClientRepositoryPaths.getUserHomeFolderPath( USERNAME_SUZY ) ).getPath(),
            "helloworld.sample", "ddfdf", false, 83 );
    RepositoryFileAcl acl =
        new RepositoryFileAcl.Builder( newFile.getId(), userNameUtils.getPrincipleId( tenantAcme, USERNAME_SUZY ),
            RepositoryFileSid.Type.USER ).entriesInheriting( false ).build();
    repo.updateAcl( acl );
  }
View Full Code Here

    defaultBackingRepositoryLifecycleManager.newTenant();
    RepositoryFile publicFolderFile =
        createSampleFile( repo.getFile(
                ClientRepositoryPaths.getUserHomeFolderPath( PentahoSessionHolder.getSession().getName() ) ).getPath(),
            "helloworld.sample", "ddfdf", false, 83 );
    RepositoryFileAcl publicFolderFileAcl =
        new RepositoryFileAcl.Builder( publicFolderFile.getId(), userNameUtils.getPrincipleId( tenantAcme,
            USERNAME_ADMIN ), RepositoryFileSid.Type.USER ).entriesInheriting( false ).ace(
            new RepositoryFileSid( roleNameUtils.getPrincipleId( tenantAcme, tenantAuthenticatedRoleName ),
                RepositoryFileSid.Type.ROLE ), RepositoryFilePermission.READ, RepositoryFilePermission.WRITE ).build();
    repo.updateAcl( publicFolderFileAcl );
View Full Code Here

    defaultBackingRepositoryLifecycleManager.newTenant();
    RepositoryFile publicFolderFile =
        createSampleFile( repo.getFile(
                ClientRepositoryPaths.getUserHomeFolderPath( PentahoSessionHolder.getSession().getName() ) ).getPath(),
            "helloworld.sample", "ddfdf", false, 83 );
    RepositoryFileAcl publicFolderFileAcl =
        new RepositoryFileAcl.Builder( publicFolderFile.getId(), userNameUtils.getPrincipleId( tenantAcme,
            USERNAME_ADMIN ), RepositoryFileSid.Type.USER ).entriesInheriting( false ).ace(
            new RepositoryFileSid( roleNameUtils.getPrincipleId( tenantAcme, tenantAuthenticatedRoleName ),
                RepositoryFileSid.Type.ROLE ), RepositoryFilePermission.READ ).build();
    repo.updateAcl( publicFolderFileAcl );
View Full Code Here

    RepositoryFile parentFolder =
        repo.getFile( ClientRepositoryPaths.getUserHomeFolderPath( PentahoSessionHolder.getSession().getName() ) );
    RepositoryFile newFolder = new RepositoryFile.Builder( "test" ).folder( true ).versioned( true ).build();
    newFolder = repo.createFolder( parentFolder.getId(), newFolder, null );

    RepositoryFileAcl acls = repo.getAcl( newFolder.getId() );

    RepositoryFileAcl.Builder newAclBuilder = new RepositoryFileAcl.Builder( acls );
    newAclBuilder.entriesInheriting( false ).ace( userNameUtils.getPrincipleId( tenantAcme, USERNAME_TIFFANY ),
        RepositoryFileSid.Type.USER, RepositoryFilePermission.READ );
    repo.updateAcl( newAclBuilder.build() );

    login( USERNAME_TIFFANY, tenantAcme, new String[] { tenantAuthenticatedRoleName } );
    RepositoryFileAcl newAcl = repo.getAcl( newFolder.getId() );

    RepositoryFileAcl.Builder anotherNewAclBuilder = new RepositoryFileAcl.Builder( newAcl );
    anotherNewAclBuilder.ace( new RepositoryFileSid( userNameUtils.getPrincipleId( tenantAcme,
            tenantAuthenticatedRoleName ), RepositoryFileSid.Type.ROLE ), RepositoryFilePermission.READ,
        RepositoryFilePermission.WRITE, RepositoryFilePermission.DELETE );
View Full Code Here

    login( USERNAME_GEORGE, tenantDuff, new String[] { tenantAuthenticatedRoleName } );

    RepositoryFile parentFolder =
        repo.getFile( ClientRepositoryPaths.getUserHomeFolderPath( PentahoSessionHolder.getSession().getName() ) );
    RepositoryFile newFile = createSampleFile( parentFolder.getPath(), "hello.xaction", "", false, 2, false );
    RepositoryFileAcl acls = repo.getAcl( newFile.getId() );

    RepositoryFileAcl.Builder newAclBuilder = new RepositoryFileAcl.Builder( acls );
    newAclBuilder.entriesInheriting( false ).ace( userNameUtils.getPrincipleId( tenantDuff, USERNAME_PAT ),
        RepositoryFileSid.Type.USER, RepositoryFilePermission.ALL );
    repo.updateAcl( newAclBuilder.build() );

    login( USERNAME_PAT, tenantDuff, new String[] { tenantAuthenticatedRoleName } );

    userRoleDao.deleteUser( userGeorge );
    // TestPrincipalProvider.enableGeorgeAndDuff(false); simulate delete of george who is owner and explicitly in
    // ACE
    RepositoryFile fetchedFile = repo.getFileById( newFile.getId() );
    assertEquals( USERNAME_GEORGE, repo.getAcl( fetchedFile.getId() ).getOwner().getName() );
    assertEquals( RepositoryFileSid.Type.USER, repo.getAcl( fetchedFile.getId() ).getOwner().getType() );

    RepositoryFileAcl updatedAcl = repo.getAcl( newFile.getId() );

    boolean foundGeorge = false;

    for ( RepositoryFileAce ace : updatedAcl.getAces() ) {
      if ( USERNAME_GEORGE.equals( ace.getSid().getName() ) ) {
        foundGeorge = true;
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.repository2.unified.RepositoryFileAcl$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.