You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2017/01/30 17:50:59 UTC
svn commit: r1780953 [9/9] - in
/axis/axis2/java/rampart/branches/RAMPART-289: ./ apidocs/ code-coverage/
etc/ legal/ modules/distribution/ modules/distribution/src/
modules/documentation/ modules/rampart-core/
modules/rampart-core/src/main/java/META-I...
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/test/java/org/apache/rahas/impl/util/SAMLUtilsTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/test/java/org/apache/rahas/impl/util/SAMLUtilsTest.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/test/java/org/apache/rahas/impl/util/SAMLUtilsTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/test/java/org/apache/rahas/impl/util/SAMLUtilsTest.java Mon Jan 30 17:50:58 2017
@@ -26,11 +26,10 @@ import org.apache.commons.logging.LogFac
import org.apache.rahas.Rahas;
import org.apache.rahas.TrustException;
import org.apache.rahas.TrustUtil;
-import org.apache.rahas.impl.AbstractIssuerConfig;
+import org.apache.rahas.test.util.AbstractTestCase;
import org.apache.rahas.test.util.TestUtil;
import org.apache.ws.security.WSSecurityException;
import org.apache.ws.security.components.crypto.Crypto;
-import org.apache.ws.security.components.crypto.CryptoFactory;
import org.apache.ws.security.message.WSSecEncryptedKey;
import org.apache.ws.security.util.Base64;
import org.joda.time.DateTime;
@@ -59,29 +58,17 @@ import java.security.cert.X509Certificat
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.Properties;
/**
* A test class for SAML 1 Token Issuer.
*/
-public class SAMLUtilsTest extends TestCase{
-
- protected static MarshallerFactory marshallerFactory;
-
- private static final boolean PRINT = false;
+public class SAMLUtilsTest extends AbstractTestCase {
private static final Log log = LogFactory.getLog(SAMLUtilsTest.class);
- public void setUp() throws AxisFault {
- Rahas rahas = new Rahas();
- rahas.init(null, null);
-
- marshallerFactory = Configuration.getMarshallerFactory();
- }
-
public void testBuildXMLObjectNegative() {
try {
- SAMLUtils.buildXMLObject(new QName("http://x.com", "y"));
+ CommonUtil.buildXMLObject(new QName("http://x.com", "y"));
Assert.fail("This should throw an exception");
} catch (TrustException e) {
}
@@ -172,7 +159,7 @@ public class SAMLUtilsTest extends TestC
public void testCreateKeyInfoWithX509Data() throws Exception {
- X509Data x509Data = SAMLUtils.createX509Data(getTestCertificate());
+ X509Data x509Data = CommonUtil.createX509Data(getTestCertificate());
org.opensaml.xml.signature.KeyInfo keyInfo = SAMLUtils.createKeyInfo(x509Data);
@@ -210,7 +197,7 @@ public class SAMLUtilsTest extends TestC
= SAMLUtils.createNamedIdentifier("joe,ou=people,ou=saml-demo,o=baltimore.com",
NameIdentifier.X509_SUBJECT);
- X509Data x509Data = SAMLUtils.createX509Data(getTestCertificate());
+ X509Data x509Data = CommonUtil.createX509Data(getTestCertificate());
org.opensaml.xml.signature.KeyInfo keyInfo = SAMLUtils.createKeyInfo(x509Data);
@@ -233,7 +220,7 @@ public class SAMLUtilsTest extends TestC
public void testCreateX509Data() throws Exception {
- X509Data x509Data = SAMLUtils.createX509Data(getTestCertificate());
+ X509Data x509Data = CommonUtil.createX509Data(getTestCertificate());
Assert.assertNotNull(x509Data);
marshallerFactory.getMarshaller(x509Data).marshall(x509Data);
@@ -273,16 +260,14 @@ public class SAMLUtilsTest extends TestC
SOAPEnvelope env = TrustUtil.createSOAPEnvelope("http://schemas.xmlsoap.org/soap/envelope/");
Document doc = ((Element) env).getOwnerDocument();
- int keySize = 256;
-
byte [] ephemeralKey = generateEphemeralKey(256);
WSSecEncryptedKey encryptedKey
- = SAMLUtils.getSymmetricKeyBasedKeyInfoContent(doc,
- ephemeralKey, getTestCertificate(), keySize, TestUtil.getCrypto());
+ = CommonUtil.getSymmetricKeyBasedKeyInfoContent(doc,
+ ephemeralKey, getTestCertificate(), TestUtil.getCrypto());
Assert.assertNotNull(encryptedKey.getEncryptedKeyElement());
- printElement(encryptedKey.getEncryptedKeyElement());
+ //printElement(encryptedKey.getEncryptedKeyElement());
return encryptedKey;
}
@@ -300,13 +285,6 @@ public class SAMLUtilsTest extends TestC
- private static void printElement(Element element) throws TransformerException {
-
- // print xml
- if (PRINT) {
- System.out.println(getXMLString(element));
- }
- }
private static X509Certificate getTestCertificate() throws IOException, WSSecurityException, TrustException {
@@ -315,21 +293,7 @@ public class SAMLUtilsTest extends TestC
return CommonUtil.getCertificateByAlias(crypto, "apache");
}
- private static String getXMLString(Element element) throws TransformerException {
- TransformerFactory transfac = TransformerFactory.newInstance();
- Transformer trans = transfac.newTransformer();
- trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
- trans.setOutputProperty(OutputKeys.INDENT, "yes");
-
- // create string from xml tree
- StringWriter sw = new StringWriter();
- StreamResult result = new StreamResult(sw);
- DOMSource source = new DOMSource(element);
- trans.transform(source, result);
- return sw.toString();
-
- }
private static boolean equals(String element1, String element2) throws ParserConfigurationException, IOException, SAXException {
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/test/java/org/apache/rahas/test/util/TestUtil.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/test/java/org/apache/rahas/test/util/TestUtil.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/test/java/org/apache/rahas/test/util/TestUtil.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/test/java/org/apache/rahas/test/util/TestUtil.java Mon Jan 30 17:50:58 2017
@@ -16,18 +16,48 @@
package org.apache.rahas.test.util;
import junit.framework.Assert;
+import org.apache.axiom.om.*;
+import org.apache.axiom.soap.*;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.rahas.RahasConstants;
+import org.apache.rahas.RahasData;
import org.apache.rahas.TrustException;
+import org.apache.rahas.TrustUtil;
import org.apache.rahas.impl.util.CommonUtil;
+import org.apache.ws.secpolicy.Constants;
+import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.WSSecurityEngineResult;
import org.apache.ws.security.WSSecurityException;
import org.apache.ws.security.components.crypto.Crypto;
import org.apache.ws.security.components.crypto.CryptoFactory;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
+import org.apache.ws.security.components.crypto.CryptoType;
+import org.apache.ws.security.handler.WSHandlerConstants;
+import org.apache.ws.security.handler.WSHandlerResult;
+import org.apache.ws.security.saml.ext.builder.SAML1Constants;
+import org.apache.xml.security.utils.XMLUtils;
+import org.opensaml.common.xml.SAMLConstants;
+import org.w3c.dom.DOMConfiguration;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamReader;
+import java.io.*;
+import java.security.Principal;
import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import java.util.Properties;
/**
@@ -37,6 +67,36 @@ public class TestUtil {
private static final Log log = LogFactory.getLog(TestUtil.class);
+ // Directly copied from WSS4J
+ public static final String SAMPLE_SOAP_MSG =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ + "<SOAP-ENV:Envelope "
+ + "xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" "
+ + "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
+ + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
+ + "<SOAP-ENV:Header"
+ + " xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2002/07/secext\""
+ + " xmlns:wsu=\"http://schemas.xmlsoap.org/ws/2002/07/utility\"/>"
+ + "<SOAP-ENV:Body>"
+ + "<add xmlns=\"http://ws.apache.org/counter/counter_port_type\">"
+ + "<value xmlns=\"\">15</value>"
+ + "</add>"
+ + "</SOAP-ENV:Body>"
+ + "</SOAP-ENV:Envelope>";
+
+ /**
+ * Convert an SOAP Envelope as a String to a org.w3c.dom.Document.
+ * Directly copied from WSS4J
+ */
+ public static org.w3c.dom.Document toSOAPPart(String xml) throws Exception {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ return builder.parse(in);
+ }
+
public static Crypto getCrypto() throws IOException, WSSecurityException, TrustException {
File file = new File("src/test/resources/crypto.config");
@@ -58,4 +118,327 @@ public class TestUtil {
return crypto;
}
+
+ public static X509Certificate getDefaultCertificate() throws WSSecurityException, TrustException, IOException {
+ Crypto crypto = getCrypto();
+
+ CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
+ cryptoType.setAlias("apache");
+
+ return crypto.getX509Certificates(cryptoType)[0];
+ }
+
+ public static Document getTestDocument() throws Exception {
+
+ InputStream is = new ByteArrayInputStream(SAMPLE_SOAP_MSG.getBytes());
+ SOAPEnvelope envelope = createSOAPEnvelope(is);
+
+ return TestUtil.getDocumentFromSOAPEnvelope(envelope, true);
+ }
+
+ public static SOAPEnvelope createSOAPEnvelope(InputStream in) throws Exception {
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createSOAPModelBuilder(in, null);
+ return (SOAPEnvelope) builder.getDocumentElement();
+ }
+
+ public static OMElement getRSTTemplate(String samlNamespace) throws Exception {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMElement element = null;
+ OMElement elem = fac.createOMElement(Constants.RST_TEMPLATE);
+ TrustUtil.createTokenTypeElement(RahasConstants.VERSION_05_02, elem).setText(samlNamespace);
+ TrustUtil.createKeyTypeElement(RahasConstants.VERSION_05_02, elem,
+ RahasConstants.KEY_TYPE_SYMM_KEY);
+ TrustUtil.createKeySizeElement(RahasConstants.VERSION_05_02, elem, 256);
+ element = TrustUtil.createClaims(RahasConstants.VERSION_05_02, elem, "http://wso2.org");
+ addClaimType(element, "http://wso2.org/claims/givenname");
+ return elem;
+ }
+
+ private static void addClaimType(OMElement parent, String uri) {
+ OMElement element = null;
+ element = parent.getOMFactory().createOMElement(new QName("http://schemas.xmlsoap.org/ws/2005/05/identity", "ClaimType", "wsid"),
+ parent);
+ element.addAttribute(parent.getOMFactory().createOMAttribute("Uri", null, uri));
+ }
+
+ public static TestSTSClient createTestSTSClient(String samlVersion) throws Exception {
+
+ ConfigurationContext configurationContext
+ = ConfigurationContextFactory.createConfigurationContextFromFileSystem("src/test/resources/repo",
+ "src/test/resources/repo/conf/client.axis2.xml");
+
+ TestSTSClient stsClient = new TestSTSClient(configurationContext);
+
+ stsClient.setRstTemplate(getRSTTemplate(samlVersion));
+ stsClient.setAction(RahasConstants.WST_NS_05_02 + RahasConstants.RST_ACTION_SCT);
+
+ return stsClient;
+
+ }
+
+ public static MessageContext createDummyMessageContext(String appliesTo) throws Exception {
+ TestSTSClient stsClient = TestUtil.createTestSTSClient(SAMLConstants.SAML20_NS);
+ OMElement requestSecurityToken = stsClient.createRST(appliesTo);
+
+ MessageContext dummyMessageContext = new MessageContext();
+
+ populateReceivedResults(dummyMessageContext);
+
+ dummyMessageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
+ AddressingConstants.Submission.WSA_NAMESPACE);
+
+ SOAPFactory factory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM).getSOAP11Factory();
+ SOAPEnvelope envelope = factory.createSOAPEnvelope();
+
+ SOAPBody soapBody = factory.createSOAPBody(envelope);
+ soapBody.addChild(requestSecurityToken);
+
+ dummyMessageContext.setEnvelope(envelope);
+
+ dummyMessageContext.setAxisService(new AxisService("TestService"));
+
+
+ AxisConfiguration axisConfiguration = new AxisConfiguration();
+ dummyMessageContext.setConfigurationContext(new ConfigurationContext(axisConfiguration));
+
+ return dummyMessageContext;
+ }
+
+ public static RahasData createTestRahasData(String appliesTo) throws Exception {
+ return new RahasData(createDummyMessageContext(appliesTo));
+ }
+
+ private static void populateReceivedResults(MessageContext messageContext) throws Exception {
+ List<WSSecurityEngineResult> wsSecEngineResults = new ArrayList<WSSecurityEngineResult>();
+ WSSecurityEngineResult result = new WSSecurityEngineResult(WSConstants.SIGN);
+
+ Principal principal = new Principal() {
+ public String getName() {
+ return "apache";
+ }
+ };
+
+ result.put(WSSecurityEngineResult.TAG_PRINCIPAL, principal);
+ result.put(WSSecurityEngineResult.TAG_X509_CERTIFICATE, getDefaultCertificate());
+
+ wsSecEngineResults.add(result);
+
+ WSHandlerResult handlerResult = new WSHandlerResult(null, wsSecEngineResults);
+
+ List<WSHandlerResult> handlerResultList = new ArrayList<WSHandlerResult>();
+ handlerResultList.add(handlerResult);
+
+ messageContext.setProperty(WSHandlerConstants.RECV_RESULTS, handlerResultList);
+
+ }
+
+ /**
+ * This is directly taken from rampart-core.
+ * TODO we need to move these common code to a new module. Otherwise code will be duplicated.
+ * We cannot use following method from rampart-core as it creates a cyclic dependency. Therefore we have
+ * to live with following.
+ * @param doc The document to convert.
+ * @param useDoom Whether to use doom or not.
+ * @return A SOAPEnvelope.
+ * @throws WSSecurityException If an error occurred during conversion.
+ */
+ public static SOAPEnvelope getSOAPEnvelopeFromDOMDocument(Document doc, boolean useDoom)
+ throws WSSecurityException {
+
+ if(useDoom) {
+ try {
+ //Get processed headers
+ SOAPEnvelope env = (SOAPEnvelope)doc.getDocumentElement();
+ ArrayList processedHeaderQNames = new ArrayList();
+ SOAPHeader soapHeader = env.getHeader();
+
+ if(soapHeader != null) {
+ Iterator headerBlocs = soapHeader.getChildElements();
+ while (headerBlocs.hasNext()) {
+
+ OMElement element = (OMElement)headerBlocs.next();
+ SOAPHeaderBlock header = null;
+
+ if (element instanceof SOAPHeaderBlock) {
+ header = (SOAPHeaderBlock) element;
+
+ // If a header block is not an instance of SOAPHeaderBlock, it means that
+ // it is a header we have added in rampart eg. EncryptedHeader and should
+ // be converted to SOAPHeaderBlock for processing
+ } else {
+ header = soapHeader.addHeaderBlock(element.getLocalName(), element.getNamespace());
+ Iterator attrIter = element.getAllAttributes();
+ while (attrIter.hasNext()) {
+ OMAttribute attr = (OMAttribute)attrIter.next();
+ header.addAttribute(attr.getLocalName(), attr.getAttributeValue(), attr.getNamespace());
+ }
+ Iterator nsIter = element.getAllDeclaredNamespaces();
+ while (nsIter.hasNext()) {
+ OMNamespace ns = (OMNamespace) nsIter.next();
+ header.declareNamespace(ns);
+ }
+ // retrieve all child nodes (including any text nodes)
+ // and re-attach to header block
+ Iterator children = element.getChildren();
+ while (children.hasNext()) {
+ OMNode child = (OMNode)children.next();
+ children.remove();
+ header.addChild(child);
+ }
+
+ element.detach();
+
+ soapHeader.build();
+
+ header.setProcessed();
+
+ }
+
+ if(header.isProcessed()) {
+ processedHeaderQNames.add(element.getQName());
+ }
+ }
+
+ }
+ XMLStreamReader reader = ((OMElement) doc.getDocumentElement())
+ .getXMLStreamReader();
+ SOAPModelBuilder stAXSOAPModelBuilder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(
+ reader);
+ SOAPEnvelope envelope = stAXSOAPModelBuilder.getSOAPEnvelope();
+
+ //Set the processed flag of the processed headers
+ SOAPHeader header = envelope.getHeader();
+ for (Iterator iter = processedHeaderQNames.iterator(); iter
+ .hasNext();) {
+ QName name = (QName) iter.next();
+ Iterator omKids = header.getChildrenWithName(name);
+ if(omKids.hasNext()) {
+ ((SOAPHeaderBlock)omKids.next()).setProcessed();
+ }
+ }
+
+ envelope.build();
+
+ return envelope;
+
+ } catch (FactoryConfigurationError e) {
+ throw new WSSecurityException(e.getMessage());
+ }
+ } else {
+ try {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ XMLUtils.outputDOM(doc.getDocumentElement(), os, true);
+ ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray());
+
+ SOAPModelBuilder stAXSOAPModelBuilder = OMXMLBuilderFactory.createSOAPModelBuilder(bais, null);
+ return stAXSOAPModelBuilder.getSOAPEnvelope();
+ } catch (Exception e) {
+ throw new WSSecurityException(e.getMessage());
+ }
+ }
+ }
+
+ /**
+ * TODO we need to move these common code to a new module. Otherwise code will be duplicated.
+ * We cannot use following method from rampart-core as it creates a cyclic dependency. Therefore we have
+ * to live with following.
+ * Creates a DOM Document using the SOAP Envelope.
+ * @param env An org.apache.axiom.soap.SOAPEnvelope instance
+ * @return Returns the DOM Document of the given SOAP Envelope.
+ * @throws Exception If an error occurred during conversion.
+ */
+ public static Document getDocumentFromSOAPEnvelope(SOAPEnvelope env, boolean useDoom)
+ throws WSSecurityException {
+ try {
+ if(env instanceof Element) {
+ Element element = (Element)env;
+ Document document = element.getOwnerDocument();
+ // For outgoing messages, Axis2 only creates the SOAPEnvelope, but no document. If
+ // the Axiom implementation also supports DOM, then the envelope (seen as a DOM
+ // element) will have an owner document, but the document and the envelope have no
+ // parent-child relationship. On the other hand, the input expected by WSS4J is
+ // a document with the envelope as document element. Therefore we need to set the
+ // envelope as document element on the owner document.
+ if (element.getParentNode() != document) {
+ document.appendChild(element);
+ }
+ // If the Axiom implementation supports DOM, then it is possible/likely that the
+ // DOM API was used to create the object model (or parts of it). In this case, the
+ // object model is not necessarily well formed with respect to namespaces because
+ // DOM doesn't generate namespace declarations automatically. This is an issue
+ // because WSS4J/Santuario expects that all namespace declarations are present.
+ // If this is not the case, then signature values or encryptions will be incorrect.
+ // To avoid this, we normalize the document. Note that if we disable the other
+ // normalizations supported by DOM, this is generally not a heavy operation.
+ // In particular, the Axiom implementation is not required to expand the object
+ // model (including OMSourcedElements) because the Axiom builder is required to
+ // perform namespace repairing, so that no modifications to unexpanded parts of
+ // the message are required.
+ DOMConfiguration domConfig = document.getDomConfig();
+ domConfig.setParameter("split-cdata-sections", Boolean.FALSE);
+ domConfig.setParameter("well-formed", Boolean.FALSE);
+ domConfig.setParameter("namespaces", Boolean.TRUE);
+ document.normalizeDocument();
+ return document;
+ }
+
+ if (useDoom) {
+ env.build();
+
+ // Workaround to prevent a bug in AXIOM where
+ // there can be an incomplete OMElement as the first child body
+ OMElement firstElement = env.getBody().getFirstElement();
+ if (firstElement != null) {
+ firstElement.build();
+ }
+
+ //Get processed headers
+ SOAPHeader soapHeader = env.getHeader();
+ ArrayList processedHeaderQNames = new ArrayList();
+ if(soapHeader != null) {
+ Iterator headerBlocs = soapHeader.getChildElements();
+ while (headerBlocs.hasNext()) {
+ SOAPHeaderBlock element = (SOAPHeaderBlock) headerBlocs.next();
+ if(element.isProcessed()) {
+ processedHeaderQNames.add(element.getQName());
+ }
+ }
+ }
+
+ SOAPModelBuilder stAXSOAPModelBuilder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(
+ OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM),
+ env.getXMLStreamReader());
+ SOAPEnvelope envelope = (stAXSOAPModelBuilder)
+ .getSOAPEnvelope();
+ envelope.getParent().build();
+
+ //Set the processed flag of the processed headers
+ SOAPHeader header = envelope.getHeader();
+ for (Iterator iter = processedHeaderQNames.iterator(); iter
+ .hasNext();) {
+ QName name = (QName) iter.next();
+ Iterator omKids = header.getChildrenWithName(name);
+ if(omKids.hasNext()) {
+ ((SOAPHeaderBlock)omKids.next()).setProcessed();
+ }
+ }
+
+ Element envElem = (Element) envelope;
+ return envElem.getOwnerDocument();
+ } else {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ env.build();
+ env.serialize(baos);
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos
+ .toByteArray());
+ DocumentBuilderFactory factory = DocumentBuilderFactory
+ .newInstance();
+ factory.setNamespaceAware(true);
+ return factory.newDocumentBuilder().parse(bais);
+ }
+ } catch (Exception e) {
+ throw new WSSecurityException(
+ "Error in converting SOAP Envelope to Document", e);
+ }
+ }
}
Modified: axis/axis2/java/rampart/branches/RAMPART-289/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/pom.xml?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/pom.xml (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/pom.xml Mon Jan 30 17:50:58 2017
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
- <version>8</version>
+ <version>17</version>
</parent>
<groupId>org.apache.rampart</groupId>
@@ -33,7 +33,7 @@
<artifactId>rampart-project</artifactId>
<packaging>pom</packaging>
<description> WS-Security, WS-Trust and WS-SecureConversation implementaion for Apache Axis2 </description>
- <version>1.7.0-SNAPSHOT</version>
+ <version>1.8.0-SNAPSHOT</version>
<name>Apache Rampart</name>
<url>http://axis.apache.org/axis2/java/rampart</url>
@@ -118,26 +118,13 @@
<url>http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk</url>
</scm>
-
- <repositories>
- <repository>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>always</updatePolicy>
- <checksumPolicy>warn</checksumPolicy>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
- <checksumPolicy>warn</checksumPolicy>
- </snapshots>
- <id>open-saml</id>
- <name>OpenSAML</name>
- <url>http://shibboleth.internet2.edu/downloads/maven2/</url>
- </repository>
-
- </repositories>
-
+ <distributionManagement>
+ <site>
+ <id>site</id>
+ <url>scm:svn:https://svn.apache.org/repos/asf/axis/site/axis2/java/rampart-staging</url>
+ </site>
+ </distributionManagement>
+
<build>
<pluginManagement>
<plugins>
@@ -146,128 +133,321 @@
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<preparationGoals>clean install</preparationGoals>
+ <tagNameFormat>v@{project.version}</tagNameFormat>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-mar-maven-plugin</artifactId>
- <version>1.5.4</version>
+ <version>${axis2.version}</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
+ <configuration>
+ <argLine>${jacoco.surefireArgLine}</argLine>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.7</version>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.gmavenplus</groupId>
+ <artifactId>gmavenplus-plugin</artifactId>
+ <version>1.5</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>2.4.4</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.6</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.7</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-repo-maven-plugin</artifactId>
+ <version>${axis2.version}</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>3.4</version>
+ <configuration>
+ <!-- Required by maven-scm-publish-plugin -->
+ <skipDeploy>true</skipDeploy>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.6</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.10.3</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
-
+ <plugin>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireNoRepositories>
+ <message>The POM must not include repository definitions since non Apache repositories threaten the build stability.</message>
+ <banRepositories>true</banRepositories>
+ <banPluginRepositories>true</banPluginRepositories>
+ <!-- We still need to allow the Apache snapshot repository -->
+ <allowSnapshotRepositories>true</allowSnapshotRepositories>
+ <allowSnapshotPluginRepositories>true</allowSnapshotPluginRepositories>
+ </requireNoRepositories>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.gmavenplus</groupId>
+ <artifactId>gmavenplus-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>initialize</id>
+ <phase>initialize</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <scripts>
+ <script>
+ <!-- Skip Jacoco if necessary -->
+ if (project.packaging == 'pom' || project.properties['skipTests'] == 'true') {
+ project.properties['skipJacoco'] = 'true'
+ }
+ </script>
+ </scripts>
+ </configuration>
+ </execution>
+ <execution>
+ <id>prepare-site</id>
+ <phase>pre-site</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <scripts>
+ <script>
+ import java.util.Date
+ import java.text.MessageFormat
+ project.properties['release_date'] = MessageFormat.format("{0,date,MMMMM dd, yyyy}", new Date())
+ project.properties['release_version'] = project.version.replaceAll("-SNAPSHOT", "")
+ project.properties['skipSiteSite'] = String.valueOf(!new File(project.basedir, 'src/site/site.xml').exists())
+ </script>
+ </scripts>
+ </configuration>
+ </execution>
+ <execution>
+ <id>check-site</id>
+ <phase>post-site</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <scripts>
+ <script>
+ project.properties['skipSiteStage'] = String.valueOf(!new File(project.reporting.outputDirectory).exists())
+ </script>
+ </scripts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>${jacoco.version}</version>
+ <executions>
+ <execution>
+ <id>prepare-agent-for-surefire</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ <configuration>
+ <propertyName>jacoco.surefireArgLine</propertyName>
+ <!-- Anonymize the session ID (by default it contains the name of the host executing the build) -->
+ <sessionId>mvn:${project.groupId}:${project.artifactId}:${project.version}:surefire</sessionId>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <skip>${skipJacoco}</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-jacoco-exec</id>
+ <phase>test</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <skipAttach>${skipJacoco}</skipAttach>
+ <artifacts>
+ <artifact>
+ <file>${project.build.directory}/jacoco.exec</file>
+ <classifier>jacoco</classifier>
+ <type>exec</type>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <!-- We need (some of) the source JARs for the code coverage analysis. -->
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>source-jars</id>
+ <goals>
+ <goal>jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <attach>true</attach>
+ </configuration>
+ </plugin>
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0</version>
<configuration>
- <source>1.5</source>
- <target>1.5</target>
+ <source>1.6</source>
+ <target>1.6</target>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>animal-sniffer-maven-plugin</artifactId>
+ <version>1.14</version>
+ <executions>
+ <execution>
+ <id>check</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <configuration>
+ <signature>
+ <groupId>org.codehaus.mojo.signature</groupId>
+ <artifactId>java16</artifactId>
+ <version>1.1</version>
+ </signature>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
- <version>2.0-beta-5</version>
- <inherited>false</inherited>
+ <executions>
+ <execution>
+ <id>default-site</id>
+ <phase>site</phase>
+ <goals>
+ <goal>site</goal>
+ </goals>
+ <configuration>
+ <skip>${skipSiteSite}</skip>
+ </configuration>
+ </execution>
+ <execution>
+ <id>site-stage</id>
+ <phase>site-deploy</phase>
+ <goals>
+ <goal>stage</goal>
+ </goals>
+ <configuration>
+ <skip>${skipSiteStage}</skip>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <!-- Don't deploy; we use maven-scm-publish-plugin -->
+ <skipDeploy>true</skipDeploy>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-scm-publish-plugin</artifactId>
+ <version>1.0-beta-2</version>
</plugin>
</plugins>
</build>
-
- <dependencies>
-
- <!-- Axis2 and Axiom Dependencies -->
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-kernel</artifactId>
- <version>${axis2.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>mex</artifactId>
- <version>${axis2.version}</version>
- <classifier>impl</classifier>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-mtompolicy</artifactId>
- <version>${axis2.version}</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>addressing</artifactId>
- <type>mar</type>
- <version>${axis2.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <!-- Other Rampart Dependencies -->
- <dependency>
- <groupId>org.apache.ws.security</groupId>
- <artifactId>wss4j</artifactId>
- <version>${wss4j.version}</version>
- <exclusions>
- <!-- We exclude xalan:xalan as a transitive dependency, but include
- org.apache.xalan:xalan as a direct dependency. This avoids
- conflicts with the dependencies of org.opensaml:opensaml
- (which uses org.apache.xalan:xalan). -->
- <exclusion>
- <artifactId>xalan</artifactId>
- <groupId>xalan</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.xalan</groupId>
- <artifactId>xalan</artifactId>
- <version>2.7.1</version>
- </dependency>
- <dependency>
- <groupId>org.opensaml</groupId>
- <artifactId>opensaml</artifactId>
- <version>${opensaml.version}</version>
- <exclusions>
- <!-- Don't allow OpenSAML to impose a particular logging implementation -->
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>log4j-over-slf4j</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.3</version>
- </dependency>
- <dependency>
- <groupId>bouncycastle</groupId>
- <artifactId>bcprov-jdk15</artifactId>
- <version>${bcprov.jdk15.version}</version>
- </dependency>
-
- <!-- Junit Dependency -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>2.8.1</version>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>project-team</report>
+ <report>dependencies</report>
+ <report>mailing-list</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ </plugins>
+ </reporting>
+
<dependencyManagement>
<dependencies>
+ <!-- Axis2 dependencies -->
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-kernel</artifactId>
+ <version>${axis2.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-mtompolicy</artifactId>
+ <version>${axis2.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>mex</artifactId>
+ <version>${axis2.version}</version>
+ <classifier>impl</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>addressing</artifactId>
+ <version>${axis2.version}</version>
+ <type>mar</type>
+ </dependency>
+
<!-- Since Rampart depends on DOOM, but axiom-dom is not a transitive
dependency, we need to manage the Axiom version. -->
<dependency>
@@ -285,16 +465,58 @@
<artifactId>axiom-dom</artifactId>
<version>${axiom.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-truth</artifactId>
+ <version>${axiom.version}</version>
+ </dependency>
+ <!-- Other Rampart Dependencies -->
+ <dependency>
+ <groupId>org.apache.ws.security</groupId>
+ <artifactId>wss4j</artifactId>
+ <version>${wss4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-jdk15on</artifactId>
+ <version>${bcprov.jdk15.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.7.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opensaml</groupId>
+ <artifactId>opensaml</artifactId>
+ <version>${opensaml.version}</version>
+ <exclusions>
+ <!-- Don't allow OpenSAML to impose a particular logging implementation -->
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-jdk15</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
- <version>1.5.5</version>
+ <version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jcl</artifactId>
- <version>1.5.5</version>
+ <version>1.6.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
@@ -327,21 +549,17 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ </dependency>
</dependencies>
</dependencyManagement>
<profiles>
<profile>
<id>apache-release</id>
- <activation>
- <property>
- <name>release</name>
- </property>
- </activation>
- <modules>
- <module>modules/documentation</module>
- <module>modules/distribution</module>
- </modules>
<build>
<plugins>
<plugin>
@@ -362,22 +580,26 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <!-- Skip the execution configured in org.apache:apache. We use our own configuration. -->
+ <id>attach-sources</id>
+ <phase>none</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</profile>
-
- <profile>
- <!-- Profile that includes all modules. This is handy when using maven-release-plugin
- for anything else than doing a release. -->
- <id>everything</id>
- <modules>
- <module>modules/documentation</module>
- <module>modules/distribution</module>
- </modules>
- </profile>
</profiles>
<modules>
+ <module>apidocs</module>
<module>modules/rampart-policy</module>
<module>modules/rampart-trust</module>
<module>modules/rampart-core</module>
@@ -385,22 +607,35 @@
<module>modules/rampart-mar</module>
<module>modules/rampart-trust-mar</module>
<module>modules/rampart-integration</module>
+ <module>modules/rampart-samples</module> <!-- Compile sample codes -->
+ <module>modules/distribution</module>
+ <module>code-coverage</module>
</modules>
<properties>
- <axis2.version>1.7.0-SNAPSHOT</axis2.version>
- <axiom.version>1.2.13-SNAPSHOT</axiom.version>
+ <axis2.version>1.8.0-SNAPSHOT</axis2.version>
+ <axiom.version>1.3.0-SNAPSHOT</axiom.version>
- <wss4j.version>1.6.4</wss4j.version>
+ <wss4j.version>1.6.19</wss4j.version>
<opensaml.version>2.5.1-1</opensaml.version>
- <bcprov.jdk15.version>140</bcprov.jdk15.version>
-
- <junit.version>3.8.2</junit.version>
+ <bcprov.jdk15.version>1.49</bcprov.jdk15.version>
- <!-- distribution properties -->
- <dist.dir>rampart-${project.version}</dist.dir>
<failIfNoTests>false</failIfNoTests>
+ <jacoco.version>0.7.5.201505241946</jacoco.version>
</properties>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache.snapshots</id>
+ <url>http://repository.apache.org/snapshots/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </pluginRepository>
+ </pluginRepositories>
</project>