use of com.djrapitops.plan.delivery.webserver.auth.FailReason in project Plan by plan-player-analytics.
the class ResponseFactory method basicAuthFail.
public Response basicAuthFail(WebUserAuthException e) {
try {
FailReason failReason = e.getFailReason();
String reason = failReason.getReason();
if (failReason == FailReason.ERROR) {
StringBuilder errorBuilder = new StringBuilder("</p><pre>");
for (String line : getStackTrace(e.getCause())) {
errorBuilder.append(line);
}
errorBuilder.append("</pre>");
reason += errorBuilder.toString();
}
return Response.builder().setMimeType(MimeType.HTML).setContent(pageFactory.errorPage(Icon.called("lock").build(), "401 Unauthorized", "Authentication Failed.</p><p><b>Reason: " + reason + "</b></p><p>").toHtml()).setStatus(401).setHeader("WWW-Authenticate", "Basic realm=\"" + failReason.getReason() + "\"").build();
} catch (IOException jarReadFailed) {
return forInternalError(e, "Failed to generate PromptAuthorizationResponse");
}
}
Aggregations