List of usage examples for com.liferay.portal.util PropsValues AUTH_FORWARD_BY_LAST_PATH
boolean AUTH_FORWARD_BY_LAST_PATH
To view the source code for com.liferay.portal.util PropsValues AUTH_FORWARD_BY_LAST_PATH.
Click Source Link
From source file:com.labimo.Oauth2Filter.java
License:Open Source License
protected String getLoginRemoteUser(HttpServletRequest request, HttpServletResponse response, HttpSession session, String[] credentials) throws Exception { if ((credentials == null) || (credentials.length != 3)) { return null; }/*from w ww . j a va 2 s .c om*/ String jUsername = credentials[0]; String jPassword = credentials[1]; boolean encPassword = GetterUtil.getBoolean(credentials[2]); if (Validator.isNull(jUsername) || Validator.isNull(jPassword)) { return null; } long userId = GetterUtil.getLong(jUsername); if (userId <= 0) { return null; } User user = UserLocalServiceUtil.fetchUserById(userId); if ((user == null) || user.isLockout()) { return null; } if (PropsValues.SESSION_ENABLE_PHISHING_PROTECTION) { session = LoginUtil.renewSession(request, session); } session.setAttribute("j_username", jUsername); // Not having access to the unencrypted password will not allow you to // connect to external resources that require it (mail server) if (encPassword) { session.setAttribute("j_password", jPassword); } else { session.setAttribute("j_password", PasswordEncryptorUtil.encrypt(jPassword)); if (PropsValues.SESSION_STORE_PASSWORD) { session.setAttribute(WebKeys.USER_PASSWORD, jPassword); } } session.setAttribute("j_remoteuser", jUsername); if (PropsValues.PORTAL_JAAS_ENABLE) { String redirect = PortalUtil.getPathMain().concat("/portal/protected"); if (PropsValues.AUTH_FORWARD_BY_LAST_PATH) { String autoLoginRedirect = (String) request .getAttribute(AutoLogin.AUTO_LOGIN_REDIRECT_AND_CONTINUE); redirect = redirect.concat("?redirect="); if (Validator.isNotNull(autoLoginRedirect)) { redirect = redirect.concat(autoLoginRedirect); } else { redirect = redirect.concat(PortalUtil.getCurrentCompleteURL(request)); } } response.sendRedirect(redirect); } return jUsername; }