users@jax-rpc.java.net

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

From: Kwan Hon Luen <hon_luen_at_YAHOO.COM>
Date: Thu, 31 Oct 2002 17:28:25 +0800

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

But I would need to use SSL. pls advise.


  ----- Original Message -----
  From: Ted O'Donovan
  To: 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 [mailto:hon_luen_at_YAHOO.COM]
    Sent: 31 October 2002 09:21
    To: 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: Ted O'Donovan
      To: 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"
          "http://java.sun.com/j2ee/dtds/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,
            "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"
            "http://java.sun.com/j2ee/dtds/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




    ---
    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