Exemplo n.º 1
0
 /**
  * Generates an X.509 certificate object and initializes it with the data read from the input
  * stream <code>is</code>.
  *
  * @param is an input stream with the certificate data.
  * @return an X.509 certificate object initialized with the data from the input stream.
  * @exception CertificateException on parsing errors.
  */
 public Certificate engineGenerateCertificate(InputStream is) throws CertificateException {
   if (is == null) {
     // clear the caches (for debugging)
     certCache.clear();
     X509CertificatePair.clearCache();
     throw new CertificateException("Missing input stream");
   }
   try {
     byte[] encoding = readOneBlock(is);
     if (encoding != null) {
       X509CertImpl cert = getFromCache(certCache, encoding);
       if (cert != null) {
         return cert;
       }
       cert = new X509CertImpl(encoding);
       addToCache(certCache, cert.getEncodedInternal(), cert);
       return cert;
     } else {
       throw new IOException("Empty input");
     }
   } catch (IOException ioe) {
     throw (CertificateException)
         new CertificateException("Could not parse certificate: " + ioe.toString()).initCause(ioe);
   }
 }
Exemplo n.º 2
0
 /**
  * Generates an X.509 certificate revocation list (CRL) object and initializes it with the data
  * read from the given input stream <code>is</code>.
  *
  * @param is an input stream with the CRL data.
  * @return an X.509 CRL object initialized with the data from the input stream.
  * @exception CRLException on parsing errors.
  */
 public CRL engineGenerateCRL(InputStream is) throws CRLException {
   if (is == null) {
     // clear the cache (for debugging)
     crlCache.clear();
     throw new CRLException("Missing input stream");
   }
   try {
     byte[] encoding = readOneBlock(is);
     if (encoding != null) {
       X509CRLImpl crl = getFromCache(crlCache, encoding);
       if (crl != null) {
         return crl;
       }
       crl = new X509CRLImpl(encoding);
       addToCache(crlCache, crl.getEncodedInternal(), crl);
       return crl;
     } else {
       throw new IOException("Empty input");
     }
   } catch (IOException ioe) {
     throw new CRLException(ioe.getMessage());
   }
 }
Exemplo n.º 3
0
 /** Clear the cache for debugging. */
 public static synchronized void clearCache() {
   cache.clear();
 }