mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8286423: Destroy password protection in the example code in KeyStore
Reviewed-by: weijun
This commit is contained in:
parent
e4439ca32a
commit
1904e9d280
1 changed files with 15 additions and 14 deletions
|
@ -143,9 +143,9 @@ import sun.security.util.Debug;
|
||||||
* to read existing entries from the keystore, or to write new entries
|
* to read existing entries from the keystore, or to write new entries
|
||||||
* into the keystore:
|
* into the keystore:
|
||||||
* <pre>
|
* <pre>
|
||||||
* KeyStore.ProtectionParameter protParam =
|
* KeyStore.PasswordProtection protParam =
|
||||||
* new KeyStore.PasswordProtection(password);
|
* new KeyStore.PasswordProtection(password);
|
||||||
*
|
* try (FileOutputStream fos = new FileOutputStream("newKeyStoreName")) {
|
||||||
* // get my private key
|
* // get my private key
|
||||||
* KeyStore.PrivateKeyEntry pkEntry = (KeyStore.PrivateKeyEntry)
|
* KeyStore.PrivateKeyEntry pkEntry = (KeyStore.PrivateKeyEntry)
|
||||||
* ks.getEntry("privateKeyAlias", protParam);
|
* ks.getEntry("privateKeyAlias", protParam);
|
||||||
|
@ -158,8 +158,9 @@ import sun.security.util.Debug;
|
||||||
* ks.setEntry("secretKeyAlias", skEntry, protParam);
|
* ks.setEntry("secretKeyAlias", skEntry, protParam);
|
||||||
*
|
*
|
||||||
* // store away the keystore
|
* // store away the keystore
|
||||||
* try (FileOutputStream fos = new FileOutputStream("newKeyStoreName")) {
|
|
||||||
* ks.store(fos, password);
|
* ks.store(fos, password);
|
||||||
|
* } finally {
|
||||||
|
* protParam.destroy();
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue