public class CreateSignature extends Object implements SignatureInterface
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 and Description |
---|
CreateSignature(KeyStore keystore,
char[] pin)
Initialize the signature creator with a keystore (pkcs12) and pin that
should be used for the signature.
|
public CreateSignature(KeyStore keystore, char[] pin)
keystore
- is a pkcs12 keystore.pin
- is the pin for the keystore / private keypublic File signPDF(File document) throws IOException, COSVisitorException, SignatureException
document
- is the pdf documentIOException
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.