Exemplo n.º 1
0
  @SuppressWarnings("unchecked")
  protected void setupFolderSyncZone() throws Exception {

    int custId = getJspTestUtils().getCustId();
    IFolderSyncManager folderMgr = ManagementContainer.getInstance().getFolderSyncManager();
    IUserManager userService = ManagementContainer.getInstance().getUserManager();

    UserAccount account = userService.getUser(getJspTestUtils().getUserAddress());
    m_userId = account.getUserID();

    // first create the topology and zone itself
    CustomerTopology ct = createTopology();
    Iterator serverIterator = ct.getAllServers();
    if (!serverIterator.hasNext()) {
      fail("No server in topology.");
    }
    CustomerServer server = (CustomerServer) serverIterator.next();
    Iterator storesIterator = ct.getAllStores();
    if (!storesIterator.hasNext()) {
      fail("No stores in server.");
    }
    CustomerStore store = (CustomerStore) storesIterator.next();
    FolderSyncZone zone = new FolderSyncZone();
    zone.setCustomerId(getJspTestUtils().getCustId());
    zone.setDisplayName("foobar");
    zone.setRegistrationKey("12345");
    zone.getServers().add(server);
    folderMgr.saveFolderSyncZone(zone);

    // now enable the user for folder sync
    account.setMessageStoreID(store.getStoreID());
    userService.updateUsers(Arrays.asList(account));
    SavedUserSet userSet = new SavedUserSet(custId);
    List<Integer> userIDs = Arrays.asList(account.getUserID());
    List<SearchConstraint> oldScList = new ArrayList<SearchConstraint>();
    oldScList.add(
        new SearchConstraint(
            UserManagerConstants.PROP_USERID,
            SearchConstraintOperator.CONSTRAINT_IN_LIST,
            userIDs));
    userSet.addUsers(oldScList);
    folderMgr.saveUserSetEnabledForSync(custId, userSet);
  }
Exemplo n.º 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);
  }