Java Code Examples for sun.security.pkcs.PKCS7#getCRLs()

The following examples show how to use sun.security.pkcs.PKCS7#getCRLs() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: X509Factory.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private Collection<? extends java.security.cert.CRL>
    parseX509orPKCS7CRL(InputStream is)
    throws CRLException, IOException
{
    Collection<X509CRLImpl> coll = new ArrayList<>();
    byte[] data = readOneBlock(is);
    if (data == null) {
        return new ArrayList<>(0);
    }
    try {
        PKCS7 pkcs7 = new PKCS7(data);
        X509CRL[] crls = pkcs7.getCRLs();
        // CRLs are optional in PKCS #7
        if (crls != null) {
            return Arrays.asList(crls);
        } else {
            // no crls provided
            return new ArrayList<>(0);
        }
    } catch (ParsingException e) {
        while (data != null) {
            coll.add(new X509CRLImpl(data));
            data = readOneBlock(is);
        }
    }
    return coll;
}
 
Example 2
Source File: X509Factory.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private Collection<? extends java.security.cert.CRL>
    parseX509orPKCS7CRL(InputStream is)
    throws CRLException, IOException
{
    Collection<X509CRLImpl> coll = new ArrayList<>();
    byte[] data = readOneBlock(is);
    if (data == null) {
        return new ArrayList<>(0);
    }
    try {
        PKCS7 pkcs7 = new PKCS7(data);
        X509CRL[] crls = pkcs7.getCRLs();
        // CRLs are optional in PKCS #7
        if (crls != null) {
            return Arrays.asList(crls);
        } else {
            // no crls provided
            return new ArrayList<>(0);
        }
    } catch (ParsingException e) {
        while (data != null) {
            coll.add(new X509CRLImpl(data));
            data = readOneBlock(is);
        }
    }
    return coll;
}
 
Example 3
Source File: X509Factory.java    From j2objc with Apache License 2.0 5 votes vote down vote up
private Collection<? extends java.security.cert.CRL>
    parseX509orPKCS7CRL(InputStream is)
    throws CRLException, IOException
{
    Collection<X509CRLImpl> coll = new ArrayList<>();
    byte[] data = readOneBlock(is);
    if (data == null) {
        return new ArrayList<>(0);
    }
    try {
        PKCS7 pkcs7 = new PKCS7(data);
        X509CRL[] crls = pkcs7.getCRLs();
        // CRLs are optional in PKCS #7
        if (crls != null) {
            return Arrays.asList(crls);
        } else {
            // no crls provided
            return new ArrayList<>(0);
        }
    } catch (ParsingException e) {
        while (data != null) {
            coll.add(new X509CRLImpl(data));
            data = readOneBlock(is);
        }
    }
    return coll;
}
 
Example 4
Source File: X509Factory.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private Collection<? extends java.security.cert.CRL>
    parseX509orPKCS7CRL(InputStream is)
    throws CRLException, IOException
{
    int peekByte;
    byte[] data;
    PushbackInputStream pbis = new PushbackInputStream(is);
    Collection<X509CRLImpl> coll = new ArrayList<>();

    // Test the InputStream for end-of-stream.  If the stream's
    // initial state is already at end-of-stream then return
    // an empty collection.  Otherwise, push the byte back into the
    // stream and let readOneBlock look for the first CRL.
    peekByte = pbis.read();
    if (peekByte == -1) {
        return new ArrayList<>(0);
    } else {
        pbis.unread(peekByte);
        data = readOneBlock(pbis);
    }

    // If we end up with a null value after reading the first block
    // then we know the end-of-stream has been reached and no CRL
    // data has been found.
    if (data == null) {
        throw new CRLException("No CRL data found");
    }

    try {
        PKCS7 pkcs7 = new PKCS7(data);
        X509CRL[] crls = pkcs7.getCRLs();
        // CRLs are optional in PKCS #7
        if (crls != null) {
            return Arrays.asList(crls);
        } else {
            // no crls provided
            return new ArrayList<>(0);
        }
    } catch (ParsingException e) {
        while (data != null) {
            coll.add(new X509CRLImpl(data));
            data = readOneBlock(pbis);
        }
    }
    return coll;
}
 
Example 5
Source File: X509Factory.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private Collection<? extends java.security.cert.CRL>
    parseX509orPKCS7CRL(InputStream is)
    throws CRLException, IOException
{
    int peekByte;
    byte[] data;
    PushbackInputStream pbis = new PushbackInputStream(is);
    Collection<X509CRLImpl> coll = new ArrayList<>();

    // Test the InputStream for end-of-stream.  If the stream's
    // initial state is already at end-of-stream then return
    // an empty collection.  Otherwise, push the byte back into the
    // stream and let readOneBlock look for the first CRL.
    peekByte = pbis.read();
    if (peekByte == -1) {
        return new ArrayList<>(0);
    } else {
        pbis.unread(peekByte);
        data = readOneBlock(pbis);
    }

    // If we end up with a null value after reading the first block
    // then we know the end-of-stream has been reached and no CRL
    // data has been found.
    if (data == null) {
        throw new CRLException("No CRL data found");
    }

    try {
        PKCS7 pkcs7 = new PKCS7(data);
        X509CRL[] crls = pkcs7.getCRLs();
        // CRLs are optional in PKCS #7
        if (crls != null) {
            return Arrays.asList(crls);
        } else {
            // no crls provided
            return new ArrayList<>(0);
        }
    } catch (ParsingException e) {
        while (data != null) {
            coll.add(new X509CRLImpl(data));
            data = readOneBlock(pbis);
        }
    }
    return coll;
}
 
Example 6
Source File: X509Factory.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private Collection<? extends java.security.cert.CRL>
    parseX509orPKCS7CRL(InputStream is)
    throws CRLException, IOException
{
    int peekByte;
    byte[] data;
    PushbackInputStream pbis = new PushbackInputStream(is);
    Collection<X509CRLImpl> coll = new ArrayList<>();

    // Test the InputStream for end-of-stream.  If the stream's
    // initial state is already at end-of-stream then return
    // an empty collection.  Otherwise, push the byte back into the
    // stream and let readOneBlock look for the first CRL.
    peekByte = pbis.read();
    if (peekByte == -1) {
        return new ArrayList<>(0);
    } else {
        pbis.unread(peekByte);
        data = readOneBlock(pbis);
    }

    // If we end up with a null value after reading the first block
    // then we know the end-of-stream has been reached and no CRL
    // data has been found.
    if (data == null) {
        throw new CRLException("No CRL data found");
    }

    try {
        PKCS7 pkcs7 = new PKCS7(data);
        X509CRL[] crls = pkcs7.getCRLs();
        // CRLs are optional in PKCS #7
        if (crls != null) {
            return Arrays.asList(crls);
        } else {
            // no crls provided
            return new ArrayList<>(0);
        }
    } catch (ParsingException e) {
        while (data != null) {
            coll.add(new X509CRLImpl(data));
            data = readOneBlock(pbis);
        }
    }
    return coll;
}
 
Example 7
Source File: X509Factory.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private Collection<? extends java.security.cert.CRL>
    parseX509orPKCS7CRL(InputStream is)
    throws CRLException, IOException
{
    int peekByte;
    byte[] data;
    PushbackInputStream pbis = new PushbackInputStream(is);
    Collection<X509CRLImpl> coll = new ArrayList<>();

    // Test the InputStream for end-of-stream.  If the stream's
    // initial state is already at end-of-stream then return
    // an empty collection.  Otherwise, push the byte back into the
    // stream and let readOneBlock look for the first CRL.
    peekByte = pbis.read();
    if (peekByte == -1) {
        return new ArrayList<>(0);
    } else {
        pbis.unread(peekByte);
        data = readOneBlock(pbis);
    }

    // If we end up with a null value after reading the first block
    // then we know the end-of-stream has been reached and no CRL
    // data has been found.
    if (data == null) {
        throw new CRLException("No CRL data found");
    }

    try {
        PKCS7 pkcs7 = new PKCS7(data);
        X509CRL[] crls = pkcs7.getCRLs();
        // CRLs are optional in PKCS #7
        if (crls != null) {
            return Arrays.asList(crls);
        } else {
            // no crls provided
            return new ArrayList<>(0);
        }
    } catch (ParsingException e) {
        while (data != null) {
            coll.add(new X509CRLImpl(data));
            data = readOneBlock(pbis);
        }
    }
    return coll;
}
 
Example 8
Source File: X509Factory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private Collection<? extends java.security.cert.CRL>
    parseX509orPKCS7CRL(InputStream is)
    throws CRLException, IOException
{
    int peekByte;
    byte[] data;
    PushbackInputStream pbis = new PushbackInputStream(is);
    Collection<X509CRLImpl> coll = new ArrayList<>();

    // Test the InputStream for end-of-stream.  If the stream's
    // initial state is already at end-of-stream then return
    // an empty collection.  Otherwise, push the byte back into the
    // stream and let readOneBlock look for the first CRL.
    peekByte = pbis.read();
    if (peekByte == -1) {
        return new ArrayList<>(0);
    } else {
        pbis.unread(peekByte);
        data = readOneBlock(pbis);
    }

    // If we end up with a null value after reading the first block
    // then we know the end-of-stream has been reached and no CRL
    // data has been found.
    if (data == null) {
        throw new CRLException("No CRL data found");
    }

    try {
        PKCS7 pkcs7 = new PKCS7(data);
        X509CRL[] crls = pkcs7.getCRLs();
        // CRLs are optional in PKCS #7
        if (crls != null) {
            return Arrays.asList(crls);
        } else {
            // no crls provided
            return new ArrayList<>(0);
        }
    } catch (ParsingException e) {
        while (data != null) {
            coll.add(new X509CRLImpl(data));
            data = readOneBlock(pbis);
        }
    }
    return coll;
}
 
Example 9
Source File: X509Factory.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
private Collection<? extends java.security.cert.CRL>
    parseX509orPKCS7CRL(InputStream is)
    throws CRLException, IOException
{
    int peekByte;
    byte[] data;
    PushbackInputStream pbis = new PushbackInputStream(is);
    Collection<X509CRLImpl> coll = new ArrayList<>();

    // Test the InputStream for end-of-stream.  If the stream's
    // initial state is already at end-of-stream then return
    // an empty collection.  Otherwise, push the byte back into the
    // stream and let readOneBlock look for the first CRL.
    peekByte = pbis.read();
    if (peekByte == -1) {
        return new ArrayList<>(0);
    } else {
        pbis.unread(peekByte);
        data = readOneBlock(pbis);
    }

    // If we end up with a null value after reading the first block
    // then we know the end-of-stream has been reached and no CRL
    // data has been found.
    if (data == null) {
        throw new CRLException("No CRL data found");
    }

    try {
        PKCS7 pkcs7 = new PKCS7(data);
        X509CRL[] crls = pkcs7.getCRLs();
        // CRLs are optional in PKCS #7
        if (crls != null) {
            return Arrays.asList(crls);
        } else {
            // no crls provided
            return new ArrayList<>(0);
        }
    } catch (ParsingException e) {
        while (data != null) {
            coll.add(new X509CRLImpl(data));
            data = readOneBlock(pbis);
        }
    }
    return coll;
}
 
Example 10
Source File: X509Factory.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private Collection<? extends java.security.cert.CRL>
    parseX509orPKCS7CRL(InputStream is)
    throws CRLException, IOException
{
    int peekByte;
    byte[] data;
    PushbackInputStream pbis = new PushbackInputStream(is);
    Collection<X509CRLImpl> coll = new ArrayList<>();

    // Test the InputStream for end-of-stream.  If the stream's
    // initial state is already at end-of-stream then return
    // an empty collection.  Otherwise, push the byte back into the
    // stream and let readOneBlock look for the first CRL.
    peekByte = pbis.read();
    if (peekByte == -1) {
        return new ArrayList<>(0);
    } else {
        pbis.unread(peekByte);
        data = readOneBlock(pbis);
    }

    // If we end up with a null value after reading the first block
    // then we know the end-of-stream has been reached and no CRL
    // data has been found.
    if (data == null) {
        throw new CRLException("No CRL data found");
    }

    try {
        PKCS7 pkcs7 = new PKCS7(data);
        X509CRL[] crls = pkcs7.getCRLs();
        // CRLs are optional in PKCS #7
        if (crls != null) {
            return Arrays.asList(crls);
        } else {
            // no crls provided
            return new ArrayList<>(0);
        }
    } catch (ParsingException e) {
        while (data != null) {
            coll.add(new X509CRLImpl(data));
            data = readOneBlock(pbis);
        }
    }
    return coll;
}
 
Example 11
Source File: X509Factory.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private Collection<? extends java.security.cert.CRL>
    parseX509orPKCS7CRL(InputStream is)
    throws CRLException, IOException
{
    int peekByte;
    byte[] data;
    PushbackInputStream pbis = new PushbackInputStream(is);
    Collection<X509CRLImpl> coll = new ArrayList<>();

    // Test the InputStream for end-of-stream.  If the stream's
    // initial state is already at end-of-stream then return
    // an empty collection.  Otherwise, push the byte back into the
    // stream and let readOneBlock look for the first CRL.
    peekByte = pbis.read();
    if (peekByte == -1) {
        return new ArrayList<>(0);
    } else {
        pbis.unread(peekByte);
        data = readOneBlock(pbis);
    }

    // If we end up with a null value after reading the first block
    // then we know the end-of-stream has been reached and no CRL
    // data has been found.
    if (data == null) {
        throw new CRLException("No CRL data found");
    }

    try {
        PKCS7 pkcs7 = new PKCS7(data);
        X509CRL[] crls = pkcs7.getCRLs();
        // CRLs are optional in PKCS #7
        if (crls != null) {
            return Arrays.asList(crls);
        } else {
            // no crls provided
            return new ArrayList<>(0);
        }
    } catch (ParsingException e) {
        while (data != null) {
            coll.add(new X509CRLImpl(data));
            data = readOneBlock(pbis);
        }
    }
    return coll;
}
 
Example 12
Source File: X509Factory.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private Collection<? extends java.security.cert.CRL>
    parseX509orPKCS7CRL(InputStream is)
    throws CRLException, IOException
{
    int peekByte;
    byte[] data;
    PushbackInputStream pbis = new PushbackInputStream(is);
    Collection<X509CRLImpl> coll = new ArrayList<>();

    // Test the InputStream for end-of-stream.  If the stream's
    // initial state is already at end-of-stream then return
    // an empty collection.  Otherwise, push the byte back into the
    // stream and let readOneBlock look for the first CRL.
    peekByte = pbis.read();
    if (peekByte == -1) {
        return new ArrayList<>(0);
    } else {
        pbis.unread(peekByte);
        data = readOneBlock(pbis);
    }

    // If we end up with a null value after reading the first block
    // then we know the end-of-stream has been reached and no CRL
    // data has been found.
    if (data == null) {
        throw new CRLException("No CRL data found");
    }

    try {
        PKCS7 pkcs7 = new PKCS7(data);
        X509CRL[] crls = pkcs7.getCRLs();
        // CRLs are optional in PKCS #7
        if (crls != null) {
            return Arrays.asList(crls);
        } else {
            // no crls provided
            return new ArrayList<>(0);
        }
    } catch (ParsingException e) {
        while (data != null) {
            coll.add(new X509CRLImpl(data));
            data = readOneBlock(pbis);
        }
    }
    return coll;
}
 
Example 13
Source File: X509Factory.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private Collection<? extends java.security.cert.CRL>
    parseX509orPKCS7CRL(InputStream is)
    throws CRLException, IOException
{
    int peekByte;
    byte[] data;
    PushbackInputStream pbis = new PushbackInputStream(is);
    Collection<X509CRLImpl> coll = new ArrayList<>();

    // Test the InputStream for end-of-stream.  If the stream's
    // initial state is already at end-of-stream then return
    // an empty collection.  Otherwise, push the byte back into the
    // stream and let readOneBlock look for the first CRL.
    peekByte = pbis.read();
    if (peekByte == -1) {
        return new ArrayList<>(0);
    } else {
        pbis.unread(peekByte);
        data = readOneBlock(pbis);
    }

    // If we end up with a null value after reading the first block
    // then we know the end-of-stream has been reached and no CRL
    // data has been found.
    if (data == null) {
        throw new CRLException("No CRL data found");
    }

    try {
        PKCS7 pkcs7 = new PKCS7(data);
        X509CRL[] crls = pkcs7.getCRLs();
        // CRLs are optional in PKCS #7
        if (crls != null) {
            return Arrays.asList(crls);
        } else {
            // no crls provided
            return new ArrayList<>(0);
        }
    } catch (ParsingException e) {
        while (data != null) {
            coll.add(new X509CRLImpl(data));
            data = readOneBlock(pbis);
        }
    }
    return coll;
}
 
Example 14
Source File: X509Factory.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private Collection<? extends java.security.cert.CRL>
    parseX509orPKCS7CRL(InputStream is)
    throws CRLException, IOException
{
    int peekByte;
    byte[] data;
    PushbackInputStream pbis = new PushbackInputStream(is);
    Collection<X509CRLImpl> coll = new ArrayList<>();

    // Test the InputStream for end-of-stream.  If the stream's
    // initial state is already at end-of-stream then return
    // an empty collection.  Otherwise, push the byte back into the
    // stream and let readOneBlock look for the first CRL.
    peekByte = pbis.read();
    if (peekByte == -1) {
        return new ArrayList<>(0);
    } else {
        pbis.unread(peekByte);
        data = readOneBlock(pbis);
    }

    // If we end up with a null value after reading the first block
    // then we know the end-of-stream has been reached and no CRL
    // data has been found.
    if (data == null) {
        throw new CRLException("No CRL data found");
    }

    try {
        PKCS7 pkcs7 = new PKCS7(data);
        X509CRL[] crls = pkcs7.getCRLs();
        // CRLs are optional in PKCS #7
        if (crls != null) {
            return Arrays.asList(crls);
        } else {
            // no crls provided
            return new ArrayList<>(0);
        }
    } catch (ParsingException e) {
        while (data != null) {
            coll.add(new X509CRLImpl(data));
            data = readOneBlock(pbis);
        }
    }
    return coll;
}
 
Example 15
Source File: X509Factory.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
private Collection<? extends java.security.cert.CRL>
    parseX509orPKCS7CRL(InputStream is)
    throws CRLException, IOException
{
    int peekByte;
    byte[] data;
    PushbackInputStream pbis = new PushbackInputStream(is);
    Collection<X509CRLImpl> coll = new ArrayList<>();

    // Test the InputStream for end-of-stream.  If the stream's
    // initial state is already at end-of-stream then return
    // an empty collection.  Otherwise, push the byte back into the
    // stream and let readOneBlock look for the first CRL.
    peekByte = pbis.read();
    if (peekByte == -1) {
        return new ArrayList<>(0);
    } else {
        pbis.unread(peekByte);
        data = readOneBlock(pbis);
    }

    // If we end up with a null value after reading the first block
    // then we know the end-of-stream has been reached and no CRL
    // data has been found.
    if (data == null) {
        throw new CRLException("No CRL data found");
    }

    try {
        PKCS7 pkcs7 = new PKCS7(data);
        X509CRL[] crls = pkcs7.getCRLs();
        // CRLs are optional in PKCS #7
        if (crls != null) {
            return Arrays.asList(crls);
        } else {
            // no crls provided
            return new ArrayList<>(0);
        }
    } catch (ParsingException e) {
        while (data != null) {
            coll.add(new X509CRLImpl(data));
            data = readOneBlock(pbis);
        }
    }
    return coll;
}