use of org.pentaho.platform.security.userroledao.PentahoRole in project pentaho-platform by pentaho.
the class AbstractJcrBackedUserRoleDao method convertToPentahoRole.
private IPentahoRole convertToPentahoRole(Group jackrabbitGroup) throws RepositoryException {
IPentahoRole role = null;
Value[] propertyValues = null;
String description = null;
try {
// $NON-NLS-1$
propertyValues = jackrabbitGroup.getProperty("description");
description = propertyValues.length > 0 ? propertyValues[0].getString() : null;
} catch (Exception ex) {
// CHECKSTYLES IGNORE
}
role = new PentahoRole(tenantedRoleNameUtils.getTenant(jackrabbitGroup.getID()), tenantedRoleNameUtils.getPrincipleName(jackrabbitGroup.getID()), description);
return role;
}
use of org.pentaho.platform.security.userroledao.PentahoRole in project pentaho-platform by pentaho.
the class ProxyPentahoUserRoleHelper method syncRoles.
/**
* Synchronizes <code>role</code> with fields from <code>proxyRole</code>. The users set of given
* <code>role</code> is unmodified.
*/
public static IPentahoRole syncRoles(IPentahoRole role, ProxyPentahoRole proxyRole) {
IPentahoRole syncedRole = role;
if (syncedRole == null) {
syncedRole = new PentahoRole(proxyRole.getName());
}
syncedRole.setDescription(proxyRole.getDescription());
return syncedRole;
}
use of org.pentaho.platform.security.userroledao.PentahoRole in project pentaho-platform by pentaho.
the class UserRoleDaoEncodeIT method testDeleteRole.
@Test
public void testDeleteRole() throws Exception {
int DEFAULT_ROLE_COUNT = 3;
loginAsRepositoryAdmin();
systemTenant = tenantManager.createTenant(null, ServerRepositoryPaths.getPentahoRootFolderName(), adminRoleName, authenticatedRoleName, "Anonymous");
userRoleDaoProxy.createUser(systemTenant, sysAdminUserName, "password", "", new String[] { adminRoleName });
login(sysAdminUserName, systemTenant, new String[] { adminRoleName, authenticatedRoleName });
mainTenant_1 = tenantManager.createTenant(systemTenant, MAIN_TENANT_1, adminRoleName, authenticatedRoleName, "Anonymous");
userRoleDaoProxy.createUser(mainTenant_1, "admin", "password", "", new String[] { adminRoleName });
mainTenant_2 = 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 });
String role_delim = ((DefaultTenantedPrincipleNameResolver) tenantedRoleNameUtils).getDelimeter();
IPentahoRole pentahoRole = userRoleDaoProxy.createRole(mainTenant_1, ROLE_6, ROLE_DESCRIPTION_6, null);
pentahoRole = userRoleDaoProxy.getRole(null, ROLE_6 + role_delim + mainTenant_1.getRootFolderAbsolutePath());
assertNotNull(pentahoRole);
logout();
login("admin", mainTenant_2, new String[] { adminRoleName, authenticatedRoleName });
try {
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (Throwable th) {
assertNotNull(th);
}
logout();
login("admin", mainTenant_1, new String[] { adminRoleName, authenticatedRoleName });
pentahoRole = userRoleDaoProxy.getRole(null, ROLE_6 + role_delim + mainTenant_1.getRootFolderAbsolutePath());
assertNull(pentahoRole);
assertEquals(DEFAULT_ROLE_COUNT, userRoleDaoProxy.getRoles(mainTenant_1).size());
pentahoRole = userRoleDaoProxy.createRole(null, ROLE_6 + role_delim + mainTenant_1.getRootFolderAbsolutePath(), ROLE_DESCRIPTION_6, null);
pentahoRole = userRoleDaoProxy.getRole(mainTenant_1, ROLE_6);
assertNotNull(pentahoRole);
userRoleDaoProxy.deleteRole(pentahoRole);
assertNull(userRoleDaoProxy.getRole(null, ROLE_6 + role_delim + mainTenant_1.getRootFolderAbsolutePath()));
try {
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (NotFoundException e) {
// Expected exception
}
try {
pentahoRole = new PentahoRole(null, ROLE_6, ROLE_DESCRIPTION_6);
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (Exception ex) {
// Expected exception
}
try {
pentahoRole = new PentahoRole(mainTenant_1, null, ROLE_DESCRIPTION_6);
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (NotFoundException e) {
// Expected exception
}
try {
pentahoRole = new PentahoRole(mainTenant_1, UNKNOWN_ROLE, ROLE_DESCRIPTION_6);
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (NotFoundException e) {
// Expected exception
}
}
use of org.pentaho.platform.security.userroledao.PentahoRole in project pentaho-platform by pentaho.
the class UserRoleDaoIT method testDeleteRole.
@Test
public void testDeleteRole() throws Exception {
int DEFAULT_ROLE_COUNT = 3;
loginAsRepositoryAdmin();
systemTenant = tenantManager.createTenant(null, ServerRepositoryPaths.getPentahoRootFolderName(), adminRoleName, authenticatedRoleName, "Anonymous");
userRoleDaoProxy.createUser(systemTenant, sysAdminUserName, "password", "", new String[] { adminRoleName });
login(sysAdminUserName, systemTenant, new String[] { adminRoleName, authenticatedRoleName });
mainTenant_1 = tenantManager.createTenant(systemTenant, MAIN_TENANT_1, adminRoleName, authenticatedRoleName, "Anonymous");
userRoleDaoProxy.createUser(mainTenant_1, "admin", "password", "", new String[] { adminRoleName });
mainTenant_2 = 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 });
String role_delim = ((DefaultTenantedPrincipleNameResolver) tenantedRoleNameUtils).getDelimeter();
IPentahoRole pentahoRole = userRoleDaoProxy.createRole(mainTenant_1, ROLE_6, ROLE_DESCRIPTION_6, null);
pentahoRole = userRoleDaoProxy.getRole(null, ROLE_6 + role_delim + mainTenant_1.getRootFolderAbsolutePath());
assertNotNull(pentahoRole);
logout();
login("admin", mainTenant_2, new String[] { adminRoleName, authenticatedRoleName });
try {
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (Throwable th) {
assertNotNull(th);
}
logout();
login("admin", mainTenant_1, new String[] { adminRoleName, authenticatedRoleName });
pentahoRole = userRoleDaoProxy.getRole(null, ROLE_6 + role_delim + mainTenant_1.getRootFolderAbsolutePath());
assertNull(pentahoRole);
assertEquals(DEFAULT_ROLE_COUNT, userRoleDaoProxy.getRoles(mainTenant_1).size());
pentahoRole = userRoleDaoProxy.createRole(null, ROLE_6 + role_delim + mainTenant_1.getRootFolderAbsolutePath(), ROLE_DESCRIPTION_6, null);
pentahoRole = userRoleDaoProxy.getRole(mainTenant_1, ROLE_6);
assertNotNull(pentahoRole);
userRoleDaoProxy.deleteRole(pentahoRole);
assertNull(userRoleDaoProxy.getRole(null, ROLE_6 + role_delim + mainTenant_1.getRootFolderAbsolutePath()));
try {
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (NotFoundException e) {
// Expected exception
}
try {
pentahoRole = new PentahoRole(null, ROLE_6, ROLE_DESCRIPTION_6);
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (Exception ex) {
// Expected exception
}
try {
pentahoRole = new PentahoRole(mainTenant_1, null, ROLE_DESCRIPTION_6);
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (NotFoundException e) {
// Expected exception
}
try {
pentahoRole = new PentahoRole(mainTenant_1, UNKNOWN_ROLE, ROLE_DESCRIPTION_6);
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (NotFoundException e) {
// Expected exception
}
}
Aggregations