GroupDocs.Signature provides CertificateSearchOptions class to specify different options to search text data within the certificate documents.
Please be aware that the search result will always be a list of MetadataSignature objects. GroupDocs.Signature reads each certificate property, such as SerialNumber, Issuer, Subject or Expiration, as a metadata entry, so every match returns the property name in getName() and its value in getValue(). The text is matched against the string form of each value; the serial number is read as a decimal number, not as a hexadecimal string.
Here are the steps to search for the values within the certificate document with GroupDocs.Signature:
Create new instance of Signature class and pass source document path and LoadOptions with the certificate password as constructor parameters.
Instantiate the CertificateSearchOptions object according to your requirements and specify search options.
This example shows how to make advanced search for text data within the certificate documents.
LoadOptionsloadOptions=newLoadOptions();loadOptions.setPassword("1234567890");Signaturesignature=newSignature("certificate.pfx",loadOptions);try{CertificateSearchOptionsoptions=newCertificateSearchOptions();// check the serial number (Java reads it as a decimal number)
options.setText("12308567976323978183");// match by substring
options.setMatchType(TextMatchType.Contains);// search for certificate data
List<MetadataSignature>result=signature.search(MetadataSignature.class,options);if(result.size()>0){System.out.println("\nCertificate contains following search results");for(MetadataSignaturetemp:result){System.out.println("\t\t-"+temp.getName()+" - "+temp.getValue());}}else{System.out.println("\nCertificate failed search process.");}}finally{signature.dispose();}
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples: