Provider 在 Java 中的方法 keySet()
可以使用 java.security.Provider 类中的 keySet() 方法,通过一个不可修改的 Set 视图来查看提供程序中的属性键。该方法不需要参数,它会根据需要返回属性键的不可修改 Set 视图。
一个展示此方法的程序如下 −
示例
import java.security.*; import java.util.*; public class Demo { public static void main(String[] argv) throws Exception { try { Signature sign = Signature.getInstance("DSA"); Provider p = sign.getProvider(); Set<Object> set = p.keySet(); Iterator i= set.iterator(); System.out.println("The unmodifiable Set view is as follows:
"); int x = 30; while (x > 0) { System.out.println(i.next()); x--; } } catch (NoSuchAlgorithmException e) { System.out.println("Error!!! NoSuchAlgorithmException"); } } }
输出
The unmodifiable Set view is as follows: Alg.Alias.Signature.SHA1/DSA Alg.Alias.Signature.1.2.840.10040.4.3 Alg.Alias.Signature.DSS SecureRandom.SHA1PRNG ImplementedIn KeyStore.JKS Alg.Alias.MessageDigest.SHA-1 MessageDigest.SHA KeyStore.CaseExactJKS CertStore.com.sun.security.IndexedCollection ImplementedIn Signature.SHA256withDSA Alg.Alias.MessageDigest.OID.1.3.14.3.2.26 Alg.Alias.Signature.DSA KeyFactory.DSA ImplementedIn KeyStore.JKS ImplementedIn AlgorithmParameters.DSA ImplementedIn Signature.NONEwithDSA Alg.Alias.CertificateFactory.X509 Signature.SHA256withDSA SupportedKeyClasses CertStore.com.sun.security.IndexedCollection Provider.id className Alg.Alias.MessageDigest.1.3.14.3.2.26 Alg.Alias.Signature.SHA-1/DSA KeyStore.DKS CertificateFactory.X.509 ImplementedIn Alg.Alias.Signature.OID.2.16.840.1.101.3.4.3.2 Alg.Alias.Signature.OID.2.16.840.1.101.3.4.3.1 Signature.SHA1withDSA KeySize Signature.NONEwithDSA KeySize CertPathValidator.PKIX ImplementedIn KeyFactory.DSA
广告