[java-opensaml] 02/02: Make a copy of KeyAgreementParameters so can be modified internally

Brent Putman putmanb at georgetown.edu
Sun Dec 20 01:15:34 UTC 2020


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

putmanb pushed a commit to branch dev/OSJ-82
in repository java-opensaml.

View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=139fc99824d08af12a5f02c7ddb3a91b36bc9c00

commit 139fc99824d08af12a5f02c7ddb3a91b36bc9c00
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Sat Dec 19 20:05:21 2020 -0500

    Make a copy of KeyAgreementParameters so can be modified internally
---
 .../xmlsec/agreement/KeyAgreementParameters.java      | 19 +++++++++++++++++++
 .../agreement/impl/AbstractKeyAgreementProcessor.java |  5 ++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/opensaml-xmlsec-api/src/main/java/org/opensaml/xmlsec/agreement/KeyAgreementParameters.java b/opensaml-xmlsec-api/src/main/java/org/opensaml/xmlsec/agreement/KeyAgreementParameters.java
index 414daf45b..8ae840683 100644
--- a/opensaml-xmlsec-api/src/main/java/org/opensaml/xmlsec/agreement/KeyAgreementParameters.java
+++ b/opensaml-xmlsec-api/src/main/java/org/opensaml/xmlsec/agreement/KeyAgreementParameters.java
@@ -17,11 +17,30 @@
 
 package org.opensaml.xmlsec.agreement;
 
+import javax.annotation.Nonnull;
+
 import net.shibboleth.utilities.java.support.collection.ClassIndexedSet;
 
 /**
  * Specialized collection type for holding sets of parameters to key agreement operations.
  */
 public class KeyAgreementParameters extends ClassIndexedSet<KeyAgreementParameter> {
+    
+    /**
+     * Constructor.
+     *
+     */
+    public KeyAgreementParameters() {
+        super();
+    }
 
+    /**
+     * Copy constructor.
+     *
+     * @param source the source set from which to copy
+     */
+    public KeyAgreementParameters(@Nonnull final KeyAgreementParameters source) {
+        super();
+        addAll(source);
+    }
 }
diff --git a/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/agreement/impl/AbstractKeyAgreementProcessor.java b/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/agreement/impl/AbstractKeyAgreementProcessor.java
index 0539a4bd3..fd76c25ee 100644
--- a/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/agreement/impl/AbstractKeyAgreementProcessor.java
+++ b/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/agreement/impl/AbstractKeyAgreementProcessor.java
@@ -39,7 +39,10 @@ public abstract class AbstractKeyAgreementProcessor implements KeyAgreementProce
     /** {@inheritDoc} */
     @Nonnull public KeyAgreementCredential execute(@Nonnull final Credential publicCredential,
             @Nonnull final String keyAlgorithm, @Nonnull final Integer keyLength,
-            @Nonnull final KeyAgreementParameters parameters) throws KeyAgreementException {
+            @Nonnull final KeyAgreementParameters inputParameters) throws KeyAgreementException {
+        
+        // Make a copy so methods can store items without mutating the input instance
+        final KeyAgreementParameters parameters = new KeyAgreementParameters(inputParameters);
         
         final Credential privateCredential = obtainPrivateCredential(publicCredential, parameters);
         

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


More information about the commits mailing list