java - Sign multiple PDFs without calling login for each file -


I have a problem when I sign multiple PDFs.

My code is: IOException throws public zero signPDF (X509 certificate certificate, list & lt; file & gt; fInl, list & lt; file & gt; fOutl, PrivateKey key) NoSuchAlgorithmException, NoSuchProviderException, Invalid ParameterSpecException, DocumentException, InvalidKeyException, SignatureException, KeyStoreException, Certificate Exceptions, UnrecoverableKeyException {CERTIFICATE [] CC = New Certificate [] {cert}; Int i = 0; (I = 0; i & lt; fInl.size (); i ++) {PDF Reader Reader = New PDF Reader (FINL.Gate (I) .getAbsolutePath ()); FileOutputStream outputFile = New FileOutputStream (fOutl.get (i) .getAbsolutePath ()); PDFStamper Stammer = PDFFormer.Scent Signature (Reader, Output File, '\ 0'); PDF Interview Display SAP = stamper.getSignatureAppearance (); sap.setVisibleSignature (new rectangle (100, 100, 200, 200), 1, zero); Calendar cal = calendar.justinstance (); PDF SIGNATURE DOCK = New PDF Certificate (PDF.N.E.O.M.P.K.L.E.T., pdfn.a.m.ad.b.m.a.dic.setDate (new PDF) (Calorie); dic.setName (PdfPKCSCS7.getSubjectFields (X509Certificate) CC [0]) getField ("CN").); Sap.setCryptoDictionary (DIC); Sap.setLayer2Text ("" + dic.get (PdfName. NAME) + "\" \ n \ n Date: "+ cal.getTime (). Signed by ToString ()); HashMap & LT; PdfName, Object & gt; Exc = New Hashmap & lt; PDF Name, Object & gt; ; (); exc.put (pdfName.CONTENTS, new integer (0x2502)); sap.preClose (exc); PDFPCCS 7PK 7 = new PDFP KCS 7 (key, cc, empty, "SHA1", blank, incorrect); message message message Diaget = messaging deveget.get instant ("SHA1"); byte buff [] = new byte [8192]; int n ; InputStream inp = sap.getRangeStream (); while ((n = inp.read (buf)) gt; 0) {messageDigest.update (buf, 0, n);} byte hash [] = messagedgest.degest (); Byte Sh [] = pk7.getAuthenticatedAttributeBytes (hash, calories); pk7.update (sh, 0, sh.length); pdfDictionary dic2 = new pdfDictionary (); Byte SG [] = pk7.getEncodedPKCS7 (hash, calories); Byte out [] = new byte [0x2500 / 2]; System Arrayopy (SG, 0, Out, 0, SG. Lamps); Dic2.put (pdfName.CONTENTS, new PDFString (outside) .setHexWriting (true)); sap.close (dic2); }}

And it works, but calls "Login token" for each file.

In this line, byte sh [] = pk7.getEncodedPKCS7 (hash, cal); The login of the installed certificate is always called and I want to call it only once.

How can I fix this?

You are receiving it because you have that line in the loop so the line executed for each frequency Will.

To resolve this, you must first authenticate and then loop the results.

Hope it helps!
Put on coding - Ares.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -