use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class AbstractWSDLBasedEndpointFactory method createBindingInfo.
protected BindingInfo createBindingInfo() {
BindingFactoryManager mgr = bus.getExtension(BindingFactoryManager.class);
String binding = bindingId;
if (binding == null && bindingConfig != null) {
binding = bindingConfig.getBindingId();
}
if (binding == null) {
// default to soap binding
binding = "http://schemas.xmlsoap.org/soap/";
}
try {
if (binding.contains("/soap")) {
if (bindingConfig == null) {
bindingConfig = createSoapBindingConfig();
}
if (bindingConfig instanceof SoapBindingConfiguration && !((SoapBindingConfiguration) bindingConfig).isSetStyle()) {
((SoapBindingConfiguration) bindingConfig).setStyle(serviceFactory.getStyle());
}
}
bindingFactory = mgr.getBindingFactory(binding);
BindingInfo inf = bindingFactory.createBindingInfo(serviceFactory.getService(), binding, bindingConfig);
for (BindingOperationInfo boi : inf.getOperations()) {
serviceFactory.updateBindingOperation(boi);
Method m = serviceFactory.getMethodDispatcher().getMethod(boi);
serviceFactory.sendEvent(FactoryBeanListener.Event.BINDING_OPERATION_CREATED, inf, boi, m);
}
serviceFactory.sendEvent(FactoryBeanListener.Event.BINDING_CREATED, inf);
return inf;
} catch (BusException ex) {
throw new ServiceConstructionException(new Message("COULD.NOT.RESOLVE.BINDING", LOG, bindingId), ex);
}
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class AbstractMessageResponseTimeInterceptor method getOperationCounterName.
protected ObjectName getOperationCounterName(Exchange ex, ObjectName sericeCounterName) {
BindingOperationInfo bop = ex.getBindingOperationInfo();
OperationInfo opInfo = bop == null ? null : bop.getOperationInfo();
if (opInfo != null) {
ObjectName o = opInfo.getProperty("javax.management.ObjectName", ObjectName.class);
if (o != null) {
return o;
}
}
String operationName = opInfo == null ? null : "\"" + opInfo.getName().getLocalPart() + "\"";
if (operationName == null) {
Object nameProperty = ex.get("org.apache.cxf.resource.operation.name");
if (nameProperty != null) {
operationName = "\"" + escapePatternChars(nameProperty.toString()) + "\"";
}
}
StringBuilder buffer = new StringBuilder(sericeCounterName.toString());
if (operationName != null) {
buffer.append("," + ManagementConstants.OPERATION_NAME_PROP + "=" + operationName);
}
String operationCounterName = buffer.toString();
ObjectName operationCounter = null;
try {
operationCounter = new ObjectName(operationCounterName);
if (opInfo != null) {
opInfo.setProperty("javax.management.ObjectName", operationCounter);
}
} catch (MalformedObjectNameException e) {
LOG.log(Level.WARNING, "CREATE_COUNTER_OBJECTNAME_FAILED", e);
}
return operationCounter;
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class AbstractMessageResponseTestBase method setupOperationForMessage.
protected void setupOperationForMessage() {
OperationInfo op = EasyMock.createMock(OperationInfo.class);
BindingOperationInfo bop = EasyMock.createMock(BindingOperationInfo.class);
EasyMock.expect(exchange.getBindingOperationInfo()).andReturn(bop);
EasyMock.expect(bop.getOperationInfo()).andReturn(op);
EasyMock.expect(op.getName()).andReturn(OPERATION_NAME);
EasyMock.expect(op.getProperty("javax.management.ObjectName", ObjectName.class)).andReturn(null).anyTimes();
op.setProperty(EasyMock.eq("javax.management.ObjectName"), EasyMock.anyObject(ObjectName.class));
EasyMock.expectLastCall();
EasyMock.replay(bop, op);
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class AbstractSTSClient method findOperation.
protected BindingOperationInfo findOperation(String suffix) {
BindingInfo bi = client.getEndpoint().getBinding().getBindingInfo();
for (BindingOperationInfo boi : bi.getOperations()) {
SoapOperationInfo soi = boi.getExtensor(SoapOperationInfo.class);
String soapAction = soi != null ? soi.getAction() : null;
Object o = boi.getOperationInfo().getInput().getExtensionAttribute(new QName("http://www.w3.org/2007/05/addressing/metadata", "Action"));
if (o instanceof QName) {
o = ((QName) o).getLocalPart();
}
String wsamAction = o == null ? null : o.toString();
if ((soapAction != null && soapAction.endsWith(suffix)) || (wsamAction != null && wsamAction.endsWith(suffix))) {
PolicyEngine pe = bus.getExtension(PolicyEngine.class);
Conduit conduit = client.getConduit();
EffectivePolicy effectivePolicy = pe.getEffectiveClientRequestPolicy(client.getEndpoint().getEndpointInfo(), boi, conduit, PhaseInterceptorChain.getCurrentMessage());
setPolicyInternal(effectivePolicy.getPolicy());
return boi;
}
}
// we can at least find it by name and then set the action and such manually later.
for (BindingOperationInfo boi : bi.getOperations()) {
if (suffix.endsWith(boi.getName().getLocalPart())) {
return boi;
}
}
// Still didn't find anything useful
for (BindingOperationInfo boi : bi.getOperations()) {
if (boi.getInput().getMessageInfo().getMessagePartsNumber() > 0) {
MessagePartInfo mpi = boi.getInput().getMessageInfo().getFirstMessagePart();
if ("RequestSecurityToken".equals(mpi.getConcreteName().getLocalPart())) {
return boi;
}
}
}
return null;
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class AbstractSTSClient method issue.
/**
* Make an "Issue" invocation and return the response as a STSResponse Object
*/
protected STSResponse issue(String appliesTo, String action, String requestType, String binaryExchange) throws Exception {
createClient();
BindingOperationInfo boi = findOperation("/RST/Issue");
client.getRequestContext().putAll(ctx);
if (action != null) {
client.getRequestContext().put(SoapBindingConstants.SOAP_ACTION, action);
} else if (isSecureConv) {
client.getRequestContext().put(SoapBindingConstants.SOAP_ACTION, namespace + "/RST/SCT");
} else {
client.getRequestContext().put(SoapBindingConstants.SOAP_ACTION, namespace + "/RST/Issue");
}
W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
writer.writeStartElement("wst", "RequestSecurityToken", namespace);
writer.writeNamespace("wst", namespace);
if (context != null) {
writer.writeAttribute(null, "Context", context);
}
boolean wroteKeySize = false;
String keyTypeTemplate = null;
String sptt = null;
if (template != null && DOMUtils.getFirstElement(template) != null) {
if (this.useSecondaryParameters()) {
writer.writeStartElement("wst", "SecondaryParameters", namespace);
}
Element tl = DOMUtils.getFirstElement(template);
while (tl != null) {
StaxUtils.copy(tl, writer);
if ("KeyType".equals(tl.getLocalName())) {
keyTypeTemplate = DOMUtils.getContent(tl);
} else if ("KeySize".equals(tl.getLocalName())) {
wroteKeySize = true;
keySize = Integer.parseInt(DOMUtils.getContent(tl));
} else if ("TokenType".equals(tl.getLocalName())) {
sptt = DOMUtils.getContent(tl);
}
tl = DOMUtils.getNextElement(tl);
}
if (this.useSecondaryParameters()) {
writer.writeEndElement();
}
}
if (isSpnego) {
tokenType = STSUtils.getTokenTypeSCT(namespace);
sendKeyType = false;
}
addRequestType(requestType, writer);
if (enableAppliesTo) {
addAppliesTo(writer, appliesTo);
}
addClaims(writer);
Element onBehalfOfToken = getOnBehalfOfToken();
if (onBehalfOfToken != null) {
writer.writeStartElement("wst", "OnBehalfOf", namespace);
StaxUtils.copy(onBehalfOfToken, writer);
writer.writeEndElement();
}
if (sptt == null) {
addTokenType(writer);
}
if (isSecureConv || enableLifetime) {
addLifetime(writer);
}
if (keyTypeTemplate == null) {
keyTypeTemplate = writeKeyType(writer, keyType);
}
byte[] requestorEntropy = null;
X509Certificate cert = null;
Crypto crypto = null;
if (keySize <= 0) {
keySize = 256;
}
if (keyTypeTemplate != null && keyTypeTemplate.endsWith("SymmetricKey")) {
requestorEntropy = writeElementsForRSTSymmetricKey(writer, wroteKeySize);
} else if (keyTypeTemplate != null && keyTypeTemplate.endsWith("PublicKey")) {
// Use the given cert, or else get it from a Crypto instance
if (useKeyCertificate != null) {
cert = useKeyCertificate;
} else {
crypto = createCrypto(false);
cert = getCert(crypto);
}
writeElementsForRSTPublicKey(writer, cert);
} else if (isSpnego || isSecureConv) {
addKeySize(keySize, writer);
}
if (binaryExchange != null) {
addBinaryExchange(binaryExchange, writer);
}
Element actAsSecurityToken = getActAsToken();
if (actAsSecurityToken != null) {
writer.writeStartElement(STSUtils.WST_NS_08_02, "ActAs");
StaxUtils.copy(actAsSecurityToken, writer);
writer.writeEndElement();
}
// Write out renewal semantics
writeRenewalSemantics(writer);
Element customElement = getCustomContent();
if (customElement != null) {
StaxUtils.copy(customElement, writer);
}
writer.writeEndElement();
Object[] obj = client.invoke(boi, new DOMSource(writer.getDocument().getDocumentElement()));
return new STSResponse((DOMSource) obj[0], requestorEntropy, cert, crypto);
}
Aggregations