List of usage examples for com.liferay.portal.util PropsValues CAS_LOGOUT_URL
String CAS_LOGOUT_URL
To view the source code for com.liferay.portal.util PropsValues CAS_LOGOUT_URL.
Click Source Link
From source file:com.ext.portal.servlet.filters.sso.cas.CASFilterExt.java
License:Open Source License
@Override protected void processFilter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws Exception { HttpSession session = request.getSession(); long companyId = PortalUtil.getCompanyId(request); String pathInfo = request.getPathInfo(); Object forceLogout = session.getAttribute(WebKeys.CAS_FORCE_LOGOUT); if (forceLogout != null) { session.removeAttribute(WebKeys.CAS_FORCE_LOGOUT); String logoutUrl = PrefsPropsUtil.getString(companyId, PropsKeys.CAS_LOGOUT_URL, PropsValues.CAS_LOGOUT_URL); response.sendRedirect(logoutUrl); return;/*w ww . j a v a 2 s. co m*/ } if (pathInfo.contains("/portal/logout")) { session.invalidate(); String logoutUrl = PrefsPropsUtil.getString(companyId, PropsKeys.CAS_LOGOUT_URL, PropsValues.CAS_LOGOUT_URL); response.sendRedirect(logoutUrl); return; } else { String login = (String) session.getAttribute(WebKeys.CAS_LOGIN); if (Validator.isNotNull(login)) { processFilter(CASFilterExt.class, request, response, filterChain); return; } String serverName = PrefsPropsUtil.getString(companyId, PropsKeys.CAS_SERVER_NAME, PropsValues.CAS_SERVER_NAME); String serviceUrl = PrefsPropsUtil.getString(companyId, PropsKeys.CAS_SERVICE_URL, PropsValues.CAS_SERVICE_URL); if (Validator.isNull(serviceUrl)) { serviceUrl = CommonUtils.constructServiceUrl(request, response, serviceUrl, serverName, "ticket", false); } String ticket = ParamUtil.getString(request, "ticket"); if (Validator.isNull(ticket)) { String loginUrl = PrefsPropsUtil.getString(companyId, PropsKeys.CAS_LOGIN_URL, PropsValues.CAS_LOGIN_URL); loginUrl = HttpUtil.addParameter(loginUrl, "service", serviceUrl); response.sendRedirect(loginUrl); return; } TicketValidator ticketValidator = getTicketValidator(companyId); Assertion assertion = ticketValidator.validate(ticket, serviceUrl); if (assertion != null) { AttributePrincipal attributePrincipal = assertion.getPrincipal(); login = attributePrincipal.getName(); session.setAttribute(WebKeys.CAS_LOGIN, login); // Try to add user if it doesn't exist //_log.info(attributePrincipal); _createUserFromCAS(companyId, login, assertion); } } processFilter(CASFilterExt.class, request, response, filterChain); }
From source file:org.intalio.tempo.web.CASFilter520.java
License:Open Source License
protected void processFilter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) {//from w ww. j a va 2 s . c om try { long companyId = PortalUtil.getCompanyId(request); if (PrefsPropsUtil.getBoolean(companyId, PropsKeys.CAS_AUTH_ENABLED, PropsValues.CAS_AUTH_ENABLED)) { String pathInfo = request.getPathInfo(); if (pathInfo.indexOf("/portal/logout") != -1) { HttpSession session = request.getSession(); session.invalidate(); String logoutUrl = PrefsPropsUtil.getString(companyId, PropsKeys.CAS_LOGOUT_URL, PropsValues.CAS_LOGOUT_URL); response.sendRedirect(logoutUrl); } else { Filter casFilter = getCASFilter(companyId); casFilter.doFilter(request, response, filterChain); } } else { processFilter(CASFilter.class, request, response, filterChain); } } catch (Exception e) { _log.error(e, e); } }