/** * Verifies a certificate chain against a KeyStore for the current date. * * @param certs the certificate chain * @param keystore the <CODE>KeyStore</CODE> * @return <CODE>null</CODE> if the certificate chain could be validated or a * <CODE>Object[]{cert,error}</CODE> where <CODE>cert</CODE> is the * failed certificate and <CODE>error</CODE> is the error message */ public static List<VerificationException> verifyCertificates(Certificate[] certs, KeyStore keystore) { return verifyCertificates(certs, keystore, DateTimeUtil.getCurrentTimeCalendar()); }
protected void initLtvVerifier(PdfDocument document) throws GeneralSecurityException { this.document = document; this.acroForm = PdfAcroForm.getAcroForm(document, true); this.sgnUtil = new SignatureUtil(document); List<String> names = sgnUtil.getSignatureNames(); signatureName = names.get(names.size() - 1); this.signDate = DateTimeUtil.getCurrentTimeDate(); pkcs7 = coversWholeDocument(); LOGGER.info(MessageFormatUtil.format("Checking {0}signature {1}", pkcs7.isTsp() ? "document-level timestamp " : "", signatureName)); }
protected void initLtvVerifier(PdfDocument document) throws GeneralSecurityException { this.document = document; this.acroForm = PdfAcroForm.getAcroForm(document, true); this.sgnUtil = new SignatureUtil(document); List<String> names = sgnUtil.getSignatureNames(); signatureName = names.get(names.size() - 1); this.signDate = DateTimeUtil.getCurrentTimeDate(); pkcs7 = coversWholeDocument(); LOGGER.info(MessageFormatUtil.format("Checking {0}signature {1}", pkcs7.isTsp() ? "document-level timestamp " : "", signatureName)); }
/** * Verifies a single certificate for the current date. * * @param cert the certificate to verify * @param crls the certificate revocation list or <CODE>null</CODE> * @return a <CODE>String</CODE> with the error description or <CODE>null</CODE> * if no error */ public static String verifyCertificate(X509Certificate cert, Collection<CRL> crls) { return verifyCertificate(cert, crls, DateTimeUtil.getCurrentTimeCalendar()); }
crlVerifier.setRootStore(rootStore); crlVerifier.setOnlineCheckingAllowed(onlineCheckingAllowed); crlVerifier.verify((X509CRL)crl, responderCert, issuerCert, DateTimeUtil.getCurrentTimeDate()); return;
/** * Verifies a single certificate for the current date. * * @param cert the certificate to verify * @param crls the certificate revocation list or <CODE>null</CODE> * @return a <CODE>String</CODE> with the error description or <CODE>null</CODE> * if no error */ public static String verifyCertificate(X509Certificate cert, Collection<CRL> crls) { return verifyCertificate(cert, crls, DateTimeUtil.getCurrentTimeCalendar()); }
crlVerifier.setRootStore(rootStore); crlVerifier.setOnlineCheckingAllowed(onlineCheckingAllowed); crlVerifier.verify((X509CRL)crl, responderCert, issuerCert, DateTimeUtil.getCurrentTimeDate()); return;
/** * Verifies a certificate chain against a KeyStore for the current date. * * @param certs the certificate chain * @param keystore the <CODE>KeyStore</CODE> * @return <CODE>null</CODE> if the certificate chain could be validated or a * <CODE>Object[]{cert,error}</CODE> where <CODE>cert</CODE> is the * failed certificate and <CODE>error</CODE> is the error message */ public static List<VerificationException> verifyCertificates(Certificate[] certs, KeyStore keystore) { return verifyCertificates(certs, keystore, DateTimeUtil.getCurrentTimeCalendar()); }
/** * Verifies a certificate chain against a KeyStore for the current date. * * @param certs the certificate chain * @param keystore the <CODE>KeyStore</CODE> * @param crls the certificate revocation list or <CODE>null</CODE> * @return <CODE>null</CODE> if the certificate chain could be validated or a * <CODE>Object[]{cert,error}</CODE> where <CODE>cert</CODE> is the * failed certificate and <CODE>error</CODE> is the error message */ public static List<VerificationException> verifyCertificates(Certificate[] certs, KeyStore keystore, Collection<CRL> crls) { return verifyCertificates(certs, keystore, crls, DateTimeUtil.getCurrentTimeCalendar()); }
/** * Verifies a certificate chain against a KeyStore for the current date. * * @param certs the certificate chain * @param keystore the <CODE>KeyStore</CODE> * @param crls the certificate revocation list or <CODE>null</CODE> * @return <CODE>null</CODE> if the certificate chain could be validated or a * <CODE>Object[]{cert,error}</CODE> where <CODE>cert</CODE> is the * failed certificate and <CODE>error</CODE> is the error message */ public static List<VerificationException> verifyCertificates(Certificate[] certs, KeyStore keystore, Collection<CRL> crls) { return verifyCertificates(certs, keystore, crls, DateTimeUtil.getCurrentTimeCalendar()); }
/** * Creates a PdfSigner instance. Uses a {@link java.io.ByteArrayOutputStream} instead of a temporary file. * * @param reader PdfReader that reads the PDF file * @param outputStream OutputStream to write the signed PDF file * @param path File to which the output is temporarily written * @param properties {@link StampingProperties} for the signing document. Note that encryption will be * preserved regardless of what is set in properties. * @throws IOException */ public PdfSigner(PdfReader reader, OutputStream outputStream, String path, StampingProperties properties) throws IOException { StampingProperties localProps = new StampingProperties(properties).preserveEncryption(); if (path == null) { temporaryOS = new ByteArrayOutputStream(); document = initDocument(reader, new PdfWriter(temporaryOS), localProps); } else { this.tempFile = FileUtil.createTempFile(path); document = initDocument(reader, new PdfWriter(FileUtil.getFileOutputStream(tempFile)), localProps); } originalOS = outputStream; signDate = DateTimeUtil.getCurrentTimeCalendar(); fieldName = getNewSigFieldName(); appearance = new PdfSignatureAppearance(document, new Rectangle(0, 0), 1); appearance.setSignDate(signDate); closed = false; }
/** * Creates a PdfSigner instance. Uses a {@link java.io.ByteArrayOutputStream} instead of a temporary file. * * @param reader PdfReader that reads the PDF file * @param outputStream OutputStream to write the signed PDF file * @param path File to which the output is temporarily written * @param properties {@link StampingProperties} for the signing document. Note that encryption will be * preserved regardless of what is set in properties. * @throws IOException */ public PdfSigner(PdfReader reader, OutputStream outputStream, String path, StampingProperties properties) throws IOException { StampingProperties localProps = new StampingProperties(properties).preserveEncryption(); if (path == null) { temporaryOS = new ByteArrayOutputStream(); document = initDocument(reader, new PdfWriter(temporaryOS), localProps); } else { this.tempFile = FileUtil.createTempFile(path); document = initDocument(reader, new PdfWriter(FileUtil.getFileOutputStream(tempFile)), localProps); } originalOS = outputStream; signDate = DateTimeUtil.getCurrentTimeCalendar(); fieldName = getNewSigFieldName(); appearance = new PdfSignatureAppearance(document, new Rectangle(0, 0), 1); appearance.setSignDate(signDate); closed = false; }