Exemplo n.º 1
0
  /**
   * Update the mail signal file with a current timestamp.
   *
   * @param client
   */
  public void stampNewmailFile(IClient client) {
    if (client == null) {
      return;
    }
    String cachePath = client.getNewMailCachePath();
    File f = new File(getCacheBase(), cachePath);

    // matches scheme used in smtpnotify.py
    long stamp = System.currentTimeMillis() / 5000;
    byte[] content = Long.toString(stamp).getBytes();

    // It's not necessary to write the file atomically.
    // It's not critical information; the worst that can happen is
    // the client does an unnecessary retrieve call into the backend.
    touchFile(f, content, client.getUserId(), false);
  }
Exemplo n.º 2
0
  @BeforeMethod
  public void setUp() throws Exception {
    // do cleanup of other tests that may have started writers.
    // this is necessary in a non-forked test suite environment
    // where partition ids could collide
    Utils.finishBackupWriters();

    m_tmpDir = new File(System.getProperty("java.io.tmpdir"), "PartitionStoreStageTest");
    if (!m_tmpDir.exists()) {
      assertTrue("Failed to make the directories.", m_tmpDir.mkdirs());
    }

    // Add a dummy partition
    String server = "test";
    String storage = m_tmpDir + "/storage";

    File storageDir = new File(storage);
    if (!storageDir.exists()) {
      assertTrue("Failed to make the storage directory.", storageDir.mkdirs());
      if (!storageDir.exists()) {
        s_logger.warn("Storage Directory " + storage + " does not exist.");
      }
    }

    String mapped = m_tmpDir + "/mapped";

    File mappedDir = new File(mapped);
    if (!mappedDir.exists()) {
      assertTrue("Failed to make the mapped directories.", mappedDir.mkdirs());
      if (!mappedDir.exists()) {
        s_logger.warn("Storage Directory " + mapped + " does not exist.");
      }
    }

    if (m_part == null) {
      IPartitionManager pm = ManagementContainer.getInstance().getPartitionManager();
      m_part = pm.initializePartition(TEST_PID, server, storage, mapped);
    }
    Utils.startBackupWriters();
  }
Exemplo n.º 3
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);
  }