[java-opensaml] branch master updated: OSJ-289 - DecryptAssertions/Attributes using unsupported list removals

Scott Cantor cantor.2 at osu.edu
Tue Nov 5 16:52:12 EST 2019


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

scantor pushed a commit to branch master
in repository java-opensaml.

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

The following commit(s) were added to refs/heads/master by this push:
       new  00ebd75   OSJ-289 - DecryptAssertions/Attributes using unsupported list removals
00ebd75 is described below

commit 00ebd7517853bfe95096e3fe80834dbbdf13605f
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Nov 5 16:52:09 2019 -0500

    OSJ-289 - DecryptAssertions/Attributes using unsupported list removals
    
    https://issues.shibboleth.net/jira/browse/OSJ-289
---
 .../opensaml/saml/saml2/profile/impl/DecryptAssertions.java |  9 ++++++---
 .../opensaml/saml/saml2/profile/impl/DecryptAttributes.java | 13 +++++++++----
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/profile/impl/DecryptAssertions.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/profile/impl/DecryptAssertions.java
index d84bcd7..7008a78 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/profile/impl/DecryptAssertions.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/profile/impl/DecryptAssertions.java
@@ -112,24 +112,27 @@ public class DecryptAssertions extends AbstractDecryptAction {
             @Nonnull final Response response) throws DecryptionException {
 
         final Collection<Assertion> decrypteds = new ArrayList<>();
+        final Collection<EncryptedAssertion> encrypteds = new ArrayList<>();
         
         final Iterator<EncryptedAssertion> i = response.getEncryptedAssertions().iterator();
         while (i.hasNext()) {
             log.debug("{} Decrypting EncryptedAssertion in Response", getLogPrefix());
             try {
-                final Assertion decrypted = processEncryptedAssertion(profileRequestContext, i.next());
+                final EncryptedAssertion encrypted = i.next();
+                final Assertion decrypted = processEncryptedAssertion(profileRequestContext, encrypted);
                 if (decrypted != null) {
+                    encrypteds.add(encrypted);
                     decrypteds.add(decrypted);
-                    i.remove();
                 }
             } catch (final DecryptionException e) {
                 if (isErrorFatal()) {
                     throw e;
                 }
-                log.warn("{} Trapped failure decrypting EncryptedAttribute in AttributeStatement", getLogPrefix(), e);
+                log.warn("{} Trapped failure decrypting EncryptedAssertion in Response", getLogPrefix(), e);
             }
         }
         
+        response.getEncryptedAssertions().removeAll(encrypteds);
         response.getAssertions().addAll(decrypteds); 
     }
     
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/profile/impl/DecryptAttributes.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/profile/impl/DecryptAttributes.java
index 532ce9f..d1397a5 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/profile/impl/DecryptAttributes.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/profile/impl/DecryptAttributes.java
@@ -117,17 +117,21 @@ public class DecryptAttributes extends AbstractDecryptAction {
     private void processAssertion(@Nonnull final ProfileRequestContext profileRequestContext,
             @Nonnull final Assertion assertion) throws DecryptionException {
 
-        final Collection<Attribute> decrypteds = new ArrayList<>();
-        
         for (final AttributeStatement s : assertion.getAttributeStatements()) {
+
+            final Collection<Attribute> decrypteds = new ArrayList<>();
+            final Collection<EncryptedAttribute> encrypteds = new ArrayList<>();
+            
             final Iterator<EncryptedAttribute> i = s.getEncryptedAttributes().iterator();
             while (i.hasNext()) {
                 log.debug("{} Decrypting EncryptedAttribute in AttributeStatement", getLogPrefix());
+                
                 try {
-                    final Attribute decrypted = processEncryptedAttribute(profileRequestContext, i.next());
+                    final EncryptedAttribute encrypted = i.next();
+                    final Attribute decrypted = processEncryptedAttribute(profileRequestContext, encrypted);
                     if (decrypted != null) {
+                        encrypteds.add(encrypted);
                         decrypteds.add(decrypted);
-                        i.remove();
                     }
                 } catch (final DecryptionException e) {
                     if (isErrorFatal()) {
@@ -138,6 +142,7 @@ public class DecryptAttributes extends AbstractDecryptAction {
                 }
             }
             
+            s.getEncryptedAttributes().removeAll(encrypteds);
             s.getAttributes().addAll(decrypteds); 
         }
     }

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


More information about the commits mailing list