Skip to content

Commit

Permalink
'#1978 Adjust tests for PCKS7
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickdalla committed Nov 14, 2023
1 parent e64b6b5 commit 7e7be84
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public void testCertificateParsingPKCS7() throws IOException, SAXException, Tika

List<Exception> exceptions = new ArrayList<>();
List<X509Certificate> certificates = new ArrayList<>();
List<Metadata> metadatas = new ArrayList<>();

context.set(EmbeddedDocumentExtractor.class, new EmbeddedDocumentExtractor() {
@Override
Expand All @@ -175,6 +176,7 @@ public void parseEmbedded(InputStream stream, ContentHandler arg1, Metadata meta
try {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
X509Certificate cert = (X509Certificate) cf.generateCertificate(stream);
certificates.add(cert);
} catch (Exception e) {
exceptions.add(e);
} finally {
Expand All @@ -188,6 +190,8 @@ public void parseEmbedded(InputStream stream, ContentHandler arg1, Metadata meta
assertEquals(exceptions.size(), 0);
assertEquals(certificates.size(), 1);
assertEquals(certificates.get(0).getSubjectDN().toString(),
"EMAILADDRESS=guilhermeandreuce@gmail.com, CN=pf.gov.br, OU=PF, O=Polícia Federal, L=Asa Sul, ST=Brasília, C=BR");
assertEquals(certificates.get(0).getSubjectX500Principal().getName(),
"1.2.840.113549.1.9.1=#161b6775696c6865726d65616e64726575636540676d61696c2e636f6d,CN=pf.gov.br,OU=PF,O=Polícia Federal,L=Asa Sul,ST=Brasília,C=BR");

}
Expand Down

0 comments on commit 7e7be84

Please sign in to comment.