axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ruchith Fernando" <ruchith.ferna...@gmail.com>
Subject Re: [Axis2 v1.0] send file with security
Date Thu, 20 Jul 2006 09:16:00 GMT
Hi Wan,

Please remove :
<optimizeParts>//xenc:EncryptedData/xenc:CipherData/xenc:CipherValue</optimizeParts>

entry from your rampart configuration parameters and try again.

Thanks,
Ruchith

On 7/20/06, Wan Kaveevivitchai <wan1551@hotmail.com> wrote:
> Dear All,
>
>        I have been trying to combine the test about sending file and
> securing message.
>        My environment is Axis2 v1.0, nightly build released 4 June 06 on the
> Jetty Servlet.
>
>        From other individual test such as sending text file, and security
> sample had no problem on this, however with the combination one i got the
> following error.
>
>        Client code:
>
> /*
> * Created on 19.07.2006
> *
> * TODO To change the template for this generated file go to
> * Window - Preferences - Java - Code Style - Code Templates
> */
> package security;
>
> /**
> * @author alice3
> *
> * TODO To change the template for this generated type comment go to
> * Window - Preferences - Java - Code Style - Code Templates
> */
>
> import org.apache.axiom.om.OMAbstractFactory;
> import org.apache.axiom.om.OMElement;
> import org.apache.axiom.om.OMFactory;
> import org.apache.axiom.om.OMNamespace;
> import org.apache.axiom.om.OMText;
> import org.apache.axis2.AxisFault;
> import org.apache.axis2.Constants;
> import org.apache.axis2.addressing.EndpointReference;
> import org.apache.axis2.client.Options;
> import org.apache.axis2.client.ServiceClient;
> import org.apache.axis2.context.ConfigurationContext;
> import org.apache.axis2.context.ConfigurationContextFactory;
>
> //import org.apache.axis2.soapmonitor.*;
>
> import javax.activation.DataHandler;
> import javax.activation.FileDataSource;
> import javax.xml.namespace.QName;
> import javax.xml.stream.XMLOutputFactory;
> import javax.xml.stream.XMLStreamException;
>
> import java.io.File;
> import java.io.StringWriter;
>
>
> public class SecureClient {
>
>     private File inputFile = null;
>
>     private QName operationName = new QName("fileSecurity");
>
>     public static void main(String[] args) {
>
>         try {
>
>             // Get the repository location from the args
>             String repo = args[0];
>             String port = args[1];
>
>             OMElement payload =
> getEchoElement("/users/alice3/myDoc/Jettty6-Axis2.txt");
>             ConfigurationContext configContext =
> ConfigurationContextFactory.createConfigurationContextFromFileSystem(repo,
> null);
>             ServiceClient serviceClient = new ServiceClient(configContext,
> null);
>             Options options = new Options();
>             options.setTo(new EndpointReference("http://127.0.0.1:" + port +
> "/axis2/services/FileSecurity"));
>             //options.setTo(new
> EndpointReference("http://localhost:8080/axis2_new/services/SecureService"));
>             options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
>             options.setProperty(Constants.Configuration.ENABLE_MTOM,
> Constants.VALUE_TRUE);
>             options.setAction("urn:fileSecurity");
>             serviceClient.setOptions(options);
>
>             //Blocking invocation
>             OMElement result = serviceClient.sendReceive(payload);
>
>             StringWriter writer = new StringWriter();
>             result.serialize(XMLOutputFactory.newInstance()
>                     .createXMLStreamWriter(writer));
>             writer.flush();
>
>
>
>            //System.out.println("Response: " + writer.toString());
>
>             System.out.println("SecureService Invocation successful :-)");
>         } catch (AxisFault axisFault) {
>             axisFault.printStackTrace();
>         } catch (XMLStreamException e) {
>             e.printStackTrace();
>         }
>     }
>
>
>     private static OMElement getEchoElement(String fileName) {
>
>
>         DataHandler dh;
>
>                 OMFactory fac = OMAbstractFactory.getOMFactory();
>             OMNamespace omNs =
> fac.createOMNamespace("http://ws.apache.org/axis2/xsd", "example1");
>
>         OMElement data = fac.createOMElement("fileSecurity", omNs);
>         OMElement input = fac.createOMElement("file", omNs);
>             OMElement pack = fac.createOMElement("pack", omNs);
>
>             FileDataSource f1 = new FileDataSource(fileName);
>         dh = new DataHandler(f1);
>
>         OMElement filename = fac.createOMElement("fileName", omNs);
>        // OMText textName = fac.createOMText(filename, "myFile.txt");
>
>         OMText textData = fac.createOMText(dh, true);
>
>         input.addChild(textData);
>
>         pack.addChild(filename);
>         pack.addChild(input);
>         data.addChild(pack);
>
>         //System.out.println(data);
>
>              return data;
>         }
> }
>
>         server code:
>
> public class fileS {
>
>         public OMElement fileSecurity(OMElement element) throws Exception
>         {
>                 //System.out.println(element);
>
>                 element.build();
>                 element.detach();
>
>             Iterator children = element.getChildElements();
>
>                 OMElement name = (OMElement)children.next();            //get name of
the file,
> first element of element
>                 OMElement content = (OMElement)children.next();     //get text that
> contains the file, second element
>
>                 System.out.println("before creating OMText");
>                 OMText fnode = (OMText)content.getFirstOMChild();
>                 System.out.println("after creating OMText");
> //              fnode.setOptimize(true);
>                 //String fname = name.getText();
>
>                 //create data handler to extract the data handler of the OMText
>                 DataHandler dfile;
>                 System.out.println("before getDataHandler from OMText");
>
>                 //String cid = fnode.getContentID();
>                 //System.out.println(cid);
>
>                 dfile = (DataHandler)fnode.getDataHandler();  //getDataHandler() and
> broken pipe
>
>                 System.out.println("after create datahandler for OMText");
>
>                 FileOutputStream outfile = new  FileOutputStream(new
> File("/users/alice3/myFile"));
>                 System.out.println("after create a fileoutputstream");
>                 dfile.writeTo(outfile);
>                 System.out.println("after writeTo()");
>
>                 //System.out.println("Successful Operation!");
>
>                 OMFactory fac = OMAbstractFactory.getOMFactory();
>         OMNamespace ns = fac.createOMNamespace("urn://fakenamespace", "ns");
>         OMElement ele = fac.createOMElement("response", ns);
>         ele.setText("Data Saved");
>         return ele;
>
>         }
>
> }
>
>        services.xml:
>
> <service name="FileSecurity" >
>   <description>
>                 This is my service for sending file over server-client with security
> setting
>         </description>
>   <parameter locked="false" name="ServiceClass" >security.fileS</parameter>
>   <operation name="fileSecurity" >
>     <messageReceiver
> class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
>   </operation>
>   <parameter name="InflowSecurity" >
>     <action>
>       <items>Timestamp Signature Encrypt</items>
>       <passwordCallbackClass>security.PWCallback</passwordCallbackClass>
>       <signaturePropFile>sec.properties</signaturePropFile>
>     </action>
>   </parameter>
>   <parameter name="OutflowSecurity" >
>     <action>
>       <items>Timestamp Signature Encrypt</items>
>       <user>bob</user>
>       <passwordCallbackClass>security.PWCallback</passwordCallbackClass>
>       <signaturePropFile>sec.properties</signaturePropFile>
>       <signatureKeyIdentifier>SKIKeyIdentifier</signatureKeyIdentifier>
>       <encryptionKeyIdentifier>SKIKeyIdentifier</encryptionKeyIdentifier>
>       <encryptionUser>alice</encryptionUser>
>
> <optimizeParts>//xenc:EncryptedData/xenc:CipherData/xenc:CipherValue</optimizeParts>
>     </action>
>   </parameter>
> </service>
>
>          and the .aar package is constucted as follow
>
>         security/
>                 security/PWCallback.class
>                 security/fileS.class
>         META-INF/
>                 META-INF/services.xml
>         sec.jks
>         sec.properties
>
>      and the result i get from the TCPMON is that at the server side
>
> HTTP/1.1 500 INTERNAL%5FSERVER%5FERROR
> Expires: Thu, 01 Jan 1970 00:00:00 GMT
> Set-Cookie: JSESSIONID=2217shn5dgknb;path=/axis2
> Content-Type: multipart/related;
> boundary=MIMEBoundaryurn_uuid_18DA9EF1316848D89311533845942031;
> type="application/xop+xml";
> start="<0.urn:uuid:18DA9EF1316848D89311533845942032@apache.org>";
> start-info="text/xml"; charset=UTF-8
> Transfer-Encoding: chunked
> Server: Jetty(6.0.x)
>
> 2DA
> --MIMEBoundaryurn_uuid_18DA9EF1316848D89311533845942031
> content-type:application/xop+xml; charset=UTF-8; type="text/xml";
> content-transfer-encoding:binary
> content-id:<0.urn:uuid:18DA9EF1316848D89311533845942032@apache.org>
>
> <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:wsa="http://www.w3.org/2005/08/addressing"><soapenv:Header><wsa:ReplyTo><wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address></wsa:ReplyTo><wsa:MessageID>urn:uuid:EE59E38396186D1F1211533845941701</wsa:MessageID><wsa:Action>http://www.w3.org/2005/08/addressing/fault</wsa:Action></soapenv:Header><soapenv:Body><soapenv:Fault><faultcode>soapenv:Client</faultcode>
> 35B
>
> --MIMEBoundaryurn_uuid_18DA9EF1316848D89311533845942031----MIMEBoundaryurn_uuid_18DA9EF1316848D89311533845942031
> content-type:application/xop+xml; charset=UTF-8; type="text/xml";
> content-transfer-encoding:binary
> content-id:<0.urn:uuid:18DA9EF1316848D89311533845942032@apache.org>
>
> <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:wsa="http://www.w3.org/2005/08/addressing"><soapenv:Header><wsa:ReplyTo><wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address></wsa:ReplyTo><wsa:MessageID>urn:uuid:EE59E38396186D1F1211533845941701</wsa:MessageID><wsa:Action>http://www.w3.org/2005/08/addressing/fault</wsa:Action></soapenv:Header><soapenv:Body><soapenv:Fault><faultcode>soapenv:Client</faultcode><faultstring>WSDoAllReceiver:
> security processing failed</faultstring>
> 1383
>
> --MIMEBoundaryurn_uuid_18DA9EF1316848D89311533845942031----MIMEBoundaryurn_uuid_18DA9EF1316848D89311533845942031
> content-type:application/xop+xml; charset=UTF-8; type="text/xml";
> content-transfer-encoding:binary
> content-id:<0.urn:uuid:18DA9EF1316848D89311533845942032@apache.org>
>
> <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:wsa="http://www.w3.org/2005/08/addressing"><soapenv:Header><wsa:ReplyTo><wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address></wsa:ReplyTo><wsa:MessageID>urn:uuid:EE59E38396186D1F1211533845941701</wsa:MessageID><wsa:Action>http://www.w3.org/2005/08/addressing/fault</wsa:Action></soapenv:Header><soapenv:Body><soapenv:Fault><faultcode>soapenv:Client</faultcode><faultstring>WSDoAllReceiver:
> security processing
> failed</faultstring><detail><Exception>org.apache.axis2.AxisFault:
> WSDoAllReceiver: security processing failed; nested exception is:
>         org.apache.ws.security.WSSecurityException: Cannot encrypt/decrypt data;
> nested exception is:
>         org.apache.xml.security.encryption.XMLEncryptionException: Error while
> decoding
> Original Exception was
> org.apache.xml.security.exceptions.Base64DecodingException: Error while
> decoding
>         at
> org.apache.axis2.security.WSDoAllReceiver.processMessage(WSDoAllReceiver.java:183)
>         at
> org.apache.axis2.security.handler.WSDoAllHandler.invoke(WSDoAllHandler.java:82)
>         at org.apache.axis2.engine.Phase.invoke(Phase.java:380)
>         at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:499)
>         at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:469)
>         at
> org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:284)
>         at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:144)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:767)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
>         at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:423)
>         at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:355)
>         at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:219)
>         at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:542)
>         at
> org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:145)
>         at
> org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:126)
>         at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
>         at org.mortbay.jetty.Server.handle(Server.java:245)
>         at org.mortbay.jetty.HttpConnection.handlerRequest(HttpConnection.java:365)
>         at org.mortbay.jetty.HttpConnection.access$1500(HttpConnection.java:38)
>         at
> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:623)
>         at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:690)
>         at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:196)
>         at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:296)
>         at
> org.mortbay.jetty.nio.SelectChannelConnector$HttpEndPoint.run(SelectChannelConnector.java:740)
>         at
> org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:435)
> Caused by: org.apache.ws.security.WSSecurityException: Cannot
> encrypt/decrypt data; nested exception is:
>         org.apache.xml.security.encryption.XMLEncryptionException: Error while
> decoding
> Original Exception was
> org.apache.xml.security.exceptions.Base64DecodingException: Error while
> decoding
>         at
> org.apache.ws.security.processor.EncryptedKeyProcessor.decryptDataRef(EncryptedKeyProcessor.java:404)
>         at
> org.apache.ws.security.processor.EncryptedKeyProcessor.handleEncryptedKey(EncryptedKeyProcessor.java:328)
>         at
> org.apache.ws.security.processor.EncryptedKeyProcessor.handleEncryptedKey(EncryptedKeyProcessor.java:84)
>         at
> org.apache.ws.security.processor.EncryptedKeyProcessor.handleToken(EncryptedKeyProcessor.java:76)
>         at
> org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:269)
>         at
> org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:191)
>         at
> org.apache.axis2.security.WSDoAllReceiver.processMessage(WSDoAllReceiver.java:180)
>         ... 24 more
> Caused by: org.apache.xml.security.encryption.XMLEncryptionException: Error
> while decoding
> Original Exception was
> org.apache.xml.security.exceptions.Base64DecodingException: Error while
> decoding
>         at
> org.apache.xml.security.encryption.XMLCipherInput.getDecryptBytes(Unknown
> Source)
>         at org.apache.xml.security.encryption.XMLCipherInput.getBytes(Unknown
> Source)
>         at org.apache.xml.security.encryption.XMLCipher.decryptToByteArray(Unknown
> Source)
>         at org.apache.xml.security.encryption.XMLCipher.decryptElement(Unknown
> Source)
>         at
> org.apache.xml.security.encryption.XMLCipher.decryptElementContent(Unknown
> Source)
>         at org.apache.xml.security.encryption.XMLCipher.doFinal(Unknown Source)
>         at
> org.apache.ws.security.processor.EncryptedKeyProcessor.decryptDataRef(EncryptedKeyProcessor.java:402)
>         ... 30 more
> </Exception></detail>
> 13B5
>
> --MIMEBoundaryurn_uuid_18DA9EF1316848D89311533845942031----MIMEBoundaryurn_uuid_18DA9EF1316848D89311533845942031
> content-type:application/xop+xml; charset=UTF-8; type="text/xml";
> content-transfer-encoding:binary
> content-id:<0.urn:uuid:18DA9EF1316848D89311533845942032@apache.org>
>
> <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:wsa="http://www.w3.org/2005/08/addressing"><soapenv:Header><wsa:ReplyTo><wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address></wsa:ReplyTo><wsa:MessageID>urn:uuid:EE59E38396186D1F1211533845941701</wsa:MessageID><wsa:Action>http://www.w3.org/2005/08/addressing/fault</wsa:Action></soapenv:Header><soapenv:Body><soapenv:Fault><faultcode>soapenv:Client</faultcode><faultstring>WSDoAllReceiver:
> security processing
> failed</faultstring><detail><Exception>org.apache.axis2.AxisFault:
> WSDoAllReceiver: security processing failed; nested exception is:
>         org.apache.ws.security.WSSecurityException: Cannot encrypt/decrypt data;
> nested exception is:
>         org.apache.xml.security.encryption.XMLEncryptionException: Error while
> decoding
> Original Exception was
> org.apache.xml.security.exceptions.Base64DecodingException: Error while
> decoding
>         at
> org.apache.axis2.security.WSDoAllReceiver.processMessage(WSDoAllReceiver.java:183)
>         at
> org.apache.axis2.security.handler.WSDoAllHandler.invoke(WSDoAllHandler.java:82)
>         at org.apache.axis2.engine.Phase.invoke(Phase.java:380)
>         at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:499)
>         at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:469)
>         at
> org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:284)
>         at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:144)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:767)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
>         at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:423)
>         at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:355)
>         at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:219)
>         at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:542)
>         at
> org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:145)
>         at
> org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:126)
>         at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
>         at org.mortbay.jetty.Server.handle(Server.java:245)
>         at org.mortbay.jetty.HttpConnection.handlerRequest(HttpConnection.java:365)
>         at org.mortbay.jetty.HttpConnection.access$1500(HttpConnection.java:38)
>         at
> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:623)
>         at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:690)
>         at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:196)
>         at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:296)
>         at
> org.mortbay.jetty.nio.SelectChannelConnector$HttpEndPoint.run(SelectChannelConnector.java:740)
>         at
> org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:435)
> Caused by: org.apache.ws.security.WSSecurityException: Cannot
> encrypt/decrypt data; nested exception is:
>         org.apache.xml.security.encryption.XMLEncryptionException: Error while
> decoding
> Original Exception was
> org.apache.xml.security.exceptions.Base64DecodingException: Error while
> decoding
>         at
> org.apache.ws.security.processor.EncryptedKeyProcessor.decryptDataRef(EncryptedKeyProcessor.java:404)
>         at
> org.apache.ws.security.processor.EncryptedKeyProcessor.handleEncryptedKey(EncryptedKeyProcessor.java:328)
>         at
> org.apache.ws.security.processor.EncryptedKeyProcessor.handleEncryptedKey(EncryptedKeyProcessor.java:84)
>         at
> org.apache.ws.security.processor.EncryptedKeyProcessor.handleToken(EncryptedKeyProcessor.java:76)
>         at
> org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:269)
>         at
> org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:191)
>         at
> org.apache.axis2.security.WSDoAllReceiver.processMessage(WSDoAllReceiver.java:180)
>         ... 24 more
> Caused by: org.apache.xml.security.encryption.XMLEncryptionException: Error
> while decoding
> Original Exception was
> org.apache.xml.security.exceptions.Base64DecodingException: Error while
> decoding
>         at
> org.apache.xml.security.encryption.XMLCipherInput.getDecryptBytes(Unknown
> Source)
>         at org.apache.xml.security.encryption.XMLCipherInput.getBytes(Unknown
> Source)
>         at org.apache.xml.security.encryption.XMLCipher.decryptToByteArray(Unknown
> Source)
>         at org.apache.xml.security.encryption.XMLCipher.decryptElement(Unknown
> Source)
>         at
> org.apache.xml.security.encryption.XMLCipher.decryptElementContent(Unknown
> Source)
>         at org.apache.xml.security.encryption.XMLCipher.doFinal(Unknown Source)
>         at
> org.apache.ws.security.processor.EncryptedKeyProcessor.decryptDataRef(EncryptedKeyProcessor.java:402)
>         ... 30 more
> </Exception></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>
> 3B
>
> --MIMEBoundaryurn_uuid_18DA9EF1316848D89311533845942031--
> 0
>
>           The client side message seems to be ok, with all the encypted
> document.
>
>           Is there any idea what can cause the fault? Greatly appreciate,
>
>          Wan
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
www.ruchith.org

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Mime
View raw message