Search in sources :

Example 11 with XAdESSignatureProperties

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

the class XAdESSignaturePropertiesTest method invalidXmlFragmentForClaimedRole.

@Test
public void invalidXmlFragmentForClaimedRole() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:exception");
    mock.expectedMessageCount(1);
    XmlSignerEndpoint endpoint = getSignerEndpoint();
    XAdESSignatureProperties props = (XAdESSignatureProperties) endpoint.getProperties();
    // Element 'ClaimedRole' is not closed correctly
    props.setSignerClaimedRoles(Collections.singletonList("<ClaimedRole>wrong XML fragment<ClaimedRole>"));
    sendBody("direct:enveloping", payload, Collections.<String, Object>emptyMap());
    assertMockEndpointsSatisfied();
    checkThrownException(mock, XmlSignatureException.class, "The XAdES confguration is invalid. The list of the claimed roles contains the invalid entry '<ClaimedRole>wrong XML fragment<ClaimedRole>'. An entry must either be a text or" + " an XML fragment with the root element 'ClaimedRole' 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 12 with XAdESSignatureProperties

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

the class XAdESSignaturePropertiesTest method testExceptionSigPolicyDigestAlgoMissing.

private void testExceptionSigPolicyDigestAlgoMissing(String value) throws InterruptedException, Exception {
    MockEndpoint mock = getMockEndpoint("mock:exception");
    mock.expectedMessageCount(1);
    XmlSignerEndpoint endpoint = getSignerEndpoint();
    XAdESSignatureProperties props = (XAdESSignatureProperties) endpoint.getProperties();
    props.setSignaturePolicyDigestAlgorithm(value);
    sendBody("direct:enveloping", payload, Collections.<String, Object>emptyMap());
    assertMockEndpointsSatisfied();
    checkThrownException(mock, XmlSignatureException.class, "The XAdES-EPES confguration is invalid. The digest algorithm for the signature policy is missing.", 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)

Example 13 with XAdESSignatureProperties

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

the class XAdESSignaturePropertiesTest method allPropertiesEmpty.

@Test
public void allPropertiesEmpty() throws Exception {
    XmlSignerEndpoint endpoint = getSignerEndpoint();
    XAdESSignatureProperties props = new XAdESSignatureProperties();
    props.setAddSigningTime(false);
    props.setCommitmentTypeId("");
    props.setCommitmentTypeIdDescription("");
    props.setCommitmentTypeIdQualifier("");
    props.setDataObjectFormatDescription("");
    props.setDataObjectFormatIdentifier("");
    props.setDataObjectFormatIdentifierDescription("");
    props.setDataObjectFormatIdentifierQualifier("");
    props.setDataObjectFormatMimeType("");
    props.setDigestAlgorithmForSigningCertificate("");
    props.setSignaturePolicy("None");
    props.setSigPolicyId("");
    props.setSigPolicyIdDescription("");
    props.setSigPolicyIdQualifier("");
    props.setSignaturePolicyDigestAlgorithm("");
    props.setSignaturePolicyDigestValue("");
    props.setSignatureProductionPlaceCity("");
    props.setSignatureProductionPlaceCountryName("");
    props.setSignatureProductionPlacePostalCode("");
    props.setSignatureProductionPlaceStateOrProvince("");
    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 14 with XAdESSignatureProperties

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

the class XAdESSignaturePropertiesTest method testExceptionSigPolicyIdMissing.

private void testExceptionSigPolicyIdMissing(String value) throws InterruptedException, Exception {
    MockEndpoint mock = getMockEndpoint("mock:exception");
    mock.expectedMessageCount(1);
    XmlSignerEndpoint endpoint = getSignerEndpoint();
    XAdESSignatureProperties props = (XAdESSignatureProperties) endpoint.getProperties();
    props.setSigPolicyId(value);
    sendBody("direct:enveloping", payload, Collections.<String, Object>emptyMap());
    assertMockEndpointsSatisfied();
    checkThrownException(mock, XmlSignatureException.class, "The XAdES-EPES confguration is invalid. The signature policy identifier is missing.", 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)

Example 15 with XAdESSignatureProperties

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

the class XAdESSignaturePropertiesTest method invalidXmlFragmentForCommitmentTypeQualifier.

@Test
public void invalidXmlFragmentForCommitmentTypeQualifier() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:exception");
    mock.expectedMessageCount(1);
    XmlSignerEndpoint endpoint = getSignerEndpoint();
    XAdESSignatureProperties props = (XAdESSignatureProperties) endpoint.getProperties();
    // end tag is not correct
    props.setCommitmentTypeQualifiers(Collections.singletonList("<CommitmentTypeQualifier>wrong XML fragment<CommitmentTypeQualifier>"));
    sendBody("direct:enveloping", payload, Collections.<String, Object>emptyMap());
    assertMockEndpointsSatisfied();
    checkThrownException(mock, XmlSignatureException.class, "The XAdES confguration is invalid. The list of the commitment type qualifiers contains the invalid entry '<CommitmentTypeQualifier>wrong XML fragment<CommitmentTypeQualifier>'." + " An entry must either be a text or an XML fragment with the root element 'CommitmentTypeQualifier' 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)

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