Search in sources :

Example 6 with BoundedInputStream

use of org.apache.commons.io.input.BoundedInputStream in project oxAuth by GluuFederation.

the class CRLCertificateVerifier method requestCRL.

public X509CRL requestCRL(String url) throws IOException, MalformedURLException, CertificateException, CRLException {
    HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
    try {
        con.setUseCaches(false);
        InputStream in = new BoundedInputStream(con.getInputStream(), maxCrlSize);
        try {
            CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
            X509CRL crl = (X509CRL) certificateFactory.generateCRL(in);
            log.debug("CRL size: " + crl.getEncoded().length + " bytes");
            return crl;
        } finally {
            IOUtils.closeQuietly(in);
        }
    } catch (IOException ex) {
        log.error("Failed to download CRL from '" + url + "'", ex);
    } finally {
        if (con != null) {
            con.disconnect();
        }
    }
    return null;
}
Also used : HttpURLConnection(java.net.HttpURLConnection) X509CRL(java.security.cert.X509CRL) BoundedInputStream(org.apache.commons.io.input.BoundedInputStream) ASN1InputStream(org.bouncycastle.asn1.ASN1InputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) BoundedInputStream(org.apache.commons.io.input.BoundedInputStream) IOException(java.io.IOException) CertificateFactory(java.security.cert.CertificateFactory) URL(java.net.URL)

Aggregations

InputStream (java.io.InputStream)6 BoundedInputStream (org.apache.commons.io.input.BoundedInputStream)6 IOException (java.io.IOException)3 HttpURLConnection (java.net.HttpURLConnection)2 LzmaInputStream (net.contrapunctus.lzma.LzmaInputStream)2 CountingInputStream (org.apache.commons.io.input.CountingInputStream)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 DataReader (info.ata4.io.DataReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 EOFException (java.io.EOFException)1 File (java.io.File)1 URL (java.net.URL)1 CertificateFactory (java.security.cert.CertificateFactory)1 X509CRL (java.security.cert.X509CRL)1 List (java.util.List)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 FSInputStream (org.apache.hadoop.fs.FSInputStream)1 HttpEntity (org.apache.http.HttpEntity)1