### Question:
ExternalSigner implements SignatureToken { @Override public X509Certificate getCertificate() { return this.signingCertificate; } ExternalSigner(X509Certificate signingCertificate); @Override X509Certificate getCertificate();  }### Answer:
@Test public void testGetCertificate() throws Exception { X509Certificate certificate = DSSUtils.loadCertificate(Base64.decodeBase64(Certificates.SIGNING_CERTIFICATE)).getCertificate(); ExternalSigner externalSigner = new ExternalSigner(certificate) { @Override public byte[] sign(DigestAlgorithm digestAlgorithm, byte[] dataToSign) { return new byte[0]; } }; Assert.assertEquals(Certificates.SIGNING_CERTIFICATE, Base64.encodeBase64String(externalSigner.getCertificate().getEncoded())); }
@Test @Ignore public void testAsyncSigning() { Container container = this.createNonEmptyContainer(); DataToSign dataToSign = SignatureBuilder.aSignature(container).withSigningCertificate(this.pkcs12SignatureToken.getCertificate()). buildDataToSign(); String containerFile = this.getFileBy("bin"); String dataToSignFile = this.getFileBy("bin"); Helper.serialize(container, containerFile); Helper.serialize(dataToSign, dataToSignFile); byte[] signatureValue = this.getExternalSignatureToken().sign(dataToSign.getDigestAlgorithm(), dataToSign.getDataToSign()); container = Helper.deserializer(containerFile); dataToSign = Helper.deserializer(dataToSignFile); Signature signature = dataToSign.finalize(signatureValue); container.addSignature(signature); container.saveAsFile(this.getFileBy("bdoc")); }