org.apache.cxf.service.model.BindingMessageInfo Java Examples
The following examples show how to use
org.apache.cxf.service.model.BindingMessageInfo.
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: SoapApiModelParser.java From syndesis with Apache License 2.0 | 6 votes |
private static DataShape getDataShape(BindingMessageInfo messageInfo) throws ParserException { // message is missing or doesn't have any headers and body parts, // probably only faults for output messages // TODO handle operation faults instead of letting CXF throw them as Exceptions if (messageInfo == null || (messageInfo.getExtensor(SoapBodyInfo.class) == null && messageInfo.getExtensor(SoapHeaderInfo.class) == null)) { return new DataShape.Builder().kind(DataShapeKinds.NONE).build(); } final BindingHelper bindingHelper; try { bindingHelper = new BindingHelper(messageInfo); } catch (ParserConfigurationException e) { throw new ParserException("Error creating XML Document parser: " + e.getMessage(), e); } return new DataShape.Builder() .kind(DataShapeKinds.XML_SCHEMA) .name(messageInfo.getMessageInfo().getName().getLocalPart()) .description(getMessageDescription(messageInfo)) .specification(bindingHelper.getSpecification()) .build(); }
Example #2
Source File: HeaderUtil.java From cxf with Apache License 2.0 | 6 votes |
private static Set<QName> getHeaderQNames(BindingMessageInfo bmi) { Set<QName> set = new HashSet<>(); List<MessagePartInfo> mps = bmi.getMessageInfo().getMessageParts(); List<ExtensibilityElement> extList = bmi.getExtensors(ExtensibilityElement.class); if (extList != null) { for (ExtensibilityElement ext : extList) { if (SOAPBindingUtil.isSOAPHeader(ext)) { SoapHeader header = SOAPBindingUtil.getSoapHeader(ext); String pn = header.getPart(); for (MessagePartInfo mpi : mps) { if (pn.equals(mpi.getName().getLocalPart())) { if (mpi.isElement()) { set.add(mpi.getElementQName()); } else { set.add(mpi.getTypeQName()); } break; } } } } } return set; }
Example #3
Source File: SoapBindingFactory.java From cxf with Apache License 2.0 | 6 votes |
private void setupHeaders(BindingOperationInfo op, BindingMessageInfo bMsg, BindingMessageInfo unwrappedBMsg, MessageInfo msg, SoapBindingConfiguration config) { List<MessagePartInfo> parts = new ArrayList<>(); for (MessagePartInfo part : msg.getMessageParts()) { if (config.isHeader(op, part)) { SoapHeaderInfo headerInfo = new SoapHeaderInfo(); headerInfo.setPart(part); headerInfo.setUse(config.getUse()); bMsg.addExtensor(headerInfo); } else { parts.add(part); } } unwrappedBMsg.setMessageParts(parts); }
Example #4
Source File: PolicyAttachmentTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testAppliesToMessage() { BindingMessageInfo bmi1 = control.createMock(BindingMessageInfo.class); BindingMessageInfo bmi2 = control.createMock(BindingMessageInfo.class); DomainExpression de = control.createMock(DomainExpression.class); Collection<DomainExpression> des = Collections.singletonList(de); PolicyAttachment pa = new PolicyAttachment(); pa.setDomainExpressions(des); EasyMock.expect(de.appliesTo(bmi1)).andReturn(false); EasyMock.expect(de.appliesTo(bmi2)).andReturn(true); control.replay(); assertFalse(pa.appliesTo(bmi1)); assertTrue(pa.appliesTo(bmi2)); control.verify(); }
Example #5
Source File: ExternalAttachmentProviderTest.java From cxf with Apache License 2.0 | 6 votes |
void setUpAttachment(Object subject, boolean applies, ExternalAttachmentProvider eap) { attachments.clear(); attachment = control.createMock(PolicyAttachment.class); attachments.add(attachment); policy = new Policy(); assertion = new PrimitiveAssertion(TEST_ASSERTION_TYPE); policy.addAssertion(assertion); eap.setAttachments(attachments); if (subject instanceof ServiceInfo) { EasyMock.expect(attachment.appliesTo((ServiceInfo)subject)).andReturn(applies); } else if (subject instanceof EndpointInfo) { EasyMock.expect(attachment.appliesTo((EndpointInfo)subject)).andReturn(applies); } else if (subject instanceof BindingOperationInfo) { EasyMock.expect(attachment.appliesTo((BindingOperationInfo)subject)).andReturn(applies); } else if (subject instanceof BindingMessageInfo) { EasyMock.expect(attachment.appliesTo((BindingMessageInfo)subject)).andReturn(applies); } else if (subject instanceof BindingFaultInfo) { EasyMock.expect(attachment.appliesTo((BindingFaultInfo)subject)).andReturn(applies); } else { System.err.println("subject class: " + subject.getClass()); } if (applies) { EasyMock.expect(attachment.getPolicy()).andReturn(policy); } }
Example #6
Source File: URIDomainExpression.java From cxf with Apache License 2.0 | 6 votes |
private boolean checkPortTypeOperationInOut(BindingMessageInfo bmi) { InterfaceInfo ini = null; if ((bmi.getBindingOperation() != null) && (bmi.getBindingOperation().getOperationInfo() != null)) { ini = bmi.getBindingOperation().getOperationInfo().getInterface(); } if ((ini != null) && (ini.getName() != null) && (bmi.getMessageInfo() != null) && (bmi.getBindingOperation() != null) && (bmi.getBindingOperation().getName() != null)) { if ((Type.INPUT == bmi.getMessageInfo().getType()) && wsdl11XPointer.matchesPortTypeOperationInput( ini.getName().getNamespaceURI(), ini.getName().getLocalPart(), bmi.getBindingOperation().getName().getLocalPart())) { return true; } if ((Type.OUTPUT == bmi.getMessageInfo().getType()) && wsdl11XPointer.matchesPortTypeOperationOutput( ini.getName().getNamespaceURI(), ini.getName().getLocalPart(), bmi.getBindingOperation().getName().getLocalPart())) { return true; } } return false; }
Example #7
Source File: URIDomainExpression.java From cxf with Apache License 2.0 | 6 votes |
private boolean checkBindingOperationInOut(BindingMessageInfo bmi) { if ((bmi.getMessageInfo() != null) && (bmi.getMessageInfo().getName() != null) && (bmi.getBindingOperation() != null) && (bmi.getBindingOperation().getName() != null) && (bmi.getBindingOperation().getBinding() != null) && (bmi.getBindingOperation().getBinding().getName() != null)) { if ((Type.INPUT == bmi.getMessageInfo().getType()) && wsdl11XPointer.matchesBindingOperationInput( bmi.getMessageInfo().getName().getNamespaceURI(), bmi.getBindingOperation().getBinding().getName().getLocalPart(), bmi.getBindingOperation().getName().getLocalPart())) { return true; } if ((Type.OUTPUT == bmi.getMessageInfo().getType()) && wsdl11XPointer.matchesBindingOperationOutput( bmi.getMessageInfo().getName().getNamespaceURI(), bmi.getBindingOperation().getBinding().getName().getLocalPart(), bmi.getBindingOperation().getName().getLocalPart())) { return true; } } return false; }
Example #8
Source File: URIDomainExpression.java From cxf with Apache License 2.0 | 6 votes |
@Override public boolean appliesTo(BindingMessageInfo bmi) { if (bmi == null) { return false; } if ((bmi.getMessageInfo() != null) && (bmi.getMessageInfo().getName() != null) && wsdl11XPointer.matchesMessage( bmi.getMessageInfo().getName().getNamespaceURI(), bmi.getMessageInfo().getName().getLocalPart())) { return true; } if (checkBindingOperationInOut(bmi)) { return true; } return checkPortTypeOperationInOut(bmi); }
Example #9
Source File: SoapClient.java From jea with Apache License 2.0 | 6 votes |
private Object[] convert(Endpoint endpoint, QName opName, Object... params) throws Exception { List<Object> listSoapObject = new ArrayList<Object>(); BindingOperationInfo boi = endpoint.getEndpointInfo().getBinding().getOperation(opName); // Operation name is processOrder BindingMessageInfo inputMessageInfo = null; if (!boi.isUnwrapped()) { inputMessageInfo = boi.getWrappedOperation().getInput(); } else { inputMessageInfo = boi.getUnwrappedOperation().getInput(); } List<MessagePartInfo> parts = inputMessageInfo.getMessageParts(); int index = 0; for(Object obj : params){ MessagePartInfo partInfo = parts.get(index++); Class<?> soapClass = partInfo.getTypeClass(); Object soapObject = copytoSoapObject(obj, soapClass); listSoapObject.add(soapObject); } return listSoapObject.toArray(); }
Example #10
Source File: JavaFirstUriDomainExpression.java From cxf with Apache License 2.0 | 6 votes |
@Override public boolean appliesTo(BindingMessageInfo bmi) { String serviceName = bmi.getBindingOperation().getBinding().getService().getName().getLocalPart(); if ("JavaFirstAttachmentPolicyService".equals(serviceName) && "usernamepassword".equals(url)) { return ("doInputMessagePolicy".equals(bmi.getBindingOperation().getName().getLocalPart()) && MessageInfo.Type.INPUT.equals(bmi.getMessageInfo().getType())) || ("doOutputMessagePolicy".equals(bmi.getBindingOperation().getName().getLocalPart()) && MessageInfo.Type.OUTPUT.equals(bmi.getMessageInfo().getType())); } else if ("SslUsernamePasswordAttachmentService".equals(serviceName) && "sslusernamepassword".equals(url)) { return MessageInfo.Type.INPUT.equals(bmi.getMessageInfo().getType()); } else { return false; } }
Example #11
Source File: CorbaDSIServant.java From cxf with Apache License 2.0 | 5 votes |
public void invoke(ServerRequest request) throws CorbaBindingException { String opName = request.operation(); QName requestOperation = operationMap.get(opName); MessageImpl msgImpl = new MessageImpl(); msgImpl.setDestination(getDestination()); Exchange exg = new ExchangeImpl(); exg.put(String.class, requestOperation.getLocalPart()); exg.put(ORB.class, getOrb()); exg.put(ServerRequest.class, request); msgImpl.setExchange(exg); CorbaMessage msg = new CorbaMessage(msgImpl); msg.setCorbaTypeMap(typeMap); // If there's no output message part in our operation then it's a oneway op BindingMessageInfo bindingMsgOutputInfo = null; BindingOperationInfo bindingOpInfo = null; try { bindingOpInfo = this.destination.getEndPointInfo().getBinding().getOperation(requestOperation); } catch (Exception ex) { throw new CorbaBindingException("Invalid Request. Operation unknown: " + opName); } if (bindingOpInfo != null) { bindingMsgOutputInfo = bindingOpInfo.getOutput(); if (bindingMsgOutputInfo == null) { exg.setOneWay(true); } } // invokes the interceptors getObserver().onMessage(msg); }
Example #12
Source File: OutgoingChainInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { control = EasyMock.createNiceControl(); phases = new ArrayList<>(); phases.add(new Phase(Phase.SEND, 1000)); empty = new ArrayList<>(); bus = control.createMock(Bus.class); PhaseManager pm = new PhaseManagerImpl(); EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(pm).anyTimes(); service = control.createMock(Service.class); endpoint = control.createMock(Endpoint.class); binding = control.createMock(Binding.class); EasyMock.expect(endpoint.getBinding()).andStubReturn(binding); MessageImpl m = new MessageImpl(); EasyMock.expect(binding.createMessage()).andStubReturn(m); EasyMock.expect(endpoint.getService()).andReturn(service).anyTimes(); EasyMock.expect(endpoint.getOutInterceptors()).andReturn(empty); EasyMock.expect(service.getOutInterceptors()).andReturn(empty); EasyMock.expect(bus.getOutInterceptors()).andReturn(empty); bopInfo = control.createMock(BindingOperationInfo.class); opInfo = control.createMock(OperationInfo.class); mInfo = control.createMock(MessageInfo.class); bmInfo = control.createMock(BindingMessageInfo.class); EasyMock.expect(bopInfo.getOperationInfo()).andReturn(opInfo).times(3); EasyMock.expect(opInfo.getOutput()).andReturn(mInfo); EasyMock.expect(opInfo.isOneWay()).andReturn(false); EasyMock.expect(bopInfo.getOutput()).andReturn(bmInfo); control.replay(); }
Example #13
Source File: ClientImpl.java From cxf with Apache License 2.0 | 5 votes |
protected void setOutMessageProperties(Message message, BindingOperationInfo boi) { message.put(Message.REQUESTOR_ROLE, Boolean.TRUE); message.put(Message.INBOUND_MESSAGE, Boolean.FALSE); if (null != boi) { message.put(BindingMessageInfo.class, boi.getInput()); message.put(MessageInfo.class, boi.getOperationInfo().getInput()); } }
Example #14
Source File: OutgoingChainInterceptor.java From cxf with Apache License 2.0 | 5 votes |
public void handleMessage(Message message) { Exchange ex = message.getExchange(); BindingOperationInfo binding = ex.getBindingOperationInfo(); //if we get this far, we're going to be outputting some valid content, but we COULD //also be "echoing" some of the content from the input. Thus, we need to //mark it as requiring the input to be cached. if (message.getExchange().get(CACHE_INPUT_PROPERTY) == null) { message.put(CACHE_INPUT_PROPERTY, Boolean.TRUE); } if (null != binding && null != binding.getOperationInfo() && binding.getOperationInfo().isOneWay()) { closeInput(message); return; } Message out = ex.getOutMessage(); if (out != null) { try { getBackChannelConduit(message); } catch (IOException ioe) { throw new Fault(ioe); } if (binding != null) { out.put(MessageInfo.class, binding.getOperationInfo().getOutput()); out.put(BindingMessageInfo.class, binding.getOutput()); } InterceptorChain outChain = out.getInterceptorChain(); if (outChain == null) { outChain = OutgoingChainInterceptor.getChain(ex, chainCache); out.setInterceptorChain(outChain); } else if (outChain.getState() == InterceptorChain.State.PAUSED) { outChain.resume(); return; } outChain.doIntercept(out); } }
Example #15
Source File: BareOutInterceptor.java From cxf with Apache License 2.0 | 5 votes |
public void handleMessage(Message message) { Exchange exchange = message.getExchange(); BindingOperationInfo operation = exchange.getBindingOperationInfo(); if (operation == null) { return; } MessageContentsList objs = MessageContentsList.getContentsList(message); if (objs == null || objs.isEmpty()) { return; } List<MessagePartInfo> parts = null; BindingMessageInfo bmsg = null; boolean client = isRequestor(message); if (!client) { if (operation.getOutput() != null) { bmsg = operation.getOutput(); parts = bmsg.getMessageParts(); } else { // partial response to oneway return; } } else { bmsg = operation.getInput(); parts = bmsg.getMessageParts(); } writeParts(message, exchange, operation, objs, parts); }
Example #16
Source File: WSDLServiceBuilder.java From cxf with Apache License 2.0 | 5 votes |
private void handleHeader(BindingMessageInfo bindingMessageInfo) { // mark all message part which should be in header List<ExtensibilityElement> extensiblilityElement = bindingMessageInfo .getExtensors(ExtensibilityElement.class); // for non-soap binding, the extensiblilityElement could be null if (extensiblilityElement == null) { return; } // for (ExtensibilityElement element : extensiblilityElement) { // LOG.info("the extensibility is " + element.getClass().getName()); // if (element instanceof SOAPHeader) { // LOG.info("the header is " + ((SOAPHeader)element).getPart()); // } // } }
Example #17
Source File: ServiceWSDLBuilder.java From cxf with Apache License 2.0 | 5 votes |
protected void buildBindingOutput(Definition def, BindingOperation bindingOperation, BindingMessageInfo bindingMessageInfo) { BindingOutput bindingOutput = null; if (bindingMessageInfo != null) { bindingOutput = def.createBindingOutput(); addDocumentation(bindingOutput, bindingMessageInfo.getDocumentation()); bindingOutput.setName(bindingMessageInfo.getMessageInfo().getName().getLocalPart()); bindingOperation.setBindingOutput(bindingOutput); addExtensibilityAttributes(def, bindingOutput, bindingMessageInfo.getExtensionAttributes()); addExtensibilityElements(def, bindingOutput, getWSDL11Extensors(bindingMessageInfo)); } }
Example #18
Source File: ServiceWSDLBuilder.java From cxf with Apache License 2.0 | 5 votes |
protected void buildBindingInput(Definition def, BindingOperation bindingOperation, BindingMessageInfo bindingMessageInfo) { BindingInput bindingInput = null; if (bindingMessageInfo != null) { bindingInput = def.createBindingInput(); addDocumentation(bindingInput, bindingMessageInfo.getDocumentation()); bindingInput.setName(bindingMessageInfo.getMessageInfo().getName().getLocalPart()); bindingOperation.setBindingInput(bindingInput); addExtensibilityAttributes(def, bindingInput, bindingMessageInfo.getExtensionAttributes()); addExtensibilityElements(def, bindingInput, getWSDL11Extensors(bindingMessageInfo)); } }
Example #19
Source File: ServiceModelUtilTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testGetSchema() throws Exception { BindingInfo bindingInfo = null; bindingInfo = serviceInfo.getBindings().iterator().next(); QName name = new QName(serviceInfo.getName().getNamespaceURI(), "inHeader"); BindingOperationInfo inHeader = bindingInfo.getOperation(name); BindingMessageInfo input = inHeader.getInput(); assertNotNull(input); assertEquals(input.getMessageInfo().getName().getLocalPart(), "inHeaderRequest"); assertEquals(input.getMessageInfo().getName().getNamespaceURI(), "http://org.apache.cxf/headers"); assertEquals(input.getMessageInfo().getMessageParts().size(), 2); assertTrue(input.getMessageInfo().getMessageParts().get(0).isElement()); assertEquals( input.getMessageInfo().getMessageParts().get(0).getElementQName().getLocalPart(), "inHeader"); assertEquals(input.getMessageInfo().getMessageParts().get(0).getElementQName().getNamespaceURI(), "http://org.apache.cxf/headers"); assertTrue(input.getMessageInfo().getMessageParts().get(0).isElement()); assertEquals( input.getMessageInfo().getMessageParts().get(1).getElementQName().getLocalPart(), "passenger"); assertEquals(input.getMessageInfo().getMessageParts().get(1).getElementQName().getNamespaceURI(), "http://mycompany.example.com/employees"); assertTrue(input.getMessageInfo().getMessageParts().get(1).isElement()); MessagePartInfo messagePartInfo = input.getMessageInfo().getMessageParts().get(0); SchemaInfo schemaInfo = ServiceModelUtil.getSchema(serviceInfo, messagePartInfo); assertEquals(schemaInfo.getNamespaceURI(), "http://org.apache.cxf/headers"); messagePartInfo = input.getMessageInfo().getMessageParts().get(1); schemaInfo = ServiceModelUtil.getSchema(serviceInfo, messagePartInfo); assertEquals(schemaInfo.getNamespaceURI(), "http://mycompany.example.com/employees"); }
Example #20
Source File: BindingHelper.java From syndesis with Apache License 2.0 | 5 votes |
BindingHelper(BindingMessageInfo bindingMessageInfo) throws ParserException, ParserConfigurationException { this.bindingMessageInfo = bindingMessageInfo; this.bindingOperation = bindingMessageInfo.getBindingOperation(); this.schemaCollection = bindingMessageInfo.getBindingOperation().getBinding().getService().getXmlSchemaCollection(); SoapOperationInfo soapOperationInfo = bindingOperation.getExtensor(SoapOperationInfo.class); SoapBindingInfo soapBindingInfo = (SoapBindingInfo) bindingOperation.getBinding(); soapVersion = soapBindingInfo.getSoapVersion(); // get binding style if (soapOperationInfo.getStyle() != null) { style = Style.valueOf(soapOperationInfo.getStyle().toUpperCase(Locale.US)); } else if (soapBindingInfo.getStyle() != null) { style = Style.valueOf(soapBindingInfo.getStyle().toUpperCase(Locale.US)); } else { style = Style.DOCUMENT; } // get body binding SoapBodyInfo soapBodyInfo = bindingMessageInfo.getExtensor(SoapBodyInfo.class); List<SoapHeaderInfo> soapHeaders = bindingMessageInfo.getExtensors(SoapHeaderInfo.class); bodyParts = soapBodyInfo.getParts(); // get any headers as MessagePartInfos hasHeaders = soapHeaders != null && !soapHeaders.isEmpty(); headerParts = hasHeaders ? soapHeaders.stream().map(SoapHeaderInfo::getPart).collect(Collectors.toList()) : null; // get required body use Use use = Use.valueOf(soapBodyInfo.getUse().toUpperCase(Locale.US)); if (ENCODED.equals(use)) { // TODO could we add support for RPC/encoded messages by setting schema type to any?? throw new ParserException("Messages with use='encoded' are not supported"); } // Document builder for create schemaset this.documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); }
Example #21
Source File: HeaderUtil.java From cxf with Apache License 2.0 | 5 votes |
private static Set<QName> getHeaderParts(BindingMessageInfo bmi) { Object obj = bmi.getProperty(HEADERS_PROPERTY); if (obj == null) { Set<QName> set = getHeaderQNames(bmi); bmi.setProperty(HEADERS_PROPERTY, set); return set; } return CastUtils.cast((Set<?>)obj); }
Example #22
Source File: SwAOutInterceptor.java From cxf with Apache License 2.0 | 5 votes |
public void handleMessage(SoapMessage message) throws Fault { Exchange ex = message.getExchange(); BindingOperationInfo bop = ex.getBindingOperationInfo(); if (bop == null) { return; } if (bop.isUnwrapped()) { bop = bop.getWrappedOperation(); } boolean client = isRequestor(message); BindingMessageInfo bmi = client ? bop.getInput() : bop.getOutput(); if (bmi == null) { return; } SoapBodyInfo sbi = bmi.getExtensor(SoapBodyInfo.class); if (sbi == null || sbi.getAttachments() == null || sbi.getAttachments().isEmpty()) { Service s = ex.getService(); DataBinding db = s.getDataBinding(); if (db instanceof JAXBDataBinding && hasSwaRef((JAXBDataBinding) db)) { setupAttachmentOutput(message); } return; } processAttachments(message, sbi); }
Example #23
Source File: ExternalAttachmentProviderTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testGetEffectiveMessagePolicy() { ExternalAttachmentProvider eap = new ExternalAttachmentProvider(); BindingMessageInfo bmi = control.createMock(BindingMessageInfo.class); setUpAttachment(bmi, false, eap); control.replay(); assertNull(eap.getEffectivePolicy(bmi, null)); control.verify(); control.reset(); setUpAttachment(bmi, true, eap); control.replay(); assertSame(assertion, eap.getEffectivePolicy(bmi, null).getAssertions().get(0)); control.verify(); }
Example #24
Source File: PolicyAttachment.java From cxf with Apache License 2.0 | 5 votes |
public boolean appliesTo(BindingMessageInfo bmi) { for (DomainExpression de : domainExpressions) { if (de.appliesTo(bmi)) { return true; } } return false; }
Example #25
Source File: EffectivePolicyImpl.java From cxf with Apache License 2.0 | 5 votes |
Assertor initialisePolicy(EndpointInfo ei, BindingOperationInfo boi, PolicyEngine engine, boolean requestor, boolean request, Assertor assertor, Message m) { if (boi.isUnwrapped()) { boi = boi.getUnwrappedOperation(); } BindingMessageInfo bmi = request ? boi.getInput() : boi.getOutput(); EndpointPolicy ep; if (requestor) { ep = engine.getClientEndpointPolicy(ei, getAssertorAs(assertor, Conduit.class), m); } else { ep = engine.getServerEndpointPolicy(ei, getAssertorAs(assertor, Destination.class), m); } policy = ep.getPolicy(); if (ep instanceof EndpointPolicyImpl) { assertor = ((EndpointPolicyImpl)ep).getAssertor(); } policy = policy.merge(((PolicyEngineImpl)engine).getAggregatedOperationPolicy(boi, m)); if (null != bmi) { policy = policy.merge(((PolicyEngineImpl)engine).getAggregatedMessagePolicy(bmi, m)); } policy = policy.normalize(engine.getRegistry(), true); return assertor; }
Example #26
Source File: ServiceModelPolicyUpdater.java From cxf with Apache License 2.0 | 5 votes |
public void addPolicyAttachments(Collection<PolicyAttachment> attachments) { for (PolicyAttachment pa : attachments) { boolean policyUsed = false; for (BindingOperationInfo boi : ei.getBinding().getOperations()) { BindingMessageInfo inputMessage = boi.getInput(); BindingMessageInfo outputMessage = boi.getOutput(); if (pa.appliesTo(boi)) { // Add wsp:PolicyReference to wsdl:binding/wsdl:operation addPolicyRef(boi, pa.getPolicy()); // Add it to wsdl:portType/wsdl:operation too // FIXME - since the appliesTo is for BindingOperationInfo, I think its dodgy // that the policy ref should also be associated with the port type addPolicyRef(ei.getInterface().getOperation(boi.getName()), pa.getPolicy()); policyUsed = true; } else if (pa.appliesTo(inputMessage)) { addPolicyRef(inputMessage, pa.getPolicy()); policyUsed = true; } else if (pa.appliesTo(outputMessage)) { addPolicyRef(outputMessage, pa.getPolicy()); policyUsed = true; } } // Add wsp:Policy to top-level wsdl:definitions if (policyUsed) { addPolicy(pa); } } }
Example #27
Source File: PolicyEngineImpl.java From cxf with Apache License 2.0 | 5 votes |
Policy getAggregatedMessagePolicy(BindingMessageInfo bmi, Message m) { Policy aggregated = null; for (PolicyProvider pp : getPolicyProviders()) { Policy p = pp.getEffectivePolicy(bmi, m); if (null == aggregated) { aggregated = p; } else if (p != null) { aggregated = aggregated.merge(p); } } return aggregated == null ? new Policy() : aggregated; }
Example #28
Source File: PolicyEngineTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testGetAggregatedMessagePolicy() { engine = new PolicyEngineImpl(); BindingMessageInfo bmi = control.createMock(BindingMessageInfo.class); control.replay(); Policy p = engine.getAggregatedMessagePolicy(bmi, null); assertTrue(p.isEmpty()); control.verify(); control.reset(); PolicyProvider provider1 = control.createMock(PolicyProvider.class); engine.getPolicyProviders().add(provider1); Policy p1 = control.createMock(Policy.class); EasyMock.expect(provider1.getEffectivePolicy(bmi, null)).andReturn(p1); control.replay(); assertSame(p1, engine.getAggregatedMessagePolicy(bmi, null)); control.verify(); control.reset(); PolicyProvider provider2 = control.createMock(PolicyProvider.class); engine.getPolicyProviders().add(provider2); Policy p2 = control.createMock(Policy.class); Policy p3 = control.createMock(Policy.class); EasyMock.expect(provider1.getEffectivePolicy(bmi, null)).andReturn(p1); EasyMock.expect(provider2.getEffectivePolicy(bmi, null)).andReturn(p2); EasyMock.expect(p1.merge(p2)).andReturn(p3); control.replay(); assertSame(p3, engine.getAggregatedMessagePolicy(bmi, null)); control.verify(); }
Example #29
Source File: EffectivePolicyImplTest.java From cxf with Apache License 2.0 | 5 votes |
private void doTestInitialisePolicy(boolean requestor) { EndpointInfo ei = control.createMock(EndpointInfo.class); BindingOperationInfo boi = control.createMock(BindingOperationInfo.class); PolicyEngineImpl engine = control.createMock(PolicyEngineImpl.class); BindingMessageInfo bmi = control.createMock(BindingMessageInfo.class); if (requestor) { EasyMock.expect(boi.getInput()).andReturn(bmi); } else { EasyMock.expect(boi.getOutput()).andReturn(bmi); } EndpointPolicy effectivePolicy = control.createMock(EndpointPolicy.class); if (requestor) { EasyMock.expect(engine.getClientEndpointPolicy(ei, (Conduit)null, null)).andReturn(effectivePolicy); } else { EasyMock.expect(engine.getServerEndpointPolicy(ei, (Destination)null, null)).andReturn(effectivePolicy); } Policy ep = control.createMock(Policy.class); EasyMock.expect(effectivePolicy.getPolicy()).andReturn(ep); Policy op = control.createMock(Policy.class); EasyMock.expect(engine.getAggregatedOperationPolicy(boi, null)).andReturn(op); Policy merged = control.createMock(Policy.class); EasyMock.expect(ep.merge(op)).andReturn(merged); Policy mp = control.createMock(Policy.class); EasyMock.expect(engine.getAggregatedMessagePolicy(bmi, null)).andReturn(mp); EasyMock.expect(merged.merge(mp)).andReturn(merged); EasyMock.expect(merged.normalize(null, true)).andReturn(merged); control.replay(); EffectivePolicyImpl epi = new EffectivePolicyImpl(); epi.initialisePolicy(ei, boi, engine, requestor, requestor, null, null); assertSame(merged, epi.getPolicy()); control.verify(); }
Example #30
Source File: ServiceProcessor.java From cxf with Apache License 2.0 | 4 votes |
private boolean isOutOfBandHeader(BindingMessageInfo bmi, ExtensibilityElement ext) { SoapHeader soapHeader = SOAPBindingUtil.getSoapHeader(ext); return soapHeader.getMessage() != null && !bmi.getMessageInfo().getName().equals(soapHeader.getMessage()); }