You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@santuario.apache.org by "t. winkler" <t....@sdz-medien.de> on 2003/02/26 10:03:08 UTC

XML Signature with Apache AXIS Problem - content.x509.XMLX509Certificate - Keystore

Hello,

Right now I'm trying to implement the Apache AXIS signature example to function with my webservice. I've deployed the Serverside Handler (called "SignatureHandler_Serverside" in my example and not "LogHandler") together with my webservice called "Umsatz_Service". The webservice cann be accessed without any problems through  .NET Webstudio and my simple Java Client application, but when I do the Call-method (as described in the book web services with Java by Torsten Langner [1] ) I receive the following error
(the keystoreFile is the one created by Christian Geuer-Pollmann with the following parameters: 
    static String keystoreType = "JKS";
    static String keystoreFile = "keystore.jks";
    static String keystorePass = "xmlsecurity";
    static String privateKeyAlias = "WebServicesTest";
    static String privateKeyPass = "xmlsecurity";
    static String certificateAlias = "WebServicesTest";
)

The error-message when starting the Client-app (all source codes have successfully been compiled):
C:\webservices\webapps\axis\WEB-INF\classes>java wsumsatz/Client
invoking...
Beginning Client signing...
java.lang.NullPointerException
        at org.apache.xml.security.keys.content.x509.XMLX509Certificate.<init>(XMLX509Certificate.java:123)
        at org.apache.xml.security.keys.content.X509Data.addCertificate(X509Data.java:284)
        at org.apache.xml.security.signature.XMLSignature.addKeyInfo(XMLSignature.java:735)
        at wsumsatz.SignedSOAPEnvelope.init(SignedSOAPEnvelope.java:106)
        at wsumsatz.SignedSOAPEnvelope.<init>(SignedSOAPEnvelope.java:62)
        at wsumsatz.SignatureHandler_Clientside.invoke(SignatureHandler_Clientside.java:34)
        at org.apache.axis.client.AxisClient.invoke(AxisClient.java:163)
        at org.apache.axis.client.Call.invokeEngine(Call.java:2113)
        at org.apache.axis.client.Call.invoke(Call.java:2102)
        at org.apache.axis.client.Call.invoke(Call.java:1851)
        at org.apache.axis.client.Call.invoke(Call.java:1777)
        at org.apache.axis.client.Call.invoke(Call.java:1315)
        at wsumsatz.Client.main(Client.java:46)
java.lang.RuntimeException: java.lang.NullPointerException

C:\webservices\webapps\axis\WEB-INF\classes>

May someone has a solution to this problem! Maybe the service doesn't understand the certificates?! How do you provide the certificates for signature? With Java's "keytool -genkey -alias" ...???

Best regards,

Tobias Winkler

PS: Considering XML Encryption with Apache AXIS: Is there an implementation right now or what API do you use for encryption? 

-----------------------------------------------------------------------------------------------------------------------
[1] source code:
package wsumsatz;

//-----------------------> Imports:
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;
import javax.xml.rpc.ParameterMode;
//import javax.xml.rpc.namespace.QName;

import javax.xml.namespace.QName;

import org.apache.axis.MessageContext;
import org.apache.axis.message.SOAPBodyElement;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.utils.XMLUtils;
//<----------------------------------

public class Client
{
    public static void main(String [] args)
    {
        try {
            SignatureHandler_Clientside signature = new SignatureHandler_Clientside ();
           
            Service  service = new Service();
            Call     call    = (Call) service.createCall();

            call.setTargetEndpointAddress(new java.net.URL("http://localhost:8080/axis/servlet/AxisServlet"));
            call.setOperationName(new QName("Umsatz_Service", "getKundennachUmsatz"));
            call.addParameter( 
              "in0", 
              XMLType.XSD_FLOAT, 
              ParameterMode.IN
            );
            call.setReturnType( 
              org.apache.axis.encoding.XMLType.XSD_STRING 
            );
            
            call.setClientHandlers (
              signature,
              null
            );
              
            System.out.println ( "invoking..." );
            String ret = (String) call.invoke( new Object[] { "2000" } );
                        
        } catch (Exception e) {
            System.err.println(e.toString());
        }
    }
}

Tobias Winkler
BA-Student

Theiss & Binkowski Aalen
GmbH & Co. Rechenzentrum
Bahnhofstrasse 65, 73430 Aalen
Telefon 07361/594-313
Telefax 07361/594-306
E-Mail t.winkler@sdz-medien.de
http://tbr.sdz-medien.de

Re: XML Signature with Apache AXIS Problem - content.x509.XMLX509Certificate - Keystore

Posted by Christian Geuer-Pollmann <ge...@nue.et-inf.uni-siegen.de>.
Hi Tobias,

I guess that you have created your own certificate in the sample key store 
as privateKeyAlias and certificateAlias are your own ones?

First question: Did you ensure that org.apache.xml.security.Init.init() is 
called before you start your magic?

It's quite hard to tell what's going on as 
wsumsatz.SignatureHandler_Clientside and wsumsatz.SignedSOAPEnvelope are 
not known. You should track down the parameters you pass in these modules 
when you call XMLSignature.addKeyInfo().

On encryption: we have encryption code, but there are no examples yet on 
how to use it...

Kind regards,
Christian


--On Mittwoch, 26. Februar 2003 10:03 +0100 "t. winkler" 
<t....@sdz-medien.de> wrote:

> Hello,
>
> Right now I'm trying to implement the Apache AXIS signature example to
> function with my webservice. I've deployed the Serverside Handler (called
> "SignatureHandler_Serverside" in my example and not "LogHandler")
> together with my webservice called "Umsatz_Service". The webservice cann
> be accessed without any problems through  .NET Webstudio and my simple
> Java Client application, but when I do the Call-method (as described in
> the book web services with Java by Torsten Langner [1] ) I receive the
> following error (the keystoreFile is the one created by Christian
> Geuer-Pollmann with the following parameters:      static String
> keystoreType = "JKS";
>     static String keystoreFile = "keystore.jks";
>     static String keystorePass = "xmlsecurity";
>     static String privateKeyAlias = "WebServicesTest";
>     static String privateKeyPass = "xmlsecurity";
>     static String certificateAlias = "WebServicesTest";
> )
>
> The error-message when starting the Client-app (all source codes have
> successfully been compiled):
> C:\webservices\webapps\axis\WEB-INF\classes>java wsumsatz/Client
> invoking...
> Beginning Client signing...
> java.lang.NullPointerException
>         at
> org.apache.xml.security.keys.content.x509.XMLX509Certificate.<init>(XMLX5
> 09Certificate.java:123)         at
> org.apache.xml.security.keys.content.X509Data.addCertificate(X509Data.jav
> a:284)         at
> org.apache.xml.security.signature.XMLSignature.addKeyInfo(XMLSignature.ja
> va:735)         at
> wsumsatz.SignedSOAPEnvelope.init(SignedSOAPEnvelope.java:106)         at
> wsumsatz.SignedSOAPEnvelope.<init>(SignedSOAPEnvelope.java:62)         at
> wsumsatz.SignatureHandler_Clientside.invoke(SignatureHandler_Clientside.j
> ava:34)         at
> org.apache.axis.client.AxisClient.invoke(AxisClient.java:163)         at
> org.apache.axis.client.Call.invokeEngine(Call.java:2113)         at
> org.apache.axis.client.Call.invoke(Call.java:2102)
>         at org.apache.axis.client.Call.invoke(Call.java:1851)
>         at org.apache.axis.client.Call.invoke(Call.java:1777)
>         at org.apache.axis.client.Call.invoke(Call.java:1315)
>         at wsumsatz.Client.main(Client.java:46)
> java.lang.RuntimeException: java.lang.NullPointerException
>
> C:\webservices\webapps\axis\WEB-INF\classes>
>
> May someone has a solution to this problem! Maybe the service doesn't
> understand the certificates?! How do you provide the certificates for
> signature? With Java's "keytool -genkey -alias" ...???
>
> Best regards,
>
> Tobias Winkler
>
> PS: Considering XML Encryption with Apache AXIS: Is there an
> implementation right now or what API do you use for encryption?
>
> -------------------------------------------------------------------------
> ---------------------------------------------- [1] source code:
> package wsumsatz;
>
> //-----------------------> Imports:
> import org.apache.axis.client.Call;
> import org.apache.axis.client.Service;
> import org.apache.axis.encoding.XMLType;
> import org.apache.axis.utils.Options;
> import javax.xml.rpc.ParameterMode;
> //import javax.xml.rpc.namespace.QName;
>
> import javax.xml.namespace.QName;
>
> import org.apache.axis.MessageContext;
> import org.apache.axis.message.SOAPBodyElement;
> import org.apache.axis.message.SOAPEnvelope;
> import org.apache.axis.utils.XMLUtils;
> //<----------------------------------
>
> public class Client
> {
>     public static void main(String [] args)
>     {
>         try {
>             SignatureHandler_Clientside signature = new
> SignatureHandler_Clientside ();
>             Service  service = new Service();
>             Call     call    = (Call) service.createCall();
>
>             call.setTargetEndpointAddress(new
> java.net.URL("http://localhost:8080/axis/servlet/AxisServlet"));
> call.setOperationName(new QName("Umsatz_Service", "getKundennachUmsatz"));
>             call.addParameter(
>               "in0",
>               XMLType.XSD_FLOAT,
>               ParameterMode.IN
>             );
>             call.setReturnType(
>               org.apache.axis.encoding.XMLType.XSD_STRING
>             );
>
>             call.setClientHandlers (
>               signature,
>               null
>             );
>
>             System.out.println ( "invoking..." );
>             String ret = (String) call.invoke( new Object[] { "2000" } );
>
>         } catch (Exception e) {
>             System.err.println(e.toString());
>         }
>     }
> }
>
> Tobias Winkler
> BA-Student
>
> Theiss & Binkowski Aalen
> GmbH & Co. Rechenzentrum
> Bahnhofstrasse 65, 73430 Aalen
> Telefon 07361/594-313
> Telefax 07361/594-306
> E-Mail t.winkler@sdz-medien.de
> http://tbr.sdz-medien.de