protected void login( ThemeDisplay themeDisplay, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { HttpServletRequest request = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(actionRequest)); HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse); String login = ParamUtil.getString(actionRequest, "login"); String password = actionRequest.getParameter("password"); boolean rememberMe = ParamUtil.getBoolean(actionRequest, "rememberMe"); if (!themeDisplay.isSignedIn()) { String portletId = PortalUtil.getPortletId(actionRequest); PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getStrictPortletSetup(themeDisplay.getLayout(), portletId); String authType = portletPreferences.getValue("authType", null); AuthenticatedSessionManagerUtil.login( request, response, login, password, rememberMe, authType); } String redirect = ParamUtil.getString(actionRequest, "redirect"); if (Validator.isNotNull(redirect)) { redirect = PortalUtil.escapeRedirect(redirect); if (Validator.isNotNull(redirect) && !redirect.startsWith(Http.HTTP)) { redirect = getCompleteRedirectURL(request, redirect); } } String mainPath = themeDisplay.getPathMain(); if (PropsValues.PORTAL_JAAS_ENABLE) { if (Validator.isNotNull(redirect)) { redirect = mainPath.concat("/portal/protected?redirect=").concat(HttpUtil.encodeURL(redirect)); } else { redirect = mainPath.concat("/portal/protected"); } actionResponse.sendRedirect(redirect); } else { if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } else { boolean doActionAfterLogin = ParamUtil.getBoolean(actionRequest, "doActionAfterLogin"); if (doActionAfterLogin) { return; } else { actionResponse.sendRedirect(mainPath); } } } }
protected void sendRedirect( ActionRequest actionRequest, ActionResponse actionResponse, ThemeDisplay themeDisplay, String login, String password) throws Exception { HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest); String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse); AuthenticatedSessionManagerUtil.login(request, response, login, password, false, null); } else { PortletURL loginURL = LoginUtil.getLoginURL(request, themeDisplay.getPlid()); loginURL.setParameter("login", login); redirect = loginURL.toString(); } actionResponse.sendRedirect(redirect); }
protected void sendRedirect( ActionRequest actionRequest, ActionResponse actionResponse, ThemeDisplay themeDisplay, User user, String password) throws Exception { String login = null; Company company = themeDisplay.getCompany(); String authType = company.getAuthType(); if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) { login = String.valueOf(user.getUserId()); } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) { login = user.getScreenName(); } else { login = user.getEmailAddress(); } HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest); String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse); AuthenticatedSessionManagerUtil.login(request, response, login, password, false, null); } else { PortletURL loginURL = LoginUtil.getLoginURL(request, themeDisplay.getPlid()); loginURL.setParameter("login", login); redirect = loginURL.toString(); } actionResponse.sendRedirect(redirect); }