use of org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties in project camel by apache.
the class XAdESSignaturePropertiesTest method testExceptionSigPolicyDigestMissing.
private void testExceptionSigPolicyDigestMissing(String value) throws InterruptedException, Exception {
MockEndpoint mock = getMockEndpoint("mock:exception");
mock.expectedMessageCount(1);
XmlSignerEndpoint endpoint = getSignerEndpoint();
XAdESSignatureProperties props = (XAdESSignatureProperties) endpoint.getProperties();
props.setSignaturePolicyDigestValue(value);
sendBody("direct:enveloping", payload, Collections.<String, Object>emptyMap());
assertMockEndpointsSatisfied();
checkThrownException(mock, XmlSignatureException.class, "The XAdES-EPES confguration is invalid. The digest value for the signature policy is missing.", null);
}
use of org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties in project camel by apache.
the class XAdESSignaturePropertiesTest method noSigningCertificate.
@Test
public void noSigningCertificate() throws Exception {
XmlSignerEndpoint endpoint = getSignerEndpoint();
XAdESSignatureProperties newProps = new XAdESSignatureProperties();
newProps.setAddSigningTime(true);
endpoint.setProperties(newProps);
Document doc = testEnveloping();
Map<String, String> prefix2Namespace = getPrefix2NamespaceMap();
String pathToSignatureProperties = getPathToSignatureProperties();
checkNode(doc, pathToSignatureProperties + "etsi:SigningTime", prefix2Namespace, true);
checkNode(doc, pathToSignatureProperties + "etsi:SigningCertificate", prefix2Namespace, false);
}
use of org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties in project camel by apache.
the class XAdESSignaturePropertiesTest method prefixAndNamespace.
@Test
public void prefixAndNamespace() throws Exception {
XmlSignerEndpoint endpoint = getSignerEndpoint();
XAdESSignatureProperties props = (XAdESSignatureProperties) endpoint.getProperties();
props.setPrefix("p");
props.setNamespace(XAdESSignatureProperties.HTTP_URI_ETSI_ORG_01903_V1_1_1);
props.setCommitmentTypeIdDescription(null);
props.setCommitmentTypeIdDocumentationReferences(Collections.<String>emptyList());
props.setCommitmentTypeIdQualifier(null);
props.setDataObjectFormatIdentifierDescription(null);
props.setDataObjectFormatIdentifierDocumentationReferences(Collections.<String>emptyList());
props.setDataObjectFormatIdentifierQualifier(null);
props.setSigPolicyIdDescription(null);
props.setSigPolicyIdDocumentationReferences(Collections.<String>emptyList());
props.setSigPolicyIdQualifier(null);
// the following lists must be set to empty because otherwise they would contain XML fragments with a wrong namespace
props.setSigPolicyQualifiers(Collections.<String>emptyList());
props.setSignerClaimedRoles(Collections.<String>emptyList());
props.setCommitmentTypeQualifiers(Collections.<String>emptyList());
Document doc = testEnveloping();
Map<String, String> prefix2Namespace = new TreeMap<String, String>();
prefix2Namespace.put("ds", XMLSignature.XMLNS);
prefix2Namespace.put("etsi", XAdESSignatureProperties.HTTP_URI_ETSI_ORG_01903_V1_1_1);
XPathExpression expr = getXpath("/ds:Signature/ds:Object/etsi:QualifyingProperties", prefix2Namespace);
Object result = expr.evaluate(doc, XPathConstants.NODE);
assertNotNull(result);
Node node = (Node) result;
assertEquals("p", node.getPrefix());
assertEquals(XAdESSignatureProperties.HTTP_URI_ETSI_ORG_01903_V1_1_1, node.getNamespaceURI());
}
use of org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties in project camel by apache.
the class XAdESSignaturePropertiesTest method headers.
@Test
public void headers() throws Exception {
Map<String, Object> header = new TreeMap<String, Object>();
header.put(XmlSignatureConstants.HEADER_XADES_PREFIX, "ns1");
header.put(XmlSignatureConstants.HEADER_XADES_NAMESPACE, XAdESSignatureProperties.HTTP_URI_ETSI_ORG_01903_V1_2_2);
header.put(XmlSignatureConstants.HEADER_XADES_QUALIFYING_PROPERTIES_ID, "QualId");
header.put(XmlSignatureConstants.HEADER_XADES_SIGNED_DATA_OBJECT_PROPERTIES_ID, "ObjId");
header.put(XmlSignatureConstants.HEADER_XADES_SIGNED_SIGNATURE_PROPERTIES_ID, "SigId");
header.put(XmlSignatureConstants.HEADER_XADES_DATA_OBJECT_FORMAT_ENCODING, "base64");
XmlSignerEndpoint endpoint = getSignerEndpoint();
XAdESSignatureProperties props = (XAdESSignatureProperties) endpoint.getProperties();
// the following lists must be set to empty because otherwise they would contain XML fragments with a wrong namespace
props.setSigPolicyQualifiers(Collections.<String>emptyList());
props.setSignerClaimedRoles(Collections.<String>emptyList());
props.setCommitmentTypeQualifiers(Collections.<String>emptyList());
Document doc = testEnveloping("direct:enveloping", header);
Map<String, String> prefix2Namespace = new TreeMap<String, String>();
prefix2Namespace.put("ds", XMLSignature.XMLNS);
prefix2Namespace.put("etsi", XAdESSignatureProperties.HTTP_URI_ETSI_ORG_01903_V1_2_2);
XPathExpression expr = getXpath("/ds:Signature/ds:Object/etsi:QualifyingProperties", prefix2Namespace);
Object result = expr.evaluate(doc, XPathConstants.NODE);
assertNotNull(result);
Node node = (Node) result;
assertEquals("ns1", node.getPrefix());
assertEquals(XAdESSignatureProperties.HTTP_URI_ETSI_ORG_01903_V1_2_2, node.getNamespaceURI());
checkXpath(doc, "/ds:Signature/ds:Object/etsi:QualifyingProperties/@Id", prefix2Namespace, "QualId");
checkXpath(doc, "/ds:Signature/ds:Object/etsi:QualifyingProperties/etsi:SignedProperties/etsi:SignedDataObjectProperties/@Id", prefix2Namespace, "ObjId");
checkXpath(doc, "/ds:Signature/ds:Object/etsi:QualifyingProperties/etsi:SignedProperties/etsi:SignedSignatureProperties/@Id", prefix2Namespace, "SigId");
checkXpath(doc, "/ds:Signature/ds:Object/etsi:QualifyingProperties/etsi:SignedProperties/etsi:SignedDataObjectProperties/etsi:DataObjectFormat/etsi:Encoding/text()", prefix2Namespace, "base64");
}
use of org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties in project camel by apache.
the class XAdESSignaturePropertiesTest method policyImplied.
@Test
public void policyImplied() throws Exception {
XmlSignerEndpoint endpoint = getSignerEndpoint();
XAdESSignatureProperties props = (XAdESSignatureProperties) endpoint.getProperties();
props.setSignaturePolicy(XAdESSignatureProperties.SIG_POLICY_IMPLIED);
Document doc = testEnveloping();
String pathToSignatureProperties = getPathToSignatureProperties();
checkNode(doc, pathToSignatureProperties + "etsi:SignaturePolicyIdentifier/etsi:SignaturePolicyId", getPrefix2NamespaceMap(), false);
checkNode(doc, pathToSignatureProperties + "etsi:SignaturePolicyIdentifier/etsi:SignaturePolicyImplied", getPrefix2NamespaceMap(), true);
}
Aggregations