Java 中的 Provider values() 方法


可以透過使用 java.security.Provider 類中的 values() 方法獲取 Provider 中的屬性值,該方法會返回一個不可修改的 Collection 檢視。此方法不需要引數,它會返回屬性值的不可修改的 Collection 檢視。

演示此方法的程式如下 −

示例

 線上演示

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();
         Collection<Object> val = p.values();
         Iterator i = val.iterator();
         System.out.println("The unmodifiable Collection view is: 
");          int x = 30;          while (x > 0) {             System.out.println(i.next());             x--;          }       } catch (NoSuchAlgorithmException e) { System.out.println("Error!!! NoSuchAlgorithmException"); } } }

輸出

The unmodifiable Collection view is:
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

更新於: 30-Jul-2019

92 次瀏覽

開啟您的 職業生涯

完成課程即可獲得認證

開始
廣告
© . All rights reserved.