文章作者 100test 发表时间 2007:09:06 11:53:31
来源 100Test.Com百考试题网
<?XML version="1.0" encoding="UTF-8" standalone="no"?> <invoice XMLns="http://www.company.com/accounting"> <items> <item> <desc>Applied Cryptography</desc> <type>book</type> <unitprice>44.50</unitprice> <quantity>1</quantity> </item> </items> <creditcard> <number>123456789</number> <expiry>10/20/2009</expiry> <lastname>John</lastname> <firstname>Smith</firstname> </creditcard> </invoice> |
keytool -genkey -keysize 512 -sigalg DSA -dname "cn=Young Yang, ou=Architecture, o=Company, L=New York, ST=NY, c=US" -alias biz -keypass kp1234 -keystore bizkeystore -storepass sp1234 -validity 180 |
public static KeyPair getKeyPair(String store,String sPass,String kPass,String alias) throws CertificateException, IOException, UnrecoverableKeyException, KeyStoreException, NoSuchAlgorithmException{ KeyStore ks = loadKeyStore(store,sPass). KeyPair keyPair = null. Key key = null. PublicKey publicKey = null. PrivateKey privateKey = null. if (ks.containsAlias(alias)){ key = ks.getKey(alias,kPass.toCharArray()). if (key instanceof PrivateKey){ Certificate cert = ks.getCertificate(alias). publicKey = cert.getPublicKey(). privateKey = (PrivateKey)key. return new KeyPair(publicKey,privateKey). }else{ return null. } } else { return null. } } |
public static PublicKey getPublicKey(String store, String sPass, String alias) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException{ KeyStore ks = loadKeyStore(store, sPass). Certificate cert = ks.getCertificate(alias). return cert.getPublicKey(). } |
private static KeyStore loadKeyStore(String store, String sPass) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException{ KeyStore myKS = KeyStore.getInstance("JKS"). FileInputStream fis = new FileInputStream(store). myKS.load(fis,sPass.toCharArray()). fis.close(). return myKS. } |
相关文章
ring2.0 JRuby快速入门
JAVA写的日期选择器
有效创建oracledblink的两种方式
JS中将字符串转为XML并读取对象的值
JavaSE6基于JSR105的XML签名之实践篇
用纯JAVA语言编程读取MAC地址的实现
JPCAP——Java中的数据链路层控制
Java小技巧:关于Cookie的操作
ApacheCXF2.0发布并通过JAX-WS2.0TCK
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛