You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jerry Miernik <jm...@cisco.com> on 2004/06/10 21:03:24 UTC

Works! RE: 2nd inquiry: how to - programmatically - authenticate oneself as Tomcat manager?

  Jake,
  This works! How did you come to know that?
  Is there a doc I should have read to know?
  Thanks, 
  Jerry.


-----Original Message-----
From: Jacob Kjome [mailto:hoju@visi.com] 
Sent: Thursday, June 10, 2004 1:44 PM
To: Tomcat Users List
Subject: Re: 2nd inquiry: how to - programmatically - authenticate oneself as Tomcat manager?

Quoting Bill Barker <wb...@wilshire.com>:
> 1)  Assuming boring system encodings, and something to do Base64 encoding:
>    String creds = username+":"+password;
>    String b64creds = Base64Util.encode(creds.getBytes());
>    tmc.addRequestProperty("Authorization","Basic "+b64creds);
> 
> 2) Not with Basic.  You might be able to rig something with Form.
> 

That's not true.  You can do:

http://username:password@www.mysite.com/

so:

URL tomcatMgr =
     new URL("http://manager:mypassword@localhost:8080/manager/undeploy?path=/any");

Jake

> 
> "Jerry Miernik" <jm...@cisco.com> wrote in message 
> news:F67EB38120F7BB4BB972C786095802072B5690@ipcbu-exchange.amer.unity.cisco.com...
>   The question is related to undeploying a webapplication
>   from a Java code. A connection to tomcat manager using
>   ....
>   URL tomcatMgr =
>     new URL("http://localhost:8080/manager/undeploy?path=/any");
>   URLConnection tmc = tomcatMgr.openConnection();
>   ....
> 
>   results in:
>   java.io.IOException:Server returned HTTP response code: 401
> 
>   The questions:
>   1. Is there a way to deliver - programmatically - username
>      and password for the undeploy to take effect?
> 
>   2. Could the username and password be parameters in the
>      undeploy request? Or an earlier request?
> 
>   3. This Java program is trying to undeploy itself, inside
>      a jspInit() method. Is this technically possible?
>      (do not see why not, except for the problem with user
>       name and password).
> 
>   Thanks,
>   Jerry.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

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


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


Re: Works! RE: 2nd inquiry: how to - programmatically - authenticate oneself as Tomcat manager?

Posted by Jacob Kjome <ho...@visi.com>.
At 12:25 PM 6/10/2004 -0700, you wrote:
>Jerry Miernik wrote:
>
>>   This works! How did you come to know that?
>>   Is there a doc I should have read to know?
>
>Well, strictly speaking, if you read the doc you'll know that's
>not a legal URL :-)

Yep, but it has worked with every server I've ever used it with.  Maybe it 
is one of those things that became a standard despite the spec, kind of 
like the innerHTML property of the MS DOM, now supported by Mozilla (not 
sure about Opera?) even though it is nowhere in the DOM spec.

Jake


>RFC 1738: Uniform Resource Locators (URL) shows the format:
>
>  3.1. Common Internet Scheme Syntax
>
>    While the syntax for the rest of the URL may vary depending on the
>    particular scheme selected, URL schemes that involve the direct use
>    of an IP-based protocol to a specified host on the Internet use a
>    common syntax for the scheme-specific data:
>
>         //<user>:<password>@<host>:<port>/<url-path>
>
>*BUT* (see last sentence)
>
>  3.3. HTTP
>
>    The HTTP URL scheme is used to designate Internet resources
>    accessible using HTTP (HyperText Transfer Protocol).
>
>    The HTTP protocol is specified elsewhere. This specification only
>    describes the syntax of HTTP URLs.
>
>    An HTTP URL takes the form:
>
>       http://<host>:<port>/<path>?<searchpart>
>
>    where <host> and <port> are as described in Section 3.1. If :<port>
>    is omitted, the port defaults to 80.  No user name or password is
>    allowed.
>
>Which is not to say that it won't, in some circumstances, "work"...
>
>FWIW!
>
>>That's not true.  You can do:
>>http://username:password@www.mysite.com/
>>so:
>>URL tomcatMgr =
>>      new 
>> URL("http://manager:mypassword@localhost:8080/manager/undeploy?path=/any");
>
>--
>Hassan Schroeder ----------------------------- hassan@webtuitive.com
>Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com
>
>                           dream.  code.
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


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


Re: Works! RE: 2nd inquiry: how to - programmatically - authenticate oneself as Tomcat manager?

Posted by Hassan Schroeder <ha...@webtuitive.com>.
Jerry Miernik wrote:

>   This works! How did you come to know that?
>   Is there a doc I should have read to know?

Well, strictly speaking, if you read the doc you'll know that's
not a legal URL :-)

RFC 1738: Uniform Resource Locators (URL) shows the format:

  3.1. Common Internet Scheme Syntax

    While the syntax for the rest of the URL may vary depending on the
    particular scheme selected, URL schemes that involve the direct use
    of an IP-based protocol to a specified host on the Internet use a
    common syntax for the scheme-specific data:

         //<user>:<password>@<host>:<port>/<url-path>

*BUT* (see last sentence)

  3.3. HTTP

    The HTTP URL scheme is used to designate Internet resources
    accessible using HTTP (HyperText Transfer Protocol).

    The HTTP protocol is specified elsewhere. This specification only
    describes the syntax of HTTP URLs.

    An HTTP URL takes the form:

       http://<host>:<port>/<path>?<searchpart>

    where <host> and <port> are as described in Section 3.1. If :<port>
    is omitted, the port defaults to 80.  No user name or password is
    allowed.

Which is not to say that it won't, in some circumstances, "work"...

FWIW!

> That's not true.  You can do:
> 
> http://username:password@www.mysite.com/
> 
> so:
> 
> URL tomcatMgr =
>      new URL("http://manager:mypassword@localhost:8080/manager/undeploy?path=/any");

-- 
Hassan Schroeder ----------------------------- hassan@webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.



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