[java-plugin-shibd] branch main updated: Add comment and decryption support to Resource-backed storage service.

Codeberg noreply at shibboleth.net
Thu Oct 15 14:10:19 UTC 2026


This is an automated email from the git hooks/post-receive script.

codeberg pushed a commit to branch main
in repository java-plugin-shibd.

View the commit online:
https://codeberg.org/Shibboleth/java-plugin-shibd/commit/72a7cb21b8fc667edeafca9f917c2d7be48da208

The following commit(s) were added to refs/heads/main by this push:
     new 72a7cb2  Add comment and decryption support to Resource-backed storage service.
72a7cb2 is described below

commit 72a7cb21b8fc667edeafca9f917c2d7be48da208
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Thu Oct 15 10:09:59 2026 -0400

    Add comment and decryption support to Resource-backed storage service.
---
 .../impl/ResourceBackedMemoryStorageService.java   | 35 ++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/storage/impl/ResourceBackedMemoryStorageService.java b/sp-server-impl/src/main/java/net/shibboleth/sp/storage/impl/ResourceBackedMemoryStorageService.java
index 88b4c1a..dd47f3c 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/storage/impl/ResourceBackedMemoryStorageService.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/storage/impl/ResourceBackedMemoryStorageService.java
@@ -40,6 +40,8 @@ import net.shibboleth.shared.logic.Constraint;
 import net.shibboleth.shared.primitive.LoggerFactory;
 import net.shibboleth.shared.primitive.StringSupport;
 import net.shibboleth.shared.resource.Resource;
+import net.shibboleth.shared.security.DataSealer;
+import net.shibboleth.shared.security.DataSealerException;
 
 import org.opensaml.storage.AbstractMapBackedStorageService;
 import org.opensaml.storage.MutableStorageRecord;
@@ -56,6 +58,8 @@ import org.slf4j.Logger;
  * <p>The implementation is read-only and throws exceptions for any methods that would mutate the data. The "cleanup"
  * task is instead used to periodically check the source file for updates and reloads the in-memory data under
  * an exclusive lock.</p>
+ * 
+ * <p>Lines starting with a '#' character are ignored as comments.</p>
  */
 public class ResourceBackedMemoryStorageService extends AbstractMapBackedStorageService implements StorageCapabilities {
 
@@ -68,6 +72,9 @@ public class ResourceBackedMemoryStorageService extends AbstractMapBackedStorage
     /** A shared lock to synchronize access. */
     @NonnullAfterInit private ReadWriteLock lock;
 
+    /** Optional encryption support. */
+    @Nullable private DataSealer dataSealer;
+    
     /** Source of information. */
     @Nullable private Resource storageResource;
     
@@ -107,6 +114,17 @@ public class ResourceBackedMemoryStorageService extends AbstractMapBackedStorage
         setCleanupInterval(interval);
     }
     
+    /**
+     * Sets the {@link DataSealer} to use, which enables decryption of the
+     * record values (but not the rest).
+     * 
+     * @param sealer data sealer
+     */
+    public void setDataSealer(@Nullable final DataSealer sealer) {
+        checkSetterPreconditions();
+        dataSealer = sealer;
+    }
+    
     /**
      * Set the resource to use.
      * 
@@ -207,7 +225,7 @@ public class ResourceBackedMemoryStorageService extends AbstractMapBackedStorage
         throw new UnsupportedOperationException("Deletes are not supported by this StorageService implementation.");
     }
     
-    // Checkstyle: AnonInnerLength OFF
+// Checkstyle: AnonInnerLength OFF
     /** {@inheritDoc} */
     @Override
     @Nullable protected TimerTask getCleanupTask() {
@@ -271,19 +289,32 @@ public class ResourceBackedMemoryStorageService extends AbstractMapBackedStorage
         try (final BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
             String line;
             while ((line = reader.readLine()) != null) {
+                if (line.startsWith("#")) {
+                    continue;
+                }
                 final String[] sploot = line.split(delimiter, 3);
                 if (sploot != null && sploot.length == 3 &&
                         sploot[0] != null && sploot[1] != null && sploot[2] != null) {
                     
+                    final String value;
+                    if (dataSealer != null) {
+                        value = dataSealer.unwrap(sploot[2]);
+                    } else {
+                        value = sploot[2];
+                    }
+                    
                     if (!theMap.containsKey(sploot[0])) {
                         theMap.put(sploot[0], new HashMap<>());
                     }
-                    theMap.get(sploot[0]).put(sploot[1], new MutableStorageRecord<>(sploot[2], null));
+                                        
+                    theMap.get(sploot[0]).put(sploot[1], new MutableStorageRecord<>(value, null));
                     
                 } else {
                     throw new IOException("Improper format detected.");
                 }
             }
+        } catch (final DataSealerException e) {
+            throw new IOException(e);
         }
         
         return theMap;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list