JcaDigestCalculatorProviderBuilder digestCalculatorProviderBuilder = new JcaDigestCalculatorProviderBuilder();
digestCalculatorProviderBuilder.setProvider(BouncyCastleProviderHelper.PROVIDER_NAME);
DigestCalculatorProvider digestCalculatorProvider = digestCalculatorProviderBuilder.build();
JcaSignerInfoGeneratorBuilder signerInfoGeneratorBuilder = new JcaSignerInfoGeneratorBuilder(digestCalculatorProvider);
// if (timeStampClient == null) {
// DERObject derObject = new ASN1UTCTime(new Date());
// DERSet derSet = new DERSet(derObject);
//
// Attribute attribute = new Attribute(PKCSObjectIdentifiers.pkcs_9_at_signingTime, derSet);
// Hashtable hashtable = new Hashtable();
// hashtable.put(PKCSObjectIdentifiers.pkcs_9_at_signingTime, attribute);
//
// AttributeTable table = new AttributeTable(hashtable);
// CMSAttributeTableGenerator attributeTableGenerator = new DefaultSignedAttributeTableGenerator(table);
// signerInfoGeneratorBuilder.setSignedAttributeGenerator(attributeTableGenerator);
// }
SignerInfoGenerator signerInfoGenerator = signerInfoGeneratorBuilder.build(contentSigner, (X509Certificate) certificate);
cmsSignedDataGenerator.addSignerInfoGenerator(signerInfoGenerator);
cmsSignedDataGenerator.addCertificates(this.getCertificateStore(chain));
}