use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class SimpleBatchSTSClient method requestBatchSecurityTokens.
public List<SecurityToken> requestBatchSecurityTokens(List<BatchRequest> batchRequestList, String action, String requestType) throws Exception {
createClient();
BindingOperationInfo boi = findOperation("/BatchIssue");
client.getRequestContext().putAll(ctx);
client.getRequestContext().put(SoapBindingConstants.SOAP_ACTION, action);
W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
writer.writeStartElement("wst", "RequestSecurityTokenCollection", namespace);
writer.writeNamespace("wst", namespace);
for (BatchRequest batchRequest : batchRequestList) {
writer.writeStartElement("wst", "RequestSecurityToken", namespace);
writer.writeNamespace("wst", namespace);
addRequestType(requestType, writer);
if (enableAppliesTo) {
addAppliesTo(writer, batchRequest.getAppliesTo());
}
writeKeyType(writer, batchRequest.getKeyType());
addLifetime(writer);
addTokenType(writer, batchRequest.getTokenType());
writer.writeEndElement();
}
writer.writeEndElement();
Object[] obj = client.invoke(boi, new DOMSource(writer.getDocument().getDocumentElement()));
Element responseCollection = getDocumentElement((DOMSource) obj[0]);
Node child = responseCollection.getFirstChild();
List<SecurityToken> tokens = new ArrayList<>();
while (child != null) {
if (child instanceof Element && "RequestSecurityTokenResponse".equals(((Element) child).getLocalName())) {
SecurityToken token = createSecurityToken((Element) child, null);
tokens.add(token);
}
child = child.getNextSibling();
}
return tokens;
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class ColocOutInterceptor method isColocated.
protected Server isColocated(List<Server> servers, Endpoint endpoint, BindingOperationInfo boi) {
if (servers != null) {
Service senderService = endpoint.getService();
EndpointInfo senderEI = endpoint.getEndpointInfo();
for (Server s : servers) {
Endpoint receiverEndpoint = s.getEndpoint();
Service receiverService = receiverEndpoint.getService();
EndpointInfo receiverEI = receiverEndpoint.getEndpointInfo();
if (receiverService.getName().equals(senderService.getName()) && receiverEI.getName().equals(senderEI.getName())) {
// Check For Operation Match.
BindingOperationInfo receiverOI = receiverEI.getBinding().getOperation(boi.getName());
if (receiverOI != null && isCompatibleOperationInfo(boi, receiverOI)) {
return s;
}
}
}
}
return null;
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class ColocMessageObserverTest method testSetExchangeProperties.
@Test
public void testSetExchangeProperties() throws Exception {
QName opName = new QName("A", "B");
msg.put(Message.WSDL_OPERATION, opName);
EasyMock.expect(ep.getService()).andReturn(srv);
Binding binding = control.createMock(Binding.class);
EasyMock.expect(ep.getBinding()).andReturn(binding);
EndpointInfo ei = control.createMock(EndpointInfo.class);
EasyMock.expect(ep.getEndpointInfo()).andReturn(ei);
BindingInfo bi = control.createMock(BindingInfo.class);
EasyMock.expect(ei.getBinding()).andReturn(bi);
BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
EasyMock.expect(bi.getOperation(opName)).andReturn(boi);
EasyMock.expect(bus.getExtension(ClassLoader.class)).andReturn(this.getClass().getClassLoader());
control.replay();
observer = new ColocMessageObserver(ep, bus);
observer.setExchangeProperties(ex, msg);
control.verify();
assertNotNull("Bus should be set", ex.getBus());
assertNotNull("Endpoint should be set", ex.getEndpoint());
assertNotNull("Binding should be set", ex.getBinding());
assertNotNull("Service should be set", ex.getService());
assertNotNull("BindingOperationInfo should be set", ex.getBindingOperationInfo());
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class ColocOutInterceptorTest method verifyIsColocatedWithDifferentOperation.
private void verifyIsColocatedWithDifferentOperation() {
// Funtion Param
Server s1 = control.createMock(Server.class);
List<Server> list = new ArrayList<>();
list.add(s1);
Endpoint sep = control.createMock(Endpoint.class);
BindingOperationInfo sboi = control.createMock(BindingOperationInfo.class);
// Local var
Service ses = control.createMock(Service.class);
ServiceInfo ssi = control.createMock(ServiceInfo.class);
EndpointInfo sei = control.createMock(EndpointInfo.class);
TestBindingInfo rbi = new TestBindingInfo(ssi, "testBinding");
Endpoint rep = control.createMock(Endpoint.class);
Service res = control.createMock(Service.class);
EndpointInfo rei = control.createMock(EndpointInfo.class);
EasyMock.expect(sep.getService()).andReturn(ses);
EasyMock.expect(sep.getEndpointInfo()).andReturn(sei);
EasyMock.expect(s1.getEndpoint()).andReturn(rep);
EasyMock.expect(rep.getService()).andReturn(res);
EasyMock.expect(rep.getEndpointInfo()).andReturn(rei);
EasyMock.expect(ses.getName()).andReturn(new QName("A", "B"));
EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));
EasyMock.expect(rei.getName()).andReturn(new QName("C", "D"));
EasyMock.expect(sei.getName()).andReturn(new QName("C", "D"));
EasyMock.expect(rei.getBinding()).andReturn(rbi);
EasyMock.expect(sboi.getName()).andReturn(new QName("E", "F"));
// Causes ConcurrentModification intermittently
// QName op = new QName("E", "F");
// EasyMock.expect(rbi.getOperation(op).andReturn(null);
control.replay();
Server val = colocOut.isColocated(list, sep, sboi);
assertEquals("Is not a colocated call", null, val);
assertEquals("BindingOperation.getOperation was not called", 1, rbi.getOpCount());
control.reset();
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class ColocOutInterceptorTest method verifyIsColocatedWithSameOperation.
private void verifyIsColocatedWithSameOperation() {
colocOut = new TestColocOutInterceptor1();
// Funtion Param
Server s1 = control.createMock(Server.class);
List<Server> list = new ArrayList<>();
list.add(s1);
Endpoint sep = control.createMock(Endpoint.class);
BindingOperationInfo sboi = control.createMock(BindingOperationInfo.class);
// Local var
Service ses = control.createMock(Service.class);
EndpointInfo sei = control.createMock(EndpointInfo.class);
BindingInfo rbi = control.createMock(BindingInfo.class);
Endpoint rep = control.createMock(Endpoint.class);
Service res = control.createMock(Service.class);
EndpointInfo rei = control.createMock(EndpointInfo.class);
BindingOperationInfo rboi = control.createMock(BindingOperationInfo.class);
QName op = new QName("E", "F");
QName intf = new QName("G", "H");
QName inmi = new QName("M", "in");
QName outmi = new QName("M", "out");
ServiceInfo ssi = new ServiceInfo();
InterfaceInfo sii = new InterfaceInfo(ssi, intf);
sii.addOperation(op);
OperationInfo soi = sii.getOperation(op);
MessageInfo mii = new MessageInfo(soi, MessageInfo.Type.INPUT, inmi);
MessageInfo mio = new MessageInfo(soi, MessageInfo.Type.OUTPUT, outmi);
soi.setInput("in", mii);
soi.setOutput("out", mio);
ServiceInfo rsi = new ServiceInfo();
InterfaceInfo rii = new InterfaceInfo(rsi, intf);
rii.addOperation(op);
OperationInfo roi = rii.getOperation(op);
roi.setInput("in", mii);
roi.setOutput("out", mio);
EasyMock.expect(sep.getService()).andReturn(ses);
EasyMock.expect(sep.getEndpointInfo()).andReturn(sei);
EasyMock.expect(s1.getEndpoint()).andReturn(rep);
EasyMock.expect(rep.getService()).andReturn(res);
EasyMock.expect(rep.getEndpointInfo()).andReturn(rei);
EasyMock.expect(ses.getName()).andReturn(new QName("A", "B"));
EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));
EasyMock.expect(rei.getName()).andReturn(new QName("C", "D"));
EasyMock.expect(sei.getName()).andReturn(new QName("C", "D"));
EasyMock.expect(rei.getBinding()).andReturn(rbi);
EasyMock.expect(sboi.getName()).andReturn(op);
EasyMock.expect(sboi.getOperationInfo()).andReturn(soi);
EasyMock.expect(rboi.getName()).andReturn(op);
EasyMock.expect(rboi.getOperationInfo()).andReturn(roi);
EasyMock.expect(rbi.getOperation(op)).andReturn(rboi);
control.replay();
Server val = colocOut.isColocated(list, sep, sboi);
assertEquals("Expecting a colocated call", s1, val);
control.reset();
}
Aggregations