[java-opensaml COMMIT] in /trunk/opensaml-storage-impl/src: main/java/org/opensaml/storage/impl/client/ClientStorageS...

noreply at shibboleth.net noreply at shibboleth.net
Sat Aug 15 22:12:42 EDT 2015


Author: scantor
Date: Sat Aug 15 22:12:40 2015
New Revision: 4324

URL: http://svn.shibboleth.net/view/java-opensaml?rev=4324&view=rev
Log:
IDP-594 - Storage load action, unit test, fixes

Added:
    trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/LoadClientStorageServices.java   (with props)
    trunk/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/client/LoadClientStorageServicesTest.java   (with props)
Modified:
    trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/ClientStorageService.java
    trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContext.java

Modified: trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/ClientStorageService.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/ClientStorageService.java?rev=4324&r1=4323&r2=4324&view=diff
==============================================================================
--- trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/ClientStorageService.java	(original)
+++ trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/ClientStorageService.java	Sat Aug 15 22:12:40 2015
@@ -27,6 +27,12 @@
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
+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.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 
@@ -56,21 +62,34 @@
  * 
  * <p>The data for this service is managed in a {@link ClientStorageServiceStore} object, which must
  * be created by some operation within the container for this implementation to function. Actual
- * load/store of the data to/from that object is driven via companion classes, but the serialization
- * of data via JSON is implemented here.</p>
+ * load/store of the data to/from that object is driven via companion classes. The serialization
+ * of data via JSON is inside the storage object class, but the encryption/decryption is here.</p>
  */
-public class ClientStorageService extends AbstractMapBackedStorageService {
+public class ClientStorageService extends AbstractMapBackedStorageService implements Filter {
 
     /** Name of session attribute for session lock. */
     @Nonnull protected static final String LOCK_ATTRIBUTE =
             "org.opensaml.storage.impl.client.ClientStorageService.lock";
-
-    /** Name of session attribute for context map. */
+    
+    /** Name of session attribute for tracking source of data. */
+    @Nonnull protected static final String SOURCE_ATTRIBUTE =
+            "org.opensaml.storage.impl.client.ClientStorageService.source";
+
+    /** Name of session attribute for storage object. */
     @Nonnull protected static final String STORAGE_ATTRIBUTE = 
             "org.opensaml.storage.impl.client.ClientStorageService.store";
+    
+    /** Enumeration of possible sources for the data. */
+    public enum ClientStorageSource {
+        /** Source was a cookie. */
+        COOKIE,
+        
+        /** Source was HTML Local Storage. */
+        HTML_LOCAL_STORAGE,
+    }
 
     /** Default label for storage tracking. */
-    @Nonnull @NotEmpty private static final String DEFAULT_STORAGE_NAME = "shib_idp_req_ss";
+    @Nonnull @NotEmpty private static final String DEFAULT_STORAGE_NAME = "shib_idp_client_ss";
     
     /** Class logger. */
     @Nonnull private final Logger log = LoggerFactory.getLogger(ClientStorageService.class);
@@ -152,6 +171,21 @@
         keyStrategy = strategy;
     }
 
+    /** {@inheritDoc} */
+    @Override
+    public void init(FilterConfig filterConfig) throws ServletException {
+        
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+            ServletException {
+        // This is just a no-op available to preserve compatibility with web.xml references to the
+        // older storage plugin that saved modified data back to a cookie on every response.
+        chain.doFilter(request, response);
+    }
+    
     /** {@inheritDoc} */
     @Override
     protected void doInitialize() throws ComponentInitializationException {
@@ -233,47 +267,51 @@
            lock.unlock();
        }
     }
-
+    
     /**
      * Reconstitute stored data and inject it into the session.
      * 
      * <p>This method should <strong>not</strong> be called while holding the session lock
      * returned by {@link #getLock()}.</p>
      * 
-     * @param raw encrypted data to load as storage contents
-     * 
-     * @throws IOException  if an error occurs reconstituting the data
-     */
-    void load(@Nonnull @NotEmpty final String raw) throws IOException {
-
-        log.trace("Loading storage state from client into session");

[... 172 lines stripped ...]


More information about the commits mailing list