[java-identity-provider COMMIT] in /trunk/idp-conf/src/main/resources/system/views/local-storage: local-storage-read....

noreply at shibboleth.net noreply at shibboleth.net
Tue Jun 9 14:11:20 EDT 2015


Author: tzeller
Date: Tue Jun  9 14:11:19 2015
New Revision: 7551

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7551&view=rev
Log:
IDP-594 Instead of storing the version as a local storage item, concatenate it with the local storage value.

Modified:
    trunk/idp-conf/src/main/resources/system/views/local-storage/local-storage-read.js
    trunk/idp-conf/src/main/resources/system/views/local-storage/local-storage-write.js

Modified: trunk/idp-conf/src/main/resources/system/views/local-storage/local-storage-read.js
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-conf/src/main/resources/system/views/local-storage/local-storage-read.js?rev=7551&r1=7550&r2=7551&view=diff
==============================================================================
--- trunk/idp-conf/src/main/resources/system/views/local-storage/local-storage-read.js	(original)
+++ trunk/idp-conf/src/main/resources/system/views/local-storage/local-storage-read.js	Tue Jun  9 14:11:19 2015
@@ -4,14 +4,31 @@
     if (localStorageSupported) {
         var success;
         try {
-            var clientVersion = localStorage.getItem("shib_idp_ls_version");
-            if (clientVersion != null) {
-                document.form1["shib_idp_ls_version"].value = clientVersion;
-                if (clientVersion > version) {
-                    var value = localStorage.getItem(key);
-                    if (value != null) {
-                        document.form1["shib_idp_ls_value"].value = value;
-                    }
+            // TODO trim key and version
+            // TODO The key typeof check might be unnecessary.
+            if (typeof key != 'string') {
+                throw ("Key [" + key + "] must be a string");
+            }
+            if (isNaN(version)) {
+                throw ("Version [" + version + "] must be a number");
+            }
+            var versionedValue = localStorage.getItem(key);
+            if (versionedValue != null) {
+                // TODO test
+                var splitPoint = versionedValue.indexOf(":");
+                if (splitPoint < 0) {
+                    throw "Unable to determine version of item value";
+                }
+                // TODO test
+                var localVersion = versionedValue.substring(0, splitPoint);
+                if (isNaN(localVersion)) {
+                    throw ("Local version [" + localVersion + "] must be a number");
+                }
+                document.form1["shib_idp_ls_version"].value = localVersion;
+                if (Number(localVersion) > Number(version)) {
+                    var value = versionedValue.substring(splitPoint + 1);
+                    // TODO check something here ?
+                    document.form1["shib_idp_ls_value"].value = value;
                 }
             }
             success = "true";

Modified: trunk/idp-conf/src/main/resources/system/views/local-storage/local-storage-write.js
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-conf/src/main/resources/system/views/local-storage/local-storage-write.js?rev=7551&r1=7550&r2=7551&view=diff
==============================================================================
--- trunk/idp-conf/src/main/resources/system/views/local-storage/local-storage-write.js	(original)
+++ trunk/idp-conf/src/main/resources/system/views/local-storage/local-storage-write.js	Tue Jun  9 14:11:19 2015
@@ -1,8 +1,19 @@
 function writeLocalStorageAndSubmit(key, value, version) {
     var success;
     try {
-    	localStorage.setItem(key, value);
-    	localStorage.setItem("shib_idp_ls_version", version);
+        // TODO The key and value typeof checks might be unnecessary.
+        if (typeof key != 'string') {
+            throw("Key [" + key + "] must be a string");
+        }
+        if (typeof value != 'string') {
+            throw("Value [" + value + "] must be a string");
+        }
+        if (isNaN(version)) {
+            throw("Version [" + version + "] must be a number");
+        }
+        // TODO trim key and version and value ?
+        var versionedValue = version + ":" + value;
+        localStorage.setItem(key, versionedValue);
         success = "true";
     } catch (e) {
         success = "false";



More information about the commits mailing list