コード例 #1
0
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws IOException {
    ManagementContainer container = ManagementContainer.getInstance();
    IAuthenticationManager am = container.getAuthenticationManager();
    HttpSession session = request.getSession();
    Integer userIdObj = (Integer) session.getAttribute(REQUEST_ID);
    if (userIdObj == null) {
      reportSingleError(request, "login", "errors.login.invalid");
      return mapping.findForward(FAILURE);
    }

    int userID = userIdObj.intValue();
    UserLoginResult result = am.checkLoginStatus(userID);
    if (result.getStatus() == LoginStatus.AUTH_PENDING) {
      return mapping.findForward("logon.wait");
    }
    session.removeAttribute(REQUEST_ID);
    if (result.getStatus() == LoginStatus.AUTH_FAILED) {
      reportSingleError(request, "login", "errors.login.invalid");
      return mapping.findForward(FAILURE);
    }

    UserContext.newContext(request, result.getUser(), result.getCustomer());

    if (result.getStatus() == LoginStatus.AUTH_OK) {
      LogonUtils.configureBranding(request, response, result.getCustomer());
    }

    return successfulLoginForward(request, response, mapping, actionForm, result);
  }
コード例 #2
0
  public boolean execute(CommandLine cmdLine) {
    ICustomerManager cm = m_container.getCustomerManager();
    List<String> domains = Collections.singletonList(ICustomerManager.EPA_CUSTOMER_DOMAIN);
    IIslandManager im = m_container.getIslandManager();
    int defaultIslandID = im.getDefaultIsland().getId();

    Customer cust =
        cm.createCustomer(
            ICustomerManager.EPA_CUSTOMER_NAME,
            "System", // fromAddress
            "System", // backendID
            "System", // templateID
            "System", // channel
            domains,
            "emsRootPW", // emsRootPassword
            false, // isPartialEnabled
            "System", // activeBrandKey
            "System", // externalID
            defaultIslandID,
            defaultIslandID,
            false);

    PasswordPolicy policy = new PasswordPolicy();
    policy.setUseStrongPasswords(true);
    cust.setPasswordPolicy(policy);
    cm.updateCustomers(Collections.singletonList(cust));

    IUserManager um = ManagementContainer.getInstance().getUserManager();
    UserAccount emsRoot = um.getUser("emsroot@" + ICustomerManager.EPA_CUSTOMER_DOMAIN);
    IAuthenticationManager am = ManagementContainer.getInstance().getAuthenticationManager();
    long seconds = 31556926; // Seconds in a year
    long time =
        System.currentTimeMillis() + (seconds * 100 * 1000L); // Lock the account for 100 years
    am.lockUserAccount(
        cust.getCustID(), emsRoot.getUserID(), "Locked from user details", "Unknown", time);

    return (cust != null);
  }