use of org.apache.cxf.message.MessageImpl in project jbossws-cxf by jbossws.
the class JaspiServerAuthenticator method validateRequest.
public void validateRequest(SoapMessage message) {
SOAPMessage soapMessage = message.getContent(SOAPMessage.class);
MessageInfo messageInfo = new GenericMessageInfo(soapMessage, null);
AuthStatus authStatus;
try {
authStatus = sctx.validateRequest(messageInfo, null, null);
} catch (AuthException e) {
if (isSOAP12(message)) {
SoapFault soap12Fault = new SoapFault(e.getMessage(), Soap12.getInstance().getReceiver());
throw soap12Fault;
} else {
throw new SoapFault(e.getMessage(), new QName("", "jaspi AuthException"));
}
}
Message response = null;
if (messageInfo.getResponseMessage() != null && !message.getExchange().isOneWay()) {
Endpoint e = message.getExchange().getEndpoint();
response = new MessageImpl();
response.setExchange(message.getExchange());
response = e.getBinding().createMessage(response);
message.getExchange().setOutMessage(response);
response.setContent(SOAPMessage.class, messageInfo.getResponseMessage());
if (AuthStatus.SEND_CONTINUE == authStatus) {
response.put(Message.RESPONSE_CODE, Integer.valueOf(303));
}
if (AuthStatus.SEND_FAILURE == authStatus) {
response.put(Message.RESPONSE_CODE, Integer.valueOf(500));
}
message.getInterceptorChain().abort();
InterceptorChain chain = OutgoingChainInterceptor.getOutInterceptorChain(message.getExchange());
response.setInterceptorChain(chain);
chain.doInterceptStartingAfter(response, SoapPreProtocolOutInterceptor.class.getName());
}
}
use of org.apache.cxf.message.MessageImpl in project jbossws-cxf by jbossws.
the class JBossWSInvokerTest method getTestExchange.
// build up a fake exchange instance, the minimum required to let the flow proceed till the JBossWSInvoker
private Exchange getTestExchange() {
Exchange exchange = new ExchangeImpl();
Message message = new MessageImpl();
message.setExchange(exchange);
exchange.setInMessage(message);
exchange.put(BindingOperationInfo.class, new BindingOperationInfo());
Service service = new ServiceImpl();
MethodDispatcher md = new MethodDispatcher() {
@Override
public Method getMethod(BindingOperationInfo op) {
return this.getClass().getMethods()[0];
}
@Override
public BindingOperationInfo getBindingOperation(Method m, Endpoint endpoint) {
return null;
}
@Override
public void bind(OperationInfo o, Method... methods) {
}
};
service.put(MethodDispatcher.class.getName(), md);
exchange.put(Service.class, service);
return exchange;
}
use of org.apache.cxf.message.MessageImpl in project tomee by apache.
the class ResourceUtils method createConstructorArguments.
public static Object[] createConstructorArguments(Constructor<?> c, Message m, boolean perRequest, Map<Class<?>, Object> contextValues, Class<?>[] params, Annotation[][] anns, Type[] genericTypes) {
if (m == null) {
m = new MessageImpl();
}
@SuppressWarnings("unchecked") MultivaluedMap<String, String> templateValues = (MultivaluedMap<String, String>) m.get(URITemplate.TEMPLATE_PARAMETERS);
Object[] values = new Object[params.length];
for (int i = 0; i < params.length; i++) {
if (AnnotationUtils.getAnnotation(anns[i], Context.class) != null) {
Object contextValue = contextValues != null ? contextValues.get(params[i]) : null;
if (contextValue == null) {
if (perRequest || InjectionUtils.VALUE_CONTEXTS.contains(params[i].getName())) {
values[i] = JAXRSUtils.createContextValue(m, genericTypes[i], params[i]);
} else {
values[i] = InjectionUtils.createThreadLocalProxy(params[i]);
}
} else {
values[i] = contextValue;
}
} else {
// this branch won't execute for singletons given that the found constructor
// is guaranteed to have only Context parameters, if any, for singletons
Parameter p = ResourceUtils.getParameter(i, anns[i], params[i]);
values[i] = JAXRSUtils.createHttpParameterValue(p, params[i], genericTypes[i], anns[i], m, templateValues, null);
}
}
return values;
}
use of org.apache.cxf.message.MessageImpl in project tomee by apache.
the class ClientImpl method getConduit.
public Conduit getConduit() {
Message message = new MessageImpl();
Exchange exchange = new ExchangeImpl();
message.setExchange(exchange);
message.putAll(getRequestContext());
setExchangeProperties(exchange, getEndpoint(), null);
return getConduitSelector().selectConduit(message);
}
use of org.apache.cxf.message.MessageImpl in project tomee by apache.
the class AbstractFaultChainInitiatorObserver method onMessage.
public void onMessage(Message message) {
assert null != message;
Bus origBus = BusFactory.getAndSetThreadDefaultBus(bus);
ClassLoaderHolder origLoader = null;
try {
if (loader != null) {
origLoader = ClassLoaderUtils.setThreadContextClassloader(loader);
}
Exchange exchange = message.getExchange();
Message faultMessage;
if (isOutboundObserver()) {
Exception ex = message.getContent(Exception.class);
if (!(ex instanceof Fault)) {
ex = new Fault(ex);
}
FaultMode mode = message.get(FaultMode.class);
faultMessage = exchange.getOutMessage();
if (null == faultMessage) {
faultMessage = new MessageImpl();
faultMessage.setExchange(exchange);
faultMessage = exchange.getEndpoint().getBinding().createMessage(faultMessage);
}
faultMessage.setContent(Exception.class, ex);
if (null != mode) {
faultMessage.put(FaultMode.class, mode);
}
// CXF-3981
if (message.get("javax.xml.ws.addressing.context.inbound") != null) {
faultMessage.put("javax.xml.ws.addressing.context.inbound", message.get("javax.xml.ws.addressing.context.inbound"));
}
exchange.setOutMessage(null);
exchange.setOutFaultMessage(faultMessage);
if (message.get(BindingFaultInfo.class) != null) {
faultMessage.put(BindingFaultInfo.class, message.get(BindingFaultInfo.class));
}
} else {
faultMessage = message;
exchange.setInMessage(null);
exchange.setInFaultMessage(faultMessage);
}
// setup chain
PhaseInterceptorChain chain = new PhaseInterceptorChain(getPhases());
initializeInterceptors(faultMessage.getExchange(), chain);
faultMessage.setInterceptorChain(chain);
try {
chain.doIntercept(faultMessage);
} catch (RuntimeException exc) {
LOG.log(Level.SEVERE, "ERROR_DURING_ERROR_PROCESSING", exc);
throw exc;
} catch (Exception exc) {
LOG.log(Level.SEVERE, "ERROR_DURING_ERROR_PROCESSING", exc);
throw new RuntimeException(exc);
}
} finally {
if (origBus != bus) {
BusFactory.setThreadDefaultBus(origBus);
}
if (origLoader != null) {
origLoader.reset();
}
}
}
Aggregations