sso/src/main/java/com/streamsets/lib/security/http/SSOUserAuthenticator.java
@Override
  protected Authentication returnUnauthorized(
      HttpServletRequest httpReq, HttpServletResponse httpRes, String principalId, String logMessageTemplate
  ) throws ServerAuthException {
    Authentication ret;
    httpRes.addCookie(createAuthCookie(httpReq, "", 0));
    if (httpReq.getHeader(SSOConstants.X_REST_CALL) != null) {
      ret = super.returnUnauthorized(httpReq, httpRes, null, logMessageTemplate);
    } else {
      redirectToLogin(httpReq, httpRes);
      ret = Authentication.SEND_FAILURE;
    }
    return ret;
  }
@Override
  protected Authentication returnUnauthorized(
      HttpServletRequest httpReq, HttpServletResponse httpRes, String principalId, String logMessageTemplate
  ) throws ServerAuthException {
    Authentication ret;
    httpRes.addCookie(createAuthCookie(httpReq, "", 0));
    if (httpReq.getHeader(SSOConstants.X_REST_CALL) != null) {
      ret = super.returnUnauthorized(httpReq, httpRes, null, logMessageTemplate);
    } else {
      redirectToLogin(httpReq, httpRes);
      ret = Authentication.SEND_FAILURE;
    }
    return ret;
  }
/*
Terminates the request with an HTTP Unauthorized response or redirects to login for page requests