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

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


    assertEquals( pentahoRole.getName(), roleName );
    assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_1 );
  }

  public void createAndTestUserWithRoles( ITenant tenant, String user, String[] roles ) {
    IPentahoUser pentahoUser = userRoleDaoProxy.createUser( tenant, user, PASSWORD_1, USER_DESCRIPTION_1, roles );
    pentahoUser = userRoleDaoProxy.getUser( tenant, user );
    assertEquals( pentahoUser.getTenant(), tenant );
    assertEquals( pentahoUser.getUsername(), user );
    assertEquals( pentahoUser.getDescription(), USER_DESCRIPTION_1 );
    assertEquals( pentahoUser.isEnabled(), true );
    for ( String role : roles ) {
      assertTrue( userRoleDaoProxy.getRoleMembers( tenant, role ).contains( pentahoUser ) );
    }
  }
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} );

    IPentahoUser pentahoUser = userRoleDaoProxy.createUser( mainTenant_1, USER_5, PASSWORD_5,
        USER_DESCRIPTION_5, null );
    pentahoUser = userRoleDaoProxy.getUser( mainTenant_1, USER_5 );
    assertEquals( pentahoUser.getDescription(), USER_DESCRIPTION_5 );

    String changedDescription1 = USER_DESCRIPTION_5 + "change1";
    userRoleDaoProxy.setUserDescription( mainTenant_1, USER_5, changedDescription1 );
    pentahoUser =
        userRoleDaoProxy.getUser( null, USER_5 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
            + mainTenant_1.getRootFolderAbsolutePath() );
    assertEquals( changedDescription1, pentahoUser.getDescription() );

    String changedDescription2 = USER_DESCRIPTION_5 + "change2";
    userRoleDaoProxy.setUserDescription( null, USER_5 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
        + mainTenant_1.getRootFolderAbsolutePath(), changedDescription2 );
    pentahoUser = userRoleDaoProxy.getUser( mainTenant_1, USER_5 );
    assertEquals( changedDescription2, pentahoUser.getDescription() );

    userRoleDaoProxy.setUserDescription( null, USER_5 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
        + mainTenant_1.getRootFolderAbsolutePath(), null );
    pentahoUser = userRoleDaoProxy.getUser( mainTenant_1, USER_5 );
    assertNull( pentahoUser.getDescription() );

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

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

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

    IPentahoUser pentahoUser = userRoleDaoProxy.createUser( mainTenant_1, USER_6,
        PASSWORD_6, USER_DESCRIPTION_6, null );
    pentahoUser =
        userRoleDaoProxy.getUser( null, USER_6 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
            + mainTenant_1.getRootFolderAbsolutePath() );
    assertNotNull( pentahoUser );
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} );
    List<IPentahoUser> users = userRoleDaoProxy.getUsers( mainTenant_1 );
    IPentahoUser pentahoUser = userRoleDaoProxy.createUser( mainTenant_1, USER_2,
        PASSWORD_2, USER_DESCRIPTION_2, null );
    pentahoUser = userRoleDaoProxy.getUser( mainTenant_1, USER_2 );
    assertEquals( pentahoUser.getTenant(), mainTenant_1 );
    assertEquals( pentahoUser.getUsername(), USER_2 );
    assertEquals( pentahoUser.getDescription(), USER_DESCRIPTION_2 );
    assertEquals( pentahoUser.isEnabled(), true );
    logout();
    /*login( "admin", subTenant2_1, new String[] { adminRoleName, authenticatedRoleName } );
    try {
      pentahoUser = userRoleDaoProxy.createUser( mainTenant_1, USER_2, PASSWORD_2,
        USER_DESCRIPTION_2, null );
      fail( "Exception not thrown" );
    } catch ( Throwable th ) {
      assertNotNull( th );
    }
    logout();*/
    login( "admin", mainTenant_1, new String[]{adminRoleName, authenticatedRoleName} );

    users = userRoleDaoProxy.getUsers( mainTenant_1 );
    int DEFAULT_USER_COUNT = 1;
    assertTrue( users.size() == 1 + DEFAULT_USER_COUNT );
    boolean foundUser = false;
    for ( IPentahoUser user : users ) {
      if ( user.getUsername().equals( USER_2 ) ) {
        foundUser = true;
        pentahoUser = user;
        break;
      }
    }
    assertTrue( foundUser );
    assertEquals( pentahoUser.getTenant(), mainTenant_1 );
    assertEquals( pentahoUser.getUsername(), USER_2 );
    assertEquals( pentahoUser.getDescription(), USER_DESCRIPTION_2 );
    assertEquals( pentahoUser.isEnabled(), true );

    logout();
    login( "admin", mainTenant_2, new String[]{adminRoleName, authenticatedRoleName} );
    pentahoUser = userRoleDaoProxy.createUser( mainTenant_2, USER_2, PASSWORD_2, USER_DESCRIPTION_2, null );

    logout();
    login( "admin", subTenant1_1, new String[]{adminRoleName, authenticatedRoleName} );
    try {
      pentahoUser = userRoleDaoProxy.createUser( mainTenant_2, USER_2, PASSWORD_2, USER_DESCRIPTION_2, null );
      fail( "Exception not thrown" );
    } catch ( Throwable th ) {
      assertNotNull( th );
    }

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

    pentahoUser = userRoleDaoProxy.getUser( mainTenant_2, USER_2 );
    assertEquals( pentahoUser.getTenant(), mainTenant_2 );
    assertEquals( pentahoUser.getUsername(), USER_2 );
    assertEquals( pentahoUser.getDescription(), USER_DESCRIPTION_2 );
    assertEquals( pentahoUser.isEnabled(), true );

    users = userRoleDaoProxy.getUsers( mainTenant_2 );
    assertTrue( users.size() == 1 + DEFAULT_USER_COUNT );
    foundUser = false;
    for ( IPentahoUser user : users ) {
      if ( user.getUsername().equals( USER_2 ) ) {
        foundUser = true;
        pentahoUser = user;
        break;
      }
    }
    assertTrue( foundUser );
    assertEquals( pentahoUser.getTenant(), mainTenant_2 );
    assertEquals( pentahoUser.getUsername(), USER_2 );
    assertEquals( pentahoUser.getDescription(), USER_DESCRIPTION_2 );
    assertEquals( pentahoUser.isEnabled(), true );

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

    pentahoUser =
        userRoleDaoProxy.createUser( null, USER_3 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
            + subTenant2_1.getRootFolderAbsolutePath(), PASSWORD_3, USER_DESCRIPTION_3, null );

    pentahoUser =
        userRoleDaoProxy.getUser( null, USER_3 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
            + subTenant2_1.getRootFolderAbsolutePath() );
    assertEquals( pentahoUser.getTenant(), subTenant2_1 );
    assertEquals( pentahoUser.getUsername(), USER_3 );
    assertEquals( pentahoUser.getDescription(), USER_DESCRIPTION_3 );
    assertEquals( pentahoUser.isEnabled(), true );

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

    try {
      pentahoUser = userRoleDaoProxy.createUser( subTenant2_1, USER_1, PASSWORD_1, USER_DESCRIPTION_1, null );
      fail( "Exception not thrown" );
    } catch ( Throwable th ) {
      assertNotNull( th );
    }

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

    users = userRoleDaoProxy.getUsers( subTenant2_1 );
    assertTrue( users.size() == 1 + DEFAULT_USER_COUNT );
    foundUser = false;
    for ( IPentahoUser user : users ) {
      if ( user.getUsername().equals( USER_3 ) ) {
        foundUser = true;
        pentahoUser = user;
        break;
      }
    }
    assertTrue( foundUser );
    assertEquals( pentahoUser.getTenant(), subTenant2_1 );
    assertEquals( pentahoUser.getUsername(), USER_3 );
    assertEquals( pentahoUser.getDescription(), USER_DESCRIPTION_3 );
    assertEquals( pentahoUser.isEnabled(), true );

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

    pentahoUser =
        userRoleDaoProxy.createUser( null, USER_4 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
            + subTenant1_1.getRootFolderAbsolutePath(), PASSWORD_4, USER_DESCRIPTION_4, null );

    pentahoUser =
        userRoleDaoProxy.getUser( null, USER_4 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
            + subTenant1_1.getRootFolderAbsolutePath() );
    assertEquals( pentahoUser.getTenant(), subTenant1_1 );
    assertEquals( pentahoUser.getUsername(), USER_4 );
    assertEquals( pentahoUser.getDescription(), USER_DESCRIPTION_4 );
    assertEquals( pentahoUser.isEnabled(), true );

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

    try {
      pentahoUser = userRoleDaoProxy.createUser( subTenant1_1, USER_1, PASSWORD_1, USER_DESCRIPTION_1, null );
      fail( "Exception not thrown" );
    } catch ( Throwable th ) {
      assertNotNull( th );
    }

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

    users = userRoleDaoProxy.getUsers( subTenant1_1 );
    assertTrue( users.size() == 1 + DEFAULT_USER_COUNT );
    foundUser = false;
    for ( IPentahoUser user : users ) {
      if ( user.getUsername().equals( USER_4 ) ) {
        foundUser = true;
        pentahoUser = user;
        break;
      }
    }
    assertTrue( foundUser );
    assertEquals( pentahoUser.getTenant(), subTenant1_1 );
    assertEquals( pentahoUser.getUsername(), USER_4 );
    assertEquals( pentahoUser.getDescription(), USER_DESCRIPTION_4 );
    assertEquals( pentahoUser.isEnabled(), true );

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

    try {
View Full Code Here

      try {
        IUserRoleDao roleDao =
            PentahoSystem.get( IUserRoleDao.class, "userRoleDaoProxy", PentahoSessionHolder.getSession() );
        StringTokenizer tokenizer = new StringTokenizer( userNames, "\t" );
        while ( tokenizer.hasMoreTokens() ) {
          IPentahoUser user = roleDao.getUser( null, tokenizer.nextToken() );
          if ( user != null ) {
            roleDao.deleteUser( user );
          }
        }
      } catch ( Throwable th ) {
View Full Code Here

          password = URLDecoder.decode( password.replace( "+", "%2B" ), "UTF-8" );
        } catch ( UnsupportedEncodingException e ) {
          password = user.getPassword();
          logger.warn( e.getMessage(), e );
        }
        IPentahoUser puser = roleDao.getUser( null, userName );
        if ( puser != null ) {
          roleDao.setPassword( null, userName, password );
        }
        return Response.ok().build();
      } catch ( Throwable t ) {
View Full Code Here

  @Override
  public IPentahoUser createUser( final ITenant tenant, final String userName, final String password,
      final String description, final String[] roles ) throws AlreadyExistsException,
    UncategorizedUserRoleDaoException {
    final IPentahoUser user;
    try {
      user = (IPentahoUser) adminJcrTemplate.execute( new JcrCallback() {
        @Override
        public Object doInJcr( Session session ) throws IOException, RepositoryException {
          return createUser( session, tenant, userName, password, description, roles );
View Full Code Here

  }

  @Override
  public ProxyPentahoUser getUser( String pUserName ) throws UserRoleException {
    ProxyPentahoUser proxyPentahoUser = null;
    IPentahoUser user = getDao().getUser( null, pUserName );
    if ( user != null ) {
      proxyPentahoUser = ProxyPentahoUserRoleHelper.toProxyUser( user );
    }
    return proxyPentahoUser;
  }
View Full Code Here

    return users.toArray( new ProxyPentahoUser[0] );
  }

  @Override
  public boolean updateUser( ProxyPentahoUser proxyUser ) throws UserRoleException {
    IPentahoUser user = getDao().getUser( proxyUser.getTenant(), proxyUser.getName() );
    if ( user == null ) {
      throw new UserRoleException( Messages.getInstance().getErrorString(
          "UserRoleWebService.ERROR_0004_FAILED_TO_FIND_USER", proxyUser.getName() ) ); //$NON-NLS-1$
    }
    if ( !StringUtils.isBlank( proxyUser.getPassword() ) ) {
View Full Code Here

    return true;
  }

  @Override
  public void setRoles( ProxyPentahoUser proxyUser, ProxyPentahoRole[] assignedRoles ) throws UserRoleException {
    IPentahoUser user = getDao().getUser( proxyUser.getTenant(), proxyUser.getName() );
    if ( user == null ) {
      throw new UserRoleException( Messages.getInstance().getErrorString(
          "UserRoleWebService.ERROR_0004_FAILED_TO_FIND_USER", proxyUser.getName() ) ); //$NON-NLS-1$
    }
    ArrayList<String> roles = new ArrayList<String>();
View Full Code Here

TOP

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

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.