|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.pdfbox.examples.signature.CreateSignature
public class CreateSignature
This is an example for singing a pdf with bouncy castle.
A keystore can be created with the java keytool (e.g. keytool -genkeypair -storepass 123456 -storetype pkcs12 -alias test -validity 365 -v -keyalg RSA -keystore keystore.p12 )
| Constructor Summary | |
|---|---|
CreateSignature(KeyStore keystore,
char[] pin)
Initialize the signature creator with a keystore (pkcs12) and pin that should be used for the signature. |
|
| Method Summary | |
|---|---|
static void |
main(String[] args)
|
byte[] |
sign(InputStream content)
SignatureInterface implementation. |
File |
signPDF(File document)
Signs the given pdf file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CreateSignature(KeyStore keystore,
char[] pin)
keystore - is a pkcs12 keystore.pin - is the pin for the keystore / private key| Method Detail |
|---|
public File signPDF(File document)
throws IOException,
org.apache.pdfbox.exceptions.COSVisitorException,
org.apache.pdfbox.exceptions.SignatureException
document - is the pdf document
IOException
org.apache.pdfbox.exceptions.COSVisitorException
org.apache.pdfbox.exceptions.SignatureException
public byte[] sign(InputStream content)
throws org.apache.pdfbox.exceptions.SignatureException,
IOException
SignatureInterface implementation.
This method will be called from inside of the pdfbox and create the pkcs7 signature. The given InputStream contains the bytes that are providen by the byte range.
This method is for internal use only.
Here the user should use his favorite cryptographic library and implement a pkcs7 signature creation.
sign in interface org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterfaceorg.apache.pdfbox.exceptions.SignatureException
IOException
public static void main(String[] args)
throws KeyStoreException,
NoSuchAlgorithmException,
CertificateException,
FileNotFoundException,
IOException,
org.apache.pdfbox.exceptions.COSVisitorException,
org.apache.pdfbox.exceptions.SignatureException
KeyStoreException
NoSuchAlgorithmException
CertificateException
FileNotFoundException
IOException
org.apache.pdfbox.exceptions.COSVisitorException
org.apache.pdfbox.exceptions.SignatureException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||