in src/main/java/com/googlesource/gerrit/plugins/gitblit/auth/GerritAuthFilter.java [96:118]
public boolean filterBasicAuth(
HttpServletRequest request, HttpServletResponse response, String hdr)
throws IOException, UnsupportedEncodingException {
if (!hdr.startsWith(LIT_BASIC)) {
response.setHeader("WWW-Authenticate", "Basic realm=\"Gerrit Code Review\"");
response.sendError(SC_UNAUTHORIZED);
return false;
}
byte[] decoded = new Base64().decode(hdr.substring(LIT_BASIC.length()).getBytes());
String usernamePassword =
new String(decoded, MoreObjects.firstNonNull(request.getCharacterEncoding(), "UTF-8"));
int splitPos = usernamePassword.indexOf(':');
if (splitPos < 1) {
response.setHeader("WWW-Authenticate", "Basic realm=\"Gerrit Code Review\"");
response.sendError(SC_UNAUTHORIZED);
return false;
}
request.setAttribute("gerrit-username", usernamePassword.substring(0, splitPos));
request.setAttribute("gerrit-password", usernamePassword.substring(splitPos + 1));
return true;
}