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);
}
}
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;
}
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;
}
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;
}
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);
}
Aggregations