[java-opensaml] 01/02: OSJ-435: Create a new Initializer for PEM parsing.

Codeberg noreply at shibboleth.net
Mon Dec 15 07:08:47 UTC 2025


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

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

View the commit online:
https://codeberg.org/Shibboleth/java-opensaml/commit/90c9c0d09bcc8a963cb97ba6bacedeee5b97d152

commit 90c9c0d09bcc8a963cb97ba6bacedeee5b97d152
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Sun Dec 14 23:48:33 2025 -0500

    OSJ-435: Create a new Initializer for PEM parsing.
    
    Added new Initializer to opensaml-security-api, which is the
    highest-level module in OpenSAML where BC is declared as a compile dep.
---
 .../security/config/BouncyCastleInitializer.java   | 43 ++++++++++++++++++++++
 .../services/org.opensaml.core.config.Initializer  |  1 +
 2 files changed, 44 insertions(+)

diff --git a/opensaml-security-api/src/main/java/org/opensaml/security/config/BouncyCastleInitializer.java b/opensaml-security-api/src/main/java/org/opensaml/security/config/BouncyCastleInitializer.java
new file mode 100644
index 000000000..7396176b4
--- /dev/null
+++ b/opensaml-security-api/src/main/java/org/opensaml/security/config/BouncyCastleInitializer.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opensaml.security.config;
+
+import javax.annotation.Nonnull;
+
+import org.opensaml.core.config.InitializationException;
+import org.opensaml.core.config.Initializer;
+import org.slf4j.Logger;
+
+import net.shibboleth.shared.primitive.LoggerFactory;
+
+/**
+ * Initializer which initializes the Bouncy Castle library. 
+ */
+public class BouncyCastleInitializer implements Initializer {
+    
+    /** Logger. */
+    @Nonnull private Logger log = LoggerFactory.getLogger(BouncyCastleInitializer.class);
+
+    /** {@inheritDoc} */
+    public void init() throws InitializationException {
+        final String laxPEMParsingPropName = "org.bouncycastle.pemreader.lax";
+        // Don't override if it was set explicitly
+        if (System.getProperty(laxPEMParsingPropName) == null) {
+            log.debug("Enabling lax PEM reader parsing in Bouncy Castle");
+            System.setProperty(laxPEMParsingPropName, "true");
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/opensaml-security-api/src/main/resources/META-INF/services/org.opensaml.core.config.Initializer b/opensaml-security-api/src/main/resources/META-INF/services/org.opensaml.core.config.Initializer
index 20479a730..0d8109d3a 100644
--- a/opensaml-security-api/src/main/resources/META-INF/services/org.opensaml.core.config.Initializer
+++ b/opensaml-security-api/src/main/resources/META-INF/services/org.opensaml.core.config.Initializer
@@ -1 +1,2 @@
+org.opensaml.security.config.BouncyCastleInitializer
 org.opensaml.security.config.GlobalNamedCurveRegistryInitializer
\ No newline at end of file

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


More information about the commits mailing list