ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1771307 [2/2] - in /webservices/wss4j/trunk: integration/src/test/java/org/apache/wss4j/integration/test/kerberos/ ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/ ws-secu...
Date Fri, 25 Nov 2016 12:30:49 GMT
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenReferenceTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenReferenceTest.java?rev=1771307&r1=1771306&r2=1771307&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenReferenceTest.java
(original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenReferenceTest.java
Fri Nov 25 12:30:49 2016
@@ -365,10 +365,10 @@ public class SAMLTokenReferenceTest exte
             WSSecHeader secHeader = new WSSecHeader(doc);
             Node assertionNode = samlAssertion.toDOM(doc);
             secHeader.insertSecurityHeader();
-            secHeader.getSecurityHeader().appendChild(assertionNode);
+            secHeader.getSecurityHeaderElement().appendChild(assertionNode);
 
             // Encrypt the SOAP body
-            WSSecEncrypt builder = new WSSecEncrypt();
+            WSSecEncrypt builder = new WSSecEncrypt(secHeader);
             builder.setUserInfo("receiver");
             builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
             builder.setKeyIdentifierType(WSConstants.CUSTOM_KEY_IDENTIFIER);
@@ -386,7 +386,7 @@ public class SAMLTokenReferenceTest exte
             parts.add(encP);
             Element refElement = builder.encryptForRef(null, parts);
             builder.addInternalRefElement(refElement);
-            builder.appendToHeader(secHeader);
+            builder.appendToHeader();
 
             javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
             transformer.transform(new DOMSource(doc), new StreamResult(baos));
@@ -450,10 +450,10 @@ public class SAMLTokenReferenceTest exte
              WSSecHeader secHeader = new WSSecHeader(doc);
              Node assertionNode = samlAssertion.toDOM(doc);
              secHeader.insertSecurityHeader();
-             secHeader.getSecurityHeader().appendChild(assertionNode);
+             secHeader.getSecurityHeaderElement().appendChild(assertionNode);
 
              // Encrypt the SOAP body
-             WSSecEncrypt builder = new WSSecEncrypt();
+             WSSecEncrypt builder = new WSSecEncrypt(secHeader);
              builder.setUserInfo("receiver");
              builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
              builder.setKeyIdentifierType(WSConstants.CUSTOM_SYMM_SIGNING);
@@ -471,7 +471,7 @@ public class SAMLTokenReferenceTest exte
              parts.add(encP);
              Element refElement = builder.encryptForRef(null, parts);
              builder.addInternalRefElement(refElement);
-             builder.appendToHeader(secHeader);
+             builder.appendToHeader();
 
              javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
              transformer.transform(new DOMSource(doc), new StreamResult(baos));
@@ -803,18 +803,18 @@ public class SAMLTokenReferenceTest exte
 
             Crypto issuerCrypto = CryptoFactory.getInstance("saml/samlissuer.properties");
             samlAssertion.signAssertion("samlissuer", "default", issuerCrypto, false);
+            
+            Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+            WSSecHeader secHeader = new WSSecHeader(doc);
+            secHeader.insertSecurityHeader();
 
-            WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
+            WSSecSignatureSAML wsSign = new WSSecSignatureSAML(secHeader);
             wsSign.setUserInfo("transmitter", "default");
             wsSign.setUseDirectReferenceToAssertion(true);
             wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
 
-            Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-            WSSecHeader secHeader = new WSSecHeader(doc);
-            secHeader.insertSecurityHeader();
-
             Crypto userCrypto = CryptoFactory.getInstance("transmitter-crypto.properties");
-            Document securedDocument = wsSign.build(doc, userCrypto, samlAssertion, null,
null, null, secHeader);
+            Document securedDocument = wsSign.build(doc, userCrypto, samlAssertion, null,
null, null);
 
             //some test that we can really sure we get what we want from WSS4J
             NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(),
WSSConstants.TAG_dsig_Signature.getLocalPart());

Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenTest.java?rev=1771307&r1=1771306&r2=1771307&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenTest.java
(original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenTest.java
Fri Nov 25 12:30:49 2016
@@ -888,11 +888,11 @@ public class SAMLTokenTest extends Abstr
             SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
             SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
-            WSSecSAMLToken wsSign = new WSSecSAMLToken();
-
             Document doc = SOAPUtil.toSOAPPart(sourceDocument);
             WSSecHeader secHeader = new WSSecHeader(doc);
             secHeader.insertSecurityHeader();
+            
+            WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
 
             wsSign.prepare(doc, samlAssertion);
 
@@ -901,7 +901,7 @@ public class SAMLTokenTest extends Abstr
             Element encryptedAssertionElement =
                 doc.createElementNS(WSConstants.SAML2_NS, WSConstants.ENCRYPED_ASSERTION_LN);
             encryptedAssertionElement.appendChild(assertionElement);
-            secHeader.getSecurityHeader().appendChild(encryptedAssertionElement);
+            secHeader.getSecurityHeaderElement().appendChild(encryptedAssertionElement);
 
             // Encrypt the Assertion
             KeyGenerator keygen = KeyGenerator.getInstance("AES");

Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SamlTokenDerivedTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SamlTokenDerivedTest.java?rev=1771307&r1=1771306&r2=1771307&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SamlTokenDerivedTest.java
(original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SamlTokenDerivedTest.java
Fri Nov 25 12:30:49 2016
@@ -87,14 +87,14 @@ public class SamlTokenDerivedTest extend
                     createSamlSTR(doc, samlAssertion, WSSConfig.getNewInstance());
             Element samlTokenElement = samlAssertion.toDOM(doc);
             Element secRefElement = secRefSaml.getElement();
-            secHeader.getSecurityHeader().appendChild(samlTokenElement);
-            secHeader.getSecurityHeader().appendChild(secRefElement);
+            secHeader.getSecurityHeaderElement().appendChild(samlTokenElement);
+            secHeader.getSecurityHeaderElement().appendChild(secRefElement);
 
             //
             // Create a Derived Key object for signature
             //
-            WSSecDKSign sigBuilder = createDKSign(doc, secRefSaml);
-            Document securedDocument = sigBuilder.build(doc, secHeader);
+            WSSecDKSign sigBuilder = createDKSign(doc, secRefSaml, secHeader);
+            Document securedDocument = sigBuilder.build(doc);
 
             //todo remove the following lines when the header ordering no longer does matter...
             /*Node firstChild = secHeader.getSecurityHeader().getFirstChild();
@@ -171,7 +171,8 @@ public class SamlTokenDerivedTest extend
      */
     private WSSecDKSign createDKSign(
             Document doc,
-            SecurityTokenReference secRefSaml
+            SecurityTokenReference secRefSaml,
+            WSSecHeader secHeader
     ) throws WSSecurityException {
         SecurityTokenReference secToken = new SecurityTokenReference(doc);
         CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
@@ -180,7 +181,7 @@ public class SamlTokenDerivedTest extend
         X509Certificate[] certs = crypto.getX509Certificates(cryptoType);
         secToken.setKeyIdentifierThumb(certs[0]);
 
-        WSSecDKSign sigBuilder = new WSSecDKSign();
+        WSSecDKSign sigBuilder = new WSSecDKSign(secHeader);
         java.security.Key key =
                 crypto.getPrivateKey("transmitter", "default");
         sigBuilder.setExternalKey(key.getEncoded(), secToken.getElement());



Mime
View raw message