private void storeToken(HttpServletRequest req) throws IOException {
    RefreshableKeycloakSecurityContext ctx =
        (RefreshableKeycloakSecurityContext)
            req.getAttribute(KeycloakSecurityContext.class.getName());
    String refreshToken = ctx.getRefreshToken();

    RefreshTokenDAO.saveToken(refreshToken);

    RefreshToken refreshTokenDecoded = RefreshTokenUtil.getRefreshToken(refreshToken);
    Boolean isOfflineToken =
        refreshTokenDecoded.getType().equals(RefreshTokenUtil.TOKEN_TYPE_OFFLINE);
    req.setAttribute("isOfflineToken", isOfflineToken);
  }
  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    if (req.getRequestURI().endsWith("/login")) {
      storeToken(req);
      req.getRequestDispatcher("/WEB-INF/pages/loginCallback.jsp").forward(req, resp);
      return;
    }

    String refreshToken = RefreshTokenDAO.loadToken();
    String refreshTokenInfo;
    boolean savedTokenAvailable;
    if (refreshToken == null) {
      refreshTokenInfo = "No token saved in database. Please login first";
      savedTokenAvailable = false;
    } else {
      RefreshToken refreshTokenDecoded = RefreshTokenUtil.getRefreshToken(refreshToken);
      String exp =
          (refreshTokenDecoded.getExpiration() == 0)
              ? "NEVER"
              : Time.toDate(refreshTokenDecoded.getExpiration()).toString();
      refreshTokenInfo =
          String.format(
              "<p>Type: %s</p><p>ID: %s</p><p>Expires: %s</p>",
              refreshTokenDecoded.getType(), refreshTokenDecoded.getId(), exp);
      savedTokenAvailable = true;
    }
    req.setAttribute("tokenInfo", refreshTokenInfo);
    req.setAttribute("savedTokenAvailable", savedTokenAvailable);

    String customers;
    if (req.getRequestURI().endsWith("/loadCustomers")) {
      customers = loadCustomers(req, refreshToken);
    } else {
      customers = "";
    }
    req.setAttribute("customers", customers);

    req.getRequestDispatcher("/WEB-INF/pages/view.jsp").forward(req, resp);
  }