< prev index next >

src/java.base/share/classes/java/security/KeyStore.java

Print this page
rev 51919 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: dfuchs, alanb


 903      * @return a keystore object of the specified type
 904      *
 905      * @throws IllegalArgumentException if the provider name is {@code null}
 906      *         or empty
 907      *
 908      * @throws KeyStoreException if a {@code KeyStoreSpi}
 909      *         implementation for the specified type is not
 910      *         available from the specified provider
 911      *
 912      * @throws NoSuchProviderException if the specified provider is not
 913      *         registered in the security provider list
 914      *
 915      * @throws NullPointerException if {@code type} is {@code null}
 916      *
 917      * @see Provider
 918      */
 919     public static KeyStore getInstance(String type, String provider)
 920         throws KeyStoreException, NoSuchProviderException
 921     {
 922         Objects.requireNonNull(type, "null type name");
 923         if (provider == null || provider.length() == 0)
 924             throw new IllegalArgumentException("missing provider");
 925         try {
 926             Object[] objs = Security.getImpl(type, "KeyStore", provider);
 927             return new KeyStore((KeyStoreSpi)objs[0], (Provider)objs[1], type);
 928         } catch (NoSuchAlgorithmException nsae) {
 929             throw new KeyStoreException(type + " not found", nsae);
 930         }
 931     }
 932 
 933     /**
 934      * Returns a keystore object of the specified type.
 935      *
 936      * <p> A new KeyStore object encapsulating the
 937      * KeyStoreSpi implementation from the specified Provider
 938      * object is returned.  Note that the specified Provider object
 939      * does not have to be registered in the provider list.
 940      *
 941      * @param type the type of keystore.
 942      * See the KeyStore section in the <a href=
 943      * "{@docRoot}/../specs/security/standard-names.html#keystore-types">




 903      * @return a keystore object of the specified type
 904      *
 905      * @throws IllegalArgumentException if the provider name is {@code null}
 906      *         or empty
 907      *
 908      * @throws KeyStoreException if a {@code KeyStoreSpi}
 909      *         implementation for the specified type is not
 910      *         available from the specified provider
 911      *
 912      * @throws NoSuchProviderException if the specified provider is not
 913      *         registered in the security provider list
 914      *
 915      * @throws NullPointerException if {@code type} is {@code null}
 916      *
 917      * @see Provider
 918      */
 919     public static KeyStore getInstance(String type, String provider)
 920         throws KeyStoreException, NoSuchProviderException
 921     {
 922         Objects.requireNonNull(type, "null type name");
 923         if (provider == null || provider.isEmpty())
 924             throw new IllegalArgumentException("missing provider");
 925         try {
 926             Object[] objs = Security.getImpl(type, "KeyStore", provider);
 927             return new KeyStore((KeyStoreSpi)objs[0], (Provider)objs[1], type);
 928         } catch (NoSuchAlgorithmException nsae) {
 929             throw new KeyStoreException(type + " not found", nsae);
 930         }
 931     }
 932 
 933     /**
 934      * Returns a keystore object of the specified type.
 935      *
 936      * <p> A new KeyStore object encapsulating the
 937      * KeyStoreSpi implementation from the specified Provider
 938      * object is returned.  Note that the specified Provider object
 939      * does not have to be registered in the provider list.
 940      *
 941      * @param type the type of keystore.
 942      * See the KeyStore section in the <a href=
 943      * "{@docRoot}/../specs/security/standard-names.html#keystore-types">


< prev index next >