Package com.jada.util

Examples of com.jada.util.IdSecurity


            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
      }
     
      Site site = getContentBean(request).getSiteDomain().getSite();
      IdSecurity idSecurity = new IdSecurity(site, form.getCustEmail(), true);
      if (idSecurity.isSuspened()) {
        idSecurity.fail();
        form.setCustPassword("");
          messages.add("login", new ActionMessage("content.error.login.suspended.temporary", String.valueOf(Constants.ID_SUSPEND_TIME / 1000 / 60)));
      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
      }
     
      ContentBean contentBean = getContentBean(request);
      char singleCheckout = contentBean.getSiteDomain().getSite().getSingleCheckout();
     
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    String sql = "from   Customer customer " +
           "where  customer.siteDomain.siteDomainId = :siteDomainId " +
           "and    custEmail = :custEmail";
        Query query = em.createQuery(sql);
        if (singleCheckout == Constants.VALUE_YES) {
            query.setParameter("siteDomainId", contentBean.getSiteDomain().getSite().getSiteDomainDefault().getSiteDomainId());
        }
        else {
          query.setParameter("siteDomainId", contentBean.getSiteDomain().getSiteDomainId());
        }
        query.setParameter("custEmail", form.getCustEmail());
       
        List<?> list = query.getResultList();
        if (list.size() == 0) {
          idSecurity.fail();
          form.setCustPassword("");
          messages.add("login", new ActionMessage("content.error.login.invalid"));
      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
        }
       
        Customer customer = (Customer) list.get(0);
        String password = AESEncoder.getInstance().decode(customer.getCustPassword());
        if (!password.equals(form.getCustPassword())) {
          idSecurity.fail();
          form.setCustPassword("");
          messages.add("login", new ActionMessage("content.error.login.invalid"));
      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
        }
        idSecurity.reset();
       
        ContentLookupDispatchAction.setCustId(request, customer.getCustId());
        // to init in order to avoid lazy initialization.
        customer.getRecCreateDatetime();
        mergeOrder(request, form, customer);
View Full Code Here


        em = JpaConnection.getInstance().getCurrentEntityManager();
        em.getTransaction().begin();
       
        Query query = em.createQuery("from Site site where systemRecord = 'Y' and siteId != '_system'");
        Site siteDefault = (Site) query.getSingleResult();
        IdSecurity idSecurity = new IdSecurity(siteDefault, form.getUserId(), true);
        if (idSecurity.isSuspened()) {
          errors.add("error", new ActionMessage("content.error.login.suspended.temporary", Constants.ID_SUSPEND_TIME / 1000 / 60));
        saveMessages(request, errors);
        form.setUserPassword("");
        idSecurity.fail();
        return actionMapping.findForward("error");
        }
         
          query = em.createQuery("from User user where userId = :userId");
      query.setParameter("userId", form.getUserId());
      List<?> list = query.getResultList();
      if (list.size() == 0) {
        errors.add("error", new ActionMessage("error.login.invalid"));
        saveMessages(request, errors);
        form.setUserPassword("");
        idSecurity.fail();
        em.getTransaction().commit();
        return actionMapping.findForward("error");
      }
      user = (User) list.get(0);
      if (user.getActive() != Constants.VALUE_YES) {
        errors.add("error", new ActionMessage("error.login.invalid"));
        saveMessages(request, errors);
        form.setUserPassword("");
        idSecurity.fail();
        em.getTransaction().commit();
        return actionMapping.findForward("error");
      }
      String userPassword = AESEncoder.getInstance().decode(user.getUserPassword());
      if (!userPassword.equals(form.getUserPassword())) {
        errors.add("error", new ActionMessage("error.login.invalid"));
        saveMessages(request, errors);
        form.setUserPassword("");
        idSecurity.fail();
        em.getTransaction().commit();
        return actionMapping.findForward("error");
      }
      Site site = null;
      if (!Format.isNullOrEmpty(user.getUserLastVisitSiteId())) {
        site = SiteDAO.load(user.getUserLastVisitSiteId());
      }
      if (site == null) {
        site = SiteDAO.getDefaultSite(user);
      }
      if (site == null) {
        errors.add("error", new ActionMessage("error.login.access"));
        saveMessages(request, errors);
        form.setUserPassword("");
        return actionMapping.findForward("error");
      }
      user.setUserLastVisitSiteId(site.getSiteId());

        HttpSession httpSession = request.getSession();
        AdminBean adminBean = new AdminBean();
        adminBean.init(user.getUserId(), site.getSiteId());
        httpSession.setAttribute("adminBean", adminBean);
        Cookie cookie = new Cookie("user", user.getUserName());
        cookie.setMaxAge(-1);
        response.addCookie(cookie);
        httpSession.setAttribute("userLastLoginDatetime", user.getUserLastLoginDatetime());
        user.setUserLastLoginDatetime(new Date());
        idSecurity.reset();
        em.getTransaction().commit();
      }
      catch (Throwable e) {
          logger.error(e);
          return actionMapping.findForward("exception");
View Full Code Here

      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
      }
     
      IdSecurity idSecurity = new IdSecurity(site, form.getCustEmail(), true);
      if (idSecurity.isSuspened()) {
        idSecurity.fail();
          form.setCustPassword("");
        this.initCartInfo(form, site, shoppingCart, request, messages);
          messages.add("login", new ActionMessage("content.error.login.suspended.temporary", String.valueOf(Constants.ID_SUSPEND_TIME / 1000 / 60)));
      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
      }

    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    String sql = "from     Customer customer " +
           "where   customer.siteDomain.siteDomainId = :siteDomainId " +
           "and     custEmail = :custEmail " +
           "and    custPassword = :custPassword ";
        Query query = em.createQuery(sql);
        if (singleCheckout == Constants.VALUE_YES) {
          Long defaultSiteDomainId = contentBean.getSiteDomain().getSite().getSiteDomainDefault().getSiteDomainId();
          query.setParameter("siteDomainId", defaultSiteDomainId);
        }
        else {
          query.setParameter("siteDomainId", contentBean.getSiteDomain().getSiteDomainId());
        }
        query.setParameter("custEmail", form.getCustEmail());
        query.setParameter("custPassword", AESEncoder.getInstance().encode(form.getCustPassword()));
       
        List<?> list = query.getResultList();
        if (list.size() == 0) {
          idSecurity.fail();
          form.setCustPassword("");
        this.initCartInfo(form, site, shoppingCart, request, messages);
          messages.add("login", new ActionMessage("content.error.login.invalid"));
      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
        }
        idSecurity.reset();
       
        Customer customer = (Customer) list.get(0);
        if (!customer.getActive().equals(Constants.VALUE_YES)) {
          messages.add("login", new ActionMessage("content.error.login.suspended"));
      saveMessages(request, messages);
View Full Code Here

TOP

Related Classes of com.jada.util.IdSecurity

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.