@Override public ServletContext getServletContext() { return this.context.getServletContext(); }
public RTopic getTopic() { String separator = keyPrefix == null || keyPrefix.isEmpty() ? "" : ":"; final String name = keyPrefix + separator + "redisson:tomcat_session_updates:" + ((Context) getContainer()).getName(); return redisson.getTopic(name); }
@Override public Principal getPrincipal() { if (this.principal == null && this.serializedPrincipal != null) { SerializablePrincipal sp = null; try { sp = (SerializablePrincipal) BlobHelper.deserializeBlob(this.serializedPrincipal); } catch (Exception e) { StringBuilder builder = new StringBuilder(); builder.append(this).append( ": Serialized principal contains a byte[] that cannot be deserialized due to the following exception"); ((DeltaSessionManager) getManager()).getLogger().warn(builder.toString(), e); return null; } this.principal = sp.getPrincipal(((DeltaSessionManager) this.manager).getTheContext().getRealm()); if (getManager() != null) { DeltaSessionManager mgr = (DeltaSessionManager) getManager(); if (mgr.getLogger().isDebugEnabled()) { mgr.getLogger().debug(this + ": Deserialized principal: " + this.principal); // mgr.logCurrentStack(); } } } return this.principal; }
ContextInfo makeContextInfo(Context context) { // copy to another object -- not the important part final ContextInfo info = new ContextInfo(context.getPath()); info.setThisPart(context.getThisPart()); info.setNotImportant(context.getNotImportant()); return info; }
public StandardWrapper addServlet(String path, String name, String clazz) throws ServletException { StandardWrapper servlet = (StandardWrapper) rootContext.createWrapper(); servlet.setName(name); servlet.setServletClass(clazz); servlet.setLoadOnStartup(1); rootContext.addChild(servlet); rootContext.addServletMapping(path, name); servlet.setParent(rootContext); // servlet.load(); return servlet; }
@Override public void invoke(Request request, Response response) throws IOException, ServletException { Manager manager = request.getContext().getManager(); DeltaSessionFacade session = null; session = (DeltaSessionFacade) request.getSession(false); DeltaSessionManager dsm = ((DeltaSessionManager) manager); if (session != null) { dsm.removeTouchedSession(session.getId()); session.commit(); if (dsm.getTheContext().getLogger().isDebugEnabled()) { dsm.getTheContext().getLogger().debug(session + ": Committed."); if (dsm.getTheContext().getLogger().isDebugEnabled()) { dsm.getTheContext().getLogger().debug(session + ": Not valid so not committing.");
getServingLayer().getContext().getServletContext().getAttribute(OryxResource.INPUT_PRODUCER_KEY);
/** * Gets the application attributes. * * @param context the context * @return the application attributes */ public static List<Attribute> getApplicationAttributes(Context context) { List<Attribute> attrs = new ArrayList<>(); ServletContext servletCtx = context.getServletContext(); for (String attrName : Collections.list(servletCtx.getAttributeNames())) { Object attrValue = servletCtx.getAttribute(attrName); Attribute attr = new Attribute(); attr.setName(attrName); attr.setValue(attrValue); attr.setType(ClassUtils.getQualifiedName(attrValue.getClass())); attrs.add(attr); } return attrs; }
context.setAllowCasualMultipartParsing(true); PippoServlet pippoServlet = new PippoServlet(); pippoServlet.setApplication(getApplication()); Wrapper wrapper = context.createWrapper(); String name = "pippoServlet"; wrapper.setLoadOnStartup(1); wrapper.setServlet(pippoServlet); context.addChild(wrapper); context.addServletMapping(pippoFilterPath, name); context.getServletContext().setAttribute(PIPPO_APPLICATION, getApplication()); context.addApplicationListener(PippoServletContextListener.class.getName()); listeners.forEach(listener -> context.addApplicationListener(listener.getName()));
/** * Called to forward to the error page * * @param request Request we are processing * @param response Response we are creating * @param config Login configuration describing how authentication * should be performed */ protected void forwardToErrorPage(Request request, Response response, LoginConfig config) { RequestDispatcher disp = context.getServletContext().getRequestDispatcher (config.getErrorPage()); try { disp.forward(request.getRequest(), response.getResponse()); } catch (Throwable t) { log.warn("Unexpected error forwarding to error page", t); } }
/** * Reset DeltaRequest from session * @param session HttpSession from current request or cross context session */ protected void resetDeltaRequest(Session session) { if(log.isDebugEnabled()) { log.debug(sm.getString("ReplicationValve.resetDeltaRequest" , session.getManager().getContext().getName() )); } ((DeltaSession)session).resetDeltaRequest(); }
/** * get Cluster DeltaManager * * @param request current request * @return manager or null */ protected Manager getManager(Request request) { Manager manager = request.getContext().getManager(); if (log.isDebugEnabled()) { if(manager != null) log.debug(sm.getString("jvmRoute.foundManager", manager, request.getContext().getName())); else log.debug(sm.getString("jvmRoute.notFoundManager", request.getContext().getName())); } return manager; }
private void doConnectorAuthenticationAuthorization(org.apache.coyote.Request req, Request request) { String username = req.getRemoteUser().toString(); if (username != null) { if (log.isDebugEnabled()) { log.debug(sm.getString("coyoteAdapter.authenticate", username)); if (req.getRemoteUserNeedsAuthorization()) { Authenticator authenticator = request.getContext().getAuthenticator(); if (!(authenticator instanceof AuthenticatorBase)) { if (log.isDebugEnabled()) { log.debug(sm.getString("coyoteAdapter.authorize", username)); request.setUserPrincipal( request.getContext().getRealm().authenticate(username)); String authtype = req.getAuthType().toString(); if (authtype != null) { request.setAuthType(authtype);
/** * Notify interested listeners that attribute has been removed. */ private void notifyAttributeRemoved(String name, Object value) { Object listeners[] = context.getApplicationEventListeners(); if ((listeners == null) || (listeners.length == 0)) { return; } ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(context.getServletContext(), getRequest(), name, value); for (int i = 0; i < listeners.length; i++) { if (!(listeners[i] instanceof ServletRequestAttributeListener)) { continue; } ServletRequestAttributeListener listener = (ServletRequestAttributeListener) listeners[i]; try { listener.attributeRemoved(event); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); context.getLogger().error(sm.getString("coyoteRequest.attributeEvent"), t); // Error valve will pick this exception up and display it to user attributes.put(RequestDispatcher.ERROR_EXCEPTION, t); } } }
@Override public void invoke(Request request, Response response) throws IOException, ServletException { String sessionId = request.getRequestedSessionId(); Session session = request.getContext().getManager().findSession(sessionId); if (session != null) { if (!session.isValid()) { session.expire(); request.getContext().getManager().remove(session); } else { manager.add(session); session.access(); session.endAccess(); } } try { getNext().invoke(request, response); } finally { manager.store(request.getSession(false)); } }
public Principal authenticateSSL(Request request, Response response) throws IOException { if (containerLog.isDebugEnabled()) { containerLog.debug(" Looking up certificates"); X509Certificate[] certs = (X509Certificate[]) request.getAttribute(Globals.CERTIFICATES_ATTR); request.getCoyoteRequest().action(ActionCode.ACTION_REQ_SSL_CERTIFICATE, null); } catch (IllegalStateException ise) { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, sm.getString("authenticator.certificates")); return null; certs = (X509Certificate[]) request.getAttribute(Globals.CERTIFICATES_ATTR); if (containerLog.isDebugEnabled()) { containerLog.debug(" No certificates included with this request"); response.sendError(HttpServletResponse.SC_UNAUTHORIZED, sm.getString("authenticator.certificates")); return null; Principal principal = getContext().getRealm().authenticate(certs); containerLog.debug(" Realm.authenticate() returned false"); response.sendError(HttpServletResponse.SC_UNAUTHORIZED, sm.getString("authenticator.unauthorized")); return null;
+ " as s where s.contextName = '" + context.getPath() + "'"); getLogger().debug("Query: " + query.getQueryString()); results = (SelectResults) query.execute(); } catch (Exception ex) { getLogger().error("Unable to perform query during doUnload", ex); return; getLogger().debug("No sessions to unload for context " + context.getPath()); return; // nothing to do File store = sessionStore(context.getPath()); if (store == null) { return;
/** * Attempt to load a class using the given Container's class loader. If the * class cannot be loaded, a debug level log message will be written to the * Container's log and null will be returned. * @param context The class loader of this context will be used to attempt * to load the class * @param className The class name * @return the loaded class or <code>null</code> if loading failed */ public static Class<?> loadClass(Context context, String className) { ClassLoader cl = context.getLoader().getClassLoader(); Log log = context.getLogger(); Class<?> clazz = null; try { clazz = cl.loadClass(className); } catch (ClassNotFoundException | NoClassDefFoundError | ClassFormatError e) { log.debug(sm.getString("introspection.classLoadFailed", className), e); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); log.debug(sm.getString("introspection.classLoadFailed", className), t); } return clazz; }
@Override protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request, HttpServletResponse response) throws Exception { String attrName = ServletRequestUtils.getStringParameter(request, "attr"); context.getServletContext().removeAttribute(attrName); return new ModelAndView(new RedirectView( request.getContextPath() + getViewName() + "?" + request.getQueryString())); }
public boolean timeout() { AtomicBoolean result = new AtomicBoolean(); request.getCoyoteRequest().action(ActionCode.ASYNC_TIMEOUT, result); if (result.get()) { ClassLoader oldCL = Thread.currentThread().getContextClassLoader(); ClassLoader newCL = request.getContext().getLoader().getClassLoader(); try { Thread.currentThread().setContextClassLoader(newCL); List<AsyncListenerWrapper> listenersCopy = new ArrayList<>(); listenersCopy.addAll(listeners); for (AsyncListenerWrapper listener : listenersCopy) { try { listener.fireOnTimeout(event); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); log.warn("onTimeout() failed for listener of type [" + listener.getClass().getName() + "]", t); } } request.getCoyoteRequest().action( ActionCode.ASYNC_IS_TIMINGOUT, result); return !result.get(); } finally { Thread.currentThread().setContextClassLoader(oldCL); } } return true; }