if(debugPrefs==null && LowLevelGrouperCapableAction.getCookie("grouperDebugPrefs",request)!=null) { try { debugPrefs = LowLevelGrouperCapableAction.readDebugPrefs(request); }catch(Exception e){} }
	public void doFilter(ServletRequest req, ServletResponse res,			FilterChain chain) throws IOException, ServletException {		HttpServletRequest request = (HttpServletRequest) req;		HttpServletResponse response = (HttpServletResponse) res;		HttpSession session = request.getSession();		UIThreadLocal.clear();		UIThreadLocal.put("navResource", new ArrayList());		UIThreadLocal.put("dynamicTiles", new ArrayList());		Map debugPrefs = (Map) session.getAttribute("debugPrefs");		if (debugPrefs != null) {			Boolean doShowResourcesInSitu = (Boolean) debugPrefs					.get("doShowResourcesInSitu");			if (Boolean.TRUE.equals(doShowResourcesInSitu)) {				UIThreadLocal.put("doShowResourcesInSitu", Boolean.TRUE);			} else {				UIThreadLocal.put("doShowResourcesInSitu", Boolean.FALSE);			}		}		Cookie[] cookies = request.getCookies();		boolean loggedOut = false;		if (cookies != null) {			for (int i = 0; i < cookies.length; i++) {				if ("_grouper_loggedOut".equals(cookies[i].getName())) {										//If pending and RemoteUser set then login					//was successful - so clear cookie					if ("pending".equals(cookies[i].getValue())							&& request.getRemoteUser() != null) {						cookies[i].setMaxAge(0);						response.addCookie(cookies[i]);						response.setHeader("GrouperRelogin", "true");					} else {						loggedOut = true;					}				}			}		}		String servletPath = request.getServletPath();		int lastSlash = servletPath.lastIndexOf("/");		String actionStr = servletPath.substring(lastSlash);		String moduleStr = "";		if (lastSlash > 1) {			moduleStr = servletPath.substring(1, lastSlash);		}		String authUser = (String) session.getAttribute("authUser");		boolean noCheck = ignore.indexOf(":" + actionStr + ":") > -1;		if (noCheck || authUser != null || loggedOut) {			if (authUser != null					&& session.getAttribute("sessionInited") == null) {				try {					SessionInitialiser.init(request);				} catch (Exception e) {					throw new ServletException(e);				}			}			Date before = new Date();			chain.doFilter(req, res);			Date after = new Date();			if (log != null) {				String timingsClass = (String) request						.getAttribute("timingsClass");				Long ms = (Long) request.getAttribute("timingsMS");				if (ms != null) {					long diff = after.getTime() - before.getTime();					long mss = ms.longValue();					long renderMs = diff - mss;					log.debug(request.getServletPath() + "," + timingsClass							+ "," + diff + "," + mss + "," + renderMs);				}			}			return;		}		String remoteUser = request.getRemoteUser();		if (remoteUser == null || remoteUser.length() == 0) {			response.sendRedirect(request.getContextPath() + failureUrl					+ moduleStr);			return;		}		edu.internet2.middleware.subject.Subject subj = null;		Source source = null;		try {			subj = SubjectFactory.getSubjectByIdentifier(remoteUser);		} catch (Exception e) {			throw new IOException(remoteUser + " is not recognised");		}		session.setAttribute("authUser", remoteUser);		//edu.internet2.middleware.subject.Subject subj =		// GrouperSubject.load(remoteUser, Grouper.DEF_SUBJ_TYPE);		GrouperSession s = GrouperSession.start(subj);		Map subjMap = GrouperHelper.subject2Map(subj);		request.getSession().setAttribute("AuthSubject", subjMap);		request.getSession().setAttribute(				"edu.intenet2.middleware.grouper.ui.GrouperSession", s);		//request.setAttribute("message",new		// Message("auth.message.login-welcome",remoteUser));		try {			SessionInitialiser.init(request);		} catch (Exception e) {			throw new ServletException(e);		}		chain.doFilter(req, res);	}