Search in sources :

Example 21 with PolicyException

use of org.apache.cxf.ws.policy.PolicyException in project cxf by apache.

the class PluggablePolicyValidatorTest method runInInterceptorAndValidate.

private void runInInterceptorAndValidate(String document, String policyDocument, List<QName> assertedInAssertions, List<QName> notAssertedInAssertions, List<CoverageType> types, Map<QName, SecurityPolicyValidator> validators) throws Exception {
    final Policy policy = this.policyBuilder.getPolicy(this.readDocument(policyDocument).getDocumentElement());
    final Document doc = this.readDocument(document);
    final AssertionInfoMap aim = new AssertionInfoMap(policy);
    this.runInInterceptorAndValidateWss(doc, aim, types, validators);
    try {
        aim.checkEffectivePolicy(policy);
    } catch (PolicyException e) {
    // Expected but not relevant
    } finally {
        if (assertedInAssertions != null) {
            for (QName assertionType : assertedInAssertions) {
                Collection<AssertionInfo> ais = aim.get(assertionType);
                assertNotNull(ais);
                for (AssertionInfo ai : ais) {
                    checkAssertion(aim, assertionType, ai, true);
                }
            }
        }
        if (notAssertedInAssertions != null) {
            for (QName assertionType : notAssertedInAssertions) {
                Collection<AssertionInfo> ais = aim.get(assertionType);
                assertNotNull(ais);
                for (AssertionInfo ai : ais) {
                    checkAssertion(aim, assertionType, ai, false);
                }
            }
        }
    }
}
Also used : Policy(org.apache.neethi.Policy) AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) PolicyException(org.apache.cxf.ws.policy.PolicyException) QName(javax.xml.namespace.QName) Document(org.w3c.dom.Document) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap)

Aggregations

PolicyException (org.apache.cxf.ws.policy.PolicyException)21 AssertionInfo (org.apache.cxf.ws.policy.AssertionInfo)8 Test (org.junit.Test)8 AssertionInfoMap (org.apache.cxf.ws.policy.AssertionInfoMap)7 Message (org.apache.cxf.common.i18n.Message)6 Policy (org.apache.neethi.Policy)6 QName (javax.xml.namespace.QName)5 Element (org.w3c.dom.Element)4 URL (java.net.URL)3 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)3 Document (org.w3c.dom.Document)3 FileNotFoundException (java.io.FileNotFoundException)2 JAXBException (javax.xml.bind.JAXBException)2 UrlResource (org.springframework.core.io.UrlResource)2 Closeable (java.io.Closeable)1 InputStream (java.io.InputStream)1 MalformedURLException (java.net.MalformedURLException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 JAXBElement (javax.xml.bind.JAXBElement)1 SOAPMessage (javax.xml.soap.SOAPMessage)1