Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Open Source Projects
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Other Open Source Projects
want to insert user-defined pass-phrase
rakhi sinha
Ranch Hand
Posts: 147
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am using following code to digitally sign the pdfs it is working well,but if i write phrase in place of "abcdef" password it does not work... (because i want to enter passwords of individual persons )
HttpSession session = request.getSession(); String no = (String)session.getAttribute("no"); HttpSession session1=request.getSession(); String phrase=(String)session1.getAttribute("[u]phrase[/u]"); HttpSession session2=request.getSession(); String path=(String)session2.getAttribute("path"); try { KeyStore ks = KeyStore.getInstance("pkcs12"); ks.load(new FileInputStream(getServletContext().getRealPath("resources/"+path)),"abcdef".toCharArray()); String alias = (String)ks.aliases().nextElement(); PrivateKey key = (PrivateKey)ks.getKey(alias, "abcdef".toCharArray()); Certificate[] chain = ks.getCertificateChain(alias); PdfReader reader = new PdfReader(getServletContext().getRealPath("/resources/a"+ no +".pdf")); FileOutputStream os = new FileOutputStream(getServletContext().getRealPath("/resources/signed"+no+".pdf")); PdfStamper stamper = null; stamper = PdfStamper.createSignature(reader, os, '\0'); PdfSignatureAppearance appearance = stamper.getSignatureAppearance(); appearance.setCrypto(key, chain, null,PdfSignatureAppearance.WINCER_SIGNED); appearance.setReason("It's personal."); appearance.setLocation("foobar"); appearance.setVisibleSignature(new Rectangle(200, 500, 290, 450), 1,"first"); stamper.close();
Tim Moores
Saloon Keeper
Posts: 7585
176
posted 11 years ago
1
Number of slices to send:
Optional 'thank-you' note:
Send
Post the code that is "not working", and tell us what "not working" actually means.
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
importing keystore and password
pdf in web browser
signature in pdf
how to remove exception
pdf
More...