org.apache.neethi.PolicyReference Java Examples
The following examples show how to use
org.apache.neethi.PolicyReference.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PolicyEngineImpl.java From cxf with Apache License 2.0 | 6 votes |
void addAssertions(PolicyComponent pc, boolean includeOptional, Collection<Assertion> assertions) { if (Constants.TYPE_ASSERTION == pc.getType()) { Assertion a = (Assertion)pc; if (includeOptional || !a.isOptional()) { assertions.add((Assertion)pc); } return; } if (Constants.TYPE_POLICY_REF == pc.getType()) { PolicyReference pr = (PolicyReference)pc; pc = pr.normalize(registry, false); } PolicyOperator po = (PolicyOperator)pc; List<PolicyComponent> pcs = CastUtils.cast(po.getPolicyComponents(), PolicyComponent.class); for (PolicyComponent child : pcs) { addAssertions(child, includeOptional, assertions); } }
Example #2
Source File: Wsdl11AttachmentPolicyProvider.java From cxf with Apache License 2.0 | 6 votes |
Policy resolveLocal(PolicyReference ref, DescriptionInfo di) { String uri = ref.getURI().substring(1); String absoluteURI = di.getBaseURI(); if (absoluteURI == null) { absoluteURI = Integer.toString(di.hashCode()) + ref.getURI(); } else { absoluteURI = absoluteURI + ref.getURI(); } Policy resolved = registry.lookup(absoluteURI); if (null != resolved) { return resolved; } ReferenceResolver resolver = new LocalServiceModelReferenceResolver(di, builder); resolved = resolver.resolveReference(uri); if (null != resolved) { ref.setURI(absoluteURI); registry.register(absoluteURI, resolved); } return resolved; }
Example #3
Source File: Wsdl11AttachmentPolicyProvider.java From cxf with Apache License 2.0 | 5 votes |
Policy resolveReference(PolicyReference ref, DescriptionInfo di) { Policy p = null; if (isExternal(ref)) { String uri = di.getBaseURI(); if (uri == null) { uri = Integer.toString(di.hashCode()); } p = resolveExternal(ref, uri); } else { p = resolveLocal(ref, di); } checkResolved(ref, p); return p; }
Example #4
Source File: ExternalAttachmentProvider.java From cxf with Apache License 2.0 | 5 votes |
Policy resolveReference(PolicyReference ref, Document doc) { Policy p = null; if (isExternal(ref)) { p = resolveExternal(ref, doc.getBaseURI()); } else { p = resolveLocal(ref, doc); } checkResolved(ref, p); return p; }
Example #5
Source File: ExternalAttachmentProvider.java From cxf with Apache License 2.0 | 5 votes |
Policy resolveLocal(PolicyReference ref, Document doc) { String relativeURI = ref.getURI().substring(1); String absoluteURI = doc.getBaseURI() + ref.getURI(); Policy resolved = registry.lookup(absoluteURI); if (null != resolved) { return resolved; } ReferenceResolver resolver = new LocalDocumentReferenceResolver(doc, builder); resolved = resolver.resolveReference(relativeURI); if (null != resolved) { ref.setURI(absoluteURI); registry.register(absoluteURI, resolved); } return resolved; }
Example #6
Source File: AbstractPolicyProvider.java From cxf with Apache License 2.0 | 5 votes |
protected Policy resolveExternal(PolicyReference ref, String baseURI) { Policy resolved = registry.lookup(ref.getURI()); if (null != resolved) { return resolved; } ReferenceResolver resolver = new RemoteReferenceResolver(baseURI, builder); return resolver.resolveReference(ref.getURI()); }
Example #7
Source File: WSPolicyFeature.java From cxf with Apache License 2.0 | 5 votes |
Policy resolveReference(PolicyReference ref, PolicyBuilder builder, Bus bus, DescriptionInfo i) { Policy p = null; if (!ref.getURI().startsWith("#")) { String base = i == null ? null : i.getBaseURI(); p = resolveExternal(ref, base, bus); } else { p = resolveLocal(ref, bus, i); } if (null == p) { throw new PolicyException(new Message("UNRESOLVED_POLICY_REFERENCE_EXC", BUNDLE, ref.getURI())); } return p; }
Example #8
Source File: WSPolicyFeature.java From cxf with Apache License 2.0 | 5 votes |
protected Policy resolveExternal(PolicyReference ref, String baseURI, Bus bus) { PolicyBuilder builder = bus.getExtension(PolicyBuilder.class); ReferenceResolver resolver = new RemoteReferenceResolver(baseURI, builder); PolicyRegistry registry = bus.getExtension(PolicyEngine.class).getRegistry(); Policy resolved = registry.lookup(ref.getURI()); if (null != resolved) { return resolved; } return resolver.resolveReference(ref.getURI()); }
Example #9
Source File: PolicyBuilderTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testGetPolicyReference() throws Exception { String name = "/samples/test26.xml"; InputStream is = PolicyBuilderTest.class.getResourceAsStream(name); PolicyReference pr = builder.getPolicyReference(is); assertEquals("#PolicyA", pr.getURI()); name = "/samples/test27.xml"; is = PolicyBuilderTest.class.getResourceAsStream(name); pr = builder.getPolicyReference(is); assertEquals("http://sample.org/test.wsdl#PolicyA", pr.getURI()); }
Example #10
Source File: PolicyEngineTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testAddAssertions() { engine = new PolicyEngineImpl(); Collection<Assertion> assertions = new ArrayList<>(); Assertion a = control.createMock(Assertion.class); EasyMock.expect(a.getType()).andReturn(Constants.TYPE_ASSERTION); EasyMock.expect(a.isOptional()).andReturn(true); control.replay(); engine.addAssertions(a, false, assertions); assertTrue(assertions.isEmpty()); control.verify(); control.reset(); EasyMock.expect(a.getType()).andReturn(Constants.TYPE_ASSERTION); control.replay(); engine.addAssertions(a, true, assertions); assertEquals(1, assertions.size()); assertSame(a, assertions.iterator().next()); control.verify(); assertions.clear(); Policy p = new Policy(); a = new PrimitiveAssertion(new QName("http://x.y.z", "a")); p.addAssertion(a); // id has no # engine.getRegistry().register("ab", p); // local reference is an id + # PolicyReference pr = new PolicyReference(); pr.setURI("#ab"); engine.addAssertions(pr, false, assertions); assertEquals(1, assertions.size()); assertSame(a, assertions.iterator().next()); }
Example #11
Source File: AbstractPolicyProvider.java From cxf with Apache License 2.0 | 4 votes |
protected boolean isExternal(PolicyReference ref) { return !ref.getURI().startsWith("#"); }
Example #12
Source File: AbstractPolicyProvider.java From cxf with Apache License 2.0 | 4 votes |
protected void checkResolved(PolicyReference ref, Policy p) { if (null == p) { throw new PolicyException(new Message("UNRESOLVED_POLICY_REFERENCE_EXC", BUNDLE, ref.getURI())); } }
Example #13
Source File: PolicyBuilder.java From cxf with Apache License 2.0 | 2 votes |
/** * Creates a PolicyReference object from a DOM element. * * @param element the element * @return the PolicyReference object constructed from the element */ PolicyReference getPolicyReference(Object element);