01: package com.nabhinc.portlet.useradmin;
02:
03: import java.io.IOException;
04:
05: import javax.portlet.ActionRequest;
06: import javax.portlet.ActionResponse;
07: import javax.portlet.PortletException;
08:
09: import com.nabhinc.portal.spi.UserAdminServiceLocator;
10: import com.nabhinc.portlet.mvcportlet.core.ActionConfig;
11: import com.nabhinc.portlet.mvcportlet.core.ActionProcessor;
12: import com.nabhinc.portlet.mvcportlet.core.BaseRequestProcessor;
13: import com.nabhinc.spi.UserAdminService;
14: import com.nabhinc.util.StringUtil;
15:
16: public class ResetPassword extends BaseRequestProcessor implements
17: ActionProcessor {
18:
19: public String process(ActionRequest request,
20: ActionResponse response, ActionConfig actionConfig)
21: throws PortletException, IOException {
22:
23: UserAdminService adminService = UserAdminServiceLocator
24: .getUserAdminService();
25: if (adminService == null) {
26: throw new PortletException(
27: "Cannot create user since user admin service is not running");
28: }
29:
30: String userName = request.getParameter("username");
31: if (StringUtil.isNullOrEmpty(userName))
32: return "user-not-found";
33:
34: String newPassword = request.getParameter("newpassword");
35: if (StringUtil.isNullOrEmpty(newPassword)) {
36: return "blank-new-password";
37: }
38: String confirmPassword = request
39: .getParameter("confirmpassword");
40: if (StringUtil.isNullOrEmpty(newPassword)) {
41: return "blank-confirm-password";
42: }
43:
44: if (!newPassword.equals(confirmPassword))
45: return "password-mismatch";
46:
47: adminService.setPassword(userName, newPassword);
48:
49: return "reset-success";
50: }
51:
52: }
|