Collection<Signature> signatures = new ArrayList<Signature>();
if (fields != null) {
List<String> list = fields.getSignatureNames();
if ((list != null) && (!list.isEmpty())) {
for (String str : list) {
PdfPKCS7 pk = fields.verifySignature(str);
PdfString string = fields.getSignatureDictionary(str).getAsString(PdfName.CONTENTS);
byte[] content = string.getBytes();
X509Certificate certificate = pk.getSigningCertificate();
Certificate[] chain = pk.getSignCertificateChain();
byte[] encoded = content;
TimeStamp timeStamp = null;
String location = pk.getLocation();
String reason = pk.getReason();
String signName = pk.getSignName();
Date date = pk.getSignDate().getTime();
Boolean valid = Boolean.TRUE;
Signatory signatory = this.toSignatory(certificate);
Store store = new JCAStore(KeyStoreType.JKS);
store.add(new CertificateEntry(new Alias(certificate.getSerialNumber().toString()), certificate));
Object[] fails = PdfPKCS7.verifyCertificates(chain, store.toKeyStore(), pk.getCRLs(), pk.getSignDate());
if (ConditionUtils.isNotEmpty(fails)) {
valid = Boolean.FALSE;
}
TimeStampToken timeStampToken = pk.getTimeStampToken();
if (timeStampToken != null) {
timeStamp = BouncyCastleTimeStampHelper.toTimeStamp(timeStampToken);
timeStampToken.getTimeStampInfo();
if (valid.booleanValue()) {
boolean ok = pk.verifyTimestampImprint();
valid = Boolean.valueOf(ok);
}
}
Signature sig = new Signature();