mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +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,23 +143,24 @@ import sun.security.util.Debug;
|
|||
* 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);
|
||||
*
|
||||
* // 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);
|
||||
*
|
||||
* // store away the keystore
|
||||
* try (FileOutputStream fos = new FileOutputStream("newKeyStoreName")) {
|
||||
* // 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);
|
||||
*
|
||||
* // store away the keystore
|
||||
* ks.store(fos, password);
|
||||
* } finally {
|
||||
* protParam.destroy();
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue