0 Replies Latest reply on Jul 2, 2014 10:36 AM by prabhusamad

    Exception in thread "main" javax.xml.ws.WebServiceException: java.lang.SecurityException: WS-Security error: The signature or decryption was invalid

    prabhusamad

      I am using OHIP(Ontario Health insurance Plan) web service to download files.I am able to download small files below 41 KB,But for large files i can download,but not decrypted and was getting exception like this.

       

      [Fatal Error] :58:21: The entity name must immediately follow the '&' in the entity reference.

      Exception in thread "main" javax.xml.ws.WebServiceException: java.lang.SecurityException: WS-Security error: The signature or decryption was invalid

          at com.sun.xml.ws.handler.ClientSOAPHandlerTube.callHandlersOnResponse(ClientSOAPHandlerTube.java:169)

          at com.sun.xml.ws.handler.HandlerTube.processResponse(HandlerTube.java:174)

          at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1147)

          at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)

          at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)

          at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)

          at com.sun.xml.ws.client.Stub.process(Stub.java:464)

          at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:174)

          at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)

          at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:91)

          at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:154)

          at com.sun.proxy.$Proxy40.download(Unknown Source)

          at com.edt.main.EdtMain.download(EdtMain.java:248)

          at com.edt.main.EdtMain.downloadTest(EdtMain.java:102)

          at com.edt.main.EdtMain.main(EdtMain.java:79)

      Caused by: java.lang.SecurityException: WS-Security error: The signature or decryption was invalid

          at com.edt.main.SRHandler.handleMessage(SRHandler.java:283)

          at com.edt.main.SRHandler.handleMessage(SRHandler.java:87)

          at com.sun.xml.ws.handler.HandlerProcessor.callHandleMessageReverse(HandlerProcessor.java:341)

          at com.sun.xml.ws.handler.HandlerProcessor.callHandlersResponse(HandlerProcessor.java:214)

          at com.sun.xml.ws.handler.ClientSOAPHandlerTube.callHandlersOnResponse(ClientSOAPHandlerTube.java:163)

          ... 14 more

      Caused by: org.apache.ws.security.WSSecurityException: The signature or decryption was invalid

          at org.apache.ws.security.processor.ReferenceListProcessor.decryptEncryptedData(ReferenceListProcessor.java:339)

          at org.apache.ws.security.processor.EncryptedKeyProcessor.decryptDataRef(EncryptedKeyProcessor.java:451)

          at org.apache.ws.security.processor.EncryptedKeyProcessor.decryptDataRefs(EncryptedKeyProcessor.java:380)

          at org.apache.ws.security.processor.EncryptedKeyProcessor.handleToken(EncryptedKeyProcessor.java:178)

          at org.apache.ws.security.processor.EncryptedKeyProcessor.handleToken(EncryptedKeyProcessor.java:65)

          at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:396)

          at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:303)

          at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:248)

          at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:202)

          at com.edt.main.SRHandler.handleMessage(SRHandler.java:278)

          ... 18 more

      Caused by: org.apache.xml.security.encryption.XMLEncryptionException: The entity name must immediately follow the '&' in the entity reference.

      Original Exception was org.xml.sax.SAXParseException; lineNumber: 58; columnNumber: 21; The entity name must immediately follow the '&' in the entity reference.

          at org.apache.xml.security.encryption.DocumentSerializer.deserialize(DocumentSerializer.java:93)

          at org.apache.xml.security.encryption.DocumentSerializer.deserialize(DocumentSerializer.java:49)

          at org.apache.xml.security.encryption.XMLCipher.decryptElement(XMLCipher.java:1625)

          at org.apache.xml.security.encryption.XMLCipher.doFinal(XMLCipher.java:980)

          at org.apache.ws.security.processor.ReferenceListProcessor.decryptEncryptedData(ReferenceListProcessor.java:337)

          ... 27 more

      Caused by: org.xml.sax.SAXParseException; lineNumber: 58; columnNumber: 21; The entity name must immediately follow the '&' in the entity reference.

          at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)

          at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)

          at org.apache.xml.security.encryption.DocumentSerializer.deserialize(DocumentSerializer.java:73)

          ... 31 more

      Java Result: 1

       

      and exception occurs from

       

       

      List<WSSecurityEngineResult> result = securityEngine.processSecurityHeader(doc, null, new MyCallbackHandler(), crypto);

      any solution for this problem will be appreciated.

      Thanks