< prev index next >
src/java.base/share/classes/java/security/KeyStore.java
Print this page
rev 15967 : [mq]: GetInstance
@@ -24,11 +24,10 @@
*/
package java.security;
import java.io.*;
-import java.net.URI;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.security.cert.CertificateException;
import java.security.spec.AlgorithmParameterSpec;
import java.util.*;
@@ -853,21 +852,24 @@
* See the KeyStore section in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyStore">
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard keystore types.
*
- * @return a keystore object of the specified type.
+ * @return a keystore object of the specified type
*
- * @exception KeyStoreException if no Provider supports a
- * KeyStoreSpi implementation for the
- * specified type.
+ * @throws KeyStoreException if no {@code Provider} supports a
+ * {@code KeyStoreSpi} implementation for the
+ * specified type
+ *
+ * @throws NullPointerException if {@code type} is {@code null}
*
* @see Provider
*/
public static KeyStore getInstance(String type)
throws KeyStoreException
{
+ Objects.requireNonNull(type, "null type name");
try {
Object[] objs = Security.getImpl(type, "KeyStore", (String)null);
return new KeyStore((KeyStoreSpi)objs[0], (Provider)objs[1], type);
} catch (NoSuchAlgorithmException nsae) {
throw new KeyStoreException(type + " not found", nsae);
@@ -893,27 +895,30 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard keystore types.
*
* @param provider the name of the provider.
*
- * @return a keystore object of the specified type.
+ * @return a keystore object of the specified type
+ *
+ * @throws IllegalArgumentException if the provider name is {@code null}
+ * or empty
*
- * @exception KeyStoreException if a KeyStoreSpi
+ * @throws KeyStoreException if a {@code KeyStoreSpi}
* implementation for the specified type is not
- * available from the specified provider.
+ * available from the specified provider
*
- * @exception NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * @throws NoSuchProviderException if the specified provider is not
+ * registered in the security provider list
*
- * @exception IllegalArgumentException if the provider name is null
- * or empty.
+ * @throws NullPointerException if {@code type} is {@code null}
*
* @see Provider
*/
public static KeyStore getInstance(String type, String provider)
throws KeyStoreException, NoSuchProviderException
{
+ Objects.requireNonNull(type, "null type name");
if (provider == null || provider.length() == 0)
throw new IllegalArgumentException("missing provider");
try {
Object[] objs = Security.getImpl(type, "KeyStore", provider);
return new KeyStore((KeyStoreSpi)objs[0], (Provider)objs[1], type);
@@ -936,25 +941,29 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard keystore types.
*
* @param provider the provider.
*
- * @return a keystore object of the specified type.
+ * @return a keystore object of the specified type
+ *
+ * @throws IllegalArgumentException if the specified provider is
+ * {@code null}
*
- * @exception KeyStoreException if KeyStoreSpi
+ * @throws KeyStoreException if {@code KeyStoreSpi}
* implementation for the specified type is not available
- * from the specified Provider object.
+ * from the specified {@code Provider} object
*
- * @exception IllegalArgumentException if the specified provider is null.
+ * @throws NullPointerException if {@code type} is {@code null}
*
* @see Provider
*
* @since 1.4
*/
public static KeyStore getInstance(String type, Provider provider)
throws KeyStoreException
{
+ Objects.requireNonNull(type, "null type name");
if (provider == null)
throw new IllegalArgumentException("missing provider");
try {
Object[] objs = Security.getImpl(type, "KeyStore", provider);
return new KeyStore((KeyStoreSpi)objs[0], (Provider)objs[1], type);
< prev index next >