List of usage examples for com.itextpdf.text.pdf.security PdfPKCS7 PdfPKCS7
@SuppressWarnings({ "unchecked" })
public PdfPKCS7(byte[] contentsKey, PdfName filterSubtype, String provider)
From source file:org.opencps.pki.Pksc7SignatureContainer.java
License:Open Source License
/** * Produces the container with the signature. * @param data the data to sign/*from w w w.j a va2s .com*/ * @return a container with the signature and other objects, like CRL and OCSP. The container will generally be a PKCS7 one. * @throws GeneralSecurityException */ @Override public byte[] sign(InputStream is) throws GeneralSecurityException { X509Certificate cert = signer.getCertificate(); PdfPKCS7 sgn = new PdfPKCS7(encodedPkcs7, PdfName.ADBE_PKCS7_DETACHED, null); X509Certificate signingCert = sgn.getSigningCertificate(); if (!signingCert.getSerialNumber().equals(cert.getSerialNumber())) { throw new SignatureException( "Encoded pkcs7 is invalid. The certificate from signer not equal pkcs7's certificate"); } return encodedPkcs7; }