use of org.apache.camel.component.xmlsecurity.api.DefaultXAdESSignatureProperties in project camel by apache.
the class XAdESSignaturePropertiesTest method getXmlSignatureProperties.
private static XmlSignatureProperties getXmlSignatureProperties(String alias) throws IOException, GeneralSecurityException {
DefaultXAdESSignatureProperties props = new DefaultXAdESSignatureProperties();
props.setKeystore(TestKeystore.getKeyStore());
props.setAlias(alias);
props.setAddSigningTime(true);
props.setDigestAlgorithmForSigningCertificate(DigestMethod.SHA256);
props.setSigningCertificateURIs(Collections.singletonList("http://certuri"));
// policy
props.setSignaturePolicy(XAdESSignatureProperties.SIG_POLICY_EXPLICIT_ID);
props.setSigPolicyId("1.2.840.113549.1.9.16.6.1");
props.setSigPolicyIdQualifier("OIDAsURN");
props.setSigPolicyIdDescription("invoice version 3.1");
props.setSignaturePolicyDigestAlgorithm(DigestMethod.SHA256);
props.setSignaturePolicyDigestValue("Ohixl6upD6av8N7pEvDABhEL6hM=");
props.setSigPolicyQualifiers(Arrays.asList(new String[] { "<SigPolicyQualifier xmlns=\"http://uri.etsi.org/01903/v1.3.2#\"><SPURI>http://test.com/sig.policy.pdf</SPURI><SPUserNotice><ExplicitText>display text</ExplicitText>" + "</SPUserNotice></SigPolicyQualifier>", "category B" }));
props.setSigPolicyIdDocumentationReferences(Arrays.asList(new String[] { "http://test.com/policy.doc.ref1.txt", "http://test.com/policy.doc.ref2.txt" }));
// production place
props.setSignatureProductionPlaceCity("Munich");
props.setSignatureProductionPlaceCountryName("Germany");
props.setSignatureProductionPlacePostalCode("80331");
props.setSignatureProductionPlaceStateOrProvince("Bavaria");
//role
props.setSignerClaimedRoles(Arrays.asList(new String[] { "test", "<a:ClaimedRole xmlns:a=\"http://uri.etsi.org/01903/v1.3.2#\"><TestRole>TestRole</TestRole></a:ClaimedRole>" }));
props.setSignerCertifiedRoles(Collections.singletonList(new XAdESEncapsulatedPKIData("Ahixl6upD6av8N7pEvDABhEL6hM=", "http://uri.etsi.org/01903/v1.2.2#DER", "IdCertifiedRole")));
// data object format
props.setDataObjectFormatDescription("invoice");
props.setDataObjectFormatMimeType("text/xml");
props.setDataObjectFormatIdentifier("1.2.840.113549.1.9.16.6.2");
props.setDataObjectFormatIdentifierQualifier("OIDAsURN");
props.setDataObjectFormatIdentifierDescription("identifier desc");
props.setDataObjectFormatIdentifierDocumentationReferences(Arrays.asList(new String[] { "http://test.com/dataobject.format.doc.ref1.txt", "http://test.com/dataobject.format.doc.ref2.txt" }));
//commitment
props.setCommitmentTypeId("1.2.840.113549.1.9.16.6.4");
props.setCommitmentTypeIdQualifier("OIDAsURI");
props.setCommitmentTypeIdDescription("description for commitment type ID");
props.setCommitmentTypeIdDocumentationReferences(Arrays.asList(new String[] { "http://test.com/commitment.ref1.txt", "http://test.com/commitment.ref2.txt" }));
props.setCommitmentTypeQualifiers(Arrays.asList(new String[] { "commitment qualifier", "<c:CommitmentTypeQualifier xmlns:c=\"http://uri.etsi.org/01903/v1.3.2#\"><C>c</C></c:CommitmentTypeQualifier>" }));
return props;
}
Aggregations