use of xades4j.providers.SignaturePolicyInfoProvider in project xades4j by luisgoncalves.
the class SignerEPESTest method testSignEPES.
@Test
public void testSignEPES() throws Exception {
System.out.printf("signEPES: %s", locationUrl);
System.out.println();
Document doc = getTestDocument();
Element elemToSign = doc.getDocumentElement();
SignaturePolicyInfoProvider policyInfoProvider = new SignaturePolicyInfoProvider() {
@Override
public SignaturePolicyBase getSignaturePolicy() {
return new SignaturePolicyIdentifierProperty(new ObjectIdentifier("oid:/1.2.4.0.9.4.5", IdentifierType.OIDAsURI, "Policy description"), new ByteArrayInputStream("Test policy input stream".getBytes())).withLocationUrl(locationUrl);
}
};
SignerEPES signer = (SignerEPES) new XadesEpesSigningProfile(keyingProviderMy, policyInfoProvider).newSigner();
new Enveloped(signer).sign(elemToSign);
outputDocument(doc, output);
}
use of xades4j.providers.SignaturePolicyInfoProvider in project xades4j by luisgoncalves.
the class SignerTTest method testSignTWithPolicy.
@Test
public void testSignTWithPolicy() throws Exception {
System.out.println("signTWithPolicy");
Document doc = getTestDocument();
Element elemToSign = doc.getDocumentElement();
SignerT signer = (SignerT) new XadesTSigningProfile(keyingProviderMy).withPolicyProvider(new SignaturePolicyInfoProvider() {
@Override
public SignaturePolicyBase getSignaturePolicy() {
return new SignaturePolicyImpliedProperty();
}
}).newSigner();
new Enveloped(signer).sign(elemToSign);
outputDocument(doc, "document.signed.t.epes.xml");
}
Aggregations