1. i need to write a java program for adding digital signature to a page in a pdf file .
* i have to use the profile created by the user where private key ,certificate and public key are stored .
* i need to use the signature found in that profile . may be i have to extract it and add it to the pdf page .
could anyone please help me out regarding this because have not worked earlier on this .
what are the requirements and how to go about it .
i am encountering this error when i compile this program ..i have used itext.jar file
pdfsign1.java:27: reference to Certificate is ambiguous, both class java.securit
y.cert.Certificate in java.security.cert and class java.security.Certificate in
java.security match
Certificate[] chain = ks.getCertificateChain(alias);
^
1 error
could you please help me out ..
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35438
9
posted
0
Both the java.security and the java.security.cert package have a "Certificate" class/interface. You can only import one with a wildcard. In this case, you want the one in java.security.cert.
catch (Exception e) {}
That's a bad idea. How a will you know what's going wrong with the code?
pavithra murthy
Ranch Hand
Joined: Feb 06, 2009
Posts: 53
posted
0
hello friend ,
i have written a java code for adding digital signature to pdf file .
i am encountering an exception when the program is run .
C:\excel>java pdfsign1
java.io.IOException: DerInputStream.getLength(): lengthTag=109, too big.
at sun.security.util.DerInputStream.getLength(Unknown Source)
at sun.security.util.DerValue.init(Unknown Source)
at sun.security.util.DerValue.<init>(Unknown Source)
at com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore.engineLoad(Unknown Sou
rce)
at java.security.KeyStore.load(Unknown Source)
at pdfsign1.main(pdfsign1.java:23)
i am creating a key with name "my_private_key.pfx" specified in the program using the command
keytool -genkey -keyalg RSA -alias myname -keypass password -keystore my_private_key.pfx
pavithra murthy
Ranch Hand
Joined: Feb 06, 2009
Posts: 53
posted
0
hello friends ,
i have written a code using jPDFProcess.jar file . there are two classes SignDocument and ExportFields.java
exportfields is super class
signdocument is subclass
i am creating a key sample PKCS#12 file using the command
both classes are compiling fine but while running i am getting the same following exceptions
could anyone please help me out
-------------------------------------------------
Exception in thread "main" java.lang.IncompatibleClassChangeError: class com.qop
pa.pdfProcess.PDFDocument has interface com.qoppa.pdfViewer.g.k as super class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)