public class CreateVisibleSignature extends Object implements SignatureInterface
This is an example for signing a pdf with bouncy castle.
And also you can create visible signature too
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 and Description |
---|
CreateVisibleSignature(KeyStore keystore,
char[] pin)
Initialize the signature creator with a keystore (pkcs12) and pin that
should be used for the signature.
|
Modifier and Type | Method and Description |
---|---|
static void |
main(String[] args)
Arguments are
[0] key store
[1] pin
[2] document that will be signed
[3] image of visible signature
|
byte[] |
sign(InputStream content)
SignatureInterface implementation.
|
File |
signPDF(File document,
PDVisibleSigProperties signatureProperties)
Signs the given pdf file.
|
public CreateVisibleSignature(KeyStore keystore, char[] pin)
keystore
- is a pkcs12 keystore.pin
- is the pin for the keystore / private keypublic File signPDF(File document, PDVisibleSigProperties signatureProperties) throws IOException, COSVisitorException, SignatureException
document
- is the pdf documentsignatureProperties
- IOException
COSVisitorException
SignatureException
public byte[] sign(InputStream content) throws 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 SignatureInterface
content
- is the content as a (Filter)InputStreamSignatureException
IOException
public static void main(String[] args) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException, COSVisitorException, SignatureException
Copyright © 2002–2013 The Apache Software Foundation. All rights reserved.