Security類中的getImpl()方法

Security類中的getImpl方法源碼:

Security.getImpl()方法返回的是一個對象數組。

數組的第一位是根據請求的算法以及類型對象的一個實例,

數組的第二位是對應算法提供者的唯一標識。其中provider的值可以爲null類型,在這種情況下,將在provider配置文件中搜尋最優先的提供者。

以下是源碼

/*

     * Returns an array of objects: the first object in the array is

     * an instance of an implementation of the requested algorithm
     * and type, and the second object in the array identifies the provider
     * of that implementation.
     * The <code>provider</code> argument can be null, in which case all
     * configured providers will be searched in order of preference.
     */
    static Object[] getImpl(String algorithm, String type, String provider)
            throws NoSuchAlgorithmException, NoSuchProviderException {
        if (provider == null) {
            return GetInstance.getInstance
                (type, getSpiClass(type), algorithm).toArray();
        } else {
            return GetInstance.getInstance
                (type, getSpiClass(type), algorithm, provider).toArray();
        }
    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章