Package org.pentaho.platform.api.engine.security.userroledao

Examples of org.pentaho.platform.api.engine.security.userroledao.IPentahoRole


  }

  public void createAndTestRole( ITenant tenant, String roleName ) {
    userRoleDaoProxy.createRole( tenant, roleName, ROLE_DESCRIPTION_1, null );
    IPentahoRole pentahoRole = userRoleDaoProxy.getRole( tenant, roleName );
    assertEquals( pentahoRole.getTenant(), tenant );
    assertEquals( pentahoRole.getName(), roleName );
    assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_1 );
  }
View Full Code Here


        tenantManager.createTenant( mainTenant_2, SUB_TENANT2_2, adminRoleName, authenticatedRoleName, "Anonymous" );
    userRoleDaoProxy.createUser( subTenant2_2, "admin", "password", "", new String[]{adminRoleName} );

    login( "admin", mainTenant_1, new String[]{adminRoleName, authenticatedRoleName} );

    IPentahoRole pentahoRole;
    userRoleDaoProxy.createRole( mainTenant_1, ROLE_1, ROLE_DESCRIPTION_1, null );

    pentahoRole = userRoleDaoProxy.getRole( mainTenant_1, ROLE_1 );
    assertEquals( pentahoRole.getTenant(), mainTenant_1 );
    assertEquals( pentahoRole.getName(), ROLE_1 );
    assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_1 );
    int DEFAULT_ROLE_COUNT = 3;
    List<IPentahoRole> roles = userRoleDaoProxy.getRoles( mainTenant_1 );
    assertTrue( roles.size() == 1 + DEFAULT_ROLE_COUNT );

    for ( IPentahoRole role : roles ) {
      if ( role.getName() == ROLE_1 ) {
        pentahoRole = role;
      }
    }

    assertEquals( pentahoRole.getTenant(), mainTenant_1 );
    assertEquals( pentahoRole.getName(), ROLE_1 );
    assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_1 );
    logout();
    login( "admin", mainTenant_1, new String[]{adminRoleName, authenticatedRoleName} );
    try {
      userRoleDaoProxy.createRole( mainTenant_1, ROLE_1, ROLE_DESCRIPTION_1, null );
      fail( "Exception not thrown" );
    } catch ( Throwable th ) {
      assertNotNull( th );
    }
    logout();
    login( "admin", mainTenant_2, new String[]{adminRoleName, authenticatedRoleName} );

    pentahoRole = userRoleDaoProxy.createRole( mainTenant_2, ROLE_1, ROLE_DESCRIPTION_2, null );

    pentahoRole = userRoleDaoProxy.getRole( mainTenant_2, ROLE_1 );
    assertEquals( pentahoRole.getTenant(), mainTenant_2 );
    assertEquals( pentahoRole.getName(), ROLE_1 );
    assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_2 );

    roles = userRoleDaoProxy.getRoles( mainTenant_2 );
    assertTrue( roles.size() == 1 + DEFAULT_ROLE_COUNT );

    for ( IPentahoRole role : roles ) {
      if ( role.getName() == ROLE_1 ) {
        pentahoRole = role;
      }
    }

    assertEquals( pentahoRole.getTenant(), mainTenant_2 );
    assertEquals( pentahoRole.getName(), ROLE_1 );
    assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_2 );

    logout();
    login( "admin", subTenant2_1, new String[]{adminRoleName, authenticatedRoleName} );
    try {
      pentahoRole = userRoleDaoProxy.createRole( mainTenant_2, ROLE_1, ROLE_DESCRIPTION_1, null );
      fail( "Exception not thrown" );
    } catch ( Throwable th ) {
      assertNotNull( th );
    }

    userRoleDaoProxy.createRole( null, ROLE_3 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
        + subTenant2_1.getRootFolderAbsolutePath(), ROLE_DESCRIPTION_3, null );

    pentahoRole =
        userRoleDaoProxy.getRole( null, ROLE_3 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
            + subTenant2_1.getRootFolderAbsolutePath() );

    assertEquals( pentahoRole.getTenant(), subTenant2_1 );
    assertEquals( pentahoRole.getName(), ROLE_3 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
        + subTenant2_1.getRootFolderAbsolutePath() );
    assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_3 );

    roles = userRoleDaoProxy.getRoles( subTenant2_1 );
    assertTrue( roles.size() == 1 + DEFAULT_ROLE_COUNT );

    for ( IPentahoRole role : roles ) {
      if ( role.getName() == ROLE_3 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
          + subTenant2_1.getRootFolderAbsolutePath() ) {
        pentahoRole = role;
      }
    }

    assertEquals( pentahoRole.getTenant(), subTenant2_1 );
    assertEquals( pentahoRole.getName(), ROLE_3 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
        + subTenant2_1.getRootFolderAbsolutePath() );
    assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_3 );

    logout();
    login( "admin", subTenant1_1, new String[]{adminRoleName, authenticatedRoleName} );
    try {
      pentahoRole = userRoleDaoProxy.createRole( subTenant2_1, ROLE_3, ROLE_DESCRIPTION_3, null );
      fail( "Exception not thrown" );
    } catch ( Throwable th ) {
      assertNotNull( th );
    }

    logout();
    login( "admin", subTenant1_1, new String[]{adminRoleName, authenticatedRoleName} );

    pentahoRole =
        userRoleDaoProxy.createRole( null, ROLE_4 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
            + subTenant1_1.getRootFolderAbsolutePath(), ROLE_DESCRIPTION_4, null );

    pentahoRole =
        userRoleDaoProxy.getRole( null, ROLE_4 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
            + subTenant1_1.getRootFolderAbsolutePath() );
    assertEquals( pentahoRole.getTenant(), subTenant1_1 );
    assertEquals( pentahoRole.getName(), ROLE_4 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
        + subTenant1_1.getRootFolderAbsolutePath() );
    assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_4 );

    roles = userRoleDaoProxy.getRoles( subTenant1_1 );
    assertTrue( roles.size() == 1 + DEFAULT_ROLE_COUNT );

    for ( IPentahoRole role : roles ) {
      if ( role.getName() == ROLE_4 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
          + subTenant1_1.getRootFolderAbsolutePath() ) {
        pentahoRole = role;
      }
    }

    assertEquals( pentahoRole.getTenant(), subTenant1_1 );
    assertEquals( pentahoRole.getName(), ROLE_4 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
        + subTenant1_1.getRootFolderAbsolutePath() );
    assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_4 );

    logout();
    login( "admin", subTenant2_1, new String[]{adminRoleName, authenticatedRoleName} );
    try {
      pentahoRole = userRoleDaoProxy.createRole( subTenant1_1, ROLE_3, ROLE_DESCRIPTION_3, null );
View Full Code Here

        tenantManager.createTenant( systemTenant, MAIN_TENANT_2, adminRoleName, authenticatedRoleName, "Anonymous" );
    userRoleDaoProxy.createUser( mainTenant_2, "admin", "password", "", new String[]{adminRoleName} );

    login( "admin", mainTenant_1, new String[]{adminRoleName, authenticatedRoleName} );

    IPentahoRole pentahoRole = userRoleDaoProxy.createRole( mainTenant_1, ROLE_5, ROLE_DESCRIPTION_5, null );
    pentahoRole = userRoleDaoProxy.getRole( mainTenant_1, ROLE_5 );
    assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_5 );

    String changedDescription1 = ROLE_DESCRIPTION_5 + "change1";
    userRoleDaoProxy.setRoleDescription( mainTenant_1, ROLE_5, changedDescription1 );

    String role_delim = ( (DefaultTenantedPrincipleNameResolver) tenantedRoleNameUtils ).getDelimeter();

    pentahoRole =
        userRoleDaoProxy.getRole( null, ROLE_5 + role_delim
            + mainTenant_1.getRootFolderAbsolutePath() );
    assertNotNull( pentahoRole );
    assertEquals( changedDescription1, pentahoRole.getDescription() );

    String changedDescription2 = ROLE_DESCRIPTION_5 + "change2";
    userRoleDaoProxy.setRoleDescription( null, ROLE_5 + role_delim
        + mainTenant_1.getRootFolderAbsolutePath(), changedDescription2 );
    pentahoRole = userRoleDaoProxy.getRole( mainTenant_1, ROLE_5 );
    assertEquals( changedDescription2, pentahoRole.getDescription() );

    userRoleDaoProxy.setRoleDescription( null, ROLE_5 + role_delim
        + mainTenant_1.getRootFolderAbsolutePath(), null );
    pentahoRole = userRoleDaoProxy.getRole( mainTenant_1, ROLE_5 );
    assertNull( pentahoRole.getDescription() );

    try {
      userRoleDaoProxy.setRoleDescription( null, null, changedDescription2 );
      fail( "Exception not thrown" );
    } catch ( Exception ex ) {
View Full Code Here

    login( "admin", mainTenant_1, new String[]{adminRoleName, authenticatedRoleName} );

    String role_delim = ( (DefaultTenantedPrincipleNameResolver) tenantedRoleNameUtils ).getDelimeter();

    IPentahoRole pentahoRole = userRoleDaoProxy.createRole( mainTenant_1, ROLE_6, ROLE_DESCRIPTION_6, null );
    pentahoRole =
        userRoleDaoProxy.getRole( null, ROLE_6 + role_delim + mainTenant_1.getRootFolderAbsolutePath() );
    assertNotNull( pentahoRole );

    logout();
View Full Code Here

      try {
        IUserRoleDao roleDao =
            PentahoSystem.get( IUserRoleDao.class, "userRoleDaoProxy", PentahoSessionHolder.getSession() );
        StringTokenizer tokenizer = new StringTokenizer( roleNames, "\t" );
        while ( tokenizer.hasMoreTokens() ) {
          IPentahoRole role = roleDao.getRole( null, tokenizer.nextToken() );
          if ( role != null ) {
            roleDao.deleteRole( role );
          }
        }
      } catch ( Throwable th ) {
View Full Code Here

  }

  @Override
  public ProxyPentahoUser[] getUsersForRole( ProxyPentahoRole proxyRole ) throws UserRoleException {
    ArrayList<ProxyPentahoUser> users = new ArrayList<ProxyPentahoUser>();
    IPentahoRole role = getDao().getRole( proxyRole.getTenant(), proxyRole.getName() );
    if ( role != null ) {
      for ( IPentahoUser user : getDao().getRoleMembers( proxyRole.getTenant(), proxyRole.getName() ) ) {
        users.add( ProxyPentahoUserRoleHelper.toProxyUser( user ) );
      }
    } else {
View Full Code Here

    getDao().setUserRoles( proxyUser.getTenant(), proxyUser.getName(), roles.toArray( new String[0] ) );
  }

  @Override
  public void setUsers( ProxyPentahoRole proxyRole, ProxyPentahoUser[] assignedUsers ) throws UserRoleException {
    IPentahoRole role = getDao().getRole( proxyRole.getTenant(), proxyRole.getName() );
    if ( role == null ) {
      throw new UserRoleException( Messages.getInstance().getErrorString(
          "UserRoleWebService.ERROR_0005_FAILED_TO_FIND_ROLE", proxyRole.getName() ) ); //$NON-NLS-1$
    }
    ArrayList<String> userNames = new ArrayList<String>();
View Full Code Here

    getDao().setRoleMembers( proxyRole.getTenant(), proxyRole.getName(), userNames.toArray( new String[0] ) );
  }

  @Override
  public void updateRole( String roleName, String description, List<String> usernames ) throws UserRoleException {
    IPentahoRole role = getDao().getRole( null, roleName );
    if ( role == null ) {
      throw new UserRoleException( Messages.getInstance().getErrorString(
          "UserRoleWebService.ERROR_0006_ROLE_UPDATE_FAILED", roleName ) ); //$NON-NLS-1$
    }
    Set<String> users = new HashSet<String>();
View Full Code Here

  }

  @Override
  public boolean updateRoleObject( ProxyPentahoRole proxyPentahoRole ) throws UserRoleException {

    IPentahoRole role = getDao().getRole( proxyPentahoRole.getTenant(), proxyPentahoRole.getName() );
    if ( role == null ) {
      throw new UserRoleException( Messages.getInstance().getErrorString(
          "UserRoleWebService.ERROR_0006_ROLE_UPDATE_FAILED", proxyPentahoRole.getName() ) ); //$NON-NLS-1$
    }
    getDao().setRoleDescription( proxyPentahoRole.getTenant(), proxyPentahoRole.getName(),
View Full Code Here

    isAdmin = true;

    service.createRole( role );

    // the last role should have the same name and description
    IPentahoRole roleVerified = userRoleDao.getRole( null, "role" );
    Assert.assertNotNull( roleVerified );
    Assert.assertEquals( "role", roleVerified.getName() );
    Assert.assertEquals( "testing", roleVerified.getDescription() );
  }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.engine.security.userroledao.IPentahoRole

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.