Search in sources :

Example 6 with XAdESSignatureProperties

use of org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties in project camel by apache.

the class XAdESSignaturePropertiesTest method noPropertiesSpecified.

@Test
public void noPropertiesSpecified() throws Exception {
    XmlSignerEndpoint endpoint = getSignerEndpoint();
    XAdESSignatureProperties props = new XAdESSignatureProperties();
    props.setAddSigningTime(false);
    endpoint.setProperties(props);
    Document doc = testEnveloping();
    // expecting no Qualifying Properties
    checkNode(doc, "/ds:Signature/ds:Object/etsi:QualifyingProperties", getPrefix2NamespaceMap(), false);
}
Also used : XAdESSignatureProperties(org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties) DefaultXAdESSignatureProperties(org.apache.camel.component.xmlsecurity.api.DefaultXAdESSignatureProperties) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 7 with XAdESSignatureProperties

use of org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties in project camel by apache.

the class XAdESSignaturePropertiesTest method invalidXmlFragmentForSigPolicyQualifier.

@Test
public void invalidXmlFragmentForSigPolicyQualifier() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:exception");
    mock.expectedMessageCount(1);
    XmlSignerEndpoint endpoint = getSignerEndpoint();
    XAdESSignatureProperties props = (XAdESSignatureProperties) endpoint.getProperties();
    // end tag is not correct
    props.setSigPolicyQualifiers(Collections.singletonList("<SigPolicyQualifier>wrong XML fragment<SigPolicyQualifier>"));
    sendBody("direct:enveloping", payload, Collections.<String, Object>emptyMap());
    assertMockEndpointsSatisfied();
    checkThrownException(mock, XmlSignatureException.class, "The XAdES confguration is invalid. The list of the signatue policy qualifiers contains the invalid entry '<SigPolicyQualifier>wrong XML fragment<SigPolicyQualifier>'." + " An entry must either be a text or an XML fragment with the root element 'SigPolicyQualifier' with the namespace 'http://uri.etsi.org/01903/v1.3.2#'.", null);
}
Also used : XAdESSignatureProperties(org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties) DefaultXAdESSignatureProperties(org.apache.camel.component.xmlsecurity.api.DefaultXAdESSignatureProperties) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 8 with XAdESSignatureProperties

use of org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties in project camel by apache.

the class XAdESSignaturePropertiesTest method noSigningTime.

@Test
public void noSigningTime() throws Exception {
    XmlSignerEndpoint endpoint = getSignerEndpoint();
    XAdESSignatureProperties props = (XAdESSignatureProperties) endpoint.getProperties();
    props.setAddSigningTime(false);
    Document doc = testEnveloping();
    Map<String, String> prefix2Namespace = getPrefix2NamespaceMap();
    String pathToSignatureProperties = getPathToSignatureProperties();
    checkNode(doc, pathToSignatureProperties + "etsi:SigningTime", prefix2Namespace, false);
}
Also used : XAdESSignatureProperties(org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties) DefaultXAdESSignatureProperties(org.apache.camel.component.xmlsecurity.api.DefaultXAdESSignatureProperties) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 9 with XAdESSignatureProperties

use of org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties in project camel by apache.

the class XAdESSignaturePropertiesTest method invalidNamespaceForTheRootElementInXmlFragmentForSigPolicyQualifier.

@Test
public void invalidNamespaceForTheRootElementInXmlFragmentForSigPolicyQualifier() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:exception");
    mock.expectedMessageCount(1);
    XmlSignerEndpoint endpoint = getSignerEndpoint();
    XAdESSignatureProperties props = (XAdESSignatureProperties) endpoint.getProperties();
    props.setSigPolicyQualifiers(Collections.singletonList("<SigPolicyQualifier xmlns=\"http://invalid.com\">XML fragment with wrong namespace for root element</SigPolicyQualifier>"));
    sendBody("direct:enveloping", payload, Collections.<String, Object>emptyMap());
    assertMockEndpointsSatisfied();
    checkThrownException(mock, XmlSignatureException.class, "The XAdES confguration is invalid. The root element 'SigPolicyQualifier' of the provided XML fragment " + "'<SigPolicyQualifier xmlns=\"http://invalid.com\">XML fragment with wrong namespace for root element</SigPolicyQualifier>' has the invalid namespace 'http://invalid.com'." + " The correct namespace is 'http://uri.etsi.org/01903/v1.3.2#'.", null);
}
Also used : XAdESSignatureProperties(org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties) DefaultXAdESSignatureProperties(org.apache.camel.component.xmlsecurity.api.DefaultXAdESSignatureProperties) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 10 with XAdESSignatureProperties

use of org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties in project camel by apache.

the class XAdESSignaturePropertiesTest method policyNone.

@Test
public void policyNone() throws Exception {
    XmlSignerEndpoint endpoint = getSignerEndpoint();
    XAdESSignatureProperties props = (XAdESSignatureProperties) endpoint.getProperties();
    props.setSignaturePolicy(XAdESSignatureProperties.SIG_POLICY_NONE);
    Document doc = testEnveloping();
    String pathToSignatureProperties = getPathToSignatureProperties();
    checkNode(doc, pathToSignatureProperties + "etsi:SignaturePolicyIdentifier", getPrefix2NamespaceMap(), false);
}
Also used : XAdESSignatureProperties(org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties) DefaultXAdESSignatureProperties(org.apache.camel.component.xmlsecurity.api.DefaultXAdESSignatureProperties) Document(org.w3c.dom.Document) Test(org.junit.Test)

Aggregations

DefaultXAdESSignatureProperties (org.apache.camel.component.xmlsecurity.api.DefaultXAdESSignatureProperties)15 XAdESSignatureProperties (org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties)15 Test (org.junit.Test)12 Document (org.w3c.dom.Document)8 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)7 TreeMap (java.util.TreeMap)2 XPathExpression (javax.xml.xpath.XPathExpression)2 Node (org.w3c.dom.Node)2