@Override public final void sessionCreated(HttpSessionEvent httpSessionEvent) { if (backend.getConfiguration().shouldGenerateSessionId()) { final String sessionId = httpSessionEvent.getSession().getId(); backend.put(TraceeConstants.SESSION_ID_KEY, anonymizedSessionKey(sessionId, backend.getConfiguration().generatedSessionIdLength())); } }
void httpRequestInitialized(HttpServletRequest request) { final TraceeFilterConfiguration configuration = backend.getConfiguration(); if (configuration.shouldProcessContext(IncomingRequest)) { mergeIncomingContextToBackend(request); } if (configuration.shouldGenerateRequestId() && !backend.containsKey(TraceeConstants.REQUEST_ID_KEY)) { backend.put(TraceeConstants.REQUEST_ID_KEY, Utilities.createRandomAlphanumeric(configuration.generatedRequestIdLength())); } if (configuration.shouldGenerateSessionId() && !backend.containsKey(TraceeConstants.SESSION_ID_KEY)) { final HttpSession session = request.getSession(false); if (session != null) { backend.put(TraceeConstants.SESSION_ID_KEY, anonymizedSessionKey(session.getId(), configuration.generatedSessionIdLength())); } } }
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception { final TraceeFilterConfiguration configuration = backend.getConfiguration(profileName); if (configuration.shouldProcessContext(IncomingRequest)) mergeIncomingContextToBackend(request, configuration); // create random RequestId if not already set if (!backend.containsKey(TraceeConstants.REQUEST_ID_KEY) && configuration.shouldGenerateRequestId()) { backend.put(TraceeConstants.REQUEST_ID_KEY, Utilities.createRandomAlphanumeric(configuration.generatedRequestIdLength())); } // create another random id to identify the http session if (!backend.containsKey(TraceeConstants.SESSION_ID_KEY) && configuration.shouldGenerateSessionId()) { final HttpSession session = request.getSession(false); if (session != null) { backend.put(TraceeConstants.SESSION_ID_KEY, Utilities.createAlphanumericHash(session.getId(), configuration.generatedSessionIdLength())); } } return true; }