[java-opensaml COMMIT] /trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/JSONRequestScopedStorageS...

noreply at shibboleth.net noreply at shibboleth.net
Tue Oct 29 00:08:14 EDT 2013


Author: scantor
Date: Tue Oct 29 00:08:14 2013
New Revision: 3490

URL: http://svn.shibboleth.net/view/java-opensaml?rev=3490&view=rev
Log:
Implement Filter interface so Spring filter can delegate to us.

Modified:
    trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/JSONRequestScopedStorageService.java

Modified: trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/JSONRequestScopedStorageService.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/JSONRequestScopedStorageService.java?rev=3490&r1=3489&r2=3490&view=diff
==============================================================================
--- trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/JSONRequestScopedStorageService.java (original)
+++ trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/JSONRequestScopedStorageService.java Tue Oct 29 00:08:14 2013
@@ -37,6 +37,12 @@
 import javax.json.JsonStructure;
 import javax.json.JsonValue;
 import javax.json.stream.JsonGenerator;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -73,7 +79,7 @@
  * and reads and writes the data with a secured string form using JSON as the underlying format.
  */
 public class JSONRequestScopedStorageService extends AbstractMapBackedStorageService
-    implements RequestScopedStorageService {
+    implements RequestScopedStorageService, Filter {
 
     /** Name of request attribute for context map. */
     @Nonnull private static final String CONTEXT_MAP_ATTRIBUTE = 
@@ -222,7 +228,7 @@
 
     /** {@inheritDoc} */
     public void load() throws IOException {
-        log.debug("Loading storage state from cookie in current request");
+        log.trace("Loading storage state from cookie in current request");
         
         getContextMap().clear();
         setDirty(false);
@@ -288,11 +294,11 @@
     /** {@inheritDoc} */
     @Nullable public void save() throws IOException {
         if (!isDirty()) {
-            log.debug("Storage state has not been modified during request, save operation skipped");
+            log.trace("Storage state has not been modified during request, save operation skipped");
             return;
         }
 
-        log.debug("Saving updated storage data to cookie");
+        log.trace("Saving updated storage data to cookie");
         
         Map<String, Map<String, MutableStorageRecord>> contextMap = getContextMap();
         if (contextMap.isEmpty()) {
@@ -360,6 +366,20 @@
             throw new IOException(e);
         }
     }
+
+    /** {@inheritDoc} */
+    public void init(FilterConfig filterConfig) throws ServletException {
+        
+    }
+
+    /** {@inheritDoc} */
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+            ServletException {
+        
+        load();
+        chain.doFilter(request, response);
+        save();
+    }
     
     /** {@inheritDoc} */
     @Nullable protected Integer updateImpl(@Nullable final Integer version, @Nonnull @NotEmpty final String context,



More information about the commits mailing list