0

how can I add authentication filter\header to

com.sun.jersey.api.client.Client ?

I'm using jersey-bundle-1.18.2

i saw two posts:

1) post:

client.addFilter(new HTTPBasicAuthFilter(user, password));

2) post:

client.setUsernamePassword("testClient", "secret");

but non of them apply to the above Client class.

These method don't exist in this type.

Community
  • 1
  • 1
Elad Benda
  • 35,076
  • 87
  • 265
  • 471

1 Answers1

0

I tried to execute addFilter after a builder method that returns Webresource

So I changed:

        client.addFilter(new HTTPBasicAuthFilter(RT_USERNAME, RT_PASSWORD);

        ClientResponse clientResponse = client
                .resource(resource)
                .queryParam("confirm", "true")
                .queryParam("id", alertId)
.addFilter(new HTTPBasicAuthFilter(RT_USERNAME, RT_PASSWORD)...

to

client.addFilter(new HTTPBasicAuthFilter(RT_USERNAME, RT_PASSWORD);

ClientResponse clientResponse = client
        .resource(resource)
        .queryParam("confirm", "true")
        .queryParam("id", alertId)
Elad Benda
  • 35,076
  • 87
  • 265
  • 471