[java-idp-plugin-duo] branch main updated: Improve method name

Codeberg noreply at shibboleth.net
Wed Sep 23 10:29:42 UTC 2026


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

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

View the commit online:
https://codeberg.org/Shibboleth/java-idp-plugin-duo/commit/25f79322e3a0c557827aac252f45d0ac23e73ff3

The following commit(s) were added to refs/heads/main by this push:
     new 25f79322 Improve method name
25f79322 is described below

commit 25f79322e3a0c557827aac252f45d0ac23e73ff3
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Wed Sep 23 11:29:18 2026 +0100

    Improve method name
---
 .../authn/duo/sdk/impl/DuoSDKClientFactory.java    | 27 ++++++++++++++--------
 .../plugin/authn/duo/duo-client-factory-bean.xml   |  2 +-
 .../duo/sdk/impl/DuoSDKClientFactoryTest.java      | 14 +++++++----
 3 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/idp-duo-sdk-client-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/sdk/impl/DuoSDKClientFactory.java b/idp-duo-sdk-client-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/sdk/impl/DuoSDKClientFactory.java
index 4bb73a5b..fd837346 100644
--- a/idp-duo-sdk-client-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/sdk/impl/DuoSDKClientFactory.java
+++ b/idp-duo-sdk-client-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/sdk/impl/DuoSDKClientFactory.java
@@ -35,6 +35,7 @@ import net.shibboleth.idp.plugin.authn.duo.DuoOIDCIntegration;
 import net.shibboleth.shared.annotation.constraint.NonnullElements;
 import net.shibboleth.shared.annotation.constraint.NotEmpty;
 import net.shibboleth.shared.annotation.constraint.Unmodifiable;
+import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.component.AbstractInitializableComponent;
 import net.shibboleth.shared.logic.ConstraintViolationException;
 import net.shibboleth.shared.primitive.DeprecationSupport;
@@ -85,21 +86,27 @@ public final class DuoSDKClientFactory extends AbstractInitializableComponent im
      * 
      * @param certResources the resources
      */
-    public synchronized void setPinnedCertificates(@Nullable final List<Resource> certResources) {
+    public synchronized void setCertificates(@Nullable final List<Resource> certResources) {
     	checkSetterPreconditions();
     	
     	if (certResources != null) {
-    		caCerts = new ArrayList<String>(certResources.size());
+    		final var certificates = new ArrayList<String>(certResources.size());
 	    	for (final Resource f : certResources) {
-	    		try (InputStream inputStream = f.getInputStream()) {
-	    			final String certificate =	new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
-	    			validateCertificate(certificate);
-	    			caCerts.add(certificate);
-	    		} catch (final IOException e) {
-	    			log.error("Failed to read certificate resource", e);
-	    			throw new ConstraintViolationException("Failed to read certificate resource: " + f.getDescription());
+	    		if (f != null) {
+		    		try (InputStream inputStream = f.getInputStream()) {
+		    			final String certificate =	new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
+		    			validateCertificate(certificate);
+		    			certificates.add(certificate);
+		    		} catch (final IOException e) {
+		    			log.error("Failed to read certificate resource '{}:{}'",f.getClass(), f.getDescription(), e);
+		    			throw new ConstraintViolationException("Failed to read certificate resource: " + 
+		    					f.getDescription());
+		    		}
 	    		}
-	        }	    	
+	    	}
+	    	caCerts = CollectionSupport.copyToList(certificates);
+    	} else {
+    		caCerts = null;
     	}
     }
     
diff --git a/idp-duo-sdk-client-impl/src/main/resources/net/shibboleth/idp/plugin/authn/duo/duo-client-factory-bean.xml b/idp-duo-sdk-client-impl/src/main/resources/net/shibboleth/idp/plugin/authn/duo/duo-client-factory-bean.xml
index 418f2a6e..fac0f25c 100644
--- a/idp-duo-sdk-client-impl/src/main/resources/net/shibboleth/idp/plugin/authn/duo/duo-client-factory-bean.xml
+++ b/idp-duo-sdk-client-impl/src/main/resources/net/shibboleth/idp/plugin/authn/duo/duo-client-factory-bean.xml
@@ -13,7 +13,7 @@
     <bean id="shibboleth.authn.DuoOIDC.sdk.clientFactory" name="shibboleth.authn.DuoOIDC.clientFactory"
         class="net.shibboleth.idp.plugin.authn.duo.sdk.impl.DuoSDKClientFactory" scope="singleton"
         p:caCerts="#{getObject('shibboleth.authn.DuoOIDC.sdk.TrustedCertificates')}"
-        p:pinnedCertificates="#{getObject('shibboleth.authn.DuoOIDC.sdk.TrustedCertificateResources') 
+        p:certificates="#{getObject('shibboleth.authn.DuoOIDC.sdk.TrustedCertificateResources') 
                 ?: getObject('shibboleth.authn.DuoOIDC.sdk.DefaultTrustedCertificateResources')}"      
         p:proxyPort="%{idp.duo.oidc.http.proxy.port:#{null}}"
         p:proxyHost="%{idp.duo.oidc.http.proxy.host:#{null}}">
diff --git a/idp-duo-sdk-client-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/sdk/impl/DuoSDKClientFactoryTest.java b/idp-duo-sdk-client-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/sdk/impl/DuoSDKClientFactoryTest.java
index 51b2d0a1..3b6d5dd8 100644
--- a/idp-duo-sdk-client-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/sdk/impl/DuoSDKClientFactoryTest.java
+++ b/idp-duo-sdk-client-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/sdk/impl/DuoSDKClientFactoryTest.java
@@ -74,15 +74,21 @@ public class DuoSDKClientFactoryTest {
     public final void testSetPinnedCertificates() {
         final List<Resource> certs = new ArrayList<>();
         certs.add(ResourceHelper.of(new ClassPathResource("trust/example.crt")));
-        factory.setPinnedCertificates(certs);
+        factory.setCertificates(certs);
     }
     
     @Test(expectedExceptions = ConstraintViolationException.class)
     public final void testSetBadPinnedCertificates() {
         final List<Resource> certs = new ArrayList<>();
         certs.add(ResourceHelper.of(new ClassPathResource("trust/example-bad.crt")));
-        factory.setPinnedCertificates(certs);
+        factory.setCertificates(certs);
     }
+    
+//    public final void testSetBadPinnedCertificates_OldType() {
+//        final List<Resource> certs = new ArrayList<>();
+//        certs.add(ResourceHelper.of(new ServletContextResource(new ServletContext(), "sha256/I/Lt/z7ekCWanjD0Cvj5EqXls2lOaThEA0H2Bg4BT/o=")));
+//        factory.setCertificates(certs);
+//    }
 
     /**
      * Test creation.
@@ -94,7 +100,7 @@ public class DuoSDKClientFactoryTest {
     public final void testCreateInstance() throws DuoClientException, ComponentInitializationException {
     	final List<Resource> certs = new ArrayList<>();
         certs.add(ResourceHelper.of(new ClassPathResource("trust/example.crt")));
-        factory.setPinnedCertificates(certs);
+        factory.setCertificates(certs);
         final DefaultDuoOIDCIntegration integ = new DefaultDuoOIDCIntegration();
         integ.setAPIHost("api-c9f24c5a.duosecurity.com");
         integ.setClientId("DIU6GEFWG5LIUTVV2M3N");
@@ -122,7 +128,7 @@ public class DuoSDKClientFactoryTest {
     @Test
     public final void testCreateInstance_EmptyCerts() throws DuoClientException, ComponentInitializationException {
     	final List<Resource> certs = new ArrayList<>();
-    	factory.setPinnedCertificates(certs);
+    	factory.setCertificates(certs);
         final DefaultDuoOIDCIntegration integ = new DefaultDuoOIDCIntegration();
         integ.setAPIHost("api-c9f24c5a.duosecurity.com");
         integ.setClientId("DIU6GEFWG5LIUTVV2M3N");

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


More information about the commits mailing list