users@jersey.java.net

[Jersey] Re: authentication using auth file

From: Roll, Stuart L <Stuart.Roll_at_ca.com>
Date: Wed, 18 May 2011 22:20:08 -0400

Your request is a bit confusing. You say you are using the Jersey
Client but then you give your example code as a cURL command.

If your goal is to provide HTTP Basic Authentication, using cURL it
would look like this:

        curl -u user:passwd <etc.>

Using the Jersey Client library you would do this:

        Client client = Client.create();
        client.addFilter(new HTTPBasicAuthFilter(user, password));
        WebResource webResource = client.resource(<your_URL_goes_here>);

I have no idea why you would want to bypass the standard credential
scheme by sending the credentials in the body of the POST request but if
you did you would need to set the Content-Type header appropriately
(e.g., application/json) and there wouldn't be a need for --data-binary
as -d would suffice.



-----Original Message-----
From: nssv12 [mailto:nssv12_at_gmail.com]
Sent: Wednesday, May 18, 2011 6:18 PM
To: users_at_jersey.java.net
Subject: [Jersey] authentication using auth file

Hi,

I am trying to use Jersey client for the first time. I have browsed
through
several tutorials, but couldn't get the following POST request working :

I am trying to execute the following POST request through Jersey Client
-

curl -b cookies -c cookies -X POST --data-binary @cred 'url'

the "cred" file contains username and password info in the following
format

"cred":
  {
    "username" : "user",
    "password" : "passwd"
  }
}

I tried to use MultivaluedMap to set username and password, but it
doesn't
work

Could you point me to an example to implement my request.

Thanks a bunch!

--
View this message in context:
http://jersey.576304.n2.nabble.com/authentication-using-auth-file-tp6379
756p6379756.html
Sent from the Jersey mailing list archive at Nabble.com.