提交 cb60f56e 编写于 作者: M mullan

6653372: Error in java.security.KeyStore example code

Reviewed-by: weijun
上级 8dc88011
/* /*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -131,17 +131,19 @@ import javax.security.auth.callback.*; ...@@ -131,17 +131,19 @@ import javax.security.auth.callback.*;
* 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 =
* new KeyStore.PasswordProtection(password);
*
* // get my private key * // get my private key
* KeyStore.PrivateKeyEntry pkEntry = (KeyStore.PrivateKeyEntry) * KeyStore.PrivateKeyEntry pkEntry = (KeyStore.PrivateKeyEntry)
* ks.getEntry("privateKeyAlias", password); * ks.getEntry("privateKeyAlias", protParam);
* PrivateKey myPrivateKey = pkEntry.getPrivateKey(); * PrivateKey myPrivateKey = pkEntry.getPrivateKey();
* *
* // save my secret key * // save my secret key
* javax.crypto.SecretKey mySecretKey; * javax.crypto.SecretKey mySecretKey;
* KeyStore.SecretKeyEntry skEntry = * KeyStore.SecretKeyEntry skEntry =
* new KeyStore.SecretKeyEntry(mySecretKey); * new KeyStore.SecretKeyEntry(mySecretKey);
* ks.setEntry("secretKeyAlias", skEntry, * ks.setEntry("secretKeyAlias", skEntry, protParam);
* new KeyStore.PasswordProtection(password));
* *
* // store away the keystore * // store away the keystore
* java.io.FileOutputStream fos = null; * java.io.FileOutputStream fos = null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册