@Override
  public String doAction(HttpServletRequest request) {
    HttpSession session = request.getSession(true);
    MainSessionController controller =
        (MainSessionController)
            session.getAttribute(MainSessionController.MAIN_SESSION_CONTROLLER_ATT);
    if (controller == null) {
      return "/Login.jsp";
    }

    SettingBundle settings =
        ResourceLocator.getSettingBundle(
            "org.silverpeas.authentication.settings.passwordExpiration");
    String passwordChangeURL =
        settings.getString("passwordChangeURL", "/defaultPasswordAboutToExpire.jsp");

    UserDetail ud = controller.getCurrentUserDetail();
    try {
      String login = ud.getLogin();
      String domainId = ud.getDomainId();
      String oldPassword = request.getParameter("oldPassword");
      String newPassword = request.getParameter("newPassword");
      AuthenticationCredential credential =
          AuthenticationCredential.newWithAsLogin(login)
              .withAsPassword(oldPassword)
              .withAsDomainId(domainId);
      AuthenticationService authenticator = AuthenticationServiceProvider.getService();
      authenticator.changePassword(credential, newPassword);

      GraphicElementFactory gef =
          (GraphicElementFactory)
              session.getAttribute(GraphicElementFactory.GE_FACTORY_SESSION_ATT);
      String favoriteFrame = gef.getLookFrame();

      return "/Main/" + favoriteFrame;
    } catch (AuthenticationException e) {
      SilverTrace.error(
          "peasCore",
          "effectiveChangePasswordHandler.doAction()",
          "peasCore.EX_USER_KEY_NOT_FOUND",
          e);
      return performUrlChangePasswordError(request, passwordChangeURL, ud);
    }
  }
Ejemplo n.º 2
0
 public String getIconsPath() {
   return GraphicElementFactory.getIconsPath();
 }