in src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java [1239:1284]
private void sendSudoCookie(
HttpServletRequest request,
HttpServletResponse response,
final String user,
final int maxAge,
final String path,
final String owner) {
final String quotedUser;
String quotedOwner = null;
try {
quotedUser = quoteCookieValue(user);
if (owner != null) {
quotedOwner = quoteCookieValue(owner);
}
} catch (IllegalArgumentException iae) {
log.error(
"sendSudoCookie: Failed to quote value '{}' of cookie {}: {}",
user,
this.sudoCookieName,
iae.getMessage());
return;
} catch (UnsupportedEncodingException e) {
log.error(
"sendSudoCookie: Failed to quote value '{}' of cookie {}: {}",
user,
this.sudoCookieName,
e.getMessage());
return;
}
if (quotedUser != null) {
final Cookie cookie = new Cookie(this.sudoCookieName, quotedUser);
cookie.setHttpOnly(true);
cookie.setSecure(request.isSecure());
cookie.setMaxAge(maxAge);
cookie.setPath((path == null || path.length() == 0) ? "/" : path);
try {
cookie.setComment(quotedOwner + " impersonates as " + quotedUser);
} catch (IllegalArgumentException iae) {
// ignore
}
response.addCookie(cookie);
}
}