Java中的提供者getProperty()方法
使用getProperty()类java.security.Provider中的方法,可以使用特定键在属性列表中搜索所需的属性。此方法需要一个参数,即搜索属性所需的键。它返回键的属性值;如果该属性值不可用,则返回null。
演示此的程序如下所示-
示例
import java.security.*;
import java.util.*;
public class Demo {
public static void main(String[] argv) throws Exception {
try {
KeyPairGenerator kpGenerator = KeyPairGenerator.getInstance("DSA");
Provider p = kpGenerator.getProvider();
Set<Object> s = p.keySet();
Iterator i = s.iterator();
int x = 30;
while (x > 0) {
System.out.println(p.getProperty((String)i.next()));
x--;
}
} catch (NoSuchAlgorithmException e) {
System.out.println("Error!!! NoSuchAlgorithmException");
}
}
}输出结果
SHA1withDSA SHA1withDSA SHA1withDSA Software sun.security.provider.JavaKeyStore$DualFormatJKS SHA sun.security.provider.SHA sun.security.provider.JavaKeyStore$CaseExactJKS Software sun.security.provider.DSA$SHA256withDSA SHA SHA1withDSA Software Software Software sun.security.provider.DSA$RawDSA X.509 java.security.interfaces.DSAPublicKey|java.security.interfaces.DSAPrivateKey sun.security.provider.certpath.IndexedCollectionCertStore sun.security.provider.Sun SHA SHA1withDSA sun.security.provider.DomainKeyStore$DKS Software SHA256withDSA SHA224withDSA 1024 1024 Software sun.security.provider.DSAKeyFactory
热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志