users@jax-rpc.java.net

Re: java.rmi.RemoteException: cannot connect to server: Unauthori zed

From: Ted O'Donovan <Ted.odonovan_at_ECET.COM>
Date: Thu, 31 Oct 2002 10:26:22 +0000

If u have changed your endpoint to use an unknown address and it worked then
you certainly have a bigger problem than SSL!

If you download some tcp monitoring software and monitor the traffic going
trhough the port 443 you should be able to see the encypted text. To do this
you can change your client to point to say port 444, then run your
monitoring software on that port and proxying requests to 443. Run your
client and you should be able to see the encypted text going across the
wire.

I think Axis has a good tcp monitoring tool.

T.

 -----Original Message-----
From: Kwan Hon Luen [mailto:hon_luen_at_YAHOO.COM]
Sent: 31 October 2002 09:53
To: JAXRPC-INTEREST_at_JAVA.SUN.COM
Subject: Re: java.rmi.RemoteException: cannot connect to server: Unauthori
zed



Thanks. I have removed those entries mentioned in web.xml

Now when I execute the client, it works fine.

But just to make sure that its going through SSL, I change the truststore to
other directory value and the truststorepassword to other value. I even
change the stub endpoint address to a unknown address. Then after
recompiling, and executing it still work! Obviously its not going by SSL,
pls advise here.


----- Original Message -----
From: HYPERLINK "mailto:Ted.odonovan_at_ECET.COM"Ted O'Donovan
To: HYPERLINK
"mailto:JAXRPC-INTEREST_at_JAVA.SUN.COM"JAXRPC-INTEREST_at_JAVA.SUN.COM
Sent: Thursday, October 31, 2002 5:47 PM
Subject: Re: java.rmi.RemoteException: cannot connect to server: Unauthori
zed

As far as I know, it is tomcat that is configured to use SSL not the war
file. If tomcat is setup to use ssl then by connecting to https and the
correct port, you are then using ssl. There is nothing needed in your
web.xml.

All you have in your web.xml there is basic authentication using usernames
and passwords. It has nothing to do with ssl. It may do some basic
encryption of the passwords but it is not ssl dependent.

T.

-----Original Message-----
From: Kwan Hon Luen [mailto:hon_luen_at_YAHOO.COM]
Sent: 31 October 2002 09:28
To: JAXRPC-INTEREST_at_JAVA.SUN.COM
Subject: Re: java.rmi.RemoteException: cannot connect to server: Unauthori
zed


Trying without the entries in web.xml will disable SSL (basic auth)?

But I would need to use SSL. pls advise.



----- Original Message -----
From: HYPERLINK "mailto:Ted.odonovan_at_ECET.COM"Ted O'Donovan
To: HYPERLINK
"mailto:JAXRPC-INTEREST_at_JAVA.SUN.COM"JAXRPC-INTEREST_at_JAVA.SUN.COM
Sent: Thursday, October 31, 2002 5:32 PM
Subject: Re: java.rmi.RemoteException: cannot connect to server: Unauthori
zed

Try without the entries in the web.xml

T.

-----Original Message-----
From: Kwan Hon Luen [ HYPERLINK
"mailto:hon_luen_at_YAHOO.COM"mailto:hon_luen_at_YAHOO.COM]
Sent: 31 October 2002 09:21
To: HYPERLINK
"mailto:JAXRPC-INTEREST_at_JAVA.SUN.COM"JAXRPC-INTEREST_at_JAVA.SUN.COM
Subject: Re: java.rmi.RemoteException: cannot connect to server: Unauthori
zed


Hi , if you look at my client code, I have added in the two lines you
mentioned, with the authorised tags in the web.xml.

What could be the cause of the error?


----- Original Message -----
From: HYPERLINK "mailto:Ted.odonovan_at_ECET.COM"Ted O'Donovan
To: HYPERLINK
"mailto:JAXRPC-INTEREST_at_JAVA.SUN.COM"JAXRPC-INTEREST_at_JAVA.SUN.COM
Sent: Thursday, October 31, 2002 5:21 PM
Subject: Re: java.rmi.RemoteException: cannot connect to server: Unauthori
zed

Yeah you have basic authentication in your web.xml. You have two options,
enter the username & password of an authorised tomcat user (e.g. admin user
setup on installation) in your client code, i.e.

            stub._setProperty(javax.xml.rpc.Stub.USERNAME_PROPERTY,
                username);
            stub._setProperty(javax.xml.rpc.Stub.PASSWORD_PROPERTY,
                password);

or remove the authorisation tags from your web.xml, i.e.


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    " HYPERLINK
"http://java.sun.com/j2ee/dtds/web-app_2_3.dtd""http://java.sun.com/j2ee/dtd
s/web-app_2_3.dtd">

<web-app>
  <display-name>hello Application</display-name>
  <description>A web application containing a JAX-RPC endpoint</description>

 <servlet>
  <servlet-name>JAXRPCEndpoint</servlet-name>
  <display-name>JAXRPCEndpoint</display-name>
  <description>Endpoint for hello Service</description>
  <servlet-class>com.sun.xml.rpc.server.http.JAXRPCServlet</servlet-class>
  <init-param>
   <param-name>configuration.file</param-name>
   <param-value>/WEB-INF/HelloService_Config.properties</param-value>
  </init-param>
  <load-on-startup>0</load-on-startup>
 </servlet>

 <servlet-mapping>
  <servlet-name>JAXRPCEndpoint</servlet-name>
  <url-pattern>/endpoint/*</url-pattern>
 </servlet-mapping>

  <session-config>
    <session-timeout>60</session-timeout>
  </session-config>
</web-app>


T.

-----Original Message-----
From: Kwan Hon Luen [mailto:hon_luen_at_YAHOO.COM]
Sent: 31 October 2002 04:19
To: JAXRPC-INTEREST_at_JAVA.SUN.COM
Subject: java.rmi.RemoteException: cannot connect to server: Unauthorized


Hi All,

Have some questions here, because I still cannot manage to connect via SSL.

I get the error below from the client code, can someone tell me what's wrong
here?

   _____


java.rmi.RemoteException: cannot connect to server: Unauthorized; nested
exception is:
        cannot connect to server: Unauthorized
        at hello.HelloIF_Stub.sayHello(HelloIF_Stub.java:77)
        at hello.HelloClient.main(HelloClient.java:10)
Caused by: cannot connect to server: Unauthorized
        at
com.sun.xml.rpc.client.http.HttpClientTransport.invoke(HttpClientTran
sport.java:119)
        at
com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:73)

        at hello.HelloIF_Stub.sayHello(HelloIF_Stub.java:60)
        ... 1 more

   _____

Here's the Client code:

package hello;
import javax.xml.rpc.Stub;

public class HelloClient
{
    public static void main(String[] args)
 {
        try
  {
   System.setProperty ("javax.net.ssl.trustStore",
"f:\\SSL\\client.keystore");
   System.setProperty("javax.net.ssl.trustStorePassword", "12345678");
   java.security.Security.addProvider(new
com.sun.net.ssl.internal.ssl.Provider());

   HelloIF_Stub stub = (HelloIF_Stub)( new
HelloService_Impl().getHelloIFPort() );
   stub._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY,
    " HYPERLINK
"https://192.168.168.88:443/helloservice/endpoint/HelloIF")"https://192.168.
168.88:443/helloservice/endpoint/HelloIF");
   stub._setProperty(javax.xml.rpc.Stub.USERNAME_PROPERTY, "honluen");
   stub._setProperty(javax.xml.rpc.Stub.PASSWORD_PROPERTY, "12345678");

   HelloIF hello = (HelloIF)stub;
   System.out.println(hello.sayHello("DSSS!"));
        }
  catch (Exception ex)
  {
            ex.printStackTrace();
        }
    }
}

   _____


Note: The Web Service machine is installed with tomcat with SSL enabled on
port 443.

On the Web Service machine:

Here's the web.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    " HYPERLINK
"http://java.sun.com/j2ee/dtds/web-app_2_3.dtd""http://java.sun.com/j2ee/dtd
s/web-app_2_3.dtd">

<web-app>
  <display-name>hello Application</display-name>
  <description>A web application containing a JAX-RPC endpoint</description>

  <security-constraint>
    <web-resource-collection>
      <web-resource-name>MyServiceName</web-resource-name>
      <url-pattern>/*</url-pattern>
      <http-method>GET</http-method>
      <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
      <role-name>manager</role-name>
    </auth-constraint>
  </security-constraint>
  <login-config>
    <auth-method>BASIC</auth-method>
  </login-config>

 <servlet>
  <servlet-name>JAXRPCEndpoint</servlet-name>
  <display-name>JAXRPCEndpoint</display-name>
  <description>Endpoint for hello Service</description>
  <servlet-class>com.sun.xml.rpc.server.http.JAXRPCServlet</servlet-class>
  <init-param>
   <param-name>configuration.file</param-name>
   <param-value>/WEB-INF/HelloService_Config.properties</param-value>
  </init-param>
  <load-on-startup>0</load-on-startup>
 </servlet>

 <servlet-mapping>
  <servlet-name>JAXRPCEndpoint</servlet-name>
  <url-pattern>/endpoint/*</url-pattern>
 </servlet-mapping>

  <session-config>
    <session-timeout>60</session-timeout>
  </session-config>
</web-app>


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.394 / Virus Database: 224 - Release Date: 03/10/2002
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.394 / Virus Database: 224 - Release Date: 03/10/2002