wink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryant Luk <bryant....@gmail.com>
Subject Re: Adding Authorization to http header using RestClient
Date Sun, 06 Jun 2010 22:52:57 GMT
Hi,

Can you try using:
org.apache.wink.client.handlers.BasicAuthSecurityHandler and add it to
your client config?

ClientConfig config = new ClientConfig();
BasicAuthSecurityHandler basicAuth = new BasicAuthSecurityHandler();
basicAuth.setUserName("mack");
basicAuth.setPassword("wink4you");
config.handlers(basicAuth);
// create the rest client instance
RestClient client = new RestClient(config);
// create the resource instance to interact with Resource
resource = client.resource("https://localhost:9080/path/to/resource");

You can also directly set any header via the client API:

client.resource("https://localhost:9080/path/to/resource").header("customHeader",
"customValue);

On Sun, Jun 6, 2010 at 5:18 PM, Paulo Borges <abudar63@hotmail.com> wrote:
>
> Hello:
>
> Our wink rest application is using container security (in Websphere). Basically any attempt
to access a resource is required to have an id and password. Normally in using java native
URL api, I use the following code to authenticate a user [say id mack and pwd wink4you] to
container:
>
> String authorization = "mack:wink4you";
> BASE64Encoder encoder = new sun.misc.BASE64Encoder();
> URL url = new URL("http://localhost:9080/....");
> HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
> urlc.setRequestProperty("Authorization", "Basic "+ encoder.encode(authorization));
>
> is there a way to achieve the above result using wink client api.
>
> _________________________________________________________________
> MSN Dating: Find someone special. Start now.
> http://go.microsoft.com/?linkid=9734384

Mime
View raw message