8235976: Directives in WWW-Authenticate should be comma separated
Reviewed-by: chegar
This commit is contained in:
parent
49048adcf2
commit
b73faca452
@ -95,10 +95,7 @@ public abstract class BasicAuthenticator extends Authenticator {
|
|||||||
*/
|
*/
|
||||||
String auth = rmap.getFirst ("Authorization");
|
String auth = rmap.getFirst ("Authorization");
|
||||||
if (auth == null) {
|
if (auth == null) {
|
||||||
Headers map = t.getResponseHeaders();
|
setAuthHeader(t);
|
||||||
var authString = "Basic realm=" + "\"" + realm + "\"" +
|
|
||||||
(isUTF8 ? " charset=\"UTF-8\"" : "");
|
|
||||||
map.set ("WWW-Authenticate", authString);
|
|
||||||
return new Authenticator.Retry (401);
|
return new Authenticator.Retry (401);
|
||||||
}
|
}
|
||||||
int sp = auth.indexOf (' ');
|
int sp = auth.indexOf (' ');
|
||||||
@ -119,13 +116,18 @@ public abstract class BasicAuthenticator extends Authenticator {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
/* reject the request again with 401 */
|
/* reject the request again with 401 */
|
||||||
|
setAuthHeader(t);
|
||||||
Headers map = t.getResponseHeaders();
|
|
||||||
map.set ("WWW-Authenticate", "Basic realm=" + "\""+realm+"\"");
|
|
||||||
return new Authenticator.Failure(401);
|
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
|
* called for each incoming request to verify the
|
||||||
* given name and password in the context of this
|
* given name and password in the context of this
|
||||||
|
@ -32,7 +32,7 @@ import jdk.test.lib.net.URIBuilder;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @bug 8199849
|
* @bug 8199849 8235976
|
||||||
* @summary
|
* @summary
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @run main/othervm ParamTest
|
* @run main/othervm ParamTest
|
||||||
@ -42,10 +42,10 @@ import jdk.test.lib.net.URIBuilder;
|
|||||||
public class ParamTest {
|
public class ParamTest {
|
||||||
|
|
||||||
static final String[] variants = {
|
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;
|
static final int LOOPS = variants.length;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user