Java Code Examples for org.apache.catalina.connector.Request#removeNote()
The following examples show how to use
org.apache.catalina.connector.Request#removeNote() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpdateValve.java From redisson with Apache License 2.0 | 5 votes |
@Override public void invoke(Request request, Response response) throws IOException, ServletException { if (getNext() == null) { return; } //check if we already filtered/processed this request if (request.getNote(ALREADY_FILTERED_NOTE) == null) { request.setNote(ALREADY_FILTERED_NOTE, Boolean.TRUE); try { getNext().invoke(request, response); } finally { request.removeNote(ALREADY_FILTERED_NOTE); final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); try { ClassLoader applicationClassLoader = request.getContext().getLoader().getClassLoader(); Thread.currentThread().setContextClassLoader(applicationClassLoader); Manager manager = request.getContext().getManager(); ((RedissonSessionManager)manager).store(request.getSession(false)); } finally { Thread.currentThread().setContextClassLoader(classLoader); } } } else { getNext().invoke(request, response); } }
Example 2
Source File: UpdateValve.java From redisson with Apache License 2.0 | 5 votes |
@Override public void invoke(Request request, Response response) throws IOException, ServletException { if (getNext() == null) { return; } //check if we already filtered/processed this request if (request.getNote(ALREADY_FILTERED_NOTE) == null) { request.setNote(ALREADY_FILTERED_NOTE, Boolean.TRUE); try { getNext().invoke(request, response); } finally { request.removeNote(ALREADY_FILTERED_NOTE); final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); try { ClassLoader applicationClassLoader = request.getContext().getLoader().getClassLoader(); Thread.currentThread().setContextClassLoader(applicationClassLoader); Manager manager = request.getContext().getManager(); ((RedissonSessionManager)manager).store(request.getSession(false)); } finally { Thread.currentThread().setContextClassLoader(classLoader); } } } else { getNext().invoke(request, response); } }
Example 3
Source File: UpdateValve.java From redisson with Apache License 2.0 | 5 votes |
@Override public void invoke(Request request, Response response) throws IOException, ServletException { if (getNext() == null) { return; } //check if we already filtered/processed this request if (request.getNote(ALREADY_FILTERED_NOTE) == null) { request.setNote(ALREADY_FILTERED_NOTE, Boolean.TRUE); try { getNext().invoke(request, response); } finally { request.removeNote(ALREADY_FILTERED_NOTE); final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); try { ClassLoader applicationClassLoader = request.getContext().getLoader().getClassLoader(); Thread.currentThread().setContextClassLoader(applicationClassLoader); Manager manager = request.getContext().getManager(); ((RedissonSessionManager)manager).store(request.getSession(false)); } finally { Thread.currentThread().setContextClassLoader(classLoader); } } } else { getNext().invoke(request, response); } }
Example 4
Source File: SingleSignOn.java From Tomcat8-Source-Read with MIT License | 4 votes |
/** * Perform single-sign-on support processing for this request. * * @param request The servlet request we are processing * @param response The servlet response we are creating * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet error occurs */ @Override public void invoke(Request request, Response response) throws IOException, ServletException { request.removeNote(Constants.REQ_SSOID_NOTE); // Has a valid user already been authenticated? if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.invoke", request.getRequestURI())); } if (request.getUserPrincipal() != null) { if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.hasPrincipal", request.getUserPrincipal().getName())); } getNext().invoke(request, response); return; } // Check for the single sign on cookie if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.cookieCheck")); } Cookie cookie = null; Cookie cookies[] = request.getCookies(); if (cookies != null) { for (int i = 0; i < cookies.length; i++) { if (Constants.SINGLE_SIGN_ON_COOKIE.equals(cookies[i].getName())) { cookie = cookies[i]; break; } } } if (cookie == null) { if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.cookieNotFound")); } getNext().invoke(request, response); return; } // Look up the cached Principal associated with this cookie value if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.principalCheck", cookie.getValue())); } SingleSignOnEntry entry = cache.get(cookie.getValue()); if (entry != null) { if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.principalFound", entry.getPrincipal() != null ? entry.getPrincipal().getName() : "", entry.getAuthType())); } request.setNote(Constants.REQ_SSOID_NOTE, cookie.getValue()); // Only set security elements if reauthentication is not required if (!getRequireReauthentication()) { request.setAuthType(entry.getAuthType()); request.setUserPrincipal(entry.getPrincipal()); } } else { if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.principalNotFound", cookie.getValue())); } // No need to return a valid SSO session ID cookie.setValue("REMOVE"); // Age of zero will trigger removal cookie.setMaxAge(0); // Domain and path have to match the original cookie to 'replace' // the original cookie cookie.setPath("/"); String domain = getCookieDomain(); if (domain != null) { cookie.setDomain(domain); } // This is going to trigger a Set-Cookie header. While the value is // not security sensitive, ensure that expectations for secure and // httpOnly are met cookie.setSecure(request.isSecure()); if (request.getServletContext().getSessionCookieConfig().isHttpOnly() || request.getContext().getUseHttpOnly()) { cookie.setHttpOnly(true); } response.addCookie(cookie); } // Invoke the next Valve in our pipeline getNext().invoke(request, response); }
Example 5
Source File: SingleSignOn.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
/** * Perform single-sign-on support processing for this request. * * @param request The servlet request we are processing * @param response The servlet response we are creating * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet error occurs */ @Override public void invoke(Request request, Response response) throws IOException, ServletException { request.removeNote(Constants.REQ_SSOID_NOTE); // Has a valid user already been authenticated? if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.invoke", request.getRequestURI())); } if (request.getUserPrincipal() != null) { if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.hasPrincipal", request.getUserPrincipal().getName())); } getNext().invoke(request, response); return; } // Check for the single sign on cookie if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.cookieCheck")); } Cookie cookie = null; Cookie cookies[] = request.getCookies(); if (cookies != null) { for (int i = 0; i < cookies.length; i++) { if (Constants.SINGLE_SIGN_ON_COOKIE.equals(cookies[i].getName())) { cookie = cookies[i]; break; } } } if (cookie == null) { if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.cookieNotFound")); } getNext().invoke(request, response); return; } // Look up the cached Principal associated with this cookie value if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.principalCheck", cookie.getValue())); } SingleSignOnEntry entry = cache.get(cookie.getValue()); if (entry != null) { if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.principalFound", entry.getPrincipal() != null ? entry.getPrincipal().getName() : "", entry.getAuthType())); } request.setNote(Constants.REQ_SSOID_NOTE, cookie.getValue()); // Only set security elements if reauthentication is not required if (!getRequireReauthentication()) { request.setAuthType(entry.getAuthType()); request.setUserPrincipal(entry.getPrincipal()); } } else { if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.principalNotFound", cookie.getValue())); } // No need to return a valid SSO session ID cookie.setValue("REMOVE"); // Age of zero will trigger removal cookie.setMaxAge(0); // Domain and path have to match the original cookie to 'replace' // the original cookie cookie.setPath("/"); String domain = getCookieDomain(); if (domain != null) { cookie.setDomain(domain); } // This is going to trigger a Set-Cookie header. While the value is // not security sensitive, ensure that expectations for secure and // httpOnly are met cookie.setSecure(request.isSecure()); if (request.getServletContext().getSessionCookieConfig().isHttpOnly() || request.getContext().getUseHttpOnly()) { cookie.setHttpOnly(true); } response.addCookie(cookie); } // Invoke the next Valve in our pipeline getNext().invoke(request, response); }
Example 6
Source File: SingleSignOn.java From tomcatsrc with Apache License 2.0 | 4 votes |
/** * Perform single-sign-on support processing for this request. * * @param request The servlet request we are processing * @param response The servlet response we are creating * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet error occurs */ @Override public void invoke(Request request, Response response) throws IOException, ServletException { request.removeNote(Constants.REQ_SSOID_NOTE); // Has a valid user already been authenticated? if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.invoke", request.getRequestURI())); } if (request.getUserPrincipal() != null) { if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.hasPrincipal", request.getUserPrincipal().getName())); } getNext().invoke(request, response); return; } // Check for the single sign on cookie if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.cookieCheck")); } Cookie cookie = null; Cookie cookies[] = request.getCookies(); if (cookies != null) { for (int i = 0; i < cookies.length; i++) { if (Constants.SINGLE_SIGN_ON_COOKIE.equals(cookies[i].getName())) { cookie = cookies[i]; break; } } } if (cookie == null) { if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.cookieNotFound")); } getNext().invoke(request, response); return; } // Look up the cached Principal associated with this cookie value if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.principalCheck", cookie.getValue())); } SingleSignOnEntry entry = cache.get(cookie.getValue()); if (entry != null) { if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.principalFound", entry.getPrincipal() != null ? entry.getPrincipal().getName() : "", entry.getAuthType())); } request.setNote(Constants.REQ_SSOID_NOTE, cookie.getValue()); // Only set security elements if reauthentication is not required if (!getRequireReauthentication()) { request.setAuthType(entry.getAuthType()); request.setUserPrincipal(entry.getPrincipal()); } } else { if (containerLog.isDebugEnabled()) { containerLog.debug(sm.getString("singleSignOn.debug.principalNotFound", cookie.getValue())); } // No need to return a valid SSO session ID cookie.setValue("REMOVE"); // Age of zero will trigger removal cookie.setMaxAge(0); // Domain and path have to match the original cookie to 'replace' // the original cookie cookie.setPath("/"); String domain = getCookieDomain(); if (domain != null) { cookie.setDomain(domain); } // This is going to trigger a Set-Cookie header. While the value is // not security sensitive, ensure that expectations for secure and // httpOnly are met cookie.setSecure(request.isSecure()); if (request.getServletContext().getSessionCookieConfig().isHttpOnly() || request.getContext().getUseHttpOnly()) { cookie.setHttpOnly(true); } response.addCookie(cookie); } // Invoke the next Valve in our pipeline getNext().invoke(request, response); }