public ActionForward executeInContext( UserContext uc, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { int uid = Integer.parseInt(request.getParameter(Constants.USER_ID_FULL)); int custID = Integer.parseInt(request.getParameter(Constants.CUSTOMER_ID)); IUserManager um = ManagementContainer.getInstance().getUserManager(); UserAccount user = um.getUserAccount(custID, uid); if (user == null) { return mapping.findForward(FAILURE); } try { um.deleteEpaUser(user.getPrimaryEmail()); } catch (Exception ex) { reportSingleError( request, ActionMessages.GLOBAL_MESSAGE, "error.epa.user.delete.error", ex.getMessage()); return mapping.findForward(FAILURE); } IAuditManager auditManager = ManagementContainer.getInstance().getAuditManager(); auditManager.saveAudit( IAuditManager.AuditCategory.EPA_MGMT, "Removed EPA user " + user.getDisplayName() + " ( " + user.getPrimaryEmail() + " )", "Remove EPA User Audit", null, uc.getCurrentUser().getPrimaryEmail()); return mapping.findForward(SUCCESS); }
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); }