Provider getProperty() 方法在 Java 中
可以使用特定鍵使用 java.security.Provider 類中的 getProperty() 方法在屬性列表中搜索所需的屬性。此方法需要一個引數,即用於搜尋屬性所需的鍵。它返回鍵的屬性值,如果屬性值不可用,則返回 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
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP