use of org.pentaho.platform.api.engine.security.userroledao.IPentahoRole in project pentaho-platform by pentaho.
the class MockUserRoleDao method setRoleDescription.
public void setRoleDescription(ITenant tenant, String roleName, String description) throws NotFoundException, UncategorizedUserRoleDaoException {
IPentahoRole role = getRole(tenant, roleName);
if (role == null) {
throw new NotFoundException(roleName);
}
role.setDescription(description);
}
use of org.pentaho.platform.api.engine.security.userroledao.IPentahoRole in project pentaho-platform by pentaho.
the class MockUserRoleDao method createRole.
public IPentahoRole createRole(ITenant tenant, String roleName, String description, String[] memberUserNames) throws AlreadyExistsException, UncategorizedUserRoleDaoException {
if (tenant == null) {
tenant = getTenant(roleName, false);
roleName = getPrincipalName(roleName, false);
}
if (tenant == null || tenant.getId() == null) {
tenant = getCurrentTenant();
}
addTenant(tenant);
MockPentahoRole role = null;
HashSet<IPentahoRole> set = tenantRoles.get(tenant);
if (set != null) {
for (IPentahoRole iRole : set) {
if (iRole.getName() == roleName) {
role = (MockPentahoRole) iRole;
}
}
}
if (role == null) {
role = new MockPentahoRole(tenant, roleName, description);
}
if (!tenantRoles.get(tenant).contains(role)) {
tenantRoles.get(tenant).add(role);
roleMembers.put(role, new HashSet<IPentahoUser>());
} else {
throw new AlreadyExistsException(roleName.toString());
}
setRoleMembers(tenant, roleName, memberUserNames);
return role;
}
use of org.pentaho.platform.api.engine.security.userroledao.IPentahoRole in project pentaho-platform by pentaho.
the class MockUserRoleDao method setUserRoles.
public void setUserRoles(ITenant tenant, String userName, String[] roleNames) throws NotFoundException, UncategorizedUserRoleDaoException {
if (tenant == null) {
tenant = getTenant(userName, true);
userName = getPrincipalName(userName, true);
}
if (tenant == null || tenant.getId() == null) {
tenant = getCurrentTenant();
}
Set<String> roleSet = new HashSet<String>();
if (roleNames != null) {
roleSet.addAll(Arrays.asList(roleNames));
}
roleSet.add(authenticatedRoleName);
IPentahoRole authRole = getRole(tenant, authenticatedRoleName);
IPentahoUser user = getUser(tenant, userName);
roleMembers.get(authRole).add(user);
HashSet<IPentahoRole> roles = userRoles.get(user);
roles.clear();
for (String roleName : roleSet) {
IPentahoRole role = getRole(tenant, roleName);
if (role != null) {
roles.add(role);
roleMembers.get(role).add(user);
}
}
}
use of org.pentaho.platform.api.engine.security.userroledao.IPentahoRole in project pentaho-platform by pentaho.
the class MockUserRoleDao method getRoleMembers.
public List<IPentahoUser> getRoleMembers(ITenant tenant, String roleName) throws UncategorizedUserRoleDaoException {
if (tenant == null) {
tenant = getTenant(roleName, false);
roleName = getPrincipalName(roleName, false);
}
if (tenant == null || tenant.getId() == null) {
tenant = getCurrentTenant();
}
IPentahoRole role = getRole(tenant, roleName);
return Collections.list(Collections.enumeration(roleMembers.get(role)));
}
use of org.pentaho.platform.api.engine.security.userroledao.IPentahoRole in project pentaho-platform by pentaho.
the class MockUserRoleDao method getRoles.
public List<IPentahoRole> getRoles(ITenant tenant, boolean includeSubTenants) throws UncategorizedUserRoleDaoException {
ArrayList<IPentahoRole> roles = new ArrayList<IPentahoRole>();
roles.addAll(getRoles(tenant));
if (includeSubTenants) {
for (ITenant tmpTenant : tenants) {
if (tmpTenant.getRootFolderAbsolutePath().startsWith(tenant.getRootFolderAbsolutePath() + "/", 0)) {
roles.addAll(getRoles(tmpTenant));
}
}
}
return roles;
}
Aggregations