Exemplo n.º 1
0
 private void performGracePeriodCheck(HttpServletRequest request) {
   CertificateManager man = CertificateManager.getInstance();
   if (man.isSatelliteCertInGracePeriod()) {
     long daysUntilExpiration = man.getDaysLeftBeforeCertExpiration();
     createSuccessMessage(
         request, "satellite.graceperiod", new Long(daysUntilExpiration).toString());
   }
 }
Exemplo n.º 2
0
  /** {@inheritDoc} */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {

    if (CertificateManager.getInstance().isSatelliteCertExpired()) {
      addMessage(request, "satellite.expired");
      request.setAttribute(LoginSetupAction.HAS_EXPIRED, new Boolean(true));
      return mapping.findForward("failure");
    }

    ActionForward ret = null;
    DynaActionForm f = (DynaActionForm) form;

    // Validate the form
    ActionErrors errors = RhnValidationHelper.validateDynaActionForm(this, f);
    if (!errors.isEmpty()) {
      performGracePeriodCheck(request);
      addErrors(request, errors);
      return mapping.findForward("failure");
    }
    String username = (String) f.get("username");
    String password = (String) f.get("password");
    String urlBounce = (String) f.get("url_bounce");

    ActionErrors e = new ActionErrors();
    User user = loginUser(username, password, request, response, e);
    RequestContext ctx = new RequestContext(request);

    if (e.isEmpty()) {
      if (urlBounce == null || urlBounce.trim().equals("")) {
        if (log.isDebugEnabled()) {
          log.debug("2 - url bounce is empty using [" + DEFAULT_URL_BOUNCE + "]");
        }
        urlBounce = DEFAULT_URL_BOUNCE;
      }
      if (urlBounce.trim().endsWith("Logout.do")) {
        if (log.isDebugEnabled()) {
          log.debug(" - handling special case of url_bounce=Logout.do");
        }
        urlBounce = DEFAULT_URL_BOUNCE;
      }
      if (user != null) {
        try {
          publishUpdateErrataCacheEvent(user.getOrg());
        } catch (ConstraintViolationException ex) {
          log.error(ex);
          User loggedInUser = ctx.getLoggedInUser();
          if (loggedInUser != null) {
            request.setAttribute("loggedInUser", loggedInUser.getLogin());
          }
          ret = mapping.findForward("error");
          return ret;
        }
      }

      if (log.isDebugEnabled()) {
        log.debug("5 - redirecting to [" + urlBounce + "]");
      }
      if (user != null) {
        pxtDelegate.updateWebUserId(request, response, user.getId());

        try {
          response.sendRedirect(urlBounce);
          return null;
        } catch (IOException ioe) {
          throw new RuntimeException("Exception while trying to redirect: " + ioe);
        }
      }
    } else {
      if (log.isDebugEnabled()) {
        log.debug("6 - forwarding to failure");
      }

      performGracePeriodCheck(request);

      addErrors(request, e);
      request.setAttribute("url_bounce", urlBounce);
      ret = mapping.findForward("failure");
    }
    if (log.isDebugEnabled()) {
      log.debug("7 - returning");
    }
    return ret;
  }