FileDocCategorySizeDatePackage
CertificateFactory.javaAPI DocAndroid 1.5 API12343Wed May 06 22:41:06 BST 2009java.security.cert

CertificateFactory

public class CertificateFactory extends Object
This class implements the functionality of a certificate factory algorithm, relying on parsing a stream of bytes.

It defines methods for parsing certificate chains (certificate paths) and Certificate Revocation Lists (CRLs).

since
Android 1.0

Fields Summary
private static final String
SERVICE
private static org.apache.harmony.security.fortress.Engine
engine
private final Provider
provider
private final CertificateFactorySpi
spiImpl
private final String
type
Constructors Summary
protected CertificateFactory(CertificateFactorySpi certFacSpi, Provider provider, String type)
Creates a new {@code CertificateFactory} instance.

param
certFacSpi the implementation delegate.
param
provider the associated provider.
param
type the certificate type.
since
Android 1.0


                                                                   
      
                
        this.provider = provider;
        this.type = type;
        this.spiImpl = certFacSpi;
    
Methods Summary
public final java.security.cert.CRLgenerateCRL(java.io.InputStream inStream)
Generates and initializes a Certificate Revocation List (CRL) from the provided input stream.

param
inStream the stream from where data is read to create the CRL.
return
an initialized CRL.
exception
CRLException if parsing problems are detected.
since
Android 1.0

        return spiImpl.engineGenerateCRL(inStream);
    
public final java.util.CollectiongenerateCRLs(java.io.InputStream inStream)
Generates and initializes a collection of Certificate Revocation List (CRL) from the provided input stream.

param
inStream the stream from which the data is read to create the CRLs.
return
an initialized collection of CRLs.
exception
CRLException if parsing problems are detected.
since
Android 1.0

        return spiImpl.engineGenerateCRLs(inStream);
    
public final java.security.cert.CertPathgenerateCertPath(java.io.InputStream inStream, java.lang.String encoding)
Generates a {@code CertPath} (a certificate chain) from the provided {@code InputStream} and the specified encoding scheme.

param
inStream {@code InputStream} containing certificate path data in specified encoding.
param
encoding encoding of the data in the input stream.
return
a {@code CertPath} initialized from the provided data.
throws
CertificateException if parsing problems are detected.
throws
UnsupportedOperationException if the provider does not implement this method.
since
Android 1.0

        return spiImpl.engineGenerateCertPath(inStream, encoding);
    
public final java.security.cert.CertPathgenerateCertPath(java.util.List certificates)
Generates a {@code CertPath} from the provided list of certificates. The encoding is the default encoding.

param
certificates the list containing certificates in a format supported by the {@code CertificateFactory}.
return
a {@code CertPath} initialized from the provided data.
throws
CertificateException if parsing problems are detected.
throws
UnsupportedOperationException if the provider does not implement this method.
since
Android 1.0

        return spiImpl.engineGenerateCertPath(certificates);
    
public final java.security.cert.CertPathgenerateCertPath(java.io.InputStream inStream)
Generates a {@code CertPath} (a certificate chain) from the provided {@code InputStream}. The default encoding scheme is applied.

param
inStream {@code InputStream} with encoded data.
return
a {@code CertPath} initialized from the provided data.
throws
CertificateException if parsing problems are detected.
since
Android 1.0

        Iterator<String> it = getCertPathEncodings();
        if (!it.hasNext()) {
            throw new CertificateException(Messages.getString("security.74")); //$NON-NLS-1$
        }
        return spiImpl.engineGenerateCertPath(inStream, it.next());
    
public final java.security.cert.CertificategenerateCertificate(java.io.InputStream inStream)
Generates and initializes a {@code Certificate} from the provided input stream.

param
inStream the stream from where data is read to create the {@code Certificate}.
return
an initialized Certificate.
throws
CertificateException if parsing problems are detected.
since
Android 1.0

        return spiImpl.engineGenerateCertificate(inStream);
    
public final java.util.CollectiongenerateCertificates(java.io.InputStream inStream)
Generates and initializes a collection of (unrelated) certificates from the provided input stream.

param
inStream the stream from which the data is read to create the collection.
return
an initialized collection of certificates.
throws
CertificateException if parsing problems are detected.
since
Android 1.0

        return spiImpl.engineGenerateCertificates(inStream);
    
public final java.util.IteratorgetCertPathEncodings()
Returns an {@code Iterator} over the supported {@code CertPath} encodings (as Strings). The first element is the default encoding scheme to apply.

return
an iterator over supported {@link CertPath} encodings (as Strings).
since
Android 1.0

        return spiImpl.engineGetCertPathEncodings();
    
public static final java.security.cert.CertificateFactorygetInstance(java.lang.String type)
Creates a new {@code CertificateFactory} instance that provides the requested certificate type.

param
type the certificate type.
return
the new {@code CertificateFactory} instance.
throws
CertificateException if the specified certificate type is not available at any installed provider.
throws
NullPointerException if {@code type} is {@code null}.
since
Android 1.0

        if (type == null) {
            throw new NullPointerException(Messages.getString("security.07")); //$NON-NLS-1$
        }
        try {
            synchronized (engine) {
                engine.getInstance(type, null);
                return new CertificateFactory((CertificateFactorySpi) engine.spi,
                        engine.provider, type);
            }
        } catch (NoSuchAlgorithmException e) {
            throw new CertificateException(e);
        }
    
public static final java.security.cert.CertificateFactorygetInstance(java.lang.String type, java.lang.String provider)
Creates a new {@code CertificateFactory} instance from the specified provider that provides the requested certificate type.

param
type the certificate type.
param
provider the name of the provider providing certificates of the specified type.
return
the new {@code CertificateFactory} instance.
throws
CertificateException if the specified certificate type is not available by the specified provider.
throws
NoSuchProviderException if no provider with the specified name can be found.
throws
IllegalArgumentException if the specified provider name is {@code null} or empty.
throws
NullPointerException it {@code type} is {@code null}.
since
Android 1.0

        if ((provider == null) || (provider.length() == 0)) {
            throw new IllegalArgumentException(Messages.getString("security.02")); //$NON-NLS-1$
        }
        Provider impProvider = Security.getProvider(provider);
        if (impProvider == null) {
            throw new NoSuchProviderException(provider);
        }
        return getInstance(type, impProvider);
    
public static final java.security.cert.CertificateFactorygetInstance(java.lang.String type, java.security.Provider provider)
Creates a new {@code CertificateFactory} instance from the specified provider that provides the requested certificate type.

param
type the certificate type.
param
provider the name of the provider providing certificates of the specified type.
return
the new {@code CertificateFactory} instance.
throws
CertificateException if the specified certificate type is not available at the specified provider.
throws
IllegalArgumentException if the specified provider is {@code null}.
throws
NullPointerException is {@code type} is {@code null}.
since
Android 1.0

        if (provider == null) {
            throw new IllegalArgumentException(Messages.getString("security.04")); //$NON-NLS-1$
        }
        if (type == null) {
            throw new NullPointerException(Messages.getString("security.07")); //$NON-NLS-1$
        }
        try {
            synchronized (engine) {
                engine.getInstance(type, provider, null);
                return new CertificateFactory((CertificateFactorySpi) engine.spi,
                        provider, type);
            }
        } catch (NoSuchAlgorithmException e) {
            throw new CertificateException(e.getMessage());
        }
    
public final java.security.ProvidergetProvider()
Returns the {@code Provider} of the certificate factory represented by the certificate.

return
the provider of this certificate factory.
since
Android 1.0

        return provider;
    
public final java.lang.StringgetType()
Returns the Certificate type.

return
type of certificate being used.
since
Android 1.0

        return type;