use of org.pentaho.platform.api.engine.security.userroledao.IPentahoUser in project pentaho-platform by pentaho.
the class UserRoleWebService method getUsersForRole.
@Override
public ProxyPentahoUser[] getUsersForRole(ProxyPentahoRole proxyRole) throws UserRoleException {
ArrayList<ProxyPentahoUser> users = new ArrayList<ProxyPentahoUser>();
IPentahoRole role = getDao().getRole(proxyRole.getTenant(), proxyRole.getName());
if (role != null) {
for (IPentahoUser user : getDao().getRoleMembers(proxyRole.getTenant(), proxyRole.getName())) {
users.add(ProxyPentahoUserRoleHelper.toProxyUser(user));
}
} else {
throw new UserRoleException(Messages.getInstance().getErrorString("UserRoleWebService.ERROR_0005_FAILED_TO_FIND_ROLE", // $NON-NLS-1$
proxyRole.getName()));
}
return users.toArray(new ProxyPentahoUser[0]);
}
use of org.pentaho.platform.api.engine.security.userroledao.IPentahoUser in project pentaho-platform by pentaho.
the class MockUserRoleDao method setUserDescription.
public void setUserDescription(ITenant tenant, String userName, String description) throws NotFoundException, UncategorizedUserRoleDaoException {
IPentahoUser user = getUser(tenant, userName);
if (user == null) {
throw new NotFoundException(userName);
}
user.setDescription(description);
}
use of org.pentaho.platform.api.engine.security.userroledao.IPentahoUser 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.IPentahoUser 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.IPentahoUser in project pentaho-platform by pentaho.
the class MockUserRoleDao method getUserRoles.
public List<IPentahoRole> getUserRoles(ITenant tenant, String userName) throws UncategorizedUserRoleDaoException {
if (tenant == null) {
tenant = getTenant(userName, true);
userName = getPrincipalName(userName, true);
}
if (tenant == null || tenant.getId() == null) {
tenant = getCurrentTenant();
}
IPentahoUser user = getUser(tenant, userName);
return Collections.list(Collections.enumeration(userRoles.get(user)));
}
Aggregations