Search in sources :

Example 1 with FailReason

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");
    }
}
Also used : FailReason(com.djrapitops.plan.delivery.webserver.auth.FailReason) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Aggregations

FailReason (com.djrapitops.plan.delivery.webserver.auth.FailReason)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1