private Result handleFailure(Exception e) { log.info("Connect Access Token authentication failed: " + e.getMessage()); log.debug("Stack Trace was: ", e); return new Result.Failure(new DefaultMessage(e.getMessage())); }
LOG.info("2-Legged-OAuth with Impersonation request has been attempted but 2-Legged-OAuth with Impersonation is not enabled for consumer:'{}'. Cannot access resource as user '{}'", consumer.getName(), userId); sendError(response, HttpServletResponse.SC_UNAUTHORIZED, message); return new Authenticator.Result.Failure(new OAuthProblem.PermissionDenied(userId)); LOG.info("2-Legged-OAuth request has been attempted but 2-Legged-OAuth is not enabled for consumer:'{}'.", consumer.getName()); sendError(response, HttpServletResponse.SC_UNAUTHORIZED, message); return new Authenticator.Result.Failure(new OAuthProblem.PermissionDenied());
private Result handleOAuthProblemException(HttpServletResponse response, OAuthMessage message, String tokenStr, OAuthProblemException ope) { logOAuthProblem(message, ope, LOG); try { OAuthServlet.handleException(response, ope, applicationProperties.getBaseUrl()); } catch (Exception e) { // there was an IOE or ServletException, nothing more we can really do LOG.error("Failure reporting OAuth error to client", e); } if (ope.getProblem().equals(CONSUMER_KEY_UNKNOWN)) { return new Result.Failure(new OAuthProblem(Problem.valueOf(ope.getProblem().toUpperCase(Locale.ENGLISH)))); } if (tokenStr != null) { return new Result.Failure(new OAuthProblem(Problem.valueOf(ope.getProblem().toUpperCase(Locale.ENGLISH)), tokenStr)); } else { return new Result.Failure(new OAuthProblem(Problem.valueOf(ope.getProblem().toUpperCase(Locale.ENGLISH)))); } }
private void fail(HttpServletRequest request, HttpServletResponse response, String externallyVisibleMessage, int httpResponseCode) { sendErrorResponse(response, httpResponseCode, externallyVisibleMessage); authenticationListener.authenticationFailure(new Authenticator.Result.Failure(createMessage("")), request, response); }
private void fail(HttpServletRequest request, HttpServletResponse response, String externallyVisibleMessage, int httpResponseCode) { sendErrorResponse(response, httpResponseCode, externallyVisibleMessage); authenticationListener.authenticationFailure(new Authenticator.Result.Failure(createMessage("")), request, response); }
private static Authenticator.Result.Failure createAndSendFailure(Exception e, HttpServletResponse response, int httpResponseCode, String externallyVisibleMessage) { log.debug("Failure during JWT authentication: ", e); sendErrorResponse(response, httpResponseCode, externallyVisibleMessage); return new Authenticator.Result.Failure(createMessage(e.getLocalizedMessage())); }
private Result getUserLoginResult(HttpServletRequest request, HttpServletResponse response, OAuthMessage message, Consumer consumer, Principal user) { // if a user is provided, they must exist and be able to login if (user != null && !authenticationController.canLogin(user, request)) { LOG.info("Access denied because user:'{}' cannot login", user.getName()); sendError(response, HttpServletResponse.SC_UNAUTHORIZED, message); return new Result.Failure(new OAuthProblem.PermissionDenied(user.getName())); } LOG.info("Authenticated app '{}' as user '{}' successfully", consumer.getKey(), user == null ? "null" : user.getName()); return new Result.Success(user); }
private static Authenticator.Result.Failure createAndSendFailure(Exception e, HttpServletResponse response, int httpResponseCode, String externallyVisibleMessage) { log.debug("Failure during JWT authentication: ", e); sendErrorResponse(response, httpResponseCode, externallyVisibleMessage); return new Authenticator.Result.Failure(createMessage(e.getLocalizedMessage())); }
private static Result.Failure createAndSendFailure(Exception e, HttpServletResponse response, int httpResponseCode, String externallyVisibleMessage) { if (e instanceof JwtSignatureMismatchException) { JwtSignatureMismatchException mismatch = (JwtSignatureMismatchException) e; String issuer = StringUtils.defaultString(mismatch.getIssuer(), "unavailable"); log.warn("Signature mismatch during JWT authentication, issuer: {}", issuer, e); } else { log.warn("Failure during JWT authentication", e); } sendErrorResponse(response, httpResponseCode, externallyVisibleMessage); return new Result.Failure(createMessage(e.getLocalizedMessage())); }
private Result handleFailure(String clientId, String userAgent, OAuth2EventPublisher.ErrorCode errorCode, Exception e) { log.info("Connect Access Token authentication failed: " + e.getMessage()); log.debug("Stack Trace was: ", e); eventPublisher.failWithClientId(clientId, userAgent, errorCode, e.getMessage()); return new Result.Failure(new DefaultMessage(e.getMessage())); } }