You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2017/08/11 11:39:44 UTC

svn commit: r1804778 - /webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java

Author: coheigea
Date: Fri Aug 11 11:39:44 2017
New Revision: 1804778

URL: http://svn.apache.org/viewvc?rev=1804778&view=rev
Log:
WSS-613 - Update OpenSAMLUtil to be able to sign generic SignableSAMLObjects

Modified:
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java

Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java?rev=1804778&r1=1804777&r2=1804778&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java Fri Aug 11 11:39:44 2017
@@ -41,6 +41,7 @@ import org.opensaml.core.xml.io.Marshall
 import org.opensaml.core.xml.io.Unmarshaller;
 import org.opensaml.core.xml.io.UnmarshallerFactory;
 import org.opensaml.core.xml.io.UnmarshallingException;
+import org.opensaml.saml.common.SignableSAMLObject;
 import org.opensaml.saml.config.SAMLConfiguration;
 import org.opensaml.xmlsec.signature.Signature;
 import org.opensaml.xmlsec.signature.support.SignatureException;
@@ -122,13 +123,13 @@ public final class OpenSAMLUtil {
 
     /**
      * Get the configured ParserPool.
-     * 
+     *
      * @return the configured ParserPool
      */
     public static ParserPool getParserPool() {
         return providerRegistry.getParserPool();
-    }    
-    
+    }
+
     /**
      * Convert a SAML Assertion from a DOM Element to an XMLObject
      *
@@ -244,27 +245,8 @@ public final class OpenSAMLUtil {
             }
 
             signObject(response.getSignature());
-        } else if (xmlObject instanceof org.opensaml.saml.saml2.core.Assertion) {
-            org.opensaml.saml.saml2.core.Assertion saml2 =
-                    (org.opensaml.saml.saml2.core.Assertion) xmlObject;
-
-            signObject(saml2.getSignature());
-        } else if (xmlObject instanceof org.opensaml.saml.saml1.core.Assertion) {
-            org.opensaml.saml.saml1.core.Assertion saml1 =
-                    (org.opensaml.saml.saml1.core.Assertion) xmlObject;
-
-            signObject(saml1.getSignature());
-        } else if (xmlObject instanceof org.opensaml.saml.saml2.core.RequestAbstractType) {
-            org.opensaml.saml.saml2.core.RequestAbstractType request =
-                    (org.opensaml.saml.saml2.core.RequestAbstractType) xmlObject;
-
-
-            signObject(request.getSignature());
-        } else if (xmlObject instanceof org.opensaml.saml.saml1.core.Request) {
-            org.opensaml.saml.saml1.core.Request request =
-                    (org.opensaml.saml.saml1.core.Request) xmlObject;
-
-            signObject(request.getSignature());
+        } else if (xmlObject instanceof SignableSAMLObject) {
+            signObject(((SignableSAMLObject)xmlObject).getSignature());
         }
     }