Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ public String getFilter(@Context HttpHeaders h) {
return "GET";
}

@GET
@Path("noauth")
public String get() {
return "GET";
}

@POST
public String post(@Context HttpHeaders h, String e) {
requestCount++;
Expand Down Expand Up @@ -278,6 +284,17 @@ public void testAuthGetWithClientFilter() {
assertEquals("GET", r.request().get(String.class));
}

@Test
public void testAuthGetBasicNoChallenge() {
ClientConfig cc = new ClientConfig();
cc.connectorProvider(new ApacheConnectorProvider());
Client client = ClientBuilder.newClient(cc);
client.register(HttpAuthenticationFeature.basicBuilder().build());
WebTarget r = client.target(getBaseUri()).path("test/noauth");

assertEquals("GET", r.request().get(String.class));
}

@Test
@Ignore("JERSEY-1750: Cannot retry request with a non-repeatable request entity. How to buffer the entity?"
+ " Allow repeatable write in jersey?")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,13 @@ private String calculateAuthentication(HttpAuthenticationFilter.Credentials cred
* Adds authentication information to the request.
*
* @param request Request context.
* @throws RequestAuthenticationException in case that basic credentials missing or are in invalid format
*/
public void filterRequest(ClientRequestContext request) throws RequestAuthenticationException {
public void filterRequest(ClientRequestContext request) {
HttpAuthenticationFilter.Credentials credentials = HttpAuthenticationFilter.getCredentials(request,
defaultCredentials, HttpAuthenticationFilter.Type.BASIC);
if (credentials == null) {
throw new RequestAuthenticationException(LocalizationMessages.AUTHENTICATION_CREDENTIALS_MISSING_BASIC());
if (credentials != null) {
request.getHeaders().add(HttpHeaders.AUTHORIZATION, calculateAuthentication(credentials));
}
request.getHeaders().add(HttpHeaders.AUTHORIZATION, calculateAuthentication(credentials));
}

/**
Expand Down