package eu.europa.esig.dss.pades.signature; import java.io.File; import java.util.Date; import org.junit.Before; import eu.europa.esig.dss.DSSDocument; import eu.europa.esig.dss.DigestAlgorithm; import eu.europa.esig.dss.EncryptionAlgorithm; import eu.europa.esig.dss.FileDocument; import eu.europa.esig.dss.MimeType; import eu.europa.esig.dss.SignatureAlgorithm; import eu.europa.esig.dss.SignatureLevel; import eu.europa.esig.dss.pades.PAdESSignatureParameters; import eu.europa.esig.dss.signature.DocumentSignatureService; import eu.europa.esig.dss.test.gen.CertificateService; import eu.europa.esig.dss.test.mock.MockPrivateKeyEntry; import eu.europa.esig.dss.validation.CertificateVerifier; import eu.europa.esig.dss.validation.CommonCertificateVerifier; public class PAdESLevelBWithECDSATest extends AbstractPAdESTestSignature { private DocumentSignatureService<PAdESSignatureParameters> service; private PAdESSignatureParameters signatureParameters; private DSSDocument documentToSign; private MockPrivateKeyEntry privateKeyEntry; @Before public void init() throws Exception { documentToSign = new FileDocument(new File("src/test/resources/sample.pdf")); CertificateService certificateService = new CertificateService(); privateKeyEntry = certificateService.generateCertificateChain(SignatureAlgorithm.ECDSA_SHA256); signatureParameters = new PAdESSignatureParameters(); signatureParameters.bLevel().setSigningDate(new Date()); signatureParameters.setSigningCertificate(privateKeyEntry.getCertificate()); signatureParameters.setCertificateChain(privateKeyEntry.getCertificateChain()); signatureParameters.setSignatureLevel(SignatureLevel.PAdES_BASELINE_B); signatureParameters.setEncryptionAlgorithm(EncryptionAlgorithm.ECDSA); signatureParameters.setDigestAlgorithm(DigestAlgorithm.SHA256); signatureParameters.setLocation("Luxembourg"); signatureParameters.setReason("DSS testing"); signatureParameters.setContactInfo("Jira"); CertificateVerifier certificateVerifier = new CommonCertificateVerifier(); service = new PAdESService(certificateVerifier); } @Override protected DocumentSignatureService<PAdESSignatureParameters> getService() { return service; } @Override protected PAdESSignatureParameters getSignatureParameters() { return signatureParameters; } @Override protected MimeType getExpectedMime() { return MimeType.PDF; } @Override protected boolean isBaselineT() { return false; } @Override protected boolean isBaselineLTA() { return false; } @Override protected DSSDocument getDocumentToSign() { return documentToSign; } @Override protected MockPrivateKeyEntry getPrivateKeyEntry() { return privateKeyEntry; } }