[java-plugin-shibd-saml] branch main updated: Fix keypair generation to create directories and limit to install only.

Codeberg noreply at shibboleth.net
Tue Sep 29 15:32:39 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-saml.

View the commit online:
https://codeberg.org/Shibboleth/java-plugin-shibd-saml/commit/93b4f44cd89a5ae38c45d5a83f37e97ce50b4b51

The following commit(s) were added to refs/heads/main by this push:
     new 93b4f44  Fix keypair generation to create directories and limit to install only.
93b4f44 is described below

commit 93b4f44cd89a5ae38c45d5a83f37e97ce50b4b51
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Tue Sep 29 10:12:49 2026 -0400

    Fix keypair generation to create directories and limit to install only.
---
 .../net/shibboleth/sp/saml/conf/SAMLModule.java    | 25 ++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/sp-saml-conf-impl/src/main/java/net/shibboleth/sp/saml/conf/SAMLModule.java b/sp-saml-conf-impl/src/main/java/net/shibboleth/sp/saml/conf/SAMLModule.java
index 7b43d21..ff14d8f 100644
--- a/sp-saml-conf-impl/src/main/java/net/shibboleth/sp/saml/conf/SAMLModule.java
+++ b/sp-saml-conf-impl/src/main/java/net/shibboleth/sp/saml/conf/SAMLModule.java
@@ -68,16 +68,30 @@ public final class SAMLModule extends PluginIdPModule {
     @Nonnull public Map<ModuleResource, ResourceResult> enable(@Nonnull final ModuleContext moduleContext) throws ModuleException {
         final Map<ModuleResource, ResourceResult> result = super.enable(moduleContext);
         
-        final Path idpHome = Path.of(moduleContext.getInstallLocation());
+        // If not initial install, we don't have additional work to do.
+        if (!ModuleContext.OperationType.Install.equals(moduleContext.getOperationType())) {
+            return result;
+        }
+        
+        // Create directory for keys if not already there.
+        final Path keyLocation = Path.of(moduleContext.getInstallLocation()).resolve("credentials").resolve("sp");
+        if (!Files.notExists(keyLocation)) {
+            try {
+                Files.createDirectories(keyLocation);
+            } catch (final IOException e) {
+                throw new ModuleException("Error creating directory for SAML keypairs", e);
+            }
+        }
+        
 
-        final Path signingKey = idpHome.resolve("credentials").resolve("sp").resolve(DEFAULT_SIGNING_KEY_FILENAME);
+        final Path signingKey = keyLocation.resolve(DEFAULT_SIGNING_KEY_FILENAME);
         if (!Files.exists(signingKey)) {
-            generateKeyPair(signingKey, idpHome.resolve("credentials").resolve("sp").resolve(DEFAULT_SIGNING_CERT_FILENAME));
+            generateKeyPair(signingKey, keyLocation.resolve(DEFAULT_SIGNING_CERT_FILENAME));
         }
 
-        final Path encryptionKey = idpHome.resolve("credentials").resolve("sp").resolve(DEFAULT_ENCRYPTION_KEY_FILENAME);
+        final Path encryptionKey = keyLocation.resolve(DEFAULT_ENCRYPTION_KEY_FILENAME);
         if (!Files.exists(encryptionKey)) {
-            generateKeyPair(encryptionKey, idpHome.resolve("credentials").resolve("sp").resolve(DEFAULT_ENCRYPTION_CERT_FILENAME));
+            generateKeyPair(encryptionKey, keyLocation.resolve(DEFAULT_ENCRYPTION_CERT_FILENAME));
         }
         
         return result;
@@ -106,7 +120,6 @@ public final class SAMLModule extends PluginIdPModule {
         try {
             generator.generate();
         } catch (final Exception e) {
-            log.error("Error generating default keypair", e);
             throw new ModuleException("Error generating default keypair.", e);
         }
     }

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


More information about the commits mailing list