httplib or urllib2 tomcat username and password

2006-01-13 Thread Michael Oliver
I am trying to write a Python client to access a Tomcat servlet using Tomcat
Realm authentication with no success.

 

I can use the httplib to connect to localhost port 8080 ok and post and get
and all that is fine, but when I try to set username and password and access
a protected part of tomcat it fails with an Unauthorized.

 

Does anyone have an example of connecting to Tomcat using the Tomcat Realm
(.i.e. tomcat-users.xml) authentication?

I have also tried urllib2 and the example in the header comments still gives
me a HTTP Error 401: Unauthorized when I try to open
http://localhost:8080/slide/



 

Thanks.


 Highly Cohesive and Loosely Coupled

Mike Oliver
CTO Alarius Systems LLC
6800 E. Lake Mead Blvd
Apt 1096
Las Vegas, NV 89156 
[EMAIL PROTECTED]
http://www.alariussystems.com/  tel: 
fax: 
mobile: (702)953-8949 
(702)974-0341
(518)378-6154   

Add me to your address book...   Want a signature like this?

-- 
http://mail.python.org/mailman/listinfo/python-list


Tomcat username and password2

2006-01-13 Thread Michael Oliver
Still trying to get python to access my local tomcat secured with the tomcat
realm

import urllib2
 

 handler = urllib2.HTTPBasicAuthHandler()
 handler.add_password(None,
 'localhost:8080/manager/html', 'root', 'root')
 
 opener = urllib2.build_opener(handler)
 urllib2.install_opener(opener)
 
 try:
 f = urllib2.urlopen( 'http://localhost:8080/manager/html' )
 except urllib2.HTTPError, e:
 if e.code == 401:
 print 'not authorized'
 elif e.code == 404:
 print 'not found'
 elif e.code == 503:
 print 'service unavailable'
 else:
 print 'unknown error: '
 else:
 print 'success'
 for line in f:
 print line,
 

[Mike Oliver>>] this returns 'not authorized' no matter what I put in for
'realm' or 'host' to the add_password() method.  I have tried None, 'tomcat'
for realm and 'localhost' and about every combination I can think of for
'host' if I go to that URL with a browser it asks for username and password
as above and that works.  I can access it with code from PHP or Java just
fine.



-- 
http://mail.python.org/mailman/listinfo/python-list


Python Client accessing Tomcat

2006-01-14 Thread Michael Oliver








I am trying to write a Python client to
access a Tomcat servlet using Tomcat Realm authentication with no success.

 

I can use the httplib to connect to
localhost port 8080 ok and post and get and all that is fine, but when I try to
set username and password and access a protected part of tomcat it fails with
an Unauthorized.

 

Does anyone have an example of connecting
to Tomcat using the Tomcat Realm (.i.e. tomcat-users.xml) authentication?

 

Thanks.

 


 
  
  
   


 
  
  
   




Highly
Cohesive and Loosely Coupled

   
  
  
  
  
   
  
 
 
  
  
   

Mike Oliver
CTO 


Alarius Systems LLC
6800 E. Lake Mead Blvd
Apt 1096
Las Vegas, NV 89156 

   
   

[EMAIL PROTECTED]
http://www.alariussystems.com/




 
  
  tel: 
  fax: 
  mobile: 
  
  
  (702)953-8949 
  (702)974-0341
  (518)378-6154 
  
 



   
  
  
  
 




 

   
  
  
  
 
 
  
  
   

Add me to your address book...


Want a signature like
this?

   
  
  
  
 


 






-- 
http://mail.python.org/mailman/listinfo/python-list

Tomcat authentication from python

2006-01-15 Thread Michael Oliver








I need to access tomcat applications from
python, some are Axis/SOAP web services, and some are file/WebDAV operations.

 

But so far I cannot get python to
authenticate and access http://localhost:8080/manager/html
much less to any of the other applications.

 

I have found examples for httplib with a
base64 Basic Authentication header, and a urllib2 Authentication Handler, but
neither one works.

 

I am not an experienced python developer,
but I am an experienced Java Developer.  I am using PyDev plugin for Eclipse, I
am using Python24.

 

I can connect to tomcat without
authentication for those pages/uri’s that do not require authentication
on that tomcat server, so the problem is with the authentication mechanism in
python.  Obviously I can connect to the entire site and all applications with a
browser and programmatically from Java.

 

Any help greatly appreciated.

 

 


 
  
  
   


 
  
  
   




Highly
Cohesive and Loosely Coupled

   
  
  
  
  
   
  
 
 
  
  
   

Mike Oliver
CTO 


Alarius Systems LLC
6800 E. Lake Mead Blvd
Apt 1096
Las Vegas, NV 89156 

   
   

[EMAIL PROTECTED]
http://www.alariussystems.com/




 
  
  tel: 
  fax: 
  mobile: 
  
  
  (702)953-8949 
  (702)974-0341
  (518)378-6154 
  
 



   
  
  
  
 




 

   
  
  
  
 
 
  
  
   

Add me to your address book...


Want a signature like
this?

   
  
  
  
 


 






-- 
http://mail.python.org/mailman/listinfo/python-list