@@ -0,0 +1,2543 @@
+/*%0A * Licensed to the Apache Software Foundation (ASF) under one%0A * or more contributor license agreements.  See the NOTICE file%0A * distributed with this work for additional information%0A * regarding copyright ownership.  The ASF licenses this file%0A * to you under the Apache License, Version 2.0 (the%0A * %22License%22); you may not use this file except in compliance%0A * with the License.  You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.glaf.base.filter;%0A%0Aimport java.io.IOException;%0Aimport java.util.Date;%0A%0Aimport javax.servlet.Filter;%0Aimport javax.servlet.FilterChain;%0Aimport javax.servlet.FilterConfig;%0Aimport javax.servlet.ServletException;%0Aimport javax.servlet.ServletRequest;%0Aimport javax.servlet.ServletResponse;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpSession;%0A%0Apublic class SessionExpirationFilter implements Filter %7B%0A%0A%09public void destroy() %7B%0A%0A%09%7D%0A%0A%09public void doFilter(ServletRequest req, ServletResponse resp,%0A%09%09%09FilterChain chain) throws IOException, ServletException %7B%0A%09%09HttpServletRequest request = (HttpServletRequest) req;%0A%0A%09%09HttpSession session = request.getSession(false);%0A%09%09if (null != session) %7B%0A%09%09%09Date expirationDate = (Date) session.getAttribute(%22expirationDate%22);%0A%0A%09%09%09if (expirationDate == null) %7B%0A%09%09%09%09expirationDate = new Date(System.currentTimeMillis()%0A%09%09%09%09%09%09+ session.getMaxInactiveInterval() * 1000 + 1000000);%0A%09%09%09%7D%0A%0A%09%09%09if (expirationDate.before(new Date())) %7B%0A%09%09%09%09session.invalidate();%0A%09%09%09%09session = null;%0A%09%09%09%7D else %7B%0A%09%09%09%09// ignore requests marked as both ajaxCall and%0A%09%09%09%09// ignoreForSessionTimeout%0A%09%09%09%09String isAjaxCall = request.getParameter(%22IsAjaxCall%22);%0A%09%09%09%09String ignoreForSessionTimeout = request%0A%09%09%09%09%09%09.getParameter(%22ignoreForSessionTimeout%22);%0A%09%09%09%09boolean ignoreForTimeout = %221%22.equals(isAjaxCall)%0A%09%09%09%09%09%09&& (%221%22.equals(ignoreForSessionTimeout));%0A%09%09%09%09if (ignoreForTimeout) %7B%0A%09%09%09%09%09// Do nothing; don't update the session timestamp%0A%09%09%09%09%7D else %7B%0A%09%09%09%09%09session.setAttribute(%0A%09%09%09%09%09%09%09%22expirationDate%22,%0A%09%09%09%09%09%09%09new Date(System.currentTimeMillis()%0A%09%09%09%09%09%09%09%09%09+ session.getMaxInactiveInterval() * 1000));%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%09chain.doFilter(req, resp);%0A%09%7D%0A%0A%09public void init(FilterConfig config) %7B%0A%0A%09%7D%0A%0A%7D

add SessionExpirationFilter