use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.
the class AbstractJcrBackedUserRoleDao method setPassword.
public void setPassword(Session session, final ITenant theTenant, final String userName, final String password) throws NotFoundException, RepositoryException {
User jackrabbitUser = getJackrabbitUser(theTenant, userName, session);
if ((jackrabbitUser == null) || !TenantUtils.isAccessibleTenant(theTenant == null ? tenantedUserNameUtils.getTenant(jackrabbitUser.getID()) : theTenant)) {
throw new NotFoundException(Messages.getInstance().getString("AbstractJcrBackedUserRoleDao.ERROR_0003_USER_NOT_FOUND"));
}
jackrabbitUser.changePassword(password);
/**
* BISERVER-9906 Clear cache after changing password
*/
purgeUserFromCache(userName);
userCache.remove(jackrabbitUser.getID());
}
use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.
the class AbstractJcrBackedUserRoleDao method deleteUser.
public void deleteUser(Session session, final IPentahoUser user) throws NotFoundException, RepositoryException {
if (canDeleteUser(session, user)) {
User jackrabbitUser = getJackrabbitUser(user.getTenant(), user.getUsername(), session);
if (jackrabbitUser != null && TenantUtils.isAccessibleTenant(tenantedUserNameUtils.getTenant(jackrabbitUser.getID()))) {
// [BISERVER-9215] Adding new user with same user name as a previously deleted user, defaults to all
// previous
// roles
Iterator<Group> currentGroups = jackrabbitUser.memberOf();
while (currentGroups.hasNext()) {
currentGroups.next().removeMember(jackrabbitUser);
}
purgeUserFromCache(user.getUsername());
// [BISERVER-9215]
jackrabbitUser.remove();
} else {
// $NON-NLS-1$
throw new NotFoundException("");
}
} else {
throw new RepositoryException(Messages.getInstance().getString("AbstractJcrBackedUserRoleDao.ERROR_0004_LAST_USER_NEEDED_IN_ROLE", tenantAdminRoleName));
}
}
use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.
the class AbstractJcrBackedUserRoleDao method deleteRole.
public void deleteRole(Session session, final IPentahoRole role) throws NotFoundException, RepositoryException {
if (canDeleteRole(session, role)) {
final List<IPentahoUser> roleMembers = this.getRoleMembers(session, role.getTenant(), role.getName());
Group jackrabbitGroup = getJackrabbitGroup(role.getTenant(), role.getName(), session);
if (jackrabbitGroup != null && TenantUtils.isAccessibleTenant(tenantedRoleNameUtils.getTenant(jackrabbitGroup.getID()))) {
jackrabbitGroup.remove();
} else {
// $NON-NLS-1$
throw new NotFoundException("");
}
for (IPentahoUser roleMember : roleMembers) {
purgeUserFromCache(roleMember.getUsername());
}
} else {
throw new RepositoryException(Messages.getInstance().getString("AbstractJcrBackedUserRoleDao.ERROR_0007_ATTEMPTED_SYSTEM_ROLE_DELETE"));
}
}
use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.
the class JcrRoleAuthorizationPolicyRoleBindingDao method setRoleBindings.
@Override
public void setRoleBindings(final ITenant tenant, final String runtimeRoleName, final List<String> logicalRoleNames) {
ITenant tempTenant = tenant;
if (tenant == null) {
tempTenant = JcrTenantUtils.getTenant(runtimeRoleName, false);
}
if (!TenantUtils.isAccessibleTenant(tempTenant)) {
throw new NotFoundException("Tenant " + tenant.getId() + " not found");
}
Assert.notNull(logicalRoleNames);
jcrTemplate.execute(new JcrCallback() {
@Override
public Object doInJcr(final Session session) throws RepositoryException, IOException {
setRoleBindings(session, tenant, runtimeRoleName, logicalRoleNames);
return null;
}
});
}
use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.
the class UserRoleDaoResourceTest method testAssignRoleToUserNotFoundException.
@Test
public void testAssignRoleToUserNotFoundException() {
String user = "testUser1";
String roles = "testRole1";
doThrow(new NotFoundException("expectedTestException")).when(userRoleService).assignRolesToUser(anyString(), anyString());
try {
userRoleResource.assignRolesToUser(user, roles);
} catch (WebApplicationException e) {
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e.getResponse().getStatus());
}
}
Aggregations