use of org.apache.cxf.ws.policy.PolicyException in project cxf by apache.
the class AbstractPolicySecurityTest method runInInterceptorAndValidate.
protected void runInInterceptorAndValidate(Document document, Policy policy, List<QName> assertedInAssertions, List<QName> notAssertedInAssertions, List<CoverageType> types) throws Exception {
final AssertionInfoMap aim = new AssertionInfoMap(policy);
this.runInInterceptorAndValidateWss(document, aim, types);
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);
}
}
}
}
}
use of org.apache.cxf.ws.policy.PolicyException in project cxf by apache.
the class DomainExpressionBuilderRegistry method build.
public DomainExpression build(Element element) {
loadDynamic();
DomainExpressionBuilder builder;
QName qname = new QName(element.getNamespaceURI(), element.getLocalName());
builder = get(qname);
if (null == builder) {
throw new PolicyException(new Message("NO_DOMAINEXPRESSIONBUILDER_EXC", BUNDLE, qname.toString()));
}
return builder.build(element);
}
use of org.apache.cxf.ws.policy.PolicyException in project cxf by apache.
the class EndpointReferenceDomainExpressionBuilder method build.
public DomainExpression build(Element e) {
Object obj = null;
try {
obj = JAXBUtils.unmarshall(createJAXBContext(), e);
} catch (JAXBException ex) {
throw new PolicyException(new Message("EPR_DOMAIN_EXPRESSION_BUILD_EXC", BUNDLE, (Object[]) null), ex);
}
if (obj instanceof JAXBElement<?>) {
JAXBElement<?> el = (JAXBElement<?>) obj;
obj = el.getValue();
}
EndpointReferenceDomainExpression eprde = new EndpointReferenceDomainExpression();
eprde.setEndpointReference((EndpointReferenceType) obj);
return eprde;
}
use of org.apache.cxf.ws.policy.PolicyException in project cxf by apache.
the class EndpointReferenceDomainExpressionBuilder method createJAXBContext.
protected synchronized JAXBContext createJAXBContext() {
if (context == null) {
try {
Class<?> clz = EndpointReferenceType.class;
String pkg = PackageUtils.getPackageName(clz);
context = JAXBContext.newInstance(pkg, clz.getClassLoader());
} catch (JAXBException ex) {
throw new PolicyException(new Message("EPR_DOMAIN_EXPRESSION_BUILDER_INIT_EXC", BUNDLE, (Object[]) null), ex);
}
}
return context;
}
use of org.apache.cxf.ws.policy.PolicyException in project cxf by apache.
the class RemoteReferenceResolver method resolveReference.
public Policy resolveReference(String uri) {
int pos = uri.indexOf('#');
String documentURI = pos == -1 ? uri : uri.substring(0, pos);
ExtendedURIResolver resolver = new ExtendedURIResolver();
InputSource is = resolver.resolve(documentURI, baseURI);
if (null == is) {
return null;
}
Document doc = null;
try {
doc = StaxUtils.read(is.getByteStream());
} catch (Exception ex) {
throw new PolicyException(ex);
} finally {
resolver.close();
}
if (pos == -1) {
return builder.getPolicy(doc.getDocumentElement());
}
String id = uri.substring(pos + 1);
for (Element elem : PolicyConstants.findAllPolicyElementsOfLocalName(doc, Constants.ELEM_POLICY)) {
if (id.equals(elem.getAttributeNS(PolicyConstants.WSU_NAMESPACE_URI, PolicyConstants.WSU_ID_ATTR_NAME))) {
return builder.getPolicy(elem);
}
}
return null;
}
Aggregations