< prev index next >
src/java.base/share/classes/java/security/cert/CertStore.java
Print this page
rev 15967 : [mq]: GetInstance
@@ -31,10 +31,11 @@
import java.security.NoSuchProviderException;
import java.security.PrivilegedAction;
import java.security.Provider;
import java.security.Security;
import java.util.Collection;
+import java.util.Objects;
import sun.security.jca.*;
import sun.security.jca.GetInstance.Instance;
/**
@@ -216,24 +217,27 @@
* for information about standard types.
*
* @param params the initialization parameters (may be {@code null}).
*
* @return a {@code CertStore} object that implements the specified
- * {@code CertStore} type.
- *
- * @throws NoSuchAlgorithmException if no Provider supports a
- * CertStoreSpi implementation for the specified type.
+ * {@code CertStore} type
*
* @throws InvalidAlgorithmParameterException if the specified
* initialization parameters are inappropriate for this
- * {@code CertStore}.
+ * {@code CertStore}
+ *
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports a
+ * {@code CertStoreSpi} implementation for the specified type
+ *
+ * @throws NullPointerException if {@code type} is {@code null}
*
* @see java.security.Provider
*/
public static CertStore getInstance(String type, CertStoreParameters params)
throws InvalidAlgorithmParameterException,
NoSuchAlgorithmException {
+ Objects.requireNonNull(type, "null type name");
try {
Instance instance = GetInstance.getInstance("CertStore",
CertStoreSpi.class, type, params);
return new CertStore((CertStoreSpi)instance.impl,
instance.provider, type, params);
@@ -241,11 +245,12 @@
return handleException(e);
}
}
private static CertStore handleException(NoSuchAlgorithmException e)
- throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
+ throws NoSuchAlgorithmException,
+ InvalidAlgorithmParameterException {
Throwable cause = e.getCause();
if (cause instanceof InvalidAlgorithmParameterException) {
throw (InvalidAlgorithmParameterException)cause;
}
throw e;
@@ -278,32 +283,35 @@
* @param params the initialization parameters (may be {@code null}).
*
* @param provider the name of the provider.
*
* @return a {@code CertStore} object that implements the
- * specified type.
+ * specified type
*
- * @throws NoSuchAlgorithmException if a CertStoreSpi
- * implementation for the specified type is not
- * available from the specified provider.
+ * @throws IllegalArgumentException if the {@code provider} is
+ * {@code null} or empty
*
* @throws InvalidAlgorithmParameterException if the specified
* initialization parameters are inappropriate for this
- * {@code CertStore}.
+ * {@code CertStore}
+ *
+ * @throws NoSuchAlgorithmException if a {@code CertStoreSpi}
+ * implementation for the specified type is not
+ * available from the specified provider
*
* @throws NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * registered in the security provider list
*
- * @exception IllegalArgumentException if the {@code provider} is
- * null or empty.
+ * @throws NullPointerException if {@code type} is {@code null}
*
* @see java.security.Provider
*/
public static CertStore getInstance(String type,
CertStoreParameters params, String provider)
throws InvalidAlgorithmParameterException,
NoSuchAlgorithmException, NoSuchProviderException {
+ Objects.requireNonNull(type, "null type name");
try {
Instance instance = GetInstance.getInstance("CertStore",
CertStoreSpi.class, type, params, provider);
return new CertStore((CertStoreSpi)instance.impl,
instance.provider, type, params);
@@ -336,28 +344,31 @@
* @param params the initialization parameters (may be {@code null}).
*
* @param provider the provider.
*
* @return a {@code CertStore} object that implements the
- * specified type.
+ * specified type
*
- * @exception NoSuchAlgorithmException if a CertStoreSpi
- * implementation for the specified type is not available
- * from the specified Provider object.
+ * @throws IllegalArgumentException if the {@code provider} is
+ * null
*
* @throws InvalidAlgorithmParameterException if the specified
* initialization parameters are inappropriate for this
* {@code CertStore}
*
- * @exception IllegalArgumentException if the {@code provider} is
- * null.
+ * @throws NoSuchAlgorithmException if a {@code CertStoreSpi}
+ * implementation for the specified type is not available
+ * from the specified Provider object
+ *
+ * @throws NullPointerException if {@code type} is {@code null}
*
* @see java.security.Provider
*/
public static CertStore getInstance(String type, CertStoreParameters params,
Provider provider) throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException {
+ Objects.requireNonNull(type, "null type name");
try {
Instance instance = GetInstance.getInstance("CertStore",
CertStoreSpi.class, type, params, provider);
return new CertStore((CertStoreSpi)instance.impl,
instance.provider, type, params);
< prev index next >