You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Garey Mills <gm...@library.berkeley.edu> on 2006/04/18 21:11:12 UTC

authentication problem using manager URLs from a script

Hello -

	I want to stop and start a context from a Java program running as
a cron job. I have tried 

	http://<host>:<port>/manager/stop?
	username=<manager-role username>&
	password=<password>&
	path=/<context path>

(without the carriage returns, of course). This yields me a 401. Reading
the manager app documentation, it doesn't actually explain how to
authenticate from a script. How do I do it?

I apologize if this question has been asked before. I studied the list for
a couple of hours before giving up;

Garey Mills
Library Systems Office
UC Berkeley

The brain is not where you think


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


Re: authentication problem using manager URLs from a script

Posted by Garey Mills <gm...@library.berkeley.edu>.
Mark -

	Thanks for the pointers. I ended up picking up code from the
Tomcat source of org.apache.catalina.ant.AbstractTask and using that to do
Basic Authentication. I've got it working now.



Garey Mills
Library Systems Office
UC Berkeley

The brain is not where you think

On Tue, 18 Apr 2006, Mark Thomas wrote:

> Garey Mills wrote:
> > Mark -
> > 
> > 	I have looked at the manager app how-to, and it doesn't describe
> > how connect from a script. I have this
> > 
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >     private static String stop =
> > "http://myhost:8080/manager/stop?path=/myapp";
> > 
> >     public static void main(String[] args) {
> > 
> > 
> >        	try {
> > 	    
> > 	    URL stopURL = new URL(stop);
> > 
> > 	    URLConnection cnxn = ustopURL.openConnection();
> > 
> > 	    cnxn.setRequestProperty("username", "user");
> > 	    cnxn.setRequestProperty("password", "password");
> > 
> > 	    cnxn.connect();
> > 
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 
> > but am still getting 401. Do you have any suggestions?
> 
> This isn't how BASIC authentication works. For details see RFC 2617 or
> for the quick solution see the applyHttpBasicAuthentication method in
> http://marc2.theaimsgroup.com/?l=fop-cvs&m=114069081209918&w=2
> 
> Alternatively take a look at HTTPClient that will hide all this fun
> and games.
> 
> Mark
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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


Re: authentication problem using manager URLs from a script

Posted by Mark Thomas <ma...@apache.org>.
Garey Mills wrote:
> Mark -
> 
> 	I have looked at the manager app how-to, and it doesn't describe
> how connect from a script. I have this
> 
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>     private static String stop =
> "http://myhost:8080/manager/stop?path=/myapp";
> 
>     public static void main(String[] args) {
> 
> 
>        	try {
> 	    
> 	    URL stopURL = new URL(stop);
> 
> 	    URLConnection cnxn = ustopURL.openConnection();
> 
> 	    cnxn.setRequestProperty("username", "user");
> 	    cnxn.setRequestProperty("password", "password");
> 
> 	    cnxn.connect();
> 
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 
> but am still getting 401. Do you have any suggestions?

This isn't how BASIC authentication works. For details see RFC 2617 or
for the quick solution see the applyHttpBasicAuthentication method in
http://marc2.theaimsgroup.com/?l=fop-cvs&m=114069081209918&w=2

Alternatively take a look at HTTPClient that will hide all this fun
and games.

Mark


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


Re: authentication problem using manager URLs from a script

Posted by Garey Mills <gm...@library.berkeley.edu>.
Mark -

	I have looked at the manager app how-to, and it doesn't describe
how connect from a script. I have this

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    private static String stop =
"http://myhost:8080/manager/stop?path=/myapp";

    public static void main(String[] args) {


       	try {
	    
	    URL stopURL = new URL(stop);

	    URLConnection cnxn = ustopURL.openConnection();

	    cnxn.setRequestProperty("username", "user");
	    cnxn.setRequestProperty("password", "password");

	    cnxn.connect();

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

but am still getting 401. Do you have any suggestions? I have a complex
app that does a number of things before stopping and starting a web app,
and I don't want to have to cram the whole thing int Ant.

Any help appreciated;

Garey Mills
Library Systems Office
UC Berkeley

The brain is not where you think

On Tue, 18 Apr 2006, Mark Thomas wrote:

> Marc Farrow wrote:
> > You have to use the webdav application provide from tomcat.  Check under
> > $tomcat_home/webapps/webdav/web.xml.  there is a line commented out that
> > states some property of read-only = false.  by default it is read-only and
> > you have to manually turn it on.
> 
> What on earth has webdav got to do with this?
> 
> > On 4/18/06, Garey Mills <gm...@library.berkeley.edu> wrote:
> >> Hello -
> >>
> >>        I want to stop and start a context from a Java program running as
> >> a cron job. I have tried
> >>
> >>        http://<host>:<port>/manager/stop?
> >>        username=<manager-role username>&
> >>        password=<password>&
> >>        path=/<context path>
> >>
> >> (without the carriage returns, of course). This yields me a 401. Reading
> >> the manager app documentation, it doesn't actually explain how to
> >> authenticate from a script. How do I do it?
> 
> The user name and password get passed as HTTP headers. The easiest way
> is probably to use the provided ant tasks. See the bottom of
> http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html for details.
> 
> 
> Mark
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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


Re: authentication problem using manager URLs from a script

Posted by Mark Thomas <ma...@apache.org>.
Marc Farrow wrote:
> You have to use the webdav application provide from tomcat.  Check under
> $tomcat_home/webapps/webdav/web.xml.  there is a line commented out that
> states some property of read-only = false.  by default it is read-only and
> you have to manually turn it on.

What on earth has webdav got to do with this?

> On 4/18/06, Garey Mills <gm...@library.berkeley.edu> wrote:
>> Hello -
>>
>>        I want to stop and start a context from a Java program running as
>> a cron job. I have tried
>>
>>        http://<host>:<port>/manager/stop?
>>        username=<manager-role username>&
>>        password=<password>&
>>        path=/<context path>
>>
>> (without the carriage returns, of course). This yields me a 401. Reading
>> the manager app documentation, it doesn't actually explain how to
>> authenticate from a script. How do I do it?

The user name and password get passed as HTTP headers. The easiest way
is probably to use the provided ant tasks. See the bottom of
http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html for details.


Mark


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


Re: authentication problem using manager URLs from a script

Posted by Marc Farrow <ma...@gmail.com>.
You have to use the webdav application provide from tomcat.  Check under
$tomcat_home/webapps/webdav/web.xml.  there is a line commented out that
states some property of read-only = false.  by default it is read-only and
you have to manually turn it on.



On 4/18/06, Garey Mills <gm...@library.berkeley.edu> wrote:
>
> Hello -
>
>        I want to stop and start a context from a Java program running as
> a cron job. I have tried
>
>        http://<host>:<port>/manager/stop?
>        username=<manager-role username>&
>        password=<password>&
>        path=/<context path>
>
> (without the carriage returns, of course). This yields me a 401. Reading
> the manager app documentation, it doesn't actually explain how to
> authenticate from a script. How do I do it?
>
> I apologize if this question has been asked before. I studied the list for
> a couple of hours before giving up;
>
> Garey Mills
> Library Systems Office
> UC Berkeley
>
> The brain is not where you think
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


--
Marc Farrow