Uploaded image for project: 'WSS4J'
  1. WSS4J
  2. WSS-563

Cannot decrypt non XML conform attachements

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.3
    • 2.0.7, 2.1.5, 2.2.0
    • WSS4J Core
    • None

    Description

      Problem description see:
      http://cxf.547215.n5.nabble.com/WSS-Client-soap-fault-namespace-problem-td5761485.html

      My not very good solution in the class:
      org.apache.wss4j.dom.util.EncryptionUtils.decryptXopAttachment(SecretKey, String, RequestData, String, Element)

      Document document = null;
      		try {
      			document = db.parse(byteArrayInputStream);
      		} catch (SAXParseException e) {
      
      			if (e.getMessage() == null || !e.getMessage().contains("soap:Fault")) {
      				throw e;
      			}
      			// add envelope namespace to root document (soap:Fault) as string
      			byteArrayInputStream = new ByteArrayInputStream(input);
      			String docStr = new String(input);
      			docStr = docStr.replace("<soap:Fault",
      					"<soap:Fault xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"");
      
      			// Try to parse again.
      			document = db.parse(new ByteArrayInputStream(docStr.getBytes()));
      		}
      
      		Node decryptedNode = encData.getOwnerDocument().importNode(document.getDocumentElement(), true);
      		encData.getParentNode().appendChild(decryptedNode);
      		org.apache.xml.security.utils.XMLUtils.repoolDocumentBuilder(db);
      		encData.getParentNode().removeChild(encData);
      
      		return decryptedNode;
      

      Attachments

        Activity

          People

            coheigea Colm O hEigeartaigh
            anpoky Andreas Pokrzywinski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: