You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wss4j-dev@ws.apache.org by Terance Dias <te...@yahoo.com> on 2006/06/08 15:43:31 UTC

"The signature verification failed" on creating SOAPEnvelope from Document

Hi,
   
  I'm using WebSphere Application Server 5.1. Here, after signing the message, I'm creating a SOAPEnvelope from the Document by doing the following:
   
  TransformerFactory fact = TransformerFactory.newInstance();
  Transformer trans = null;
  try 
  {
   trans = fact.newTransformer();
  } 
  catch (TransformerConfigurationException e1) 
  {
   e1.printStackTrace();
   throw e1;
  }
  DOMSource source = new DOMSource(doc.getDocumentElement()); ///doc is the signed Document
  StreamResult result = new StreamResult(new StringWriter());
  try 
  {
   trans.transform(source,result);
  } 
  catch (TransformerException e) 
  {
   e.printStackTrace();
   throw e;
  }
  String str = result.getWriter().toString();
   
  MessageFactory factory = MessageFactory.newInstance();
SOAPEnvelope env = factory.createMessage(null, new ByteArrayInputStream(str.getBytes())).getSOAPPart().getEnvelope();
   
  I have to do this to set the signed document in the SOAPMessage that I am going to send. But, now when I try to verify the signature by doing the following, the signature verification fails.
   
  DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
  dFactory.setNamespaceAware(true);
DocumentBuilder build = dFactory.newDocumentBuilder();
ByteArrayInputStream input = new ByteArrayInputStream(env.toString().getBytes());
Document doc = build.parse(input);
   
  Now if I try to verify the signature with this document, it fails.
  Has anybody faced this problem. I've checked the xml and it looks fine, except for the namespaces moving from child nodes to parent nodes.
  Any help with this will be highly appreciated.
   
  Thanks and Regards,
  Terance. 

 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com