Skip to content
Permalink
Browse files
8286423: Destroy password protection in the example code in KeyStore
Reviewed-by: weijun
  • Loading branch information
XueleiFan committed May 12, 2022
1 parent e4439ca commit 1904e9d280d1cce2deead4d4aa39dda1beb9dff1
Showing 1 changed file with 14 additions and 13 deletions.
@@ -143,23 +143,24 @@
* to read existing entries from the keystore, or to write new entries
* into the keystore:
* <pre>
* KeyStore.ProtectionParameter protParam =
* KeyStore.PasswordProtection protParam =
* new KeyStore.PasswordProtection(password);
* try (FileOutputStream fos = new FileOutputStream("newKeyStoreName")) {
* // get my private key
* KeyStore.PrivateKeyEntry pkEntry = (KeyStore.PrivateKeyEntry)
* ks.getEntry("privateKeyAlias", protParam);
* PrivateKey myPrivateKey = pkEntry.getPrivateKey();
*
* // get my private key
* KeyStore.PrivateKeyEntry pkEntry = (KeyStore.PrivateKeyEntry)
* ks.getEntry("privateKeyAlias", protParam);
* PrivateKey myPrivateKey = pkEntry.getPrivateKey();
*
* // save my secret key
* javax.crypto.SecretKey mySecretKey;
* KeyStore.SecretKeyEntry skEntry =
* new KeyStore.SecretKeyEntry(mySecretKey);
* ks.setEntry("secretKeyAlias", skEntry, protParam);
* // save my secret key
* javax.crypto.SecretKey mySecretKey;
* KeyStore.SecretKeyEntry skEntry =
* new KeyStore.SecretKeyEntry(mySecretKey);
* ks.setEntry("secretKeyAlias", skEntry, protParam);
*
* // store away the keystore
* try (FileOutputStream fos = new FileOutputStream("newKeyStoreName")) {
* // store away the keystore
* ks.store(fos, password);
* } finally {
* protParam.destroy();
* }
* </pre>
*

1 comment on commit 1904e9d

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 1904e9d May 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.