Package org.pentaho.platform.repository2.unified.jcr.jackrabbit.security

Examples of org.pentaho.platform.repository2.unified.jcr.jackrabbit.security.SpringSecurityRolePrincipal


  public void init0() {
    microPlatform = new MicroPlatform( "test-src/solution/" );
    microPlatform.define( ISolutionEngine.class, SolutionEngine.class );
    microPlatform.define( IChartBeansGenerator.class, DefaultChartBeansGenerator.class );
    microPlatform.define( IUnifiedRepository.class, FileSystemBackedUnifiedRepository.class, Scope.GLOBAL );
    FileSystemBackedUnifiedRepository repo =
        (FileSystemBackedUnifiedRepository) PentahoSystem.get( IUnifiedRepository.class );
    repo.setRootDir( new File( "test-src/solution" ) );

    session = new StandaloneSession();
  }
View Full Code Here


            tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME );
    userRoleDao.createUser( tenantAcme, USERNAME_SUZY, PASSWORD, "", new String[]{tenantAdminRoleName} );
    logout();
    login( USERNAME_SUZY, tenantAcme, new String[]{tenantAdminRoleName, tenantAuthenticatedRoleName} );
    logger.info( "getFile" );
    JcrRepositoryDumpToFile dumpToFile =
        new JcrRepositoryDumpToFile( testJcrTemplate, jcrTransactionTemplate, repositoryAdminUsername,
            "c:/build/testrepo_9", Mode.CUSTOM );
    dumpToFile.execute();
    RepositoryFile f = repo.getFile( ClientRepositoryPaths.getUserHomeFolderPath( USERNAME_SUZY ) );
    assertNotNull( f.getId() );
    assertEquals( ClientRepositoryPaths.getUserHomeFolderPath( USERNAME_SUZY ), f.getPath() );
    assertNotNull( f.getCreatedDate() );
    assertEquals( USERNAME_SUZY, f.getName() );
View Full Code Here

  private void setAclManagement() {
    testJcrTemplate.execute( new JcrCallback() {
      @Override
      public Object doInJcr( Session session ) throws IOException, RepositoryException {
        PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants( session );
        Workspace workspace = session.getWorkspace();
        PrivilegeManager privilegeManager = ( (JackrabbitWorkspace) workspace ).getPrivilegeManager();
        try {
          privilegeManager.getPrivilege( pentahoJcrConstants.getPHO_ACLMANAGEMENT_PRIVILEGE() );
        } catch ( AccessControlException ace ) {
          privilegeManager.registerPrivilege( pentahoJcrConstants.getPHO_ACLMANAGEMENT_PRIVILEGE(), false,
              new String[0] );
        }
        session.save();
        return null;
      }
View Full Code Here

  private void setAclManagement() {
    testJcrTemplate.execute( new JcrCallback() {
      @Override
      public Object doInJcr( Session session ) throws IOException, RepositoryException {
        PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants( session );
        Workspace workspace = session.getWorkspace();
        PrivilegeManager privilegeManager = ( (JackrabbitWorkspace) workspace ).getPrivilegeManager();
        try {
          privilegeManager.getPrivilege( pentahoJcrConstants.getPHO_ACLMANAGEMENT_PRIVILEGE() );
        } catch ( AccessControlException ace ) {
          privilegeManager.registerPrivilege( pentahoJcrConstants.getPHO_ACLMANAGEMENT_PRIVILEGE(), false,
              new String[0] );
        }
        session.save();
        return null;
      }
View Full Code Here

    mp.define( ITenant.class, Tenant.class );
    mp.defineInstance( "tenantedUserNameUtils", tenantedUserNameUtils );
    mp.defineInstance( "tenantedRoleNameUtils", tenantedRoleNameUtils );
    mp.defineInstance( "roleAuthorizationPolicyRoleBindingDaoTarget", roleBindingDaoTarget );
    mp.defineInstance( "repositoryAdminUsername", repositoryAdminUsername );
    mp.defineInstance( "RepositoryFileProxyFactory", new RepositoryFileProxyFactory( this.jcrTemplate, this.repositoryFileDao ) );
    mp.defineInstance("useMultiByteEncoding", new Boolean( false ) );
    // Start the micro-platform
    mp.start();
    loginAsRepositoryAdmin();
    setAclManagement();
View Full Code Here

    mp.define( ITenant.class, Tenant.class );
    mp.defineInstance( "tenantedUserNameUtils", tenantedUserNameUtils );
    mp.defineInstance( "tenantedRoleNameUtils", tenantedRoleNameUtils );
    mp.defineInstance( "roleAuthorizationPolicyRoleBindingDaoTarget", roleBindingDaoTarget );
    mp.defineInstance( "repositoryAdminUsername", repositoryAdminUsername );
    mp.defineInstance( "RepositoryFileProxyFactory", new RepositoryFileProxyFactory( this.jcrTemplate, this.repositoryFileDao ) );
    mp.defineInstance("useMultiByteEncoding", new Boolean( false ) );
    // Start the micro-platform
    mp.start();
    loginAsRepositoryAdmin();
    setAclManagement();
View Full Code Here

    // add entries to now empty list but only if not inheriting; force user to start with clean slate
    if ( !acl.isEntriesInheriting() ) {
      for ( RepositoryFileAce ace : acl.getAces() ) {
        Principal principal = null;
        if ( RepositoryFileSid.Type.ROLE == ace.getSid().getType() ) {
          principal = new SpringSecurityRolePrincipal( JcrTenantUtils.getTenantedRole( ace.getSid().getName() ) );
        } else {
          principal = new SpringSecurityUserPrincipal( JcrTenantUtils.getTenantedUser( ace.getSid().getName() ) );
        }
        IPermissionConversionHelper permissionConversionHelper = new DefaultPermissionConversionHelper( session );
        acList.addAccessControlEntry( principal, permissionConversionHelper.pentahoPermissionsToPrivileges( session,
View Full Code Here

            AccessControlEntry[] acEntries = acList.getAccessControlEntries();
            List<AccessControlEntry> cleanedAcEntries =
                JcrRepositoryFileAclUtils.removeAclMetadata( Arrays.asList( acEntries ) );
            for ( AccessControlEntry acEntry : cleanedAcEntries ) {
              if ( !acEntry.getPrincipal().equals(
                  new SpringSecurityRolePrincipal( JcrTenantUtils.getTenantedRole( tenantAdminAuthorityName ) ) ) ) {
                aces.add( toAce( session, acEntry ) );
              }
            }
            return aces;
          }
        }

        // none are entriesInheriting=false so root aces are the effective aces
        AccessControlList acList = (AccessControlList) acPolicies[acPolicies.length - 1];
        List<RepositoryFileAce> aces = new ArrayList<RepositoryFileAce>();
        AccessControlEntry[] acEntries = acList.getAccessControlEntries();
        List<AccessControlEntry> cleanedAcEntries =
            JcrRepositoryFileAclUtils.removeAclMetadata( Arrays.asList( acEntries ) );
        for ( AccessControlEntry acEntry : cleanedAcEntries ) {
          if ( !acEntry.getPrincipal().equals(
              new SpringSecurityRolePrincipal( JcrTenantUtils.getTenantedRole( tenantAdminAuthorityName ) ) ) ) {
            aces.add( toAce( session, acEntry ) );
          }
        }
        return aces;
      }
View Full Code Here

    List<AccessControlEntry> cleanedAcEntries =
        JcrRepositoryFileAclUtils.removeAclMetadata( Arrays.asList( acList.getAccessControlEntries() ) );

    for ( AccessControlEntry acEntry : cleanedAcEntries ) {
      if ( !acEntry.getPrincipal().equals(
          new SpringSecurityRolePrincipal( JcrTenantUtils.getTenantedRole( tenantAdminAuthorityName ) ) ) ) {
        aclBuilder.ace( toAce( session, acEntry ) );
      }
    }
    return aclBuilder.build();
View Full Code Here

        if ( RepositoryFileSid.Type.ROLE == ace.getSid().getType() ) {
          String principalName = JcrTenantUtils.getRoleNameUtils().getPrincipleName( ace.getSid().getName() );
          if ( tenantAdminAuthorityName.equals( principalName ) ) {
            adminPrincipalExist = true;
          }
          principal = new SpringSecurityRolePrincipal( JcrTenantUtils.getTenantedRole( ace.getSid().getName() ) );
        } else {
          principal = new SpringSecurityUserPrincipal( JcrTenantUtils.getTenantedUser( ace.getSid().getName() ) );
        }
        acList.addAccessControlEntry( principal, permissionConversionHelper.pentahoPermissionsToPrivileges( session,
            ace.getPermissions() ) );
      }
      if ( !adminPrincipalExist ) {
        if ( acl.getAces() != null && acl.getAces().size() > 0 ) {
          principalTenant = JcrTenantUtils.getRoleNameUtils().getTenant( acl.getAces().get( 0 ).getSid().getName() );
        }

        if ( principalTenant == null || principalTenant.getId() == null ) {
          principalTenant = JcrTenantUtils.getTenant();
        }

        List<RepositoryFilePermission> permissionList = new ArrayList<RepositoryFilePermission>();
        permissionList.add( RepositoryFilePermission.ALL );
        Principal adminPrincipal =
            new SpringSecurityRolePrincipal( JcrTenantUtils.getRoleNameUtils().getPrincipleId( principalTenant,
                tenantAdminAuthorityName ) );
        acList.addAccessControlEntry( adminPrincipal, permissionConversionHelper.pentahoPermissionsToPrivileges(
            session, EnumSet.copyOf( permissionList ) ) );
      }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.repository2.unified.jcr.jackrabbit.security.SpringSecurityRolePrincipal

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.