summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/java/security/cert
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/java/security/cert')
-rw-r--r--libjava/classpath/java/security/cert/CertPath.java4
-rw-r--r--libjava/classpath/java/security/cert/CertPathBuilder.java113
-rw-r--r--libjava/classpath/java/security/cert/CertPathValidator.java103
-rw-r--r--libjava/classpath/java/security/cert/CertStore.java121
-rw-r--r--libjava/classpath/java/security/cert/CertStoreSpi.java6
-rw-r--r--libjava/classpath/java/security/cert/CertificateFactory.java136
-rw-r--r--libjava/classpath/java/security/cert/CertificateFactorySpi.java10
-rw-r--r--libjava/classpath/java/security/cert/CollectionCertStoreParameters.java5
-rw-r--r--libjava/classpath/java/security/cert/PKIXBuilderParameters.java4
-rw-r--r--libjava/classpath/java/security/cert/PKIXCertPathChecker.java5
-rw-r--r--libjava/classpath/java/security/cert/PKIXParameters.java19
-rw-r--r--libjava/classpath/java/security/cert/PolicyNode.java12
-rw-r--r--libjava/classpath/java/security/cert/PolicyQualifierInfo.java5
-rw-r--r--libjava/classpath/java/security/cert/X509CRL.java4
-rw-r--r--libjava/classpath/java/security/cert/X509CRLSelector.java5
-rw-r--r--libjava/classpath/java/security/cert/X509CertSelector.java17
-rw-r--r--libjava/classpath/java/security/cert/X509Certificate.java9
-rw-r--r--libjava/classpath/java/security/cert/X509Extension.java6
18 files changed, 315 insertions, 269 deletions
diff --git a/libjava/classpath/java/security/cert/CertPath.java b/libjava/classpath/java/security/cert/CertPath.java
index e818763aab4..781eb3e2776 100644
--- a/libjava/classpath/java/security/cert/CertPath.java
+++ b/libjava/classpath/java/security/cert/CertPath.java
@@ -161,7 +161,7 @@ public abstract class CertPath implements Serializable
*
* @return the iterator of supported encodings in the path
*/
- public abstract Iterator getEncodings();
+ public abstract Iterator<String> getEncodings();
/**
* Compares this path to another for semantic equality. To be equal, both
@@ -226,7 +226,7 @@ public abstract class CertPath implements Serializable
*
* @return the list of certificates, non-null but possibly empty
*/
- public abstract List getCertificates();
+ public abstract List<? extends Certificate> getCertificates();
/**
* Serializes the path in its encoded form, to ensure reserialization with
diff --git a/libjava/classpath/java/security/cert/CertPathBuilder.java b/libjava/classpath/java/security/cert/CertPathBuilder.java
index f6965205f53..519ed2b6c52 100644
--- a/libjava/classpath/java/security/cert/CertPathBuilder.java
+++ b/libjava/classpath/java/security/cert/CertPathBuilder.java
@@ -40,6 +40,7 @@ package java.security.cert;
import gnu.java.security.Engine;
+import java.lang.reflect.InvocationTargetException;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
@@ -111,50 +112,54 @@ public class CertPathBuilder
}
/**
- * Get an instance of a named CertPathBuilder, from the first provider
- * that implements it.
- *
- * @param algorithm The name of the CertPathBuilder to create.
+ * Returns an instance of a named <code>CertPathBuilder</code> from the
+ * first provider that implements it.
+ *
+ * @param algorithm The name of the <code>CertPathBuilder</code> to create.
* @return The new instance.
- * @throws NoSuchAlgorithmException If no installed provider
- * implements the named algorithm.
+ * @throws NoSuchAlgorithmException If no installed provider implements the
+ * named algorithm.
+ * @throws IllegalArgumentException if <code>algorithm</code> is
+ * <code>null</code> or is an empty string.
*/
public static CertPathBuilder getInstance(String algorithm)
- throws NoSuchAlgorithmException
+ throws NoSuchAlgorithmException
{
Provider[] p = Security.getProviders();
-
+ NoSuchAlgorithmException lastException = null;
for (int i = 0; i < p.length; i++)
- {
- try
- {
- return getInstance(algorithm, p[i]);
- }
- catch (NoSuchAlgorithmException e)
- {
- // Ignored.
- }
- }
-
+ try
+ {
+ return getInstance(algorithm, p[i]);
+ }
+ catch (NoSuchAlgorithmException x)
+ {
+ lastException = x;
+ }
+ if (lastException != null)
+ throw lastException;
throw new NoSuchAlgorithmException(algorithm);
}
/**
- * Get an instance of a named CertPathBuilder from the named
+ * Returns an instance of a named <code>CertPathBuilder</code> from a named
* provider.
- *
- * @param algorithm The name of the CertPathBuilder to create.
- * @param provider The name of the provider from which to get the
- * implementation.
+ *
+ * @param algorithm The name of the <code>CertPathBuilder</code> to create.
+ * @param provider The name of the provider to use.
* @return The new instance.
- * @throws NoSuchAlgorithmException If no installed provider
- * implements the named algorithm.
- * @throws NoSuchProviderException If the named provider does not
- * exist.
+ * @throws NoSuchAlgorithmException If no installed provider implements the
+ * named algorithm.
+ * @throws NoSuchProviderException If the named provider does not exist.
+ * @throws IllegalArgumentException if either <code>algorithm</code> or
+ * <code>provider</code> is <code>null</code>, or if
+ * <code>algorithm</code> is an empty string.
*/
public static CertPathBuilder getInstance(String algorithm, String provider)
- throws NoSuchAlgorithmException, NoSuchProviderException
+ throws NoSuchAlgorithmException, NoSuchProviderException
{
+ if (provider == null)
+ throw new IllegalArgumentException("provider MUST NOT be null");
Provider p = Security.getProvider(provider);
if (p == null)
throw new NoSuchProviderException(provider);
@@ -162,41 +167,47 @@ public class CertPathBuilder
}
/**
- * Get an instance of a named CertPathBuilder from the specified
- * provider.
- *
- * @param algorithm The name of the CertPathBuilder to create.
- * @param provider The provider from which to get the implementation.
+ * Returns an instance of a named <code>CertPathBuilder</code> from the
+ * specified provider.
+ *
+ * @param algorithm The name of the <code>CertPathBuilder</code> to create.
+ * @param provider The provider to use.
* @return The new instance.
- * @throws NoSuchAlgorithmException If no installed provider
- * implements the named algorithm.
- * @throws IllegalArgumentException If <i>provider</i> in
- * <tt>null</tt>.
+ * @throws NoSuchAlgorithmException If no installed provider implements the
+ * named algorithm.
+ * @throws IllegalArgumentException if either <code>algorithm</code> or
+ * <code>provider</code> is <code>null</code>, or if
+ * <code>algorithm</code> is an empty string.
*/
public static CertPathBuilder getInstance(String algorithm, Provider provider)
- throws NoSuchAlgorithmException
+ throws NoSuchAlgorithmException
{
- if (provider == null)
- throw new IllegalArgumentException("null provider");
+ StringBuilder sb = new StringBuilder("CertPathBuilder for algorithm [")
+ .append(algorithm).append("] from provider[")
+ .append(provider).append("] could not be created");
+ Throwable cause;
try
{
- return new CertPathBuilder((CertPathBuilderSpi)
- Engine.getInstance(CERT_PATH_BUILDER, algorithm, provider),
- provider, algorithm);
+ Object spi = Engine.getInstance(CERT_PATH_BUILDER, algorithm, provider);
+ return new CertPathBuilder((CertPathBuilderSpi) spi, provider, algorithm);
}
- catch (java.lang.reflect.InvocationTargetException ite)
+ catch (InvocationTargetException x)
{
- throw new NoSuchAlgorithmException(algorithm);
+ cause = x.getCause();
+ if (cause instanceof NoSuchAlgorithmException)
+ throw (NoSuchAlgorithmException) cause;
+ if (cause == null)
+ cause = x;
}
- catch (ClassCastException cce)
+ catch (ClassCastException x)
{
- throw new NoSuchAlgorithmException(algorithm);
+ cause = x;
}
+ NoSuchAlgorithmException x = new NoSuchAlgorithmException(sb.toString());
+ x.initCause(cause);
+ throw x;
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
/**
* Return the name of this CertPathBuilder algorithm.
*
diff --git a/libjava/classpath/java/security/cert/CertPathValidator.java b/libjava/classpath/java/security/cert/CertPathValidator.java
index 5fed19e9a78..bf7c9746e24 100644
--- a/libjava/classpath/java/security/cert/CertPathValidator.java
+++ b/libjava/classpath/java/security/cert/CertPathValidator.java
@@ -40,6 +40,7 @@ package java.security.cert;
import gnu.java.security.Engine;
+import java.lang.reflect.InvocationTargetException;
import java.security.AccessController;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
@@ -124,91 +125,103 @@ public class CertPathValidator {
}
/**
- * Get an instance of the given validator from the first provider that
+ * Returns an instance of the given validator from the first provider that
* implements it.
- *
+ *
* @param algorithm The name of the algorithm to get.
* @return The new instance.
- * @throws NoSuchAlgorithmException If no installed provider
- * implements the requested algorithm.
+ * @throws NoSuchAlgorithmException If no installed provider implements the
+ * requested algorithm.
+ * @throws IllegalArgumentException if <code>algorithm</code> is
+ * <code>null</code> or is an empty string.
*/
public static CertPathValidator getInstance(String algorithm)
throws NoSuchAlgorithmException
{
Provider[] p = Security.getProviders();
+ NoSuchAlgorithmException lastException = null;
for (int i = 0; i < p.length; i++)
- {
- try
- {
- return getInstance(algorithm, p[i]);
- }
- catch (NoSuchAlgorithmException e)
- {
- // Ignored.
- }
- }
+ try
+ {
+ return getInstance(algorithm, p[i]);
+ }
+ catch (NoSuchAlgorithmException x)
+ {
+ lastException = x;
+ }
+ if (lastException != null)
+ throw lastException;
throw new NoSuchAlgorithmException(algorithm);
}
/**
- * Get an instance of the given validator from the named provider.
- *
+ * Returns an instance of the given validator from the named provider.
+ *
* @param algorithm The name of the algorithm to get.
- * @param provider The name of the provider from which to get the
- * implementation.
+ * @param provider The name of the provider from which to get the
+ * implementation.
* @return The new instance.
- * @throws NoSuchAlgorithmException If the named provider does not
- * implement the algorithm.
- * @throws NoSuchProviderException If no provider named
- * <i>provider</i> is installed.
+ * @throws NoSuchAlgorithmException If the named provider does not implement
+ * the algorithm.
+ * @throws NoSuchProviderException If no provider named <i>provider</i> is
+ * installed.
+ * @throws IllegalArgumentException if either <code>algorithm</code> or
+ * <code>provider</code> is <code>null</code>, or if
+ * <code>algorithm</code> is an empty string.
*/
- public static CertPathValidator getInstance(String algorithm,
- String provider)
- throws NoSuchAlgorithmException, NoSuchProviderException
+ public static CertPathValidator getInstance(String algorithm, String provider)
+ throws NoSuchAlgorithmException, NoSuchProviderException
{
+ if (provider == null)
+ throw new IllegalArgumentException("provider MUST NOT be null");
Provider p = Security.getProvider(provider);
if (p == null)
throw new NoSuchProviderException(provider);
-
return getInstance(algorithm, p);
}
/**
- * Get an instance of the given validator from the given provider.
- *
+ * Returns an instance of the given validator from the given provider.
+ *
* @param algorithm The name of the algorithm to get.
- * @param provider The provider from which to get the implementation.
+ * @param provider The provider from which to get the implementation.
* @return The new instance.
- * @throws NoSuchAlgorithmException If the provider does not implement
- * the algorithm.
- * @throws IllegalArgumentException If <i>provider</i> is null.
+ * @throws NoSuchAlgorithmException If the provider does not implement the
+ * algorithm.
+ * @throws IllegalArgumentException if either <code>algorithm</code> or
+ * <code>provider</code> is <code>null</code>, or if
+ * <code>algorithm</code> is an empty string.
*/
public static CertPathValidator getInstance(String algorithm,
Provider provider)
throws NoSuchAlgorithmException
{
- if (provider == null)
- throw new IllegalArgumentException("null provider");
-
+ StringBuilder sb = new StringBuilder("CertPathValidator for algorithm [")
+ .append(algorithm).append("] from provider[")
+ .append(provider).append("] could not be created");
+ Throwable cause;
try
{
- return new CertPathValidator((CertPathValidatorSpi)
- Engine.getInstance(CERT_PATH_VALIDATOR, algorithm, provider),
- provider, algorithm);
+ Object spi = Engine.getInstance(CERT_PATH_VALIDATOR, algorithm, provider);
+ return new CertPathValidator((CertPathValidatorSpi) spi, provider, algorithm);
}
- catch (java.lang.reflect.InvocationTargetException ite)
+ catch (InvocationTargetException x)
{
- throw new NoSuchAlgorithmException(algorithm);
+ cause = x.getCause();
+ if (cause instanceof NoSuchAlgorithmException)
+ throw (NoSuchAlgorithmException) cause;
+ if (cause == null)
+ cause = x;
}
- catch (ClassCastException cce)
+ catch (ClassCastException x)
{
- throw new NoSuchAlgorithmException(algorithm);
+ cause = x;
}
+ NoSuchAlgorithmException x = new NoSuchAlgorithmException(sb.toString());
+ x.initCause(cause);
+ throw x;
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
/**
* Return the name of this validator.
*
diff --git a/libjava/classpath/java/security/cert/CertStore.java b/libjava/classpath/java/security/cert/CertStore.java
index 864da868f19..a27086562e6 100644
--- a/libjava/classpath/java/security/cert/CertStore.java
+++ b/libjava/classpath/java/security/cert/CertStore.java
@@ -40,6 +40,7 @@ package java.security.cert;
import gnu.java.security.Engine;
+import java.lang.reflect.InvocationTargetException;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
@@ -52,7 +53,7 @@ import java.util.Collection;
* A CertStore is a read-only repository for certificates and
* certificate revocation lists.
*
- * @since JDK 1.4
+ * @since 1.4
*/
public class CertStore
{
@@ -123,59 +124,63 @@ public class CertStore
}
/**
- * Get an instance of the given certificate store from the first
+ * Returns an instance of the given certificate store type from the first
* installed provider.
- *
- * @param type The type of CertStore to create.
- * @param params The parameters to initialize this cert store with.
+ *
+ * @param type The type of <code>CertStore</code> to create.
+ * @param params The parameters to initialize this cert store with.
* @return The new instance.
- * @throws InvalidAlgorithmParameterException If the instance rejects
- * the specified parameters.
- * @throws NoSuchAlgorithmException If no installed provider
- * implements the specified CertStore.
- * @throws IllegalArgumentException If <i>provider</i> is null.
+ * @throws InvalidAlgorithmParameterException If the instance rejects the
+ * specified parameters.
+ * @throws NoSuchAlgorithmException If no installed provider implements the
+ * specified CertStore.
+ * @throws IllegalArgumentException if <code>type</code> is
+ * <code>null</code> or is an empty string.
*/
public static CertStore getInstance(String type, CertStoreParameters params)
throws InvalidAlgorithmParameterException, NoSuchAlgorithmException
{
Provider[] p = Security.getProviders();
+ NoSuchAlgorithmException lastException = null;
for (int i = 0; i < p.length; i++)
- {
- try
- {
- return getInstance(type, params, p[i]);
- }
- catch (NoSuchAlgorithmException e)
- {
- // Ignored.
- }
- }
-
+ try
+ {
+ return getInstance(type, params, p[i]);
+ }
+ catch (NoSuchAlgorithmException x)
+ {
+ lastException = x;
+ }
+ if (lastException != null)
+ throw lastException;
throw new NoSuchAlgorithmException(type);
}
/**
- * Get an instance of the given certificate store from the named
+ * Returns an instance of the given certificate store type from a named
* provider.
- *
- * @param type The type of CertStore to create.
- * @param params The parameters to initialize this cert store with.
- * @param provider The name of the provider from which to get the
- * implementation.
+ *
+ * @param type The type of <code>CertStore</code> to create.
+ * @param params The parameters to initialize this cert store with.
+ * @param provider The name of the provider to use.
* @return The new instance.
- * @throws InvalidAlgorithmParameterException If the instance rejects
- * the specified parameters.
+ * @throws InvalidAlgorithmParameterException If the instance rejects the
+ * specified parameters.
* @throws NoSuchAlgorithmException If the specified provider does not
- * implement the specified CertStore.
- * @throws NoSuchProviderException If no provider named
- * <i>provider</i> is installed.
- * @throws IllegalArgumentException If <i>provider</i> is null.
+ * implement the specified CertStore.
+ * @throws NoSuchProviderException If no provider named <i>provider</i> is
+ * installed.
+ * @throws IllegalArgumentException if either <code>type</code> or
+ * <code>provider</code> is <code>null</code>, or if
+ * <code>type</code> is an empty string.
*/
public static CertStore getInstance(String type, CertStoreParameters params,
String provider)
throws InvalidAlgorithmParameterException, NoSuchAlgorithmException,
NoSuchProviderException
{
+ if (provider == null)
+ throw new IllegalArgumentException("provider MUST NOT be null");
Provider p = Security.getProvider(provider);
if (p == null)
throw new NoSuchProviderException(provider);
@@ -183,48 +188,52 @@ public class CertStore
}
/**
- * Get an instance of the given certificate store from the given
+ * Returns an instance of the given certificate store type from a given
* provider.
*
- * @param type The type of CertStore to create.
+ * @param type The type of <code>CertStore</code> to create.
* @param params The parameters to initialize this cert store with.
- * @param provider The provider from which to get the implementation.
+ * @param provider The provider to use.
* @return The new instance.
* @throws InvalidAlgorithmParameterException If the instance rejects
* the specified parameters.
* @throws NoSuchAlgorithmException If the specified provider does not
* implement the specified CertStore.
- * @throws IllegalArgumentException If <i>provider</i> is null.
+ * @throws IllegalArgumentException if either <code>type</code> or
+ * <code>provider</code> is <code>null</code>, or if
+ * <code>type</code> is an empty string.
*/
public static CertStore getInstance(String type, CertStoreParameters params,
Provider provider)
- throws InvalidAlgorithmParameterException, NoSuchAlgorithmException
+ throws InvalidAlgorithmParameterException, NoSuchAlgorithmException
{
- if (provider == null)
- throw new IllegalArgumentException("null provider");
-
+ StringBuilder sb = new StringBuilder("CertStore of type [")
+ .append(type).append("] from provider[")
+ .append(provider).append("] could not be created");
+ Throwable cause;
try
{
- return new CertStore((CertStoreSpi) Engine.getInstance(CERT_STORE,
- type, provider, new Object[] { params }), provider, type, params);
+ Object[] args = new Object[] { params };
+ Object spi = Engine.getInstance(CERT_STORE, type, provider, args);
+ return new CertStore((CertStoreSpi) spi, provider, type, params);
}
- catch (ClassCastException cce)
+ catch (InvocationTargetException x)
{
- throw new NoSuchAlgorithmException(type);
+ cause = x.getCause();
+ if (cause instanceof NoSuchAlgorithmException)
+ throw (NoSuchAlgorithmException) cause;
+ if (cause == null)
+ cause = x;
}
- catch (java.lang.reflect.InvocationTargetException ite)
+ catch (ClassCastException x)
{
- Throwable cause = ite.getCause();
- if (cause instanceof InvalidAlgorithmParameterException)
- throw (InvalidAlgorithmParameterException) cause;
- else
- throw new NoSuchAlgorithmException(type);
+ cause = x;
}
+ NoSuchAlgorithmException x = new NoSuchAlgorithmException(sb.toString());
+ x.initCause(cause);
+ throw x;
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
/**
* Return the type of certificate store this instance represents.
*
@@ -268,7 +277,7 @@ public class CertStore
* @return The collection of certificates.
* @throws CertStoreException If the certificates cannot be retrieved.
*/
- public final Collection getCertificates(CertSelector selector)
+ public final Collection<? extends Certificate> getCertificates(CertSelector selector)
throws CertStoreException
{
return storeSpi.engineGetCertificates(selector);
@@ -286,7 +295,7 @@ public class CertStore
* @return The collection of certificate revocation lists.
* @throws CertStoreException If the CRLs cannot be retrieved.
*/
- public final Collection getCRLs(CRLSelector selector)
+ public final Collection<? extends CRL> getCRLs(CRLSelector selector)
throws CertStoreException
{
return storeSpi.engineGetCRLs(selector);
diff --git a/libjava/classpath/java/security/cert/CertStoreSpi.java b/libjava/classpath/java/security/cert/CertStoreSpi.java
index a69545f0d32..976d65ce922 100644
--- a/libjava/classpath/java/security/cert/CertStoreSpi.java
+++ b/libjava/classpath/java/security/cert/CertStoreSpi.java
@@ -50,7 +50,7 @@ import java.util.Collection;
* implement the {@link CertStoreParameters} interface, if they require
* parameters.
*
- * @since JDK 1.4
+ * @since 1.4
* @see CertStore
* @see CollectionCertStoreParameters
* @see LDAPCertStoreParameters
@@ -86,7 +86,7 @@ public abstract class CertStoreSpi
* @return A (non-null) collection of certificates.
* @throws CertStoreException If the certificates cannot be retrieved.
*/
- public abstract Collection engineGetCertificates(CertSelector selector)
+ public abstract Collection<? extends Certificate> engineGetCertificates(CertSelector selector)
throws CertStoreException;
/**
@@ -98,6 +98,6 @@ public abstract class CertStoreSpi
* @return A (non-null) collection of certificate revocation list.
* @throws CertStoreException If the CRLs cannot be retrieved.
*/
- public abstract Collection engineGetCRLs(CRLSelector selector)
+ public abstract Collection<? extends CRL> engineGetCRLs(CRLSelector selector)
throws CertStoreException;
}
diff --git a/libjava/classpath/java/security/cert/CertificateFactory.java b/libjava/classpath/java/security/cert/CertificateFactory.java
index aedeff53573..8139c6ec5c3 100644
--- a/libjava/classpath/java/security/cert/CertificateFactory.java
+++ b/libjava/classpath/java/security/cert/CertificateFactory.java
@@ -41,6 +41,8 @@ package java.security.cert;
import gnu.java.security.Engine;
import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
@@ -56,7 +58,7 @@ import java.util.List;
*
* @author Mark Benvenuto
* @author Casey Marshall
- * @since JDK 1.2
+ * @since 1.2
* @status Fully compatible with JDK 1.4.
*/
public class CertificateFactory
@@ -84,106 +86,102 @@ public class CertificateFactory
this.type = type;
}
- // Class methods.
- // ------------------------------------------------------------------------
-
- /**
- * Gets an instance of the CertificateFactory class representing
- * the specified certificate factory. If the type is not
- * found then, it throws CertificateException.
- *
- * @param type The type of certificate factory to create.
- * @return a CertificateFactory repesenting the desired type
- * @throws CertificateException If the type of certificate is not
- * implemented by any installed provider.
+ /**
+ * Returns an instance of a <code>CertificateFactory</code> representing the
+ * specified certificate factory type.
+ *
+ * @param type The type of certificate factory to create.
+ * @return A <code>CertificateFactory</code> of the desired type.
+ * @throws CertificateException If the type of certificate factory is not
+ * implemented by any installed provider.
+ * @throws IllegalArgumentException if <code>type</code> is
+ * <code>null</code> or is an empty string.
*/
public static final CertificateFactory getInstance(String type)
- throws CertificateException
+ throws CertificateException
{
Provider[] p = Security.getProviders();
-
+ CertificateException lastException = null;
for (int i = 0; i < p.length; i++)
- {
- try
- {
- return getInstance(type, p[i]);
- }
- catch (CertificateException e)
- {
- // Ignored.
- }
- }
-
+ try
+ {
+ return getInstance(type, p[i]);
+ }
+ catch (CertificateException x)
+ {
+ lastException = x;
+ }
+ if (lastException != null)
+ throw lastException;
throw new CertificateException(type);
}
- /**
- * Gets an instance of the CertificateFactory class representing
- * the specified certificate factory from the specified provider.
- * If the type is not found then, it throws {@link CertificateException}.
- * If the provider is not found, then it throws
- * {@link java.security.NoSuchProviderException}.
- *
- * @param type The type of certificate factory to create.
- * @param provider The name of the provider from which to get the
- * implementation.
- * @return A CertificateFactory for the desired type.
- * @throws CertificateException If the type of certificate is not
- * implemented by the named provider.
+ /**
+ * Returns an instance of a <code>CertificateFactory</code> representing the
+ * specified certificate factory type from the named provider.
+ *
+ * @param type The type of certificate factory to create.
+ * @param provider The name of the provider to use.
+ * @return A <code>CertificateFactory</code> for the desired type.
+ * @throws CertificateException If the type of certificate is not implemented
+ * by the named provider.
* @throws NoSuchProviderException If the named provider is not installed.
+ * @throws IllegalArgumentException if either <code>type</code> or
+ * <code>provider</code> is <code>null</code>, or if
+ * <code>type</code> is an empty string.
*/
public static final CertificateFactory getInstance(String type,
String provider)
throws CertificateException, NoSuchProviderException
{
+ if (provider == null)
+ throw new IllegalArgumentException("provider MUST NOT be null");
Provider p = Security.getProvider(provider);
- if( p == null)
+ if (p == null)
throw new NoSuchProviderException(provider);
-
return getInstance(type, p);
}
/**
- * Get a certificate factory for the given certificate type from the
- * given provider.
- *
- * @param type The type of certificate factory to create.
+ * Returns an instance of a <code>CertificateFactory</code> representing the
+ * specified certificate factory type from the designated provider.
+ *
+ * @param type The type of certificate factory to create.
* @param provider The provider from which to get the implementation.
- * @return A CertificateFactory for the desired type.
- * @throws CertificateException If the type of certificate is not
- * implemented by the provider.
- * @throws IllegalArgumentException If the provider is null.
+ * @return A <code>CertificateFactory</code> for the desired type.
+ * @throws CertificateException If the type of certificate is not implemented
+ * by the provider.
+ * @throws IllegalArgumentException if either <code>type</code> or
+ * <code>provider</code> is <code>null</code>, or if
+ * <code>type</code> is an empty string.
*/
public static final CertificateFactory getInstance(String type,
Provider provider)
- throws CertificateException
+ throws CertificateException
{
- if (provider == null)
- throw new IllegalArgumentException("null provider");
-
+ Throwable cause;
try
{
- return new CertificateFactory((CertificateFactorySpi)
- Engine.getInstance(CERTIFICATE_FACTORY, type, provider),
- provider, type);
+ Object spi = Engine.getInstance(CERTIFICATE_FACTORY, type, provider);
+ return new CertificateFactory((CertificateFactorySpi) spi, provider, type);
}
- catch (ClassCastException cce)
+ catch (ClassCastException x)
{
- throw new CertificateException(type);
+ cause = x;
}
- catch (java.lang.reflect.InvocationTargetException ite)
+ catch (InvocationTargetException x)
{
- throw new CertificateException(type);
+ cause = x.getCause() != null ? x.getCause() : x;
}
- catch (NoSuchAlgorithmException nsae)
+ catch (NoSuchAlgorithmException x)
{
- throw new CertificateException(nsae.getMessage());
+ cause = x;
}
+ CertificateException x = new CertificateException(type);
+ x.initCause(cause);
+ throw x;
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
/**
* Gets the provider of this implementation.
*
@@ -249,7 +247,7 @@ public class CertificateFactory
* @throws CertificateException If an error occurs decoding the
* certificates.
*/
- public final Collection generateCertificates(InputStream inStream)
+ public final Collection<? extends Certificate> generateCertificates(InputStream inStream)
throws CertificateException
{
return certFacSpi.engineGenerateCertificates(inStream);
@@ -291,7 +289,7 @@ public class CertificateFactory
* InputStream data.
* @throws CRLException If an error occurs decoding the CRLs.
*/
- public final Collection generateCRLs(InputStream inStream)
+ public final Collection<? extends CRL> generateCRLs(InputStream inStream)
throws CRLException
{
return certFacSpi.engineGenerateCRLs( inStream );
@@ -338,7 +336,7 @@ public class CertificateFactory
* @throws CertificateException If an error occurs generating the
* CertPath.
*/
- public final CertPath generateCertPath(List certificates)
+ public final CertPath generateCertPath(List<? extends Certificate> certificates)
throws CertificateException
{
return certFacSpi.engineGenerateCertPath(certificates);
@@ -351,7 +349,7 @@ public class CertificateFactory
*
* @return The Iterator of supported encodings.
*/
- public final Iterator getCertPathEncodings()
+ public final Iterator<String> getCertPathEncodings()
{
return certFacSpi.engineGetCertPathEncodings();
}
diff --git a/libjava/classpath/java/security/cert/CertificateFactorySpi.java b/libjava/classpath/java/security/cert/CertificateFactorySpi.java
index beea9646a67..e6a22b4ebf8 100644
--- a/libjava/classpath/java/security/cert/CertificateFactorySpi.java
+++ b/libjava/classpath/java/security/cert/CertificateFactorySpi.java
@@ -54,7 +54,7 @@ import java.util.List;
Certificate factories are used to generate certificates and
certificate revocation lists (CRL) from their encoding.
- @since JDK 1.2
+ @since 1.2
@author Mark Benvenuto
*/
@@ -117,7 +117,7 @@ public abstract class CertificateFactorySpi
@throws CertificateException Certificate parsing error
*/
- public abstract Collection engineGenerateCertificates(InputStream inStream)
+ public abstract Collection<? extends Certificate> engineGenerateCertificates(InputStream inStream)
throws CertificateException;
/**
@@ -157,7 +157,7 @@ public abstract class CertificateFactorySpi
@throws CRLException CRL parsing error
*/
- public abstract Collection engineGenerateCRLs(InputStream inStream)
+ public abstract Collection<? extends CRL> engineGenerateCRLs(InputStream inStream)
throws CRLException;
// 1.4 instance methods.
@@ -204,7 +204,7 @@ public abstract class CertificateFactorySpi
* @throws CertificateException If an error occurs generating the
* CertPath.
*/
- public CertPath engineGenerateCertPath(List certificates)
+ public CertPath engineGenerateCertPath(List<? extends Certificate> certificates)
throws CertificateException
{
throw new UnsupportedOperationException("not implemented");
@@ -217,7 +217,7 @@ public abstract class CertificateFactorySpi
*
* @return The Iterator of supported encodings.
*/
- public Iterator engineGetCertPathEncodings()
+ public Iterator<String> engineGetCertPathEncodings()
{
throw new UnsupportedOperationException("not implemented");
}
diff --git a/libjava/classpath/java/security/cert/CollectionCertStoreParameters.java b/libjava/classpath/java/security/cert/CollectionCertStoreParameters.java
index bac1e3b3e4f..b3ee93235f8 100644
--- a/libjava/classpath/java/security/cert/CollectionCertStoreParameters.java
+++ b/libjava/classpath/java/security/cert/CollectionCertStoreParameters.java
@@ -51,6 +51,7 @@ import java.util.Collections;
* collection may be changed at any time.
*
* @see CertStore
+ * @since 1.4
*/
public class CollectionCertStoreParameters implements CertStoreParameters
{
@@ -81,7 +82,7 @@ public class CollectionCertStoreParameters implements CertStoreParameters
* @param collection The collection.
* @throws NullPointerException If <i>collection</i> is null.
*/
- public CollectionCertStoreParameters(Collection collection)
+ public CollectionCertStoreParameters(Collection<?> collection)
{
if (collection == null)
throw new NullPointerException();
@@ -103,7 +104,7 @@ public class CollectionCertStoreParameters implements CertStoreParameters
*
* @return The collection.
*/
- public Collection getCollection()
+ public Collection<?> getCollection()
{
return collection;
}
diff --git a/libjava/classpath/java/security/cert/PKIXBuilderParameters.java b/libjava/classpath/java/security/cert/PKIXBuilderParameters.java
index 38b3df5e78a..5e234cec158 100644
--- a/libjava/classpath/java/security/cert/PKIXBuilderParameters.java
+++ b/libjava/classpath/java/security/cert/PKIXBuilderParameters.java
@@ -48,6 +48,7 @@ import java.util.Set;
* Parameters for building certificate paths using the PKIX algorithm.
*
* @see CertPathBuilder
+ * @since 1.4
*/
public class PKIXBuilderParameters extends PKIXParameters
{
@@ -97,7 +98,8 @@ public class PKIXBuilderParameters extends PKIXParameters
* @throws ClassCastException If every element in <i>trustAnchors</i>
* is not a {@link TrustAnchor}.
*/
- public PKIXBuilderParameters(Set trustAnchors, CertSelector targetConstraints)
+ public PKIXBuilderParameters(Set<TrustAnchor> trustAnchors,
+ CertSelector targetConstraints)
throws InvalidAlgorithmParameterException
{
super(trustAnchors);
diff --git a/libjava/classpath/java/security/cert/PKIXCertPathChecker.java b/libjava/classpath/java/security/cert/PKIXCertPathChecker.java
index a6eef41a298..a69347fcd0b 100644
--- a/libjava/classpath/java/security/cert/PKIXCertPathChecker.java
+++ b/libjava/classpath/java/security/cert/PKIXCertPathChecker.java
@@ -59,6 +59,7 @@ import java.util.Set;
* the most-trusted certificate.
*
* @see PKIXParameters
+ * @since 1.4
*/
public abstract class PKIXCertPathChecker implements Cloneable
{
@@ -116,7 +117,7 @@ public abstract class PKIXCertPathChecker implements Cloneable
* @return An immutable set of Strings of the supported X.509 OIDs, or
* null if no extensions are supported.
*/
- public abstract Set getSupportedExtensions();
+ public abstract Set<String> getSupportedExtensions();
/**
* Checks a certificate, removing any critical extensions that are
@@ -128,6 +129,6 @@ public abstract class PKIXCertPathChecker implements Cloneable
* @throws CertPathValidatorException If this certificate fails this
* check.
*/
- public abstract void check(Certificate cert, Collection unresolvedCritExts)
+ public abstract void check(Certificate cert, Collection<String> unresolvedCritExts)
throws CertPathValidatorException;
}
diff --git a/libjava/classpath/java/security/cert/PKIXParameters.java b/libjava/classpath/java/security/cert/PKIXParameters.java
index 16ef07f8870..bb68cb93726 100644
--- a/libjava/classpath/java/security/cert/PKIXParameters.java
+++ b/libjava/classpath/java/security/cert/PKIXParameters.java
@@ -56,6 +56,7 @@ import java.util.Set;
* (Public-Key Infrastructure (X.509)) algorithm.
*
* @see CertPathBuilder
+ * @since 1.4
*/
public class PKIXParameters implements CertPathParameters
{
@@ -144,7 +145,7 @@ public class PKIXParameters implements CertPathParameters
* @throws ClassCastException If every element in <i>trustAnchors</i>
* is not a {@link TrustAnchor}.
*/
- public PKIXParameters(Set trustAnchors)
+ public PKIXParameters(Set<TrustAnchor> trustAnchors)
throws InvalidAlgorithmParameterException
{
this();
@@ -199,7 +200,7 @@ public class PKIXParameters implements CertPathParameters
*
* @return A (never null, never empty) immutable set of trust anchors.
*/
- public Set getTrustAnchors()
+ public Set<TrustAnchor> getTrustAnchors()
{
return Collections.unmodifiableSet(trustAnchors);
}
@@ -216,7 +217,7 @@ public class PKIXParameters implements CertPathParameters
* @throws ClassCastException If every element in <i>trustAnchors</i>
* is not a {@link TrustAnchor}.
*/
- public void setTrustAnchors(Set trustAnchors)
+ public void setTrustAnchors(Set<TrustAnchor> trustAnchors)
throws InvalidAlgorithmParameterException
{
if (trustAnchors.isEmpty())
@@ -235,7 +236,7 @@ public class PKIXParameters implements CertPathParameters
* @return An immutable set of initial policy OID strings, or the
* empty set if any policy is acceptable.
*/
- public Set getInitialPolicies()
+ public Set<String> getInitialPolicies()
{
return Collections.unmodifiableSet(initPolicies);
}
@@ -249,7 +250,7 @@ public class PKIXParameters implements CertPathParameters
* @throws ClassCastException If any element in <i>initPolicies</i> is
* not a string.
*/
- public void setInitialPolicies(Set initPolicies)
+ public void setInitialPolicies(Set<String> initPolicies)
{
this.initPolicies.clear();
if (initPolicies == null)
@@ -277,7 +278,7 @@ public class PKIXParameters implements CertPathParameters
*
* @return The list of cert stores.
*/
- public List getCertStores()
+ public List<CertStore> getCertStores()
{
return Collections.unmodifiableList(certStores);
}
@@ -288,7 +289,7 @@ public class PKIXParameters implements CertPathParameters
*
* @param certStores The cert stores.
*/
- public void setCertStores(List certStores)
+ public void setCertStores(List<CertStore> certStores)
{
this.certStores.clear();
if (certStores == null)
@@ -446,7 +447,7 @@ public class PKIXParameters implements CertPathParameters
*
* @return An immutable list of all certificate path checkers.
*/
- public List getCertPathCheckers()
+ public List<PKIXCertPathChecker> getCertPathCheckers()
{
return Collections.unmodifiableList(pathCheckers);
}
@@ -459,7 +460,7 @@ public class PKIXParameters implements CertPathParameters
* @throws ClassCastException If any element of <i>pathCheckers</i> is
* not a {@link PKIXCertPathChecker}.
*/
- public void setCertPathCheckers(List pathCheckers)
+ public void setCertPathCheckers(List<PKIXCertPathChecker> pathCheckers)
{
this.pathCheckers.clear();
if (pathCheckers == null)
diff --git a/libjava/classpath/java/security/cert/PolicyNode.java b/libjava/classpath/java/security/cert/PolicyNode.java
index 58d411cd3ad..b1196037e87 100644
--- a/libjava/classpath/java/security/cert/PolicyNode.java
+++ b/libjava/classpath/java/security/cert/PolicyNode.java
@@ -38,6 +38,12 @@ exception statement from your version. */
package java.security.cert;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * @since 1.4
+ */
public interface PolicyNode
{
@@ -47,7 +53,7 @@ public interface PolicyNode
*
* @return An iterator over the child nodes.
*/
- java.util.Iterator getChildren();
+ Iterator<? extends PolicyNode> getChildren();
/**
* Get the depth of this node within the tree, starting at 0 for the
@@ -64,7 +70,7 @@ public interface PolicyNode
*
* @return The set of expected policies.
*/
- java.util.Set getExpectedPolicies();
+ Set<String> getExpectedPolicies();
/**
* Returns the parent node of this node, or null if this is the root
@@ -81,7 +87,7 @@ public interface PolicyNode
*
* @return The set of {@link PolicyQualifierInfo} objects.
*/
- java.util.Set getPolicyQualifiers();
+ Set<? extends PolicyQualifierInfo> getPolicyQualifiers();
/**
* Get the policy OID this node represents. The root node should return
diff --git a/libjava/classpath/java/security/cert/PolicyQualifierInfo.java b/libjava/classpath/java/security/cert/PolicyQualifierInfo.java
index 7dcf2315632..b50f3f31245 100644
--- a/libjava/classpath/java/security/cert/PolicyQualifierInfo.java
+++ b/libjava/classpath/java/security/cert/PolicyQualifierInfo.java
@@ -59,9 +59,10 @@ import java.io.IOException;
* PolicyQualifierId ::= OBJECT IDENTIFIER
* </pre>
*
- * @since JDK 1.4
+ * @since 1.4
+ * @specnote this class was final in 1.4, but beginning with 1.5 is not
*/
-public final class PolicyQualifierInfo
+public class PolicyQualifierInfo
{
// Fields.
diff --git a/libjava/classpath/java/security/cert/X509CRL.java b/libjava/classpath/java/security/cert/X509CRL.java
index 5657b3eb3f5..a00706e678f 100644
--- a/libjava/classpath/java/security/cert/X509CRL.java
+++ b/libjava/classpath/java/security/cert/X509CRL.java
@@ -97,7 +97,7 @@ import javax.security.auth.x500.X500Principal;
@author Mark Benvenuto
- @since JDK 1.2
+ @since 1.2
*/
public abstract class X509CRL extends CRL implements X509Extension
{
@@ -304,7 +304,7 @@ public abstract class X509CRL extends CRL implements X509Extension
@return a set of revoked certificates.
*/
- public abstract Set getRevokedCertificates();
+ public abstract Set<? extends X509CRLEntry> getRevokedCertificates();
/**
Returns the DER ASN.1 encoded tbsCertList which is
diff --git a/libjava/classpath/java/security/cert/X509CRLSelector.java b/libjava/classpath/java/security/cert/X509CRLSelector.java
index 3c79fba9cb8..56b171369fb 100644
--- a/libjava/classpath/java/security/cert/X509CRLSelector.java
+++ b/libjava/classpath/java/security/cert/X509CRLSelector.java
@@ -69,6 +69,7 @@ import javax.security.auth.x500.X500Principal;
* use or modify this class then they need to synchronize on the object.
*
* @author Casey Marshall (csm@gnu.org)
+ * @since 1.4
*/
public class X509CRLSelector implements CRLSelector, Cloneable
{
@@ -157,7 +158,7 @@ public class X509CRLSelector implements CRLSelector, Cloneable
* @throws IOException If any of the elements in the collection is not
* a valid name.
*/
- public void setIssuerNames(Collection names) throws IOException
+ public void setIssuerNames(Collection<?> names) throws IOException
{
if (names == null)
{
@@ -224,7 +225,7 @@ public class X509CRLSelector implements CRLSelector, Cloneable
*
* @return The set of issuer names.
*/
- public Collection getIssuerNames()
+ public Collection<Object> getIssuerNames()
{
if (issuerNames != null)
return Collections.unmodifiableList(issuerNames);
diff --git a/libjava/classpath/java/security/cert/X509CertSelector.java b/libjava/classpath/java/security/cert/X509CertSelector.java
index 175e4c673c9..154ed2e4d98 100644
--- a/libjava/classpath/java/security/cert/X509CertSelector.java
+++ b/libjava/classpath/java/security/cert/X509CertSelector.java
@@ -76,6 +76,7 @@ import javax.security.auth.x500.X500Principal;
* use or modify this class then they need to synchronize on the object.
*
* @author Casey Marshall (csm@gnu.org)
+ * @since 1.4
*/
public class X509CertSelector implements CertSelector, Cloneable
{
@@ -573,7 +574,7 @@ public class X509CertSelector implements CertSelector, Cloneable
*
* @return The set of key purpose OIDs (strings).
*/
- public Set getExtendedKeyUsage()
+ public Set<String> getExtendedKeyUsage()
{
if (keyPurposeSet != null)
return Collections.unmodifiableSet(keyPurposeSet);
@@ -588,7 +589,7 @@ public class X509CertSelector implements CertSelector, Cloneable
* @param keyPurposeSet The set of key purpose OIDs.
* @throws IOException If any element of the set is not a valid OID string.
*/
- public void setExtendedKeyUsage(Set keyPurposeSet) throws IOException
+ public void setExtendedKeyUsage(Set<String> keyPurposeSet) throws IOException
{
if (keyPurposeSet == null)
{
@@ -653,7 +654,7 @@ public class X509CertSelector implements CertSelector, Cloneable
* @param altNames The alternative names.
* @throws IOException If any element of the argument is invalid.
*/
- public void setSubjectAlternativeNames(Collection altNames)
+ public void setSubjectAlternativeNames(Collection<List<?>> altNames)
throws IOException
{
if (altNames == null)
@@ -786,7 +787,7 @@ public class X509CertSelector implements CertSelector, Cloneable
// certificate, and check it against the specified set.
// FIXME
-// public void setPolicy(Set policy) throws IOException
+// public void setPolicy(Set<String> policy) throws IOException
// {
// if (policy != null)
// {
@@ -807,7 +808,7 @@ public class X509CertSelector implements CertSelector, Cloneable
// }
// FIXME
-// public void setPathToNames(Collection names) throws IOException
+// public void setPathToNames(Collection<List<?>> names) throws IOException
// {
// if (names == null)
// {
@@ -843,19 +844,19 @@ public class X509CertSelector implements CertSelector, Cloneable
// }
// FIXME
-// public Collection getSubjectAlternativeNames()
+// public Collection<List<?>> getSubjectAlternativeNames()
// {
// return null;
// }
// FIXME
-// public Set getPolicy()
+// public Set<String> getPolicy()
// {
// return null;
// }
// FIXME
-// public Collection getPathToNames()
+// public Collection<List<?>> getPathToNames()
// {
// return null;
// }
diff --git a/libjava/classpath/java/security/cert/X509Certificate.java b/libjava/classpath/java/security/cert/X509Certificate.java
index f6c6fcfb9a4..bc1b5c2351c 100644
--- a/libjava/classpath/java/security/cert/X509Certificate.java
+++ b/libjava/classpath/java/security/cert/X509Certificate.java
@@ -41,6 +41,7 @@ package java.security.cert;
import java.math.BigInteger;
import java.security.Principal;
import java.util.Date;
+import java.util.List;
/**
* X509Certificate is the abstract class for X.509 certificates.
@@ -131,7 +132,7 @@ import java.util.Date;
* Profile</a></i>.</li>
* </ol>
*
- * @since JDK 1.2
+ * @since 1.2
* @author Mark Benvenuto
* @author Casey Marshall (rsdio@metastatic.org)
*/
@@ -487,7 +488,7 @@ public abstract class X509Certificate
* @throws CertificateParsingException If this extension cannot be
* parsed from its encoded form.
*/
- public java.util.List getExtendedKeyUsage()
+ public java.util.List<String> getExtendedKeyUsage()
throws CertificateParsingException
{
throw new UnsupportedOperationException();
@@ -531,7 +532,7 @@ public abstract class X509Certificate
* be parsed.
* @since JDK 1.4
*/
- public java.util.Collection getSubjectAlternativeNames()
+ public java.util.Collection<List<?>> getSubjectAlternativeNames()
throws CertificateParsingException
{
throw new UnsupportedOperationException();
@@ -558,7 +559,7 @@ public abstract class X509Certificate
* be parsed.
* @since JDK 1.4
*/
- public java.util.Collection getIssuerAlternativeNames()
+ public java.util.Collection<List<?>> getIssuerAlternativeNames()
throws CertificateParsingException
{
throw new UnsupportedOperationException();
diff --git a/libjava/classpath/java/security/cert/X509Extension.java b/libjava/classpath/java/security/cert/X509Extension.java
index d2cb80a9f57..bd9473782e4 100644
--- a/libjava/classpath/java/security/cert/X509Extension.java
+++ b/libjava/classpath/java/security/cert/X509Extension.java
@@ -70,7 +70,7 @@ import java.util.Set;
@author Mark Benvenuto
- @since JDK 1.2
+ @since 1.2
*/
public interface X509Extension
{
@@ -91,7 +91,7 @@ public interface X509Extension
@return A Set containing the OIDs. If there are no CRITICAL
extensions or extensions at all this returns null.
*/
- Set getCriticalExtensionOIDs();
+ Set<String> getCriticalExtensionOIDs();
/**
Returns a set of the NON-CRITICAL extension OIDs from the
@@ -101,7 +101,7 @@ public interface X509Extension
@return A Set containing the OIDs. If there are no NON-CRITICAL
extensions or extensions at all this returns null.
*/
- Set getNonCriticalExtensionOIDs();
+ Set<String> getNonCriticalExtensionOIDs();
/**
Returns the DER encoded OCTET string for the specified
OpenPOWER on IntegriCloud