/** * Sets the user's password. * * @param username * the username. * @param password * the password. * * @throws NotFoundException * if specified {@link User} doesn't exist. * @throws IllegalOperationException * if the user is one of the protected users. * @throws GenericException * if some error occurs. */ public void setUserPassword(final String username, final String password) throws IllegalOperationException, NotFoundException, GenericException { final String userDN = getUserDN(username); if (this.rodaGuestDN.equals(userDN) || this.ldapProtectedUsers.contains(username)) { throw new IllegalOperationException(String.format("User (%s) is protected and cannot be modified.", username)); } setUserPasswordUnchecked(username, password); }
/** * Removes a group. * * @param groupname * the name of the group to remove. * @throws IllegalOperationException * if the user is one of the protected users. * @throws GenericException * if some error occurred. */ public void removeGroup(final String groupname) throws GenericException, IllegalOperationException { if (this.rodaAdministratorsDN.equals(getGroupDN(groupname)) || this.ldapProtectedGroups.contains(groupname)) { throw new IllegalOperationException("Group (" + groupname + ") is protected and cannot be removed."); } try { removeMember(service.getAdminSession(), getGroupDN(groupname)); } catch (final LdapException e) { throw new GenericException("Error removing group " + groupname, e); } }
/** * Removes a {@link User}. * * @param username * the name of the user to remove. * * @throws IllegalOperationException * if the user is one of the protected users. * @throws GenericException * if some error occurred. */ public void removeUser(final String username) throws IllegalOperationException, GenericException { final String userDN = getUserDN(username); if (this.rodaAdminDN.equals(userDN) || this.rodaGuestDN.equals(userDN) || this.ldapProtectedUsers.contains(username)) { throw new IllegalOperationException(userMessage(username, " is protected and cannot be removed.")); } try { removeMember(service.getAdminSession(), getUserDN(username)); } catch (final LdapException e) { throw new GenericException("Error removing user " + username, e); } }
throw new IllegalOperationException( String.format("Group (%s) is protected and cannot be modified.", modifiedGroup.getName()));
throw new IllegalOperationException("User (" + modifiedUser.getName() + ") is protected and cannot be modified.");