Package org.pentaho.platform.core.mt

Examples of org.pentaho.platform.core.mt.Tenant


    }
  }

  @Test
  public void testGetAllAuthoritiesWithRolePrefixForTenant() throws Exception {
    ITenant defaultTenant = new Tenant( "/pentaho/tenant0", true );
    login( "admin", defaultTenant );
    JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
    dao.setAllAuthoritiesQuery( "SELECT DISTINCT(AUTHORITY) AS AUTHORITY FROM AUTHORITIES ORDER BY 1" ); //$NON-NLS-1$
    dao.setRolePrefix( "ARBITRARY_PREFIX_" ); //$NON-NLS-1$
    dao.afterPropertiesSet();
    List<String> auths = dao.getAllRoles( defaultTenant );
    assertTrue( "Authorities list should not be empty", auths.size() > 0 ); //$NON-NLS-1$
    for ( String role : auths ) {
      System.out.println( "Authority with prefix: " + role ); //$NON-NLS-1$
    }

    try {
      auths = dao.getAllRoles( new Tenant( "/pentaho", true ) );
    } catch ( UnsupportedOperationException uoe ) {
      assertNotNull( uoe );
    }
  }
View Full Code Here


    }
  }

  @Test
  public void testGetAllUsernamesInRoleForTenant() throws Exception {
    ITenant defaultTenant = new Tenant( "/pentaho/tenant0", true );
    login( "admin", defaultTenant );
    JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
    dao.setAllUsernamesInRoleQuery(
      "SELECT DISTINCT(USERNAME) AS USERNAME FROM AUTHORITIES WHERE AUTHORITY = ? ORDER BY 1" ); //$NON-NLS-1$
    dao.afterPropertiesSet();
    List<String> allUsers = dao.getUsersInRole( defaultTenant, "ROLE_TELLER" ); //$NON-NLS-1$
    assertTrue( "User List should not be empty", allUsers.size() > 0 ); //$NON-NLS-1$
    for ( String username : allUsers ) {
      System.out.println( "ROLE_TELLER User: " + username ); //$NON-NLS-1$
    }

    try {
      allUsers = dao.getUsersInRole( new Tenant( "/pentaho", true ), "ROLE_TELLER" );
    } catch ( UnsupportedOperationException uoe ) {
      assertNotNull( uoe );
    }

  }
View Full Code Here

  }

  @Test
  public void testGetRolesForUserForTenant() throws Exception {
    ITenant defaultTenant = new Tenant( "/pentaho/tenant0", true );
    login( "admin", defaultTenant );
    JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
    dao.setUserDetailsService( makePopulatedJdbcDao() );
    dao.afterPropertiesSet();
    List<String> roles = dao.getRolesForUser( defaultTenant, "rod" ); //$NON-NLS-1$
    assertTrue( roles.contains( "ROLE_TELLER" ) ); //$NON-NLS-1$
    assertTrue( roles.contains( "ROLE_SUPERVISOR" ) ); //$NON-NLS-1$

    try {
      roles = dao.getRolesForUser( new Tenant( "/pentaho", true ), "rod" );
    } catch ( UnsupportedOperationException uoe ) {
      assertNotNull( uoe );
    }
  }
View Full Code Here

      ITenantedPrincipleNameResolver tenantedUserNameUtils =
          PentahoSystem.get( ITenantedPrincipleNameResolver.class, "tenantedUserNameUtils", pentahoSession );
      if ( tenantedUserNameUtils != null ) {
        ITenant tenant = tenantedUserNameUtils.getTenant( pentahoSession.getId() );
        pentahoSession.setAttribute( IPentahoSession.TENANT_ID_KEY, tenant.getId() );
        return new Tenant( tenant.getId(), true );
      }
    }

    return new Tenant( tenantId, true );
  }
View Full Code Here

  public void setUserRoleDao( final IUserRoleDao userRoleDao ) {
    this.userRoleDao = userRoleDao;
  }

  protected ITenant getSampleTenant() {
    return new Tenant( "/penahot/steel-wheels", true );
  }
View Full Code Here

  getOrCreateTrashInternalFolderNode( final Session session, final PentahoJcrConstants pentahoJcrConstants )
    throws RepositoryException {
    IPentahoSession pentahoSession = PentahoSessionHolder.getSession();
    String tenantId = (String) pentahoSession.getAttribute( IPentahoSession.TENANT_ID_KEY );
    Node userHomeFolderNode =
        (Node) session.getItem( ServerRepositoryPaths.getUserHomeFolderPath( new Tenant( tenantId, true ),
            JcrStringHelper.fileNameEncode( PentahoSessionHolder.getSession().getName() ) ) );
    if ( userHomeFolderNode.hasNode( FOLDER_NAME_TRASH ) ) {
      return userHomeFolderNode.getNode( FOLDER_NAME_TRASH );
    } else {
      return userHomeFolderNode.addNode( FOLDER_NAME_TRASH, pentahoJcrConstants.getPHO_NT_INTERNALFOLDER() );
View Full Code Here

    // if this file was non-permanently deleted, delete its containing folder too
    IPentahoSession pentahoSession = PentahoSessionHolder.getSession();
    String tenantId = (String) pentahoSession.getAttribute( IPentahoSession.TENANT_ID_KEY );
    String trashFolder =
        ServerRepositoryPaths.getUserHomeFolderPath( new Tenant( tenantId, true ), PentahoSessionHolder.getSession()
            .getName() )
            + RepositoryFile.SEPARATOR + FOLDER_NAME_TRASH;
    if ( fileNode.getPath().startsWith( trashFolder ) ) {
      fileNode.getParent().remove();
    } else {
View Full Code Here

  }

  protected ITenant getCurrentTenant() {
    if ( PentahoSessionHolder.getSession() != null ) {
      String tenantId = (String) PentahoSessionHolder.getSession().getAttribute( IPentahoSession.TENANT_ID_KEY );
      return tenantId != null ? new Tenant( tenantId, true ) : null;
    }
    return null;
  }
View Full Code Here

              .substring( delimiterIndex + 1 ) );
      if ( !isTenantValid( tenantName ) ) {
        tenantName = null;
      }
    }
    return new Tenant( tenantName, true );
  }
View Full Code Here

    proxyPentahoUser.setName( user.getUsername() );
    proxyPentahoUser.setDescription( user.getDescription() );
    proxyPentahoUser.setEnabled( user.isEnabled() );
    proxyPentahoUser.setPassword( "" ); //$NON-NLS-1$
    ITenant tenant = user.getTenant();
    proxyPentahoUser.setTenant( new Tenant( tenant.getId(), tenant.isEnabled() ) );
    return proxyPentahoUser;
  }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.core.mt.Tenant

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.