本文整理汇总了Java中org.apache.cxf.message.Exchange.getBindingOperationInfo方法的典型用法代码示例。如果您正苦于以下问题:Java Exchange.getBindingOperationInfo方法的具体用法?Java Exchange.getBindingOperationInfo怎么用?Java Exchange.getBindingOperationInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cxf.message.Exchange
的用法示例。
在下文中一共展示了Exchange.getBindingOperationInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareCamelExchange
import org.apache.cxf.message.Exchange; //导入方法依赖的package包/类
private org.apache.camel.Exchange prepareCamelExchange(Exchange cxfExchange) {
// get CXF binding
CxfEndpoint endpoint = (CxfEndpoint)getEndpoint();
CxfBinding binding = endpoint.getCxfBinding();
// create a Camel exchange, the default MEP is InOut
org.apache.camel.Exchange camelExchange = endpoint.createExchange();
DataFormat dataFormat = endpoint.getDataFormat();
BindingOperationInfo boi = cxfExchange.getBindingOperationInfo();
// make sure the "boi" is remained as wrapped in PAYLOAD mode
if (boi != null && dataFormat == DataFormat.PAYLOAD && boi.isUnwrapped()) {
boi = boi.getWrappedOperation();
cxfExchange.put(BindingOperationInfo.class, boi);
}
if (boi != null) {
camelExchange.setProperty(BindingOperationInfo.class.getName(), boi);
LOG.trace("Set exchange property: BindingOperationInfo: {}", boi);
// set the message exchange patter with the boi
if (boi.getOperationInfo().isOneWay()) {
camelExchange.setPattern(ExchangePattern.InOnly);
}
} else {
if (cxfEndpoint.getExchangePattern().equals(ExchangePattern.InOnly)) {
camelExchange.setPattern(ExchangePattern.InOnly);
}
}
// set data format mode in Camel exchange
camelExchange.setProperty(CxfConstants.DATA_FORMAT_PROPERTY, dataFormat);
LOG.trace("Set Exchange property: {}={}", DataFormat.class.getName(), dataFormat);
camelExchange.setProperty(Message.MTOM_ENABLED, String.valueOf(endpoint.isMtomEnabled()));
if (endpoint.getMergeProtocolHeaders()) {
camelExchange.setProperty(CxfConstants.CAMEL_CXF_PROTOCOL_HEADERS_MERGED, Boolean.TRUE);
}
// bind the CXF request into a Camel exchange
binding.populateExchangeFromCxfRequest(cxfExchange, camelExchange);
// extract the javax.xml.ws header
Map<String, Object> context = new HashMap<String, Object>();
binding.extractJaxWsContext(cxfExchange, context);
// put the context into camelExchange
camelExchange.setProperty(CxfConstants.JAXWS_CONTEXT, context);
// we want to handle the UoW
try {
CxfConsumer.this.createUoW(camelExchange);
} catch (Exception e) {
log.error("Error processing request", e);
throw new Fault(e);
}
return camelExchange;
}
示例2: checkAuthorization
import org.apache.cxf.message.Exchange; //导入方法依赖的package包/类
protected void checkAuthorization(MessageContext ctx)
{
if ((Boolean) ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY))
{
return;
}
Message message = ((WrappedMessageContext) ctx).getWrappedMessage();
Exchange exchange = message.getExchange();
Endpoint ep = exchange.get(Endpoint.class);
EJBMethodSecurityAttributeProvider attributeProvider = ep
.getAttachment(EJBMethodSecurityAttributeProvider.class);
if (attributeProvider != null) //ejb endpoints only can be associated with this...
{
SecurityContext secCtx = message.get(SecurityContext.class);
BindingOperationInfo bop = exchange.getBindingOperationInfo();
MethodDispatcher md = (MethodDispatcher) exchange.getService().get(MethodDispatcher.class.getName());
Method method = md.getMethod(bop);
EJBMethodSecurityAttribute attributes = attributeProvider.getSecurityAttributes(method);
if (attributes == null || attributes.isPermitAll()) //no security requirement or method marked @PermitAll
{
return;
}
if (!attributes.isDenyAll())
{
if (attributes.getRolesAllowed() != null)
{
for (String role : attributes.getRolesAllowed())
{
if (secCtx.isUserInRole(role))
{
return;
}
}
}
}
final Principal p = secCtx.getUserPrincipal();
ctx.put(KEY, true);
throw MESSAGES.authorizationFailed(p != null ? p.getName() : null);
}
}