CrlFileUtil { public File stripCRLFile(File file) throws IOException { File tempFile = File.createTempFile("candlepin_crl_", ".pem"); try (BufferedReader r = new BufferedReader(new FileReader(file)); BufferedWriter w = new BufferedWriter(new FileWriter(tempFile))) { String line = null; do { line = r.readLine(); } while (line != null && (WHITESPACE.matcher(line).matches() || CRL_HEADER_PATTERN.matcher(line).matches())); if (line == null) { throw new IOException("No data left in file " + file); } do { w.write(line); line = r.readLine(); } while (line != null && !CRL_FOOTER_PATTERN.matcher(line).matches()); return tempFile; } } @Inject  CrlFileUtil(CertificateReader certificateReader, PKIUtility pkiUtility,
        CertificateSerialCurator curator, Configuration config); void initializeCRLFile(File file, Collection<BigInteger> revoke); File stripCRLFile(File file); void updateCRLFile(File file, final Collection<BigInteger> revoke,
        final Collection<BigInteger> unrevoke); @Transactional int batchSyncCRLWithDB(File crlFile, int batchSize); void syncCRLWithDB(File file);  }
@Test public void testStripCRLFile() throws Exception { URL pemUrl = CrlFileUtilTest.class.getClassLoader().getResource("crl.pem"); File pemFile = new File(pemUrl.getFile()); File strippedFile = cfu.stripCRLFile(pemFile); BufferedReader r = new BufferedReader(new FileReader(strippedFile)); String l; while ((l = r.readLine()) != null) { assertThat(l, matchesPattern("^[A-Za-z0-9+/=]*$")); } r.close(); }