Пример #1
0
  /**
   * Assigns the given certificate to the given alias.
   *
   * <p>If the given alias already exists in this keystore and identifies a <i>trusted certificate
   * entry</i>, the certificate associated with it is overridden by the given certificate.
   *
   * @param alias the alias name
   * @param cert the certificate
   * @exception KeyStoreException if the given alias already exists and does not identify a
   *     <i>trusted certificate entry</i>, or this operation fails for some other reason.
   */
  public void engineSetCertificateEntry(String alias, Certificate cert) throws KeyStoreException {
    AbstractMap.SimpleEntry<String, AbstractMap.SimpleEntry<String, KeyStore>> pair =
        getKeystoreForWriting(alias);

    if (pair == null) {
      throw new KeyStoreException("Error setting certificate entry for '" + alias + "'");
    }
    String entryAlias = pair.getKey();
    Map.Entry<String, KeyStore> keystore = pair.getValue();
    keystore.getValue().setCertificateEntry(entryAlias, cert);
  }
Пример #2
0
  /**
   * Deletes the entry identified by the given alias from this keystore.
   *
   * @param alias the alias name
   * @exception KeyStoreException if the entry cannot be removed.
   */
  public void engineDeleteEntry(String alias) throws KeyStoreException {
    AbstractMap.SimpleEntry<String, AbstractMap.SimpleEntry<String, KeyStore>> pair =
        getKeystoreForWriting(alias);

    if (pair == null) {
      throw new KeyStoreException("Error deleting entry for '" + alias + "'");
    }
    String entryAlias = pair.getKey();
    Map.Entry<String, KeyStore> keystore = pair.getValue();
    keystore.getValue().deleteEntry(entryAlias);
  }
Пример #3
0
  /**
   * Assigns the given private key to the given alias, protecting it with the given password as
   * defined in PKCS8.
   *
   * <p>The given j86.java.security.PrivateKey <code>key</code> must be accompanied by a certificate
   * chain certifying the corresponding public key.
   *
   * <p>If the given alias already exists, the keystore information associated with it is overridden
   * by the given key and certificate chain.
   *
   * @param alias the alias name
   * @param key the private key to be associated with the alias
   * @param password the password to protect the key
   * @param chain the certificate chain for the corresponding public key (only required if the given
   *     key is of type <code>j86.java.security.PrivateKey</code>).
   * @exception KeyStoreException if the given key is not a private key, cannot be protected, or
   *     this operation fails for some other reason
   */
  public void engineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain)
      throws KeyStoreException {
    AbstractMap.SimpleEntry<String, AbstractMap.SimpleEntry<String, KeyStore>> pair =
        getKeystoreForWriting(alias);

    if (pair == null) {
      throw new KeyStoreException("Error setting key entry for '" + alias + "'");
    }
    String entryAlias = pair.getKey();
    Map.Entry<String, KeyStore> keystore = pair.getValue();
    keystore.getValue().setKeyEntry(entryAlias, key, password, chain);
  }