Skip to content
Permalink
Browse files

8235976: Directives in WWW-Authenticate should be comma separated

Reviewed-by: chegar
  • Loading branch information
Michael-Mc-Mahon committed Dec 16, 2019
1 parent 49048ad commit b73faca4527cc88df455ebe945d758cf04556ebb
@@ -95,10 +95,7 @@ public Result authenticate (HttpExchange t)
*/
String auth = rmap.getFirst ("Authorization");
if (auth == null) {
Headers map = t.getResponseHeaders();
var authString = "Basic realm=" + "\"" + realm + "\"" +
(isUTF8 ? " charset=\"UTF-8\"" : "");
map.set ("WWW-Authenticate", authString);
setAuthHeader(t);
return new Authenticator.Retry (401);
}
int sp = auth.indexOf (' ');
@@ -119,13 +116,18 @@ public Result authenticate (HttpExchange t)
);
} else {
/* reject the request again with 401 */

Headers map = t.getResponseHeaders();
map.set ("WWW-Authenticate", "Basic realm=" + "\""+realm+"\"");
setAuthHeader(t);
return new Authenticator.Failure(401);
}
}

private void setAuthHeader(HttpExchange t) {
Headers map = t.getResponseHeaders();
var authString = "Basic realm=" + "\"" + realm + "\"" +
(isUTF8 ? ", charset=\"UTF-8\"" : "");
map.set ("WWW-Authenticate", authString);
}

/**
* called for each incoming request to verify the
* given name and password in the context of this
@@ -32,7 +32,7 @@

/**
* @test
* @bug 8199849
* @bug 8199849 8235976
* @summary
* @library /test/lib
* @run main/othervm ParamTest
@@ -42,10 +42,10 @@
public class ParamTest {

static final String[] variants = {
" charset=utf-8",
" charset=UtF-8",
" charset=\"utF-8\"",
" charset=\"UtF-8\""
" ,charset=utf-8",
" ,charset=UtF-8",
" ,charset=\"utF-8\"",
" ,charset=\"UtF-8\""
};

static final int LOOPS = variants.length;

0 comments on commit b73faca

Please sign in to comment.