Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 9d3c27e25 -> 47b80b935


Trying to fix the SAMLP response decryption issue


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/47b80b93
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/47b80b93
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/47b80b93

Branch: refs/heads/3.0.x-fixes
Commit: 47b80b935f2fa1f70af71ba58baef4e2d9b226a5
Parents: 9d3c27e
Author: Sergey Beryozkin <[email protected]>
Authored: Thu Jul 31 11:21:57 2014 +0300
Committer: Sergey Beryozkin <[email protected]>
Committed: Thu Jul 31 13:04:24 2014 +0300

----------------------------------------------------------------------
 .../security/saml/sso/SAMLProtocolResponseValidator.java | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/47b80b93/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SAMLProtocolResponseValidator.java
----------------------------------------------------------------------
diff --git 
a/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SAMLProtocolResponseValidator.java
 
b/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SAMLProtocolResponseValidator.java
index 08b906e..42e2aab 100644
--- 
a/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SAMLProtocolResponseValidator.java
+++ 
b/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SAMLProtocolResponseValidator.java
@@ -115,10 +115,9 @@ public class SAMLProtocolResponseValidator {
         // Decrypt any encrypted Assertions and add them to the Response (note 
that this will break any
         // signature on the Response)
         for (org.opensaml.saml2.core.EncryptedAssertion assertion : 
samlResponse.getEncryptedAssertions()) {
-            EncryptedData encryptedData = assertion.getEncryptedData();
-            Element encryptedDataDOM = encryptedData.getDOM();
             
-            Element decAssertion = decryptAssertion(encryptedDataDOM, 
sigCrypto, callbackHandler);
+            Element decAssertion = 
+                decryptAssertion(assertion, sigCrypto, callbackHandler);
             
             SamlAssertionWrapper wrapper = new 
SamlAssertionWrapper(decAssertion);
             samlResponse.getAssertions().add(wrapper.getSaml2());
@@ -409,9 +408,9 @@ public class SAMLProtocolResponseValidator {
     }
     
     private Element decryptAssertion(
-        Element encryptedDataDOM, Crypto sigCrypto, CallbackHandler 
callbackHandler
+        org.opensaml.saml2.core.EncryptedAssertion assertion, Crypto 
sigCrypto, CallbackHandler callbackHandler
     ) throws WSSecurityException {
-        Element encKeyElement = getNode(encryptedDataDOM, WSConstants.ENC_NS, 
"EncryptedKey", 0);
+        Element encKeyElement = getNode(assertion.getDOM(), 
WSConstants.ENC_NS, "EncryptedKey", 0);
         if (encKeyElement == null) {
             LOG.log(Level.FINE, "EncryptedKey element is not available");
             throw new 
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, 
"invalidSAMLsecurity");
@@ -459,6 +458,8 @@ public class SAMLProtocolResponseValidator {
             throw new 
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, 
"invalidSAMLsecurity");
         }
         
+        EncryptedData encryptedData = assertion.getEncryptedData();
+        Element encryptedDataDOM = encryptedData.getDOM();
         String symKeyAlgo = getEncodingMethodAlgorithm(encryptedDataDOM);
         
         byte[] decryptedPayload = null;

Reply via email to