You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2006/04/26 09:54:24 UTC
svn commit: r397136 [3/3] - in
/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security:
./ cert/
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateFactory.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateFactory.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateFactory.java Wed Apr 26 00:54:18 2006
@@ -1,218 +1,312 @@
-/*
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
-* @author Vera Y. Petrashkova
-* @version $Revision$
-*/
-
-package java.security.cert;
-
-import java.io.InputStream;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.harmony.security.fortress.Engine;
-
-
-/**
- * @com.intel.drl.spec_ref
- *
- */
-
-public class CertificateFactory {
-
- // Store CertificateFactory service name
- private static final String SERVICE = "CertificateFactory";
-
- // Used to access common engine functionality
- private static Engine engine = new Engine(SERVICE);
-
- // Store used provider
- private final Provider provider;
-
- // Store used CertificateFactorySpi implementation
- private final CertificateFactorySpi spiImpl;
-
- // Store used type
- private final String type;
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- protected CertificateFactory(CertificateFactorySpi certFacSpi,
- Provider provider, String type) {
- this.provider = provider;
- this.type = type;
- this.spiImpl = certFacSpi;
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- * throws CertificateException using NoSuchAlgorithmException information
- *
- * throws NullPointerException if algorithm is null (instead of
- * CertificateException as in 1.4 release)
- */
- public static final CertificateFactory getInstance(String type)
- throws CertificateException {
- if (type == null) {
- throw new NullPointerException("type is null");
- }
- try {
- synchronized (engine) {
- engine.getInstance(type, null);
- return new CertificateFactory((CertificateFactorySpi) engine.spi,
- engine.provider, type);
- }
- } catch (NoSuchAlgorithmException e) {
- throw new CertificateException(e);
- }
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- * throws NullPointerException if algorithm is null (instead of
- * CertificateException as in 1.4 release)
- */
- public static final CertificateFactory getInstance(String type,
- String provider) throws CertificateException,
- NoSuchProviderException {
- if ((provider == null) || (provider.length() == 0)) {
- throw new IllegalArgumentException("Provider is null or empty");
- }
- Provider impProvider = Security.getProvider(provider);
- if (impProvider == null) {
- throw new NoSuchProviderException(provider);
- }
- return getInstance(type, impProvider);
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- * throws CertificateException using NoSuchAlgorithmException information
- *
- * throws NullPointerException if algorithm is null (instead of
- * CertificateException as in 1.4 release)
- */
- public static final CertificateFactory getInstance(String type,
- Provider provider) throws CertificateException {
- if (provider == null) {
- throw new IllegalArgumentException("Provider is null");
- }
- if (type == null) {
- throw new NullPointerException("type is null");
- }
- try {
- synchronized (engine) {
- engine.getInstance(type, provider, null);
- return new CertificateFactory((CertificateFactorySpi) engine.spi,
- provider, type);
- }
- } catch (NoSuchAlgorithmException e) {
- throw new CertificateException(e.getMessage());
- }
- }
-
- /**
- * @com.intel.drl.spec_ref
- */
- public final Provider getProvider() {
- return provider;
- }
-
- /**
- * @com.intel.drl.spec_ref
- */
- public final String getType() {
- return type;
- }
-
- /**
- * @com.intel.drl.spec_ref
- */
- public final Certificate generateCertificate(InputStream inStream)
- throws CertificateException {
- return spiImpl.engineGenerateCertificate(inStream);
- }
-
- /**
- * @com.intel.drl.spec_ref
- */
- public final Iterator<String> getCertPathEncodings() {
- return spiImpl.engineGetCertPathEncodings();
- }
-
- /**
- * @com.intel.drl.spec_ref
- */
- public final CertPath generateCertPath(InputStream inStream)
- throws CertificateException {
- Iterator it = getCertPathEncodings();
- if (!it.hasNext()) {
- throw new CertificateException("There are no CertPath encodings");
- }
- return spiImpl.engineGenerateCertPath(inStream, (String) it.next());
- }
-
- /**
- * @com.intel.drl.spec_ref
- */
- public final CertPath generateCertPath(InputStream inStream, String encoding)
- throws CertificateException {
- return spiImpl.engineGenerateCertPath(inStream, encoding);
- }
-
- /**
- * @com.intel.drl.spec_ref
- */
- public final CertPath generateCertPath(List<? extends Certificate> certificates)
- throws CertificateException {
- return spiImpl.engineGenerateCertPath(certificates);
- }
-
- /**
- * @com.intel.drl.spec_ref
- */
- public final Collection<? extends Certificate> generateCertificates(InputStream inStream)
- throws CertificateException {
- return spiImpl.engineGenerateCertificates(inStream);
- }
-
- /**
- * @com.intel.drl.spec_ref
- */
- public final CRL generateCRL(InputStream inStream) throws CRLException {
- return spiImpl.engineGenerateCRL(inStream);
- }
-
- /**
- * @com.intel.drl.spec_ref
- */
- public final Collection<? extends CRL> generateCRLs(InputStream inStream)
- throws CRLException {
- return spiImpl.engineGenerateCRLs(inStream);
- }
-}
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+* @author Vera Y. Petrashkova
+* @version $Revision$
+*/
+
+package java.security.cert;
+
+import java.io.InputStream;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.Security;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.harmony.security.fortress.Engine;
+
+
+/**
+ * This class provides the functionality of a certificate factory algorithm.
+ */
+
+public class CertificateFactory {
+
+ // Store CertificateFactory service name
+ private static final String SERVICE = "CertificateFactory";
+
+ // Used to access common engine functionality
+ private static Engine engine = new Engine(SERVICE);
+
+ // Store used provider
+ private final Provider provider;
+
+ // Store used CertificateFactorySpi implementation
+ private final CertificateFactorySpi spiImpl;
+
+ // Store used type
+ private final String type;
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ protected CertificateFactory(CertificateFactorySpi certFacSpi,
+ Provider provider, String type) {
+ this.provider = provider;
+ this.type = type;
+ this.spiImpl = certFacSpi;
+ }
+
+ /**
+ * Answers a new CertificateFactory of the given type.
+ *
+ * @param type
+ * java.lang.String Type of certificate desired
+ * @return CertificateFactory a concrete implementation for the certificate
+ * type desired.
+ *
+ * @exception CertificateException
+ * If the type cannot be found
+ *
+ * @exception NullPointerException
+ * If the type is null
+ */
+ public static final CertificateFactory getInstance(String type)
+ throws CertificateException {
+ if (type == null) {
+ throw new NullPointerException("type is null");
+ }
+ try {
+ synchronized (engine) {
+ engine.getInstance(type, null);
+ return new CertificateFactory((CertificateFactorySpi) engine.spi,
+ engine.provider, type);
+ }
+ } catch (NoSuchAlgorithmException e) {
+ throw new CertificateException(e);
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ * throws NullPointerException if algorithm is null (instead of
+ * CertificateException as in 1.4 release)
+ */
+ public static final CertificateFactory getInstance(String type,
+ String provider) throws CertificateException,
+ NoSuchProviderException {
+ if ((provider == null) || (provider.length() == 0)) {
+ throw new IllegalArgumentException("Provider is null or empty");
+ }
+ Provider impProvider = Security.getProvider(provider);
+ if (impProvider == null) {
+ throw new NoSuchProviderException(provider);
+ }
+ return getInstance(type, impProvider);
+ }
+
+ /**
+ * Answers a new CertificateFactory of the given type.
+ *
+ * @param type
+ * java.lang.String Type of certificatem desired
+ * @param provider
+ * java.security.Provider Provider which has to implement the
+ * algorithm
+ * @return CertificateFactory a concrete implementation for the certificate
+ * type desired.
+ *
+ * @exception CertificateException
+ * If the type cannot be found
+ *
+ * @exception NullPointerException
+ * If algorithm is null
+ */
+ public static final CertificateFactory getInstance(String type,
+ Provider provider) throws CertificateException {
+ if (provider == null) {
+ throw new IllegalArgumentException("Provider is null");
+ }
+ if (type == null) {
+ throw new NullPointerException("type is null");
+ }
+ try {
+ synchronized (engine) {
+ engine.getInstance(type, provider, null);
+ return new CertificateFactory((CertificateFactorySpi) engine.spi,
+ provider, type);
+ }
+ } catch (NoSuchAlgorithmException e) {
+ throw new CertificateException(e.getMessage());
+ }
+ }
+
+ /**
+ * Returns the Provider of the certificate factory represented by the
+ * receiver.
+ *
+ * @return Provider an instance of a subclass of java.security.Provider
+ */
+ public final Provider getProvider() {
+ return provider;
+ }
+
+ /**
+ * Returns the Certificate type
+ *
+ * @return String type of certificate being used
+ */
+ public final String getType() {
+ return type;
+ }
+
+ /**
+ * Generates and initializes a Certificate from data from the
+ * provided input stream.
+ *
+ * @param inStream
+ * InputStream Stream from where data is read to create the
+ * Certificate
+ *
+ * @return Certificate an initialized Certificate
+ * @exception CertificateException
+ * if parsing problems are detected
+ */
+ public final Certificate generateCertificate(InputStream inStream)
+ throws CertificateException {
+ return spiImpl.engineGenerateCertificate(inStream);
+ }
+
+ /**
+ * Returns an Iterator over the supported CertPath encodings (as Strings).
+ * The first element is the default encoding.
+ *
+ * @return Iterator Iterator over supported CertPath encodings (as Strings)
+ */
+ public final Iterator<String> getCertPathEncodings() {
+ return spiImpl.engineGetCertPathEncodings();
+ }
+
+ /**
+ * Generates a <code>CertPath</code> from data from the provided
+ * <code>InputStream</code>. The default encoding is assumed.
+ *
+ * @param inStream
+ * InputStream with PKCS7 or PkiPath encoded data
+ *
+ * @return CertPath a CertPath initialized from the provided data
+ *
+ * @throws CertificateException
+ * if parsing problems are detected
+ */
+ public final CertPath generateCertPath(InputStream inStream)
+ throws CertificateException {
+ Iterator it = getCertPathEncodings();
+ if (!it.hasNext()) {
+ throw new CertificateException("There are no CertPath encodings");
+ }
+ return spiImpl.engineGenerateCertPath(inStream, (String) it.next());
+ }
+
+ /**
+ * Generates a <code>CertPath</code> from data from the provided
+ * <code>InputStream</code>. The encoding is that specified by the
+ * encoding parameter.
+ *
+ * @param inStream
+ * InputStream containing certificate path data in specified
+ * encoding
+ * @param encoding
+ * encoding of the data in the input stream
+ *
+ * @return CertPath a CertPath initialized from the provided data
+ *
+ * @throws CertificateException
+ * if parsing problems are detected
+ * @throws UnsupportedOperationException
+ * if the provider does not implement this method
+ */
+ public final CertPath generateCertPath(InputStream inStream, String encoding)
+ throws CertificateException {
+ return spiImpl.engineGenerateCertPath(inStream, encoding);
+ }
+
+ /**
+ * Generates a <code>CertPath</code> from the provided List of
+ * Certificates. The encoding is the default encoding.
+ *
+ * @param certificates
+ * List containing certificates in a format supported by the
+ * CertificateFactory
+ *
+ * @return CertPath a CertPath initialized from the provided data
+ *
+ * @throws CertificateException
+ * if parsing problems are detected
+ * @throws UnsupportedOperationException
+ * if the provider does not implement this method
+ */
+ public final CertPath generateCertPath(List<? extends Certificate> certificates)
+ throws CertificateException {
+ return spiImpl.engineGenerateCertPath(certificates);
+ }
+
+ /**
+ * Generates and initializes a collection of Certificates from
+ * data from the provided input stream.
+ *
+ * @param inStream
+ * InputStream Stream from where data is read to create the
+ * Certificates
+ *
+ * @return Collection an initialized collection of Certificates
+ * @exception CertificateException
+ * if parsing problems are detected
+ */
+ public final Collection<? extends Certificate> generateCertificates(InputStream inStream)
+ throws CertificateException {
+ return spiImpl.engineGenerateCertificates(inStream);
+ }
+
+ /**
+ * Generates and initializes a Certificate Revocation List from data from
+ * the provided input stream.
+ *
+ * @param inStream
+ * InputStream Stream from where data is read to create the CRL
+ *
+ * @return CRL an initialized Certificate Revocation List
+ * @exception CRLException
+ * if parsing problems are detected
+ */
+ public final CRL generateCRL(InputStream inStream) throws CRLException {
+ return spiImpl.engineGenerateCRL(inStream);
+ }
+
+ /**
+ * Generates and initializes a collection of Certificate Revocation List
+ * from data from the provided input stream.
+ *
+ * @param inStream
+ * InputStream Stream from where data is read to create the CRLs
+ *
+ * @return Collection an initialized collection of Certificate Revocation
+ * List
+ * @exception CRLException
+ * if parsing problems are detected
+ *
+ */
+ public final Collection<? extends CRL> generateCRLs(InputStream inStream)
+ throws CRLException {
+ return spiImpl.engineGenerateCRLs(inStream);
+ }
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateFactorySpi.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateFactorySpi.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateFactorySpi.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateFactorySpi.java Wed Apr 26 00:54:18 2006
@@ -27,44 +27,88 @@
import java.util.List;
/**
- * @com.intel.drl.spec_ref
- *
+ * This class is a Service Provider Interface (therefore the Spi suffix) for
+ * certificate factories to be supplied by providers.
*/
public abstract class CertificateFactorySpi {
/**
- * @com.intel.drl.spec_ref
+ * Constructs a new instance of this class.
*/
public CertificateFactorySpi() {
}
/**
- * @com.intel.drl.spec_ref
+ * Generates and initializes a Certificate from data from the
+ * provided input stream.
+ *
+ * @param inStream
+ * InputStream Stream from where data is read to create the
+ * Certificate
+ *
+ * @return Certificate an initialized Certificate
+ * @exception CertificateException
+ * if parsing problems are detected
*/
public abstract Certificate engineGenerateCertificate(InputStream inStream)
throws CertificateException;
/**
- * @com.intel.drl.spec_ref
+ * Generates and initializes a collection of Certificates from
+ * data from the provided input stream.
+ *
+ * @param inStream
+ * InputStream Stream from where data is read to create the
+ * Certificates
+ *
+ * @return Collection an initialized collection of Certificates
+ * @exception CertificateException
+ * if parsing problems are detected
*/
public abstract Collection<? extends Certificate>
engineGenerateCertificates(InputStream inStream) throws CertificateException;
/**
- * @com.intel.drl.spec_ref
+ * Generates and initializes a Certificate Revocation List from data from
+ * the provided input stream.
+ *
+ * @param inStream
+ * InputStream Stream from where data is read to create the CRL
+ *
+ * @return CRL an initialized Certificate Revocation List
+ * @exception CRLException
+ * if parsing problems are detected
*/
public abstract CRL engineGenerateCRL(InputStream inStream)
throws CRLException;
/**
- * @com.intel.drl.spec_ref
+ * Generates and initializes a collection of Certificate Revocation List
+ * from data from the provided input stream.
+ *
+ * @param inStream
+ * InputStream Stream from where data is read to create the CRLs
+ *
+ * @return Collection an initialized collection of Certificate Revocation
+ * List
+ * @exception CRLException
+ * if parsing problems are detected
*/
public abstract Collection<? extends CRL>
engineGenerateCRLs(InputStream inStream) throws CRLException;
/**
- * @com.intel.drl.spec_ref
+ * Generates a <code>CertPath</code> from data from the provided
+ * <code>InputStream</code>. The default encoding is assumed.
+ *
+ * @param inStream
+ * InputStream with PKCS7 or PkiPath encoded data
+ *
+ * @return CertPath a CertPath initialized from the provided data
+ *
+ * @throws CertificateException
+ * if parsing problems are detected
*/
public CertPath engineGenerateCertPath(InputStream inStream)
throws CertificateException {
@@ -73,7 +117,22 @@
}
/**
- * @com.intel.drl.spec_ref
+ * Generates a <code>CertPath</code> from data from the provided
+ * <code>InputStream</code>. The encoding is that specified by the
+ * encoding parameter.
+ *
+ * @param inStream
+ * InputStream containing certificate path data in specified
+ * encoding
+ * @param encoding
+ * encoding of the data in the input stream
+ *
+ * @return CertPath a CertPath initialized from the provided data
+ *
+ * @throws CertificateException
+ * if parsing problems are detected
+ * @throws UnsupportedOperationException
+ * if the provider does not implement this method
*/
public CertPath engineGenerateCertPath(InputStream inStream, String encoding)
throws CertificateException {
@@ -82,7 +141,19 @@
}
/**
- * @com.intel.drl.spec_ref
+ * Generates a <code>CertPath</code> from the provided List of
+ * Certificates. The encoding is the default encoding.
+ *
+ * @param certificates
+ * List containing certificates in a format supported by the
+ * CertificateFactory
+ *
+ * @return CertPath a CertPath initialized from the provided data
+ *
+ * @throws CertificateException
+ * if parsing problems are detected
+ * @throws UnsupportedOperationException
+ * if the provider does not implement this method
*/
public CertPath engineGenerateCertPath(List<? extends Certificate> certificates)
throws CertificateException {
@@ -91,7 +162,10 @@
}
/**
- * @com.intel.drl.spec_ref
+ * Returns an Iterator over the supported CertPath encodings (as Strings).
+ * The first element is the default encoding.
+ *
+ * @return Iterator Iterator over supported CertPath encodings (as Strings)
*/
public Iterator<String> engineGetCertPathEncodings() {
throw new UnsupportedOperationException(
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateNotYetValidException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateNotYetValidException.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateNotYetValidException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateNotYetValidException.java Wed Apr 26 00:54:18 2006
@@ -22,8 +22,7 @@
package java.security.cert;
/**
- * @com.intel.drl.spec_ref
- *
+ * This class indicates that a given certificate is not valid yet.
*/
public class CertificateNotYetValidException extends CertificateException {
/**
@@ -31,16 +30,20 @@
*/
private static final long serialVersionUID = 4355919900041064702L;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ * @param msg
+ * String The detail message for the exception.
+ */
public CertificateNotYetValidException(String msg) {
super(msg);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ */
public CertificateNotYetValidException() {
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateParsingException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateParsingException.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateParsingException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateParsingException.java Wed Apr 26 00:54:18 2006
@@ -22,8 +22,7 @@
package java.security.cert;
/**
- * @com.intel.drl.spec_ref
- *
+ * This class indicates that a given certificate could not be parsed.
*/
public class CertificateParsingException extends CertificateException {
@@ -32,16 +31,20 @@
*/
private static final long serialVersionUID = -7989222416793322029L;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ * @param msg
+ * String The detail message for the exception.
+ */
public CertificateParsingException(String msg) {
super(msg);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ */
public CertificateParsingException() {
}
@@ -58,4 +61,4 @@
public CertificateParsingException(Throwable cause) {
super(cause);
}
-}
\ No newline at end of file
+}