Package com.adito.core

Examples of com.adito.core.RedirectWithMessages


            log.error("Failed to upload.", ce);
            ActionMessages errs = getErrors(request);
            errs.add(Globals.ERROR_KEY, ce.getBundleActionMessage());
            saveErrors(request, errs);
            if (null != upload.getUploadedForward())
                return new RedirectWithMessages(upload.getUploadedForward(), request);
            else
                throw ce;
        }       
        catch (Exception e) {
            log.error("Failed to upload.", e);
View Full Code Here


            ActionMessages msgs = new ActionMessages();
            msgs.add(Globals.MESSAGE_KEY, new ActionMessage("createAccount.message.accountSaved"));
            saveMessages(request, msgs);
            return mapping.findForward("setPassword");
        } else {
            return new RedirectWithMessages(mapping.findForward("success"), request);
        }
    }
View Full Code Here

     * @return ActionForward
     * @throws Exception
     */
    public ActionForward cancel(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        return new RedirectWithMessages(mapping.findForward("cancel"), request);
    }
View Full Code Here

       
        // First look for a 'done' forward in the current mapping. If there is
        // none, then use the referer in the form, otherwise redirect to home
      ActionForward fwd = mapping.findForward("done");
      if(fwd != null) {
            return new RedirectWithMessages(fwd, request);           
      }
        if (((CoreForm) form).getReferer() == null) {
            log.warn("Original referer was null, forwarding to home");
            return mapping.findForward("home");
        } else {
            return new RedirectWithMessages(((CoreForm) form).getReferer(), request);
        }
    }
View Full Code Here

    protected static ActionForward getRedirectWithMessages(ActionMapping mapping, HttpServletRequest request) {
        return getRedirectWithMessages("refresh", mapping, request);
    }

    protected static ActionForward getRedirectWithMessages(String redirect, ActionMapping mapping, HttpServletRequest request) {
        return new RedirectWithMessages(mapping.findForward(redirect), request);
    }
View Full Code Here

        if (ticket.equals(this.getSessionInfo(request).getLogonTicket())) {
          log.error("You cannot log yourself off.");
          ActionMessages mesgs = new ActionMessages();
          mesgs.add(Globals.ERROR_KEY, new ActionMessage("status.sessions.cannotLogoffYourself"));
          saveErrors(request, mesgs);
          return new RedirectWithMessages(mapping.findForward("success"), request);
        }
        Map map = LogonControllerFactory.getInstance().getActiveSessions();
        synchronized (map) {
          SessionInfo info = (SessionInfo) map.get(ticket);
          if (info == null) {
View Full Code Here

            request.getSession().removeAttribute(Constants.AUTH_SESSION);
            request.getSession().removeAttribute(LogonStateAndCache.LOGON_STATE_MACHINE);
            LogonControllerFactory.getInstance().logoffSession(request, response);
            msgs.add(Globals.ERROR_KEY, new ActionMessage("login.logonNotAllowed", "Session no longer valid, logon again."));
            saveErrors(request, msgs);
            return new RedirectWithMessages(mapping.findForward("logon"), request);
        }
       
        if (logonStateMachine == null) {
            logonStateMachine = new LogonStateAndCache(LogonStateAndCache.STATE_STARTED, request.getSession());
            request.getSession().setAttribute(LogonStateAndCache.LOGON_STATE_MACHINE, logonStateMachine);
        }
        if (scheme == null) {

            ActionForward fwd = null;
            try {
                fwd = ShowLogonAction.checkAuthSession(null, false, mapping, request, response, logonStateMachine);
            } catch(CoreException ce) {
             
            } catch (Throwable e) {
                log.error("Logon not allowed.", e);
                ActionMessages errs = new ActionMessages();
                if(e instanceof CoreException) {
                  errs.add(Globals.ERROR_KEY, ((CoreException)e).getBundleActionMessage());
                }
                else {
                  errs.add(Globals.ERROR_KEY, new ActionMessage("login.logonNotAllowed",
                                  "Please contact your administrator."));
                }
                saveErrors(request, errs);
                request.getSession().removeAttribute(Constants.AUTH_SESSION);
                request.getSession().removeAttribute(LogonStateAndCache.LOGON_STATE_MACHINE);
                if (form != null)
                    form.reset(mapping, request);
                return new RedirectWithMessages(mapping.findForward("failed"), request);
            }
            if (fwd != null) {
                scheme = (AuthenticationScheme) request.getSession().getAttribute(Constants.AUTH_SESSION);
            }
        }

        if (scheme != null) {
            AuthenticationModule module = scheme.currentAuthenticationModule();
            if (module == null) {
                log.error("No authentication module.");
                request.getSession().removeAttribute(Constants.AUTH_SESSION);
                return mapping.findForward("logon");
            }

            try {             
              // If there is no user in the scheme then it is an invalid login
              if(scheme.getUser() == null) {
                throw new InvalidLoginCredentialsException();
              }
             
              // Check the account is enabled and not locked
              if(!PolicyUtil.isEnabled(scheme.getUser())) {
                throw new AccountLockedException(scheme.getUsername(), "Account disabled.", true, 0);
              }
             
              // Check for locks
              LogonControllerFactory.getInstance().checkForAccountLock(scheme.getUsername(), scheme.getUser().getRealm().getResourceName());

              // Authenticate
                authenticate(scheme, request);

                // Check logon is currently allowed
                String logonNotAllowedReason = LogonControllerFactory.getInstance().checkLogonAllowed(
                                scheme.getUser());

                if (logonNotAllowedReason != null) {
                    log.warn("Logon not allowed because '" + logonNotAllowedReason + "'");
                    msgs.add(Globals.ERROR_KEY, new ActionMessage("login.logonNotAllowed", logonNotAllowedReason));
                    saveErrors(request, msgs);
                    return new RedirectWithMessages(mapping.findForward("logon"), request);
                }

                // Check for the next authentication modules
                AuthenticationModule nextModule = scheme.nextAuthenticationModule();
                if (nextModule != null && request.getSession().getAttribute(Constants.SESSION_LOCKED) == null) {
                    if (log.isDebugEnabled())
                        log.debug("There are more authentication modules to satisfy (current mapping = " + mapping.getPath());
                    ActionForward fw = new RedirectWithMessages(mapping.findForward("logon"), request);
                    return fw;
                }

                return finishAuthentication(scheme, request, response);
            } catch (InputRequiredException ex) {
                // The page wants to display or redirect somewhere
              if(ex.getForward()==null)
                return mapping.findForward("logon");
              else
                return ex.getForward();
            } catch (AccountLockedException ale) {
                return accountLocked(mapping, request, ale, msgs);
            } catch (InvalidLoginCredentialsException ex) {
                log.error("[" + request.getRemoteHost()
                    + "] authentication failed", ex);

                LogonForm logonForm = (LogonForm) form;

                CoreServlet.getServlet().fireCoreEvent(
                    new CoreEvent(this, CoreEventConstants.LOGON, null, null, ex).addAttribute(
                        CoreAttributeConstants.EVENT_ATTR_IP_ADDRESS, request.getRemoteAddr()).addAttribute(
                        CoreAttributeConstants.EVENT_ATTR_HOST, request.getRemoteHost()).addAttribute(
                        CoreAttributeConstants.EVENT_ATTR_SCHEME, scheme.getSchemeName()).addAttribute(
                        CoreAttributeConstants.EVENT_ATTR_ACCOUNT, logonForm.getUsername()));

               
              request.getSession().removeAttribute(LogonStateAndCache.LOGON_STATE_MACHINE);
                request.getSession().removeAttribute(Constants.AUTH_SESSION);

                try {
                    scheme.setAccountLock(LogonControllerFactory.getInstance().logonFailed(((LogonForm)form).getUsername(),
                                    ((LogonForm)form).getRealmName(), scheme.getAccountLock()));
                } catch (AccountLockedException ale) {
                  return accountLocked(mapping, request, ale, msgs);
                }

                msgs.add(Globals.ERROR_KEY, new ActionMessage("login.invalidCredentials"));
                saveErrors(request, msgs);
                return new RedirectWithMessages(mapping.findForward("logon"), request);
            } catch (Exception e) {
                log.error("Internal error authenticating.", e);
                msgs.add(Globals.ERROR_KEY, new BundleActionMessage("security", "login.error", e.getMessage()));
                saveErrors(request, msgs);
                request.getSession().setAttribute(Constants.EXCEPTION, e);
              request.getSession().removeAttribute(LogonStateAndCache.LOGON_STATE_MACHINE);
                request.getSession().removeAttribute(Constants.AUTH_SESSION);
                return new RedirectWithMessages(mapping.findForward("logon"), request);
            }
        } else {
            ActionMessages errs = new ActionMessages();
            errs.add(Globals.MESSAGE_KEY, new BundleActionMessage("security", "login.logonNotAllowed", "No scheme available."));
            saveErrors(request, errs);
            request.getSession().removeAttribute(LogonStateAndCache.LOGON_STATE_MACHINE);
            request.getSession().removeAttribute(Constants.AUTH_SESSION);
            if (form != null)
                form.reset(mapping, request);
            return new RedirectWithMessages(mapping.findForward("logon"), request);
        }
    }
View Full Code Here

    request.getSession().removeAttribute(LogonStateAndCache.LOGON_STATE_MACHINE);
    msgs.add(Globals.ERROR_KEY, new ActionMessage(ale.isDisabled() ? "login.accountDisabled" : "login.accountLocked",
            String.valueOf(((ale.getTimeLeft() / 1000) + 59) / 60)));
    log.warn(ale.getUsername() + " [" + request.getRemoteHost() + "] account locked", ale);
    saveErrors(request, msgs);
    return new RedirectWithMessages(mapping.findForward("logon"), request);
  }
View Full Code Here

            errs.add(Globals.ERROR_KEY, see.getBundleActionMessage());
            saveErrors(request, errs);
            request.getSession().removeAttribute(LogonStateAndCache.LOGON_STATE_MACHINE);
            if (form != null)
                form.reset(mapping, request);
            return new RedirectWithMessages(mapping.findForward("refresh"), request);
        } catch (Throwable e) {
            ActionMessages messages = new ActionMessages();
            log.error("Logon not allowed.", e);
            messages.add(Globals.ERROR_KEY, new ActionMessage("login.logonNotAllowed", "Please contact your administrator."));
            saveErrors(request, messages);
            request.getSession().removeAttribute(LogonStateAndCache.LOGON_STATE_MACHINE);
            if (form != null)
                form.reset(mapping, request);
            return new RedirectWithMessages(mapping.findForward("refresh"), request);
        }
        Util.noCache(response);
        return fwd;
    }
View Full Code Here

       
        // Forward on to the appropriate place
       
        switch(info.getNavigationContext()) {
        case SessionInfo.MANAGEMENT_CONSOLE_CONTEXT:
            return new RedirectWithMessages(mapping.findForward("managementConsole"), request);
        }
        return new RedirectWithMessages(mapping.findForward("userConsole"), request);
    }
View Full Code Here

TOP

Related Classes of com.adito.core.RedirectWithMessages

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.