Package org.pentaho.platform.core.mt

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


      }
    } else {
      IPentahoSession session = PentahoSessionHolder.getSession();
      String tenantPath = (String) session.getAttribute( IPentahoSession.TENANT_ID_KEY );
      if ( tenantPath != null ) {
        tenant = new Tenant( tenantPath, true );
      }
    }
    return tenant;
  }
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;
    } else {
      return null;
    }
  }
View Full Code Here

    return createFile( parentFolderId, file, data, createDefaultAcl(), versionMessage );
  }

  private RepositoryFileAcl createDefaultAcl() {
    RepositoryFileAcl.Builder builder =
        new RepositoryFileAcl.Builder( userNameUtils.getPrincipleId( new Tenant( "/pentaho", true ),
            currentUserProvider.getUser() ) );
    builder.entriesInheriting( true );
    return builder.build();
  }
View Full Code Here

    mockLifecycleManager.setThrowException( false );
    listener.setLifecycleManager( mockLifecycleManager );
    assertEquals( mockLifecycleManager, listener.getLifecycleManager() );

    // Test that the "newTenant() method is executed as the system currentUser and the
    String principleName = usernamePrincipleUtils.getPrincipleId( new Tenant( CURRENT_TENANT, true ), CURRENT_USER );
    listener.onApplicationEvent( new MockAbstractAuthenticationEvent( new MockAuthentication( principleName ) ) );
    final List<MethodTrackingData> methodTrackerHistory1 = mockLifecycleManager.getMethodTrackerHistory();
    assertEquals( 4, methodTrackerHistory1.size() );
    assertEquals( "newTenant", methodTrackerHistory1.get( 0 ).getMethodName() );
    assertEquals( 2, methodTrackerHistory1.get( 0 ).getParameters().size() );
View Full Code Here

  }

  @Test
  public void testGetAuthoritiesForUser1ForTenant() throws Exception {
    ITenant defaultTenant = new Tenant( "/pentaho/tenant0", true );
    login( "suzy", defaultTenant );

    LdapUserSearch userSearch = getUserSearch( "ou=users", "(uid={0})" ); //$NON-NLS-1$//$NON-NLS-2$

    LdapUserDetailsService service = new LdapUserDetailsService( userSearch, new NoOpLdapAuthoritiesPopulator() );

    RolePreprocessingMapper mapper = new RolePreprocessingMapper();
    mapper.setRoleAttributes( new String[] { "uniqueMember" } ); //$NON-NLS-1$
    mapper.setTokenName( "cn" ); //$NON-NLS-1$
    service.setUserDetailsMapper( mapper );

    DefaultLdapUserRoleListService userRoleListService = new DefaultLdapUserRoleListService();

    userRoleListService.setUserDetailsService( service );

    List res = userRoleListService.getRolesForUser( defaultTenant, "suzy" ); //$NON-NLS-1$

    assertTrue( res.contains( "ROLE_A" ) ); //$NON-NLS-1$

    if ( logger.isDebugEnabled() ) {
      logger.debug( "results of getAuthoritiesForUser1(): " + res ); //$NON-NLS-1$
    }

    try {
      userRoleListService.getRolesForUser( new Tenant( "/pentaho", true ), "suzy" );
    } catch ( UnsupportedOperationException uoe ) {
      assertNotNull( uoe );
    }

  }
View Full Code Here

    }
  }

  @Test
  public void testGetAllUserNames1ForTenant() throws Exception {
    ITenant defaultTenant = new Tenant( "/pentaho/tenant0", true );
    login( "suzy", defaultTenant );

    SearchControls con1 = new SearchControls();
    con1.setReturningAttributes( new String[] { "uniqueMember" } ); //$NON-NLS-1$

    LdapSearchParamsFactoryImpl paramFactory =
        new LdapSearchParamsFactoryImpl( "ou=groups", "(objectClass=groupOfUniqueNames)", con1 ); //$NON-NLS-1$//$NON-NLS-2$
    paramFactory.afterPropertiesSet();

    Transformer transformer1 = new SearchResultToAttrValueList( "uniqueMember", "uid" ); //$NON-NLS-1$ //$NON-NLS-2$

    GenericLdapSearch allUsernamesSearch = new GenericLdapSearch( getContextSource(), paramFactory, transformer1 );
    allUsernamesSearch.afterPropertiesSet();

    DefaultLdapUserRoleListService userRoleListService = new DefaultLdapUserRoleListService();

    userRoleListService.setAllUsernamesSearch( allUsernamesSearch );

    List res = userRoleListService.getAllUsers( defaultTenant );

    assertTrue( res.contains( "pat" ) ); //$NON-NLS-1$
    assertTrue( res.contains( "admin" ) ); //$NON-NLS-1$

    if ( logger.isDebugEnabled() ) {
      logger.debug( "results of getAllUserNames1(): " + res ); //$NON-NLS-1$
    }

    try {
      userRoleListService.getAllUsers( new Tenant( "/pentaho", true ) );
    } catch ( UnsupportedOperationException uoe ) {
      assertNotNull( uoe );
    }

  }
View Full Code Here

    }
  }

  @Test
  public void testGetUsernamesInRole1ForTenant() {
    ITenant defaultTenant = new Tenant( "/pentaho/tenant0", true );
    login( "suzy", defaultTenant );

    SearchControls con1 = new SearchControls();
    con1.setReturningAttributes( new String[] { "uid" } ); //$NON-NLS-1$

    LdapSearchParamsFactory paramFactory =
        new LdapSearchParamsFactoryImpl( "ou=users", "(businessCategory=cn={0}*)", con1 ); //$NON-NLS-1$//$NON-NLS-2$

    Transformer transformer1 = new SearchResultToAttrValueList( "uid" ); //$NON-NLS-1$

    GrantedAuthorityToString transformer2 = new GrantedAuthorityToString();

    LdapSearch usernamesInRoleSearch =
        new GenericLdapSearch( getContextSource(), paramFactory, transformer1, transformer2 );

    DefaultLdapUserRoleListService userRoleListService = new DefaultLdapUserRoleListService();

    userRoleListService.setUsernamesInRoleSearch( usernamesInRoleSearch );

    List<String> res = userRoleListService.getUsersInRole( defaultTenant, "DEV" ); //$NON-NLS-1$

    assertTrue( res.contains( "pat" ) ); //$NON-NLS-1$
    assertTrue( res.contains( "tiffany" ) ); //$NON-NLS-1$

    if ( logger.isDebugEnabled() ) {
      logger.debug( "results of getUsernamesInRole1(): " + res ); //$NON-NLS-1$
    }

    try {
      userRoleListService.getUsersInRole( new Tenant( "/pentaho", true ), "DEV" );
    } catch ( UnsupportedOperationException uoe ) {
      assertNotNull( uoe );
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testGetAllAuthorities1ForTenant() {
    ITenant defaultTenant = new Tenant( "/pentaho/tenant0", true );
    login( "suzy", defaultTenant );
    SearchControls con1 = new SearchControls();
    con1.setReturningAttributes( new String[] { "cn" } ); //$NON-NLS-1$

    LdapSearchParamsFactory paramsFactory =
        new LdapSearchParamsFactoryImpl( "ou=roles", "(objectClass=organizationalRole)", con1 ); //$NON-NLS-1$//$NON-NLS-2$

    Transformer one = new SearchResultToAttrValueList( "cn" ); //$NON-NLS-1$
    Transformer two = new StringToGrantedAuthority();
    Transformer[] transformers = { one, two };
    Transformer transformer = new ChainedTransformer( transformers );

    LdapSearch rolesSearch = new GenericLdapSearch( getContextSource(), paramsFactory, transformer );

    DefaultLdapUserRoleListService userRoleListService = new DefaultLdapUserRoleListService();

    userRoleListService.setAllAuthoritiesSearch( rolesSearch );

    List res = userRoleListService.getAllRoles( defaultTenant );

    assertTrue( res.contains( "ROLE_CTO" ) ); //$NON-NLS-1$
    assertTrue( res.contains( "ROLE_CEO" ) ); //$NON-NLS-1$

    if ( logger.isDebugEnabled() ) {
      logger.debug( "results of getAllAuthorities1(): " + res ); //$NON-NLS-1$
    }

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

    }
  }

  @Test
  public void testGetAllUsernamesForTenant() throws Exception {
    ITenant defaultTenant = new Tenant( "/pentaho/tenant0", true );
    login( "admin", defaultTenant );
    JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
    dao.setAllUsernamesQuery( "SELECT DISTINCT(USERNAME) FROM USERS ORDER BY USERNAME" ); //$NON-NLS-1$
    dao.afterPropertiesSet();
    List<String> allUsers = dao.getAllUsers( defaultTenant );
    assertTrue( "User List should not be empty", allUsers.size() > 0 ); //$NON-NLS-1$
    for ( String username : allUsers ) {
      System.out.println( "User: " + username ); //$NON-NLS-1$
    }
    try {
      allUsers = dao.getAllUsers( new Tenant( "/pentaho", true ) );
    } catch ( UnsupportedOperationException uoe ) {
      assertNotNull( uoe );
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testGetAllAuthoritiesForTenant() 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.afterPropertiesSet();
    List<String> auths = dao.getAllRoles( defaultTenant );
    assertTrue( "Authorities list should not be empty", auths.size() > 0 ); //$NON-NLS-1$
    for ( String auth : auths ) {
      System.out.println( "Authority: " + auth ); //$NON-NLS-1$
    }

    try {
      auths = dao.getAllRoles( new Tenant( "/pentaho", true ) );
    } catch ( UnsupportedOperationException uoe ) {
      assertNotNull( uoe );
    }
  }
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.