Example #1
0
  /**
   * Adds an existing hash database to the set of hash databases used to classify files as known or
   * known bad. Does not save the configuration - the configuration is only saved on demand to
   * support cancellation of configuration panels.
   *
   * @param hashSetName Name used to represent the hash database in user interface components.
   * @param path Full path to either a hash database file or a hash database index file.
   * @param searchDuringIngest A flag indicating whether or not the hash database should be searched
   *     during ingest.
   * @param sendIngestMessages A flag indicating whether hash set hit messages should be sent as
   *     ingest messages.
   * @param knownFilesType The classification to apply to files whose hashes are found in the hash
   *     database.
   * @return A HashDb representing the hash database.
   * @throws HashDbManagerException, TskCoreException
   */
  synchronized HashDb addExistingHashDatabaseInternal(
      String hashSetName,
      String path,
      boolean searchDuringIngest,
      boolean sendIngestMessages,
      HashDb.KnownFilesType knownFilesType)
      throws HashDbManagerException, TskCoreException {
    if (!new File(path).exists()) {
      throw new HashDbManagerException(
          NbBundle.getMessage(
              HashDbManager.class, "HashDbManager.hashDbDoesNotExistExceptionMsg", path));
    }

    if (hashSetPaths.contains(path)) {
      throw new HashDbManagerException(
          NbBundle.getMessage(
              HashDbManager.class, "HashDbManager.hashDbAlreadyAddedExceptionMsg", path));
    }

    if (hashSetNames.contains(hashSetName)) {
      throw new HashDbManagerException(
          NbBundle.getMessage(
              HashDbManager.class, "HashDbManager.duplicateHashSetNameExceptionMsg", hashSetName));
    }

    return addHashDatabase(
        SleuthkitJNI.openHashDatabase(path),
        hashSetName,
        searchDuringIngest,
        sendIngestMessages,
        knownFilesType);
  }