本文整理汇总了Java中org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature类的典型用法代码示例。如果您正苦于以下问题:Java PDSignature类的具体用法?Java PDSignature怎么用?Java PDSignature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PDSignature类属于org.apache.pdfbox.pdmodel.interactive.digitalsignature包,在下文中一共展示了PDSignature类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: sign
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
/**
* <a href="http://stackoverflow.com/questions/41767351/create-pkcs7-signature-from-file-digest">
* Create pkcs7 signature from file digest
* </a>
* <p>
* A minimal signing frame work merely requiring a {@link SignatureInterface}
* instance.
* </p>
*/
void sign(PDDocument document, OutputStream output, SignatureInterface signatureInterface) throws IOException
{
PDSignature signature = new PDSignature();
signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
signature.setName("Example User");
signature.setLocation("Los Angeles, CA");
signature.setReason("Testing");
signature.setSignDate(Calendar.getInstance());
document.addSignature(signature);
ExternalSigningSupport externalSigning =
document.saveIncrementalForExternalSigning(output);
// invoke external signature service
byte[] cmsSignature = signatureInterface.sign(externalSigning.getContent());
// set signature bytes received from the service
externalSigning.setSignature(cmsSignature);
}
开发者ID:mkl-public,项目名称:testarea-pdfbox2,代码行数:27,代码来源:CreateSignature.java
示例2: signPdf
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
/** Signe un document PDF
* @param inStream
* @param name
* @param location
* @param reason
* @param contactInfo
* @return l'inputStream
* @throws IOException
*/
public InputStream signPdf(ByteArrayInOutStream inStream, String name, String location, String reason, String contactInfo) throws IOException {
if (inStream == null) {
throw new FileNotFoundException("Document for signing does not exist");
}
// sign
PDDocument doc = PDDocument.load(inStream.getInputStream());
// create signature dictionary
PDSignature signature = new PDSignature();
signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
signature.setName(name);
signature.setLocation(location);
signature.setContactInfo(contactInfo);
signature.setReason(reason);
// the signing date, needed for valid signature
signature.setSignDate(Calendar.getInstance());
// register signature dictionary and sign interface
doc.addSignature(signature, this);
// write incremental (only for signing purpose)
ByteArrayInOutStream outStream = new ByteArrayInOutStream();
doc.saveIncremental(outStream);
doc.close();
inStream.close();
return outStream.getInputStream();
}
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:39,代码来源:CreateSignaturePdf.java
示例3: PDF
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
private PDF(String name, byte[] content) {
this.content = content;
try (InputStream inputStream = new ByteArrayInputStream(content)) {
try (PDDocument pdf = PDDocument.load(inputStream)) {
this.text = new PDFTextStripper().getText(pdf);
this.numberOfPages = pdf.getNumberOfPages();
this.author = pdf.getDocumentInformation().getAuthor();
this.creationDate = pdf.getDocumentInformation().getCreationDate();
this.creator = pdf.getDocumentInformation().getCreator();
this.keywords = pdf.getDocumentInformation().getKeywords();
this.producer = pdf.getDocumentInformation().getProducer();
this.subject = pdf.getDocumentInformation().getSubject();
this.title = pdf.getDocumentInformation().getTitle();
this.encrypted = pdf.isEncrypted();
PDSignature signature = pdf.getLastSignatureDictionary();
this.signed = signature != null;
this.signerName = signature == null ? null : signature.getName();
this.signatureTime = signature == null ? null : signature.getSignDate();
}
}
catch (Exception e) {
throw new IllegalArgumentException("Invalid PDF file: " + name, e);
}
}
开发者ID:codeborne,项目名称:pdf-test,代码行数:27,代码来源:PDF.java
示例4: PdfBoxDocTimestampInfo
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
/**
* @param validationCertPool
* @param dssDictionary
* the DSS dictionary
* @param cms
* the CMS (CAdES) bytes
* @param isArchiveTimestamp
* @param inputStream
* the stream of the whole signed document
* @throws DSSException
*/
PdfBoxDocTimestampInfo(CertificatePool validationCertPool, PDSignature signature, PdfDict dictionary, PdfDssDict dssDictionary, byte[] cms, byte[] signedContent,
boolean isArchiveTimestamp) throws DSSException {
super(signature, dictionary, dssDictionary, cms, signedContent);
try {
TimestampType timestampType = TimestampType.SIGNATURE_TIMESTAMP;
if (isArchiveTimestamp) {
timestampType = TimestampType.ARCHIVE_TIMESTAMP;
}
timestampToken = new TimestampToken(cms, timestampType, validationCertPool);
content = cms;
LOG.debug("Created PdfBoxDocTimestampInfo {} : {}", timestampType, uniqueId());
} catch (Exception e) {
throw new DSSException(e);
}
}
开发者ID:esig,项目名称:dss,代码行数:27,代码来源:PdfBoxDocTimestampInfo.java
示例5: digest
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
@Override
public byte[] digest(final InputStream toSignDocument, final PAdESSignatureParameters parameters, final DigestAlgorithm digestAlgorithm)
throws DSSException {
final byte[] signatureValue = DSSUtils.EMPTY_BYTE_ARRAY;
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PDDocument pdDocument = null;
try {
pdDocument = PDDocument.load(toSignDocument);
PDSignature pdSignature = createSignatureDictionary(parameters, pdDocument);
return signDocumentAndReturnDigest(parameters, signatureValue, outputStream, pdDocument, pdSignature, digestAlgorithm);
} catch (IOException e) {
throw new DSSException(e);
} finally {
Utils.closeQuietly(pdDocument);
Utils.closeQuietly(outputStream);
}
}
开发者ID:esig,项目名称:dss,代码行数:20,代码来源:PdfBoxSignatureService.java
示例6: isDSSDictionaryPresentInPreviousRevision
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
private boolean isDSSDictionaryPresentInPreviousRevision(byte[] originalBytes) {
PDDocument doc = null;
PdfDssDict dssDictionary = null;
try {
doc = PDDocument.load(originalBytes);
List<PDSignature> pdSignatures = doc.getSignatureDictionaries();
if (Utils.isCollectionNotEmpty(pdSignatures)) {
PdfDict catalog = new PdfBoxDict(doc.getDocumentCatalog().getCOSObject(), doc);
dssDictionary = PdfDssDict.extract(catalog);
}
} catch (Exception e) {
LOG.warn("Cannot check in previous revisions if DSS dictionary already exist : " + e.getMessage(), e);
} finally {
Utils.closeQuietly(doc);
}
return dssDictionary != null;
}
开发者ID:esig,项目名称:dss,代码行数:19,代码来源:PdfBoxSignatureService.java
示例7: getAvailableSignatureFields
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
@Override
public List<String> getAvailableSignatureFields(DSSDocument document) throws DSSException {
List<String> result = new ArrayList<String>();
try (InputStream is = document.openStream()) {
PDDocument pdfDoc = PDDocument.load(is);
List<PDSignatureField> signatureFields = pdfDoc.getSignatureFields();
for (PDSignatureField pdSignatureField : signatureFields) {
PDSignature signature = pdSignatureField.getSignature();
if (signature == null) {
result.add(pdSignatureField.getPartialName());
}
}
} catch (Exception e) {
throw new DSSException("Unable to determine signature fields", e);
}
return result;
}
开发者ID:esig,项目名称:dss,代码行数:18,代码来源:PdfBoxSignatureService.java
示例8: signDetached
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
void signDetached(byte[] pdf, OutputStream output, SignatureInterface signatureInterface)throws IOException, SignatureException, COSVisitorException
{
PDDocument document = PDDocument.load(new ByteArrayInputStream(pdf));
// create signature dictionary
PDSignature signature = new PDSignature();
signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
signature.setName("Example User");
signature.setLocation("Los Angeles, CA");
signature.setReason("Testing");
// TODO extract the above details from the signing certificate? Reason as a parameter?
// the signing date, needed for valid signature
signature.setSignDate(Calendar.getInstance());
// register signature dictionary and sign interface
document.addSignature(signature, signatureInterface);
// write incremental (only for signing purpose)
document.saveIncremental(new ByteArrayInputStream(pdf), output);
}
开发者ID:mkl-public,项目名称:testarea-pdfbox1,代码行数:22,代码来源:SignInMemory.java
示例9: testValidateSignatureVlidationTest
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
/**
* <a href="http://stackoverflow.com/questions/41116833/pdf-signature-validation">
* PDF Signature Validation
* </a>
* <br/>
* <a href="https://drive.google.com/file/d/0BzEmZ9pRWLhPOUJSYUdlRjg2eEU/view?usp=sharing">
* SignatureVlidationTest.pdf
* </a>
* <p>
* The code completely ignores the <b>SubFilter</b> of the signature.
* It is appropriate for signatures with <b>SubFilter</b> values
* <b>adbe.pkcs7.detached</b> and <b>ETSI.CAdES.detached</b>
* but will fail for signatures with <b>SubFilter</b> values
* <b>adbe.pkcs7.sha1</b> and <b>adbe.x509.rsa.sha1</b>.
* </p>
* <p>
* The example document has been signed with a signatures with
* <b>SubFilter</b> value <b>adbe.pkcs7.sha1</b>.
* </p>
*/
@Test
public void testValidateSignatureVlidationTest() throws Exception
{
System.out.println("\nValidate signature in SignatureVlidationTest.pdf; original code.");
byte[] pdfByte;
PDDocument pdfDoc = null;
SignerInformationVerifier verifier = null;
try
{
pdfByte = IOUtils.toByteArray(this.getClass().getResourceAsStream("SignatureVlidationTest.pdf"));
pdfDoc = PDDocument.load(new ByteArrayInputStream(pdfByte));
PDSignature signature = pdfDoc.getSignatureDictionaries().get(0);
byte[] signatureAsBytes = signature.getContents(pdfByte);
byte[] signedContentAsBytes = signature.getSignedContent(pdfByte);
CMSSignedData cms = new CMSSignedData(new CMSProcessableByteArray(signedContentAsBytes), signatureAsBytes);
SignerInformation signerInfo = (SignerInformation) cms.getSignerInfos().getSigners().iterator().next();
X509CertificateHolder cert = (X509CertificateHolder) cms.getCertificates().getMatches(signerInfo.getSID())
.iterator().next();
verifier = new JcaSimpleSignerInfoVerifierBuilder().setProvider(new BouncyCastleProvider()).build(cert);
// result if false
boolean verifyRt = signerInfo.verify(verifier);
System.out.println("Verify result: " + verifyRt);
}
finally
{
if (pdfDoc != null)
{
pdfDoc.close();
}
}
}
开发者ID:mkl-public,项目名称:testarea-pdfbox2,代码行数:54,代码来源:ValidateSignature.java
示例10: testValidateSignatureVlidationTestAdbePkcs7Sha1
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
/**
* <a href="http://stackoverflow.com/questions/41116833/pdf-signature-validation">
* PDF Signature Validation
* </a>
* <br/>
* <a href="https://drive.google.com/file/d/0BzEmZ9pRWLhPOUJSYUdlRjg2eEU/view?usp=sharing">
* SignatureVlidationTest.pdf
* </a>
* <p>
* This code also ignores the <b>SubFilter</b> of the signature,
* it is appropriate for signatures with <b>SubFilter</b> value
* <b>adbe.pkcs7.sha1</b> which the example document has been
* signed with.
* </p>
*/
@Test
public void testValidateSignatureVlidationTestAdbePkcs7Sha1() throws Exception
{
System.out.println("\nValidate signature in SignatureVlidationTest.pdf; special adbe.pkcs7.sha1 code.");
byte[] pdfByte;
PDDocument pdfDoc = null;
SignerInformationVerifier verifier = null;
try
{
pdfByte = IOUtils.toByteArray(this.getClass().getResourceAsStream("SignatureVlidationTest.pdf"));
pdfDoc = PDDocument.load(new ByteArrayInputStream(pdfByte));
PDSignature signature = pdfDoc.getSignatureDictionaries().get(0);
byte[] signatureAsBytes = signature.getContents(pdfByte);
CMSSignedData cms = new CMSSignedData(new ByteArrayInputStream(signatureAsBytes));
SignerInformation signerInfo = (SignerInformation) cms.getSignerInfos().getSigners().iterator().next();
X509CertificateHolder cert = (X509CertificateHolder) cms.getCertificates().getMatches(signerInfo.getSID())
.iterator().next();
verifier = new JcaSimpleSignerInfoVerifierBuilder().setProvider(new BouncyCastleProvider()).build(cert);
boolean verifyRt = signerInfo.verify(verifier);
System.out.println("Verify result: " + verifyRt);
byte[] signedContentAsBytes = signature.getSignedContent(pdfByte);
MessageDigest md = MessageDigest.getInstance("SHA1");
byte[] calculatedDigest = md.digest(signedContentAsBytes);
byte[] signedDigest = (byte[]) cms.getSignedContent().getContent();
System.out.println("Document digest equals: " + Arrays.equals(calculatedDigest, signedDigest));
}
finally
{
if (pdfDoc != null)
{
pdfDoc.close();
}
}
}
开发者ID:mkl-public,项目名称:testarea-pdfbox2,代码行数:53,代码来源:ValidateSignature.java
示例11: getFilter
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
@Override
protected COSName getFilter(PAdESSignatureParameters parameters) {
if (Utils.isStringNotEmpty(parameters.getTimestampFilter())) {
return COSName.getPDFName(parameters.getTimestampFilter());
}
return PDSignature.FILTER_ADOBE_PPKLITE;
}
开发者ID:esig,项目名称:dss,代码行数:8,代码来源:PdfBoxDocTimeStampService.java
示例12: PdfBoxCMSInfo
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
/**
*
* @param signature
* The signature object
* @param dssDictionary
* the DSS dictionary
* @param cms
* the signature binary
* @param signedContent
* the signed content
*/
PdfBoxCMSInfo(PDSignature signature, PdfDict dict, PdfDssDict dssDictionary, byte[] cms, byte[] signedContent) {
this.cms = cms;
this.location = signature.getLocation();
this.reason = signature.getReason();
this.contactInfo = signature.getContactInfo();
this.filter = signature.getFilter();
this.subFilter = signature.getSubFilter();
this.signingDate = signature.getSignDate() != null ? signature.getSignDate().getTime() : null;
this.signatureByteRange = signature.getByteRange();
this.signaturedictionary = dict;
this.dssDictionary = dssDictionary;
this.signedBytes = signedContent;
}
开发者ID:esig,项目名称:dss,代码行数:25,代码来源:PdfBoxCMSInfo.java
示例13: PdfBoxSignatureInfo
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
/**
* @param validationCertPool
* @param dssDictionary
* the DSS dictionary
* @param cms
* the CMS (CAdES) bytes
* @param originalBytes
* the original bytes of the whole signed document
* @throws IOException
*/
PdfBoxSignatureInfo(CertificatePool validationCertPool, PDSignature signature, PdfDict dictionary, PdfDssDict dssDictionary, byte[] cms, byte[] originalBytes)
throws IOException {
super(signature, dictionary, dssDictionary, cms, originalBytes);
try {
cades = new CAdESSignature(cms, validationCertPool);
content = cms;
final DSSDocument detachedContent = new InMemoryDocument(getSignedDocumentBytes());
cades.setDetachedContents(Arrays.asList(detachedContent));
} catch (CMSException e) {
throw new IOException(e);
}
}
开发者ID:esig,项目名称:dss,代码行数:23,代码来源:PdfBoxSignatureInfo.java
示例14: sign
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
@Override
public void sign(final InputStream pdfData, final byte[] signatureValue, final OutputStream signedStream, final PAdESSignatureParameters parameters,
final DigestAlgorithm digestAlgorithm) throws DSSException {
PDDocument pdDocument = null;
try {
pdDocument = PDDocument.load(pdfData);
final PDSignature pdSignature = createSignatureDictionary(parameters, pdDocument);
signDocumentAndReturnDigest(parameters, signatureValue, signedStream, pdDocument, pdSignature, digestAlgorithm);
} catch (IOException e) {
throw new DSSException(e);
} finally {
Utils.closeQuietly(pdDocument);
}
}
开发者ID:esig,项目名称:dss,代码行数:16,代码来源:PdfBoxSignatureService.java
示例15: signDocumentAndReturnDigest
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
private byte[] signDocumentAndReturnDigest(final PAdESSignatureParameters parameters, final byte[] signatureBytes, final OutputStream fileOutputStream,
final PDDocument pdDocument, final PDSignature pdSignature, final DigestAlgorithm digestAlgorithm) throws DSSException {
SignatureOptions options = new SignatureOptions();
try {
final MessageDigest digest = DSSUtils.getMessageDigest(digestAlgorithm);
// register signature dictionary and sign interface
SignatureInterface signatureInterface = new SignatureInterface() {
@Override
public byte[] sign(InputStream content) throws IOException {
byte[] b = new byte[4096];
int count;
while ((count = content.read(b)) > 0) {
digest.update(b, 0, count);
}
return signatureBytes;
}
};
options.setPreferredSignatureSize(parameters.getSignatureSize());
fillImageParameters(pdDocument, parameters, options);
pdDocument.addSignature(pdSignature, signatureInterface, options);
saveDocumentIncrementally(parameters, fileOutputStream, pdDocument);
final byte[] digestValue = digest.digest();
if (LOG.isDebugEnabled()) {
LOG.debug("Digest to be signed: " + Utils.toHex(digestValue));
}
return digestValue;
} catch (IOException e) {
throw new DSSException(e);
} finally {
Utils.closeQuietly(options.getVisualSignature());
}
}
开发者ID:esig,项目名称:dss,代码行数:39,代码来源:PdfBoxSignatureService.java
示例16: getFilter
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
protected COSName getFilter(PAdESSignatureParameters parameters) {
if (Utils.isStringNotEmpty(parameters.getSignatureFilter())) {
return COSName.getPDFName(parameters.getSignatureFilter());
}
return PDSignature.FILTER_ADOBE_PPKLITE;
}
开发者ID:esig,项目名称:dss,代码行数:7,代码来源:PdfBoxSignatureService.java
示例17: getSubFilter
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
protected COSName getSubFilter(PAdESSignatureParameters parameters) {
if (Utils.isStringNotEmpty(parameters.getSignatureSubFilter())) {
return COSName.getPDFName(parameters.getSignatureSubFilter());
}
return PDSignature.SUBFILTER_ETSI_CADES_DETACHED;
}
开发者ID:esig,项目名称:dss,代码行数:7,代码来源:PdfBoxSignatureService.java
示例18: vri
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
@Test
public void vri() throws Exception {
String path = "src/test/resources/plugtest/esig2014/ESIG-PAdES/HU_MIC/Signature-P-HU_MIC-3.pdf";
String vriValue = "C41B1DBFE0E816D8A6F99A9DB98FD43960A5CF45";
PDDocument pdDoc = PDDocument.load(new FileInputStream(path));
List<PDSignature> signatureDictionaries = pdDoc.getSignatureDictionaries();
assertTrue(Utils.isCollectionNotEmpty(signatureDictionaries));
PDSignature pdSignature = signatureDictionaries.get(0);
byte[] contents = pdSignature.getContents(new FileInputStream(path));
byte[] digest = DSSUtils.digest(DigestAlgorithm.SHA1, contents);
assertEquals(vriValue, Utils.upperCase(Utils.toHex(digest)));
// We can't use CMSSignedData, the pdSignature content is trimmed (000000)
}
开发者ID:esig,项目名称:dss,代码行数:16,代码来源:VRITest.java
示例19: signPdf
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
boolean signPdf(File pdfFile, File signedPdfFile) {
try (
FileInputStream fis1 = new FileInputStream(pdfFile);
FileOutputStream fos = new FileOutputStream(signedPdfFile);
FileInputStream fis = new FileInputStream(fixed ? signedPdfFile : pdfFile);
PDDocument doc = PDDocument.load(pdfFile)) {
int readCount;
byte[] buffer = new byte[8 * 1024];
while ((readCount = fis1.read(buffer)) != -1) {
fos.write(buffer, 0, readCount);
}
PDSignature signature = new PDSignature();
signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
signature.setName("NAME");
signature.setLocation("LOCATION");
signature.setReason("REASON");
signature.setSignDate(Calendar.getInstance());
doc.addSignature(signature, this);
doc.saveIncremental(fis, fos);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
开发者ID:mkl-public,项目名称:testarea-pdfbox1,代码行数:29,代码来源:CreateSignature.java
示例20: doSignOneStep
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; //导入依赖的package包/类
/**
* {@link #doSignOriginal(InputStream, InputStream, File)} changed to add the image and sign at the same time.
*/
public void doSignOneStep(InputStream inputStream, InputStream logoStream, File outputDocument) throws Exception
{
byte inputBytes[] = IOUtils.toByteArray(inputStream);
PDDocument pdDocument = PDDocument.load(new ByteArrayInputStream(inputBytes));
PDJpeg ximage = new PDJpeg(pdDocument, ImageIO.read(logoStream));
PDPage page = (PDPage) pdDocument.getDocumentCatalog().getAllPages().get(0);
PDPageContentStream contentStream = new PDPageContentStream(pdDocument, page, true, true);
contentStream.drawXObject(ximage, 50, 50, 356, 40);
contentStream.close();
page.getResources().getCOSObject().setNeedToBeUpdate(true);
page.getResources().getCOSDictionary().getDictionaryObject(COSName.XOBJECT).setNeedToBeUpdate(true);
ximage.getCOSObject().setNeedToBeUpdate(true);
PDSignature signature = new PDSignature();
signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
signature.setName("signer name");
signature.setLocation("signer location");
signature.setReason("reason for signature");
signature.setSignDate(Calendar.getInstance());
pdDocument.addSignature(signature, new TC3());
FileOutputStream fos = new FileOutputStream(outputDocument);
fos.write(inputBytes);
FileInputStream is = new FileInputStream(outputDocument);
pdDocument.saveIncremental(is, fos);
}
开发者ID:mkl-public,项目名称:testarea-pdfbox1,代码行数:35,代码来源:SignLikeUnOriginalToo.java
注:本文中的org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论