/** * Setup and maintain profiler context to be used to reap rule caches * for principals on session end. * * @param context request context * @throws ProfilerException when subject or principal not available */ private void setupProfilerContext(RequestContext context) throws ProfilerException { // validate profiler context ProfilerContext profilerContext = (ProfilerContext) context.getSessionAttribute(PROFILER_CONTEXT_ATTRIBUTE_NAME); try { // access session principal and test for change Principal principal = SubjectHelper.getBestPrincipal(context.getSubject(), UserSubjectPrincipal.class); if (principal == null) { throw new NullPointerException("Principal not found"); } if ((profilerContext == null) || (profilerContext.getPrincipal() != principal)) { // setup/reset profiler context context.setSessionAttribute(PROFILER_CONTEXT_ATTRIBUTE_NAME, new ProfilerContext(this, principal)); } } catch (Exception e) { String message = "Unable to access principal in pipeline: " + e; log.error(message, e); throw new ProfilerException(message, e); } }
/** * Notifies this context that it is being unbound * from a session and identifies the session. * * @param event session binding event */ public void valueUnbound(HttpSessionBindingEvent event) { evictPrincipal(); }
/** * Notification that the session is about to be passivated. * * @param event session activation event */ public void sessionWillPassivate(HttpSessionEvent event) { evictPrincipal(); }