public void sessionDestroyed(final HttpSessionEvent event) { if (sessionMappingStorage == null) { sessionMappingStorage = GeoServerCasAuthenticationFilter.getHandler().getSessionMappingStorage(); } final HttpSession session = event.getSession(); sessionMappingStorage.removeBySessionById(session.getId()); } }
@Override public GeoServerSecurityFilter createFilter(SecurityNamedServiceConfig config) { return new GeoServerCasAuthenticationFilter(pgtStorage); }
/** */ @Override protected String getPreAuthenticatedPrincipalName(HttpServletRequest request) { Assertion assertion = getCASAssertion(request); if (assertion==null) return null; request.setAttribute(GeoServerCasConstants.CAS_ASSERTION_KEY,assertion); return assertion.getPrincipal().getName(); }
HttpServletResponse httpRes = (HttpServletResponse) res; SingleSignOutHandler handler = getHandler(); if (isLogoutRequest(httpReq)) { if (singleSignOut) { // do we participate LOGGER.info("Single Sign Out received from CAS server --> starting log out"); LogoutFilterChain logOutChain = (LogoutFilterChain) getSecurityManager() .getSecurityConfig() .getFilterChain() .getRequestChainByName("webLogout"); logOutChain.doLogout(getSecurityManager(), httpReq, httpRes, getName()); handler.process(httpReq, httpRes); } else LOGGER.info("Single Sign Out received from CAS server --> ignoring");
HttpServletResponse httpRes= (HttpServletResponse) res; SingleSignOutHandler handler = getHandler(); handler.destroySession(httpReq); LogoutFilterChain logOutChain = (LogoutFilterChain) getSecurityManager().getSecurityConfig().getFilterChain().getRequestChainByName("webLogout"); logOutChain.doLogout(getSecurityManager(), httpReq, httpRes,getName()); } else LOGGER.info("Single Sign Out received from CAS server --> ignoring"); getHandler().recordSession(httpReq); if (LOGGER.isLoggable(Level.INFO)) LOGGER.info("Record HTTP Session "+session.getId()+ " for CAS single sign out");
protected Assertion getCASAssertion(HttpServletRequest request) { String ticket = request.getParameter(GeoServerCasConstants.ARTIFACT_PARAMETER); if (ticket==null) return null; if ((ticket.startsWith(GeoServerCasConstants.PROXY_TICKET_PREFIX) || ticket.startsWith(GeoServerCasConstants.SERVICE_TICKET_PREFIX))==false) return null; try { String service = retrieveService(request); return validator.validate(ticket,service ); } catch (TicketValidationException e) { LOGGER.warning(e.getMessage()); } return null; }
getSecurityManager().loadFilter(casFilterName); casFilter.doFilter(request, response, chain); assertEquals(HttpServletResponse.SC_OK, response.getErrorCode()); assertTrue(response.wasRedirectSent());
protected Assertion getCASAssertion(HttpServletRequest request) { String ticket = request.getParameter(GeoServerCasConstants.ARTIFACT_PARAMETER); if (ticket == null) return null; if ((ticket.startsWith(GeoServerCasConstants.PROXY_TICKET_PREFIX) || ticket.startsWith(GeoServerCasConstants.SERVICE_TICKET_PREFIX)) == false) return null; try { String service = retrieveService(request); return validator.validate(ticket, service); } catch (TicketValidationException e) { LOGGER.warning(e.getMessage()); } return null; }
public void sessionDestroyed(final HttpSessionEvent event) { if (sessionMappingStorage == null) { sessionMappingStorage = GeoServerCasAuthenticationFilter.getHandler().getSessionMappingStorage(); } final HttpSession session = event.getSession(); sessionMappingStorage.removeBySessionById(session.getId()); }
sp.setService(GeoServerCasAuthenticationFilter.retrieveService(request));
/** */ @Override protected String getPreAuthenticatedPrincipalName(HttpServletRequest request) { Assertion assertion = getCASAssertion(request); if (assertion == null) return null; request.setAttribute(GeoServerCasConstants.CAS_ASSERTION_KEY, assertion); return assertion.getPrincipal().getName(); }
@Override public GeoServerSecurityFilter createFilter(SecurityNamedServiceConfig config) { return new GeoServerCasAuthenticationFilter(pgtStorage); }
protected String getPreAuthenticatedPrincipal(HttpServletRequest request) { String principal = super.getPreAuthenticatedPrincipal(request); HttpSession session = request.getSession(false); if (principal!=null && session!=null) { session.setAttribute(GeoServerCasConstants.CAS_ASSERTION_KEY, request.getAttribute(GeoServerCasConstants.CAS_ASSERTION_KEY)); request.removeAttribute(GeoServerCasConstants.CAS_ASSERTION_KEY); getHandler().recordSession(request); } if (principal==null) { request.removeAttribute(GeoServerCasConstants.CAS_ASSERTION_KEY); } return principal; }
sp.setService(GeoServerCasAuthenticationFilter.retrieveService(request));
protected String getPreAuthenticatedPrincipal(HttpServletRequest request) { String principal = super.getPreAuthenticatedPrincipal(request); HttpSession session = request.getSession(false); if (principal != null && session != null) { session.setAttribute( GeoServerCasConstants.CAS_ASSERTION_KEY, request.getAttribute(GeoServerCasConstants.CAS_ASSERTION_KEY)); request.removeAttribute(GeoServerCasConstants.CAS_ASSERTION_KEY); getHandler().process(request, null); } if (principal == null) { request.removeAttribute(GeoServerCasConstants.CAS_ASSERTION_KEY); } return principal; }
assertTrue(auth.getAuthorities().contains(new GeoServerRole(rootRole))); assertTrue(auth.getAuthorities().contains(new GeoServerRole(derivedRole))); assertNotNull(GeoServerCasAuthenticationFilter.getHandler().getSessionMappingStorage() .removeSessionByMappingId(ticket)); helper.ssoLogout(); assertEquals(username, auth.getPrincipal()); assertEquals(1, auth.getAuthorities().size()); assertNotNull(GeoServerCasAuthenticationFilter.getHandler().getSessionMappingStorage() .removeSessionByMappingId(ticket)); helper.ssoLogout(); assertTrue(auth.getAuthorities().size() == 1); assertTrue(auth.getAuthorities().contains(GeoServerRole.ADMIN_ROLE)); assertNotNull(GeoServerCasAuthenticationFilter.getHandler().getSessionMappingStorage() .removeSessionByMappingId(ticket)); helper.ssoLogout(); assertNull(ctx); assertNull(SecurityContextHolder.getContext().getAuthentication()); assertNull(GeoServerCasAuthenticationFilter.getHandler().getSessionMappingStorage() .removeSessionByMappingId(ticket)); updateUser("ug1", username, true); assertNull(ctx); assertNull(SecurityContextHolder.getContext().getAuthentication()); assertNull(GeoServerCasAuthenticationFilter.getHandler().getSessionMappingStorage() .removeSessionByMappingId(ticket)); helper.ssoLogout();
assertNotNull(request.getAttribute(GeoServerCasConstants.CAS_ASSERTION_KEY)); assertNull(GeoServerCasAuthenticationFilter.getHandler().getSessionMappingStorage() .removeSessionByMappingId(ticket)); helper.ssoLogout();
assertNull(request.getSession(false)); assertNull(GeoServerCasAuthenticationFilter.getHandler().getSessionMappingStorage() .removeSessionByMappingId(proxyTicket)); helper.ssoLogout();