File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes how to send user credentials to a protected restful webservice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "how to send user credentials to a protected restful webservice" Watch "how to send user credentials to a protected restful webservice" New topic
Author

how to send user credentials to a protected restful webservice

saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
hello ranchers,

i am trying to get the data from a restful webservice which is running using a java client program. I am able to connect to it and get the data, but the limitation in my code is that it can't connect to the restful endpoint which needs authentication. I h've tried search for this over online but couldn't get a proper clue. Can any one help me out.

The intention is to pass the username and password to the rest url where the authentication is required.

the two types of approaches i h've made is
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 471
    
    4
If this help http://hc.apache.org/httpcomponents-client-ga/tutorial/html/authentication.html
Ask the restful web service provider for the type/kind of authentication needed.
T.A. Nguyen
Ranch Hand

Joined: Sep 02, 2008
Posts: 36

Hello Saipraneeth,

You can use this tiny program I created here: http://ta.cnci.org/more-about-java/29-java-servers-and-services/232-remoteservice-a-simple-client-to-test-your-restful-and-soap-services
if you are accessing a BASIC authentication type. Different authentication will required different headers setting.

Good luck,
T.A.


T.A. Nguyen
http://ta.cnci.org
http://www.linkedin.com/in/nguyenta
Roger Sterling
Ranch Hand

Joined: Apr 06, 2012
Posts: 426

If the authentication type is OATH 1, this site will walk you through the needed header construction steps :

http://hueniverse.com/2008/10/beginners-guide-to-oauth-part-iv-signing-requests/

This article explains how to use some of the Java routines within an ESB :

http://www.soabus.org/viewtopic.php?f=3&t=13
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to send user credentials to a protected restful webservice