It's not a secret anymore!*
The moose likes Security and the fly likes Http Basic Authentication for localhost(apache server) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "Http Basic Authentication for localhost(apache server)" Watch "Http Basic Authentication for localhost(apache server)" New topic
Author

Http Basic Authentication for localhost(apache server)

naveen yadav
Ranch Hand

Joined: Oct 23, 2011
Posts: 384

hi ranchers ,

i have tried to access a resource located on Apache-Coyote server on my localhost:8080. The server requires me to authenticate with credentials with Basic scheme.
WWW-Authenticate :Basic realm="Tomcat Manager Application".

i have gone throught the RFC for HTTP Basic authentication , whcih state that a
Authorization requst header field is to be set with appropriate credentials(user_name and password)

ok. i can do that by

Further it state that
To receive authorization, the client sends the userid and password, separated by a single colon (":") character, within a base64
encoded string in the credentials.


now it seems that "Basic nav:111" string is to be encoded in base64.

but how can i do that ?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9924
    
158

naveen yadav wrote:

now it seems that "Basic nav:111" string is to be encoded in base64.

but how can i do that ?


There are many libraries out there which have an API to help you convert the string to a base64 string. A google search for base64 java library will show up some of them.


[My Blog] [JavaRanch Journal]
naveen yadav
Ranch Hand

Joined: Oct 23, 2011
Posts: 384

Thanks Jaikiran Pai. i'm using the Apache's common-codec library for Base64 encoding.

But still getting the 401:unauthorized error

here is code running in Eclipse


and

 
 
subject: Http Basic Authentication for localhost(apache server)
 
Similar Threads
How to determine if HTTP authentication is required
How to provide basic authetication from SOAP request to access SAP XI service
Integrating Custom Authentication with Tomcat Authorization
How to authenticate HttpURLConnection?
Creating a login Screen like in Weblogic6.1