Commit 89e051f5 authored by Alinga Yeung's avatar Alinga Yeung
Browse files

Story ac2. Added PasswordServlet to provide setPassword service.

parent 469163fc
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -236,6 +236,34 @@ public class LdapUserPersistence<T extends Principal>
        }
    }

    /**
     * Update a user's password. The given user and authenticating user must match.
     *
     * @param user
     * @param oldPassword   current password.
     * @param newPassword   new password.
     * @throws UserNotFoundException If the given user does not exist.
     * @throws TransientException   If an temporary, unexpected problem occurred.
     * @throws AccessControlException If the operation is not permitted.
     */
    public void setPassword(User<T> user, final String oldPassword, final String newPassword)
            throws UserNotFoundException, TransientException, AccessControlException
    {
        LdapUserDAO<T> userDAO = null;
        try
        {
            userDAO = new LdapUserDAO<T>(this.config);
            userDAO.setPassword(user, oldPassword, newPassword);
        }
        finally
        {
            if (userDAO != null)
            {
                userDAO.close();
            }
        }
    }
    
    /**
     * Delete the user specified by userID.
     *