Пример #1
0
  public void testSHA1WithRSAEncapsulatedParser() throws Exception {
    MimeBodyPart res = generateEncapsulatedRsa("SHA1withRSA", msg);
    SMIMESignedParser s =
        new SMIMESignedParser(
            new JcaDigestCalculatorProviderBuilder().setProvider(BC).build(), res);

    FileBackedMimeBodyPart content = (FileBackedMimeBodyPart) s.getContent();

    verifyMessageBytes(msg, content);

    content.dispose();

    verifySigners(s.getCertificates(), s.getSignerInfos());

    s.close();
  }
Пример #2
0
  public void testSHA1WithRSAEncapsulatedParserAndFile() throws Exception {
    File tmp = File.createTempFile("bcTest", ".mime");
    MimeBodyPart res = generateEncapsulatedRsa("SHA1withRSA", msg);
    SMIMESignedParser s =
        new SMIMESignedParser(
            new JcaDigestCalculatorProviderBuilder().setProvider(BC).build(), res, tmp);
    FileBackedMimeBodyPart content = (FileBackedMimeBodyPart) s.getContent();

    verifyMessageBytes(msg, s.getContent());

    verifySigners(s.getCertificates(), s.getSignerInfos());

    assertTrue(tmp.exists());

    s.close();

    content.dispose();

    assertFalse(tmp.exists());
  }