Search in sources :

Example 21 with Tenant

use of org.pentaho.platform.core.mt.Tenant in project pentaho-platform by pentaho.

the class DefaultLdapUserRoleListServiceTest method testGetAllUserNames1ForTenant.

@Test
public void testGetAllUserNames1ForTenant() throws Exception {
    ITenant defaultTenant = new Tenant("/pentaho/tenant0", true);
    login("suzy", defaultTenant);
    SearchControls con1 = new SearchControls();
    // $NON-NLS-1$
    con1.setReturningAttributes(new String[] { "uniqueMember" });
    LdapSearchParamsFactoryImpl paramFactory = // $NON-NLS-1$//$NON-NLS-2$
    new LdapSearchParamsFactoryImpl("ou=groups", "(objectClass=groupOfUniqueNames)", con1);
    paramFactory.afterPropertiesSet();
    // $NON-NLS-1$ //$NON-NLS-2$
    Transformer transformer1 = new SearchResultToAttrValueList("uniqueMember", "uid");
    GenericLdapSearch allUsernamesSearch = new GenericLdapSearch(getContextSource(), paramFactory, transformer1);
    allUsernamesSearch.afterPropertiesSet();
    DefaultLdapUserRoleListService userRoleListService = getDefaultLdapUserRoleListService();
    userRoleListService.setAllUsernamesSearch(allUsernamesSearch);
    List res = userRoleListService.getAllUsers(defaultTenant);
    // $NON-NLS-1$
    assertTrue(res.contains("pat"));
    // $NON-NLS-1$
    assertTrue(res.contains("admin"));
    if (logger.isDebugEnabled()) {
        // $NON-NLS-1$
        logger.debug("results of getAllUserNames1(): " + res);
    }
    try {
        userRoleListService.getAllUsers(new Tenant("/pentaho", true));
    } catch (UnsupportedOperationException uoe) {
        assertNotNull(uoe);
    }
}
Also used : DefaultLdapUserRoleListService(org.pentaho.platform.plugin.services.security.userrole.ldap.DefaultLdapUserRoleListService) ITenant(org.pentaho.platform.api.mt.ITenant) Tenant(org.pentaho.platform.core.mt.Tenant) ITenant(org.pentaho.platform.api.mt.ITenant) ChainedTransformer(org.apache.commons.collections.functors.ChainedTransformer) Transformer(org.apache.commons.collections.Transformer) SearchControls(javax.naming.directory.SearchControls) SearchResultToAttrValueList(org.pentaho.platform.plugin.services.security.userrole.ldap.transform.SearchResultToAttrValueList) GenericLdapSearch(org.pentaho.platform.plugin.services.security.userrole.ldap.search.GenericLdapSearch) ArrayList(java.util.ArrayList) SearchResultToAttrValueList(org.pentaho.platform.plugin.services.security.userrole.ldap.transform.SearchResultToAttrValueList) List(java.util.List) LdapSearchParamsFactoryImpl(org.pentaho.platform.plugin.services.security.userrole.ldap.search.LdapSearchParamsFactoryImpl) Test(org.junit.Test)

Example 22 with Tenant

use of org.pentaho.platform.core.mt.Tenant in project pentaho-platform by pentaho.

the class AbstractRepositoryTenantManager method getTenant.

public ITenant getTenant(Session session, String tenantId) throws RepositoryException {
    ITenant tenant = null;
    RepositoryFile tenantRootFolder = JcrRepositoryFileUtils.getFileByAbsolutePath(session, tenantId, pathConversionHelper, null, false, null);
    if ((tenantRootFolder != null) && isTenantRoot(session, tenantRootFolder.getId())) {
        tenant = new Tenant(tenantId, isTenantEnabled(session, tenantRootFolder.getId()));
    }
    return tenant;
}
Also used : ITenant(org.pentaho.platform.api.mt.ITenant) Tenant(org.pentaho.platform.core.mt.Tenant) ITenant(org.pentaho.platform.api.mt.ITenant) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile)

Example 23 with Tenant

use of org.pentaho.platform.core.mt.Tenant in project pentaho-platform by pentaho.

the class ProxyPentahoUserRoleHelper method toProxyRole.

public static ProxyPentahoRole toProxyRole(IPentahoRole role) {
    ProxyPentahoRole proxyRole = new ProxyPentahoRole(role.getName());
    proxyRole.setDescription(role.getDescription());
    ITenant tenant = role.getTenant();
    proxyRole.setTenant(new Tenant(tenant.getId(), tenant.isEnabled()));
    return proxyRole;
}
Also used : ITenant(org.pentaho.platform.api.mt.ITenant) Tenant(org.pentaho.platform.core.mt.Tenant) ITenant(org.pentaho.platform.api.mt.ITenant)

Example 24 with Tenant

use of org.pentaho.platform.core.mt.Tenant in project pentaho-platform by pentaho.

the class ProxyPentahoUserRoleHelper method toProxyUser.

public static ProxyPentahoUser toProxyUser(IPentahoUser user) {
    ProxyPentahoUser proxyPentahoUser = new ProxyPentahoUser();
    proxyPentahoUser.setName(user.getUsername());
    proxyPentahoUser.setDescription(user.getDescription());
    proxyPentahoUser.setEnabled(user.isEnabled());
    // $NON-NLS-1$
    proxyPentahoUser.setPassword("");
    ITenant tenant = user.getTenant();
    proxyPentahoUser.setTenant(new Tenant(tenant.getId(), tenant.isEnabled()));
    return proxyPentahoUser;
}
Also used : ITenant(org.pentaho.platform.api.mt.ITenant) Tenant(org.pentaho.platform.core.mt.Tenant) ITenant(org.pentaho.platform.api.mt.ITenant)

Example 25 with Tenant

use of org.pentaho.platform.core.mt.Tenant in project pentaho-platform by pentaho.

the class SpringSecurityPrincipalProvider_PrincipalCreation_Test method callGetPrincipalForUserString.

private Principal callGetPrincipalForUserString(String verifyUser, UserDetails dummyDetails) throws Exception {
    when(userResolver.isValid(USERNAME)).thenReturn(true);
    when(userResolver.getTenant(USERNAME)).thenReturn(new Tenant(USERNAME, true));
    if (verifyUser != null) {
        Properties p = createBasicProperties();
        p.put(SKIP_USER_VERIFICATION_PROP_KEY, verifyUser);
        setUpProvider(p);
    }
    provider = spy(provider);
    doReturn(dummyDetails).when(provider).internalGetUserDetails(USERNAME);
    return provider.getPrincipal(USERNAME);
}
Also used : Tenant(org.pentaho.platform.core.mt.Tenant) Properties(java.util.Properties)

Aggregations

Tenant (org.pentaho.platform.core.mt.Tenant)28 ITenant (org.pentaho.platform.api.mt.ITenant)26 Test (org.junit.Test)10 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)8 ArrayList (java.util.ArrayList)5 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)5 JdbcUserRoleListService (org.pentaho.platform.plugin.services.security.userrole.jdbc.JdbcUserRoleListService)5 List (java.util.List)4 DefaultLdapUserRoleListService (org.pentaho.platform.plugin.services.security.userrole.ldap.DefaultLdapUserRoleListService)4 SearchResultToAttrValueList (org.pentaho.platform.plugin.services.security.userrole.ldap.transform.SearchResultToAttrValueList)4 IOException (java.io.IOException)3 Node (javax.jcr.Node)3 SearchControls (javax.naming.directory.SearchControls)3 Transformer (org.apache.commons.collections.Transformer)3 ChainedTransformer (org.apache.commons.collections.functors.ChainedTransformer)3 Serializable (java.io.Serializable)2 HashSet (java.util.HashSet)2 Properties (java.util.Properties)2 PropertyIterator (javax.jcr.PropertyIterator)2 RepositoryException (javax.jcr.RepositoryException)2