Esempio n. 1
0
 /**
  * Returns {@code true} if the PSE has been initialized (created). Some keystore formats may not
  * require initialization and may always return {@code true}. {@code false} may also be returned
  * if the keystore passphrase is incorrect.
  *
  * @return {@code true} if the PSE has been previously initialized otherwise {@code false}.
  */
 public boolean isInitialized() {
   try {
     if (keystore_password != null) {
       return keystore_manager.isInitialized(keystore_password);
     } else {
       return keystore_manager.isInitialized();
     }
   } catch (Exception ignored) {
     return false;
   }
 }
Esempio n. 2
0
  /**
   * Initializes the PSE environment.
   *
   * @throws KeyStoreException When the wrong keystore has been provided.
   * @throws IOException For errors related to processing the keystore.
   */
  public void initialize() throws KeyStoreException, IOException {

    Logging.logCheckedInfo(LOG, "Initializing new PSE keystore...");

    synchronized (keystore_manager) {
      try {

        if (keystore_manager.isInitialized(keystore_password)) return;

        keystore_manager.createKeyStore(keystore_password);

      } catch (KeyStoreException failed) {

        Logging.logCheckedSevere(LOG, "Failure accessing or creating keystore.\n", failed);
        keystore_manager.eraseKeyStore();
        throw failed;
      }
    }
  }