Skip to content

Commit

Permalink
'#1978 Adding some more metadata extraction.
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickdalla committed Nov 14, 2023
1 parent 7f8d6a4 commit e64b6b5
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ public class CertificateParser extends AbstractParser {
public static final Property NOTBEFORE = Property.internalDate("certificate:notBefore"); //$NON-NLS-1$
public static final Property NOTAFTER = Property.internalDate("certificate:notAfter"); //$NON-NLS-1$
public static final String ISSUER = "certificate:issuer"; //$NON-NLS-1$
private static final String X500_ISSUER = "certificate:X500Issuer";
public static final String SUBJECT = "certificate:subject"; //$NON-NLS-1$
public static final String X500_SUBJECT = "certificate:X500Subject"; //$NON-NLS-1$
public static final Property ISSUBJECTAUTHORITY = Property.internalBoolean("certificate:subjectIsCertAuthority"); //$NON-NLS-1$
public static final String NOALTNAMES = "This certificate has no alternative names.";


public CertificateParser() {
MetadataUtil.setMetadataType(NOTBEFORE.getName(), Date.class);
Expand Down Expand Up @@ -147,8 +150,11 @@ public void parse(InputStream stream, ContentHandler handler, Metadata metadata,

metadata.set(NOTBEFORE, cert.getNotBefore());
metadata.set(NOTAFTER, cert.getNotAfter());
metadata.set(ISSUER, cert.getIssuerX500Principal().getName());
metadata.set(SUBJECT, cert.getSubjectX500Principal().getName());

metadata.set(X500_ISSUER, cert.getIssuerX500Principal().getName());
metadata.set(ISSUER, cert.getIssuerDN().getName());
metadata.set(X500_SUBJECT, cert.getSubjectX500Principal().getName());
metadata.set(SUBJECT, cert.getSubjectDN().getName());
if (cert.getBasicConstraints() <= -1) {
metadata.set(ISSUBJECTAUTHORITY, Boolean.FALSE.toString());
} else {
Expand Down Expand Up @@ -189,6 +195,15 @@ private void generateCertificateHtml(X509Certificate cert, XHTMLContentHandler x
xhtml.endElement("td");
xhtml.endElement("tr");

xhtml.startElement("tr");
xhtml.startElement("td");
xhtml.characters("Subject");
xhtml.endElement("td");
xhtml.startElement("td");
xhtml.characters(cert.getSubjectDN().getName());
xhtml.endElement("td");
xhtml.endElement("tr");

xhtml.startElement("tr");
xhtml.startElement("td");
xhtml.characters("Version");
Expand Down

0 comments on commit e64b6b5

Please sign in to comment.