CRLParser { public X509CRLEntry retrieveRevocationInfo(InputStream s, BigInteger serialNumber) throws IOException { consumeTagIntro(s); consumeTagIntro(s); int tag = -1; int tagNo = BERTags.NULL; int length = -1; do { tag = DERUtil.readTag(s); tagNo = DERUtil.readTagNumber(s, tag); length = DERUtil.readLength(s); skip(s, length); } while (!isDate(tagNo)); tag = DERUtil.readTag(s); tagNo = DERUtil.readTagNumber(s, tag); length = DERUtil.readLength(s); if (isDate(tagNo)) { skip(s, length); tag = DERUtil.readTag(s); tagNo = DERUtil.readTagNumber(s, tag); length = DERUtil.readLength(s); } while (tagNo == BERTags.SEQUENCE) { tag = DERUtil.readTag(s); if (tag < 0) { return null; } tagNo = DERUtil.readTagNumber(s, tag); length = DERUtil.readLength(s); if (tagNo == BERTags.SEQUENCE) { byte[] entryArray = readNbBytes(s, length); try (InputStream is = new ByteArrayInputStream(entryArray)) { int entryTag = DERUtil.readTag(is); int entryTagNo = DERUtil.readTagNumber(is, entryTag); int entryLength = DERUtil.readLength(is); if (BERTags.INTEGER == entryTagNo) { ASN1Integer asn1SerialNumber = rebuildASN1Integer(readNbBytes(is, entryLength)); if (serialNumber.equals(asn1SerialNumber.getValue())) { ASN1Sequence asn1Sequence = rebuildASN1Sequence(entryArray); CRLEntry crlEntry = CRLEntry.getInstance(asn1Sequence); return new X509CRLEntryObject(crlEntry); } } } } else { LOG.debug("Should only contain SEQUENCEs : tagNo = {} (ignored)", tagNo); skip(s, length); } } return null; }  void getSignedData(BinaryFilteringInputStream is); X509CRLEntry retrieveRevocationInfo(InputStream s, BigInteger serialNumber); CRLInfo retrieveInfo(InputStream s);  }
@Test public void retrieveRevocationInfo() throws IOException { try (InputStream fis = CRLParserTest.class.getResourceAsStream("/LTGRCA.crl"); BufferedInputStream is = new BufferedInputStream(fis)) { BigInteger serialNumber = new BigInteger("5203"); X509CRLEntry entry = parser.retrieveRevocationInfo(fis, serialNumber); assertNotNull(entry); assertNotNull(entry.getRevocationDate()); assertNotNull(entry.getRevocationReason()); assertNotNull(entry.getSerialNumber()); assertEquals(serialNumber, entry.getSerialNumber()); } }
@Test public void retrieveRevocationInfoNull() throws IOException { try (InputStream fis = CRLParserTest.class.getResourceAsStream("/LTGRCA.crl")) { BigInteger serialNumber = new BigInteger("52030000000"); assertNull(parser.retrieveRevocationInfo(fis, serialNumber)); } }
@Test public void retrieveRevocationInfoMedium() throws IOException { try (InputStream fis = CRLParserTest.class.getResourceAsStream("/http___crl.globalsign.com_gs_gspersonalsign2sha2g2.crl")) { BigInteger serialNumber = new BigInteger("288350169419475868349393253038503091234"); X509CRLEntry entry = parser.retrieveRevocationInfo(fis, serialNumber); assertNotNull(entry); assertNotNull(entry.getRevocationDate()); assertNull(entry.getRevocationReason()); assertNotNull(entry.getSerialNumber()); assertEquals(serialNumber, entry.getSerialNumber()); } }
@Test public void retrieveRevocationInfoMediumLastEntry() throws IOException { try (InputStream fis = CRLParserTest.class.getResourceAsStream("/http___crl.globalsign.com_gs_gspersonalsign2sha2g2.crl")) { BigInteger serialNumber = new BigInteger("288350169419475868349393264025423631520"); X509CRLEntry entry = parser.retrieveRevocationInfo(fis, serialNumber); assertNotNull(entry); assertNotNull(entry.getRevocationDate()); assertNull(entry.getRevocationReason()); assertNotNull(entry.getSerialNumber()); assertEquals(serialNumber, entry.getSerialNumber()); } }