src/share/classes/java/security/Security.java

Print this page




 661 
 662     // Map containing cached Spi Class objects of the specified type
 663     private static final Map<String,Class> spiMap =
 664                                 new ConcurrentHashMap<String,Class>();
 665 
 666     /**
 667      * Return the Class object for the given engine type
 668      * (e.g. "MessageDigest"). Works for Spis in the java.security package
 669      * only.
 670      */
 671     private static Class getSpiClass(String type) {
 672         Class clazz = spiMap.get(type);
 673         if (clazz != null) {
 674             return clazz;
 675         }
 676         try {
 677             clazz = Class.forName("java.security." + type + "Spi");
 678             spiMap.put(type, clazz);
 679             return clazz;
 680         } catch (ClassNotFoundException e) {
 681             throw (Error)new AssertionError("Spi class not found").initCause(e);
 682         }
 683     }
 684 
 685     /*
 686      * Returns an array of objects: the first object in the array is
 687      * an instance of an implementation of the requested algorithm
 688      * and type, and the second object in the array identifies the provider
 689      * of that implementation.
 690      * The <code>provider</code> argument can be null, in which case all
 691      * configured providers will be searched in order of preference.
 692      */
 693     static Object[] getImpl(String algorithm, String type, String provider)
 694             throws NoSuchAlgorithmException, NoSuchProviderException {
 695         if (provider == null) {
 696             return GetInstance.getInstance
 697                 (type, getSpiClass(type), algorithm).toArray();
 698         } else {
 699             return GetInstance.getInstance
 700                 (type, getSpiClass(type), algorithm, provider).toArray();
 701         }




 661 
 662     // Map containing cached Spi Class objects of the specified type
 663     private static final Map<String,Class> spiMap =
 664                                 new ConcurrentHashMap<String,Class>();
 665 
 666     /**
 667      * Return the Class object for the given engine type
 668      * (e.g. "MessageDigest"). Works for Spis in the java.security package
 669      * only.
 670      */
 671     private static Class getSpiClass(String type) {
 672         Class clazz = spiMap.get(type);
 673         if (clazz != null) {
 674             return clazz;
 675         }
 676         try {
 677             clazz = Class.forName("java.security." + type + "Spi");
 678             spiMap.put(type, clazz);
 679             return clazz;
 680         } catch (ClassNotFoundException e) {
 681             throw new AssertionError("Spi class not found", e);
 682         }
 683     }
 684 
 685     /*
 686      * Returns an array of objects: the first object in the array is
 687      * an instance of an implementation of the requested algorithm
 688      * and type, and the second object in the array identifies the provider
 689      * of that implementation.
 690      * The <code>provider</code> argument can be null, in which case all
 691      * configured providers will be searched in order of preference.
 692      */
 693     static Object[] getImpl(String algorithm, String type, String provider)
 694             throws NoSuchAlgorithmException, NoSuchProviderException {
 695         if (provider == null) {
 696             return GetInstance.getInstance
 697                 (type, getSpiClass(type), algorithm).toArray();
 698         } else {
 699             return GetInstance.getInstance
 700                 (type, getSpiClass(type), algorithm, provider).toArray();
 701         }