You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by hi...@apache.org on 2013/07/12 21:25:41 UTC
svn commit: r1502663 [1/7] - in /synapse/trunk/java: ./
modules/core/src/main/java/org/apache/synapse/core/relay/
modules/integration/src/test/resources/axis2Xml/synapse/
modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru...
Author: hiranya
Date: Fri Jul 12 19:25:40 2013
New Revision: 1502663
URL: http://svn.apache.org/r1502663
Log:
Adding the fixes for SYNAPSE-920. Temporarily disabled the integration tests.
Added:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/relay/
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/relay/ServiceRequestEarlyBuilder.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ClientWorker.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ConnectCallback.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/DeliveryAgent.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ErrorCodes.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/HostnameVerifier.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/HttpGetRequestProcessor.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/PassThroughConstants.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/PassThroughHttpListener.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/PassThroughHttpSSLListener.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/PassThroughHttpSSLSender.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/PassThroughHttpSender.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/Pipe.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ProtocolState.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/SSLSourceIOEventDispatch.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/SSLTargetIOEventDispatch.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ServerWorker.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/SourceContext.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/SourceHandler.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/SourceIOEventDispatch.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/SourceRequest.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/SourceResponse.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetContext.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetErrorHandler.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetHandler.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetIOEventDispatch.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetRequest.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetResponse.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/config/
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/config/BaseConfiguration.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/config/PassThroughConfigPNames.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/config/PassThroughConfiguration.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/config/SourceConfiguration.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/config/TargetConfiguration.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/connections/
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/connections/HostConnections.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/connections/SourceConnections.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/connections/TargetConnections.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/jmx/
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/jmx/ConnectionsView.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/jmx/ConnectionsViewMBean.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/jmx/LatencyView.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/jmx/LatencyViewMBean.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/jmx/MBeanRegistrar.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/jmx/PassThroughTransportMetricsCollector.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/jmx/TransportView.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/jmx/TransportViewMBean.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/logging/
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/logging/LoggingIOSession.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/logging/LoggingNHttpSourceConnection.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/logging/LoggingNHttpTargetConnection.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/logging/LoggingSourceHandler.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/logging/LoggingTargetHandler.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/logging/LoggingUtils.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/logging/Wire.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/util/
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/util/BinaryRelayBuilder.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/util/BufferFactory.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/util/DeferredMessageBuilder.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/util/ExpandingMessageFormatter.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/util/PassThroughTransportUtils.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/util/RelayConstants.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/util/RelaySecurityMessageBuilderDispatchHandler.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/util/RelayUtils.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/util/SourceResponseFactory.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/util/StreamingOnRequestDataSource.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/util/TargetRequestFactory.java
synapse/trunk/java/repository/conf/axis2_server.xml
Modified:
synapse/trunk/java/modules/integration/src/test/resources/axis2Xml/synapse/axis2_def.xml
synapse/trunk/java/pom.xml
synapse/trunk/java/repository/conf/axis2.xml
Added: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/relay/ServiceRequestEarlyBuilder.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/relay/ServiceRequestEarlyBuilder.java?rev=1502663&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/relay/ServiceRequestEarlyBuilder.java (added)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/relay/ServiceRequestEarlyBuilder.java Fri Jul 12 19:25:40 2013
@@ -0,0 +1,119 @@
+/*
+* Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+* WSO2 Inc. licenses this file to you under the Apache License,
+* Version 2.0 (the "License"); you may not use this file except
+* in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.synapse.core.relay;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.synapse.SynapseConstants;
+import org.apache.synapse.config.SynapseConfiguration;
+import org.apache.synapse.core.axis2.ProxyService;
+import org.apache.synapse.transport.passthru.util.RelayConstants;
+import org.apache.synapse.transport.passthru.util.RelayUtils;
+
+import javax.xml.stream.XMLStreamException;
+import java.io.IOException;
+
+public class ServiceRequestEarlyBuilder extends AbstractHandler {
+
+ public InvocationResponse invoke(MessageContext messageContext) throws AxisFault {
+ OperationContext operationContext = messageContext.getOperationContext();
+ if (operationContext == null) {
+ AxisService service = messageContext.getAxisService();
+ if (service != null) {
+ if ("__ADDR_ONLY__".equals(service.getName())) {
+ // handling dual channel invocations
+ return buildMessage(messageContext);
+ }
+
+ // Possible service mediation mode
+ AxisConfiguration axisConfiguration = messageContext.getConfigurationContext().
+ getAxisConfiguration();
+ SynapseConfiguration synapseConfig = (SynapseConfiguration) axisConfiguration.getParameterValue(
+ SynapseConstants.SYNAPSE_CONFIG);
+ ProxyService proxy = synapseConfig.getProxyService(service.getName());
+ if (proxy != null) {
+ AxisOperation operation = messageContext.getAxisOperation();
+ if (proxy.isModuleEngaged() || (operation == null && proxy.isWsdlPublished())) {
+ // We have some Axis2 level processing to do (security, RM, addressing etc)
+ // or we have more dispatching left to do
+ return buildMessage(messageContext);
+ } else if (operation == null && !proxy.isWsdlPublished()) {
+ operation = service.getOperation(SynapseConstants.SYNAPSE_OPERATION_NAME);
+ }
+
+ if (operation != null) {
+ return invokeMessageReceiver(messageContext, operation);
+ }
+ }
+ } else {
+ // Message mediation mode
+ service = messageContext.getConfigurationContext().
+ getAxisConfiguration().getService(SynapseConstants.SYNAPSE_SERVICE_NAME);
+ messageContext.setAxisService(service);
+ AxisOperation operation = service.getOperation(SynapseConstants.SYNAPSE_OPERATION_NAME);
+ messageContext.setAxisOperation(operation);
+ return invokeMessageReceiver(messageContext, operation);
+ }
+ } else {
+ MessageContext outMessage = operationContext.getMessageContext(
+ WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+ if (outMessage != null && Boolean.TRUE.equals(
+ outMessage.getProperty(RelayConstants.FORCE_RESPONSE_EARLY_BUILD))) {
+ return buildMessage(messageContext);
+ }
+
+ AxisOperation operation = messageContext.getAxisOperation();
+ if (operation != null && operation.getName().getLocalPart().
+ startsWith(Sandesha2Constants.SANDESHA_OP_PREFIX)) {
+ return buildMessage(messageContext);
+ }
+ }
+
+ return InvocationResponse.CONTINUE;
+ }
+
+ private InvocationResponse invokeMessageReceiver(MessageContext messageContext,
+ AxisOperation operation) throws AxisFault {
+ messageContext.getConfigurationContext().
+ fillServiceContextAndServiceGroupContext(messageContext);
+ OperationContext opContext = operation.findOperationContext(messageContext,
+ messageContext.getServiceContext());
+ messageContext.setOperationContext(opContext);
+ operation.getMessageReceiver().receive(messageContext);
+ return InvocationResponse.ABORT;
+ }
+
+ private InvocationResponse buildMessage(MessageContext messageContext) throws AxisFault {
+ try {
+ RelayUtils.buildMessage(messageContext, true);
+ } catch (IOException e) {
+ throw new AxisFault("I/O error while reading from the input stream");
+ } catch (XMLStreamException e) {
+ throw new AxisFault("Unexpected error while parsing the XML content");
+ }
+ return InvocationResponse.CONTINUE;
+ }
+}
\ No newline at end of file
Modified: synapse/trunk/java/modules/integration/src/test/resources/axis2Xml/synapse/axis2_def.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/resources/axis2Xml/synapse/axis2_def.xml?rev=1502663&r1=1502662&r2=1502663&view=diff
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/resources/axis2Xml/synapse/axis2_def.xml (original)
+++ synapse/trunk/java/modules/integration/src/test/resources/axis2Xml/synapse/axis2_def.xml Fri Jul 12 19:25:40 2013
@@ -127,15 +127,15 @@
<!--format serialization in Axis2. These message formats are expected to be resolved based on the content type. -->
<messageFormatters>
<messageFormatter contentType="application/x-www-form-urlencoded"
- class="org.apache.synapse.core.relay.ExpandingMessageFormatter"/>
+ class="org.apache.synapse.transport.passthru.util.ExpandingMessageFormatter"/>
<messageFormatter contentType="multipart/form-data"
- class="org.apache.synapse.core.relay.ExpandingMessageFormatter"/>
+ class="org.apache.synapse.transport.passthru.util.ExpandingMessageFormatter"/>
<messageFormatter contentType="application/xml"
- class="org.apache.synapse.core.relay.ExpandingMessageFormatter"/>
+ class="org.apache.synapse.transport.passthru.util.ExpandingMessageFormatter"/>
<messageFormatter contentType="text/xml"
- class="org.apache.synapse.core.relay.ExpandingMessageFormatter"/>
+ class="org.apache.synapse.transport.passthru.util.ExpandingMessageFormatter"/>
<messageFormatter contentType="multipart/related"
- class="org.apache.synapse.core.relay.ExpandingMessageFormatter"/>
+ class="org.apache.synapse.transport.passthru.util.ExpandingMessageFormatter"/>
<!--messageFormatter contentType="application/x-www-form-urlencoded"
class="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/>
@@ -159,15 +159,15 @@
<!--formats in Axis2. These message formats are expected to be resolved based on the content type. -->
<messageBuilders>
<messageBuilder contentType="application/xml"
- class="org.apache.synapse.core.relay.BinaryRelayBuilder"/>
+ class="org.apache.synapse.transport.passthru.util.BinaryRelayBuilder"/>
<messageBuilder contentType="application/x-www-form-urlencoded"
- class="org.apache.synapse.core.relay.BinaryRelayBuilder"/>
+ class="org.apache.synapse.transport.passthru.util.BinaryRelayBuilder"/>
<messageBuilder contentType="multipart/form-data"
- class="org.apache.synapse.core.relay.BinaryRelayBuilder"/>
+ class="org.apache.synapse.transport.passthru.util.BinaryRelayBuilder"/>
<messageBuilder contentType="text/xml"
- class="org.apache.synapse.core.relay.BinaryRelayBuilder"/>
+ class="org.apache.synapse.transport.passthru.util.BinaryRelayBuilder"/>
<messageBuilder contentType="multipart/related"
- class="org.apache.synapse.core.relay.BinaryRelayBuilder"/>
+ class="org.apache.synapse.transport.passthru.util.BinaryRelayBuilder"/>
<!--messageBuilder contentType="application/xml"
class="org.apache.axis2.builder.ApplicationXMLBuilder"/>
Added: synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ClientWorker.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ClientWorker.java?rev=1502663&view=auto
==============================================================================
--- synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ClientWorker.java (added)
+++ synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ClientWorker.java Fri Jul 12 19:25:40 2013
@@ -0,0 +1,248 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.synapse.transport.passthru;
+
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.http.HttpStatus;
+import org.apache.http.protocol.HTTP;
+import org.apache.axis2.builder.BuilderUtil;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.Constants;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axiom.soap.*;
+import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.transport.nhttp.NhttpConstants;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.Comparator;
+
+public class ClientWorker implements Runnable {
+ private Log log = LogFactory.getLog(ClientWorker.class);
+ /** the Axis2 configuration context */
+ private ConfigurationContext cfgCtx = null;
+ /** the response message context that would be created */
+ private org.apache.axis2.context.MessageContext responseMsgCtx = null;
+ /** the HttpResponse received */
+ private TargetResponse response = null;
+ /** weather a body is expected or not */
+ private boolean expectEntityBody = true;
+
+ public ClientWorker(ConfigurationContext cfgCtx,
+ MessageContext outMsgCtx,
+ TargetResponse response) {
+ this.cfgCtx = cfgCtx;
+ this.response = response;
+ this.expectEntityBody = response.isExpectResponseBody();
+
+ Map<String,String> headers = response.getHeaders();
+
+ String oriURL = headers.get(PassThroughConstants.LOCATION);
+
+ // Special casing 302 scenario in following section. Not sure whether it's the correct fix,
+ // but this fix makes it possible to do http --> https redirection.
+ if (oriURL != null && response.getStatus() != HttpStatus.SC_MOVED_TEMPORARILY) {
+ URL url = null;
+ try {
+ url = new URL(oriURL);
+ } catch (MalformedURLException e) {
+ log.error("Invalid URL received",e);
+ return;
+ }
+
+ headers.remove(PassThroughConstants.LOCATION);
+ String prfix = (String) outMsgCtx.getProperty(PassThroughConstants.SERVICE_PREFIX);
+ if (prfix != null) {
+ headers.put(PassThroughConstants.LOCATION, prfix + url.getFile());
+ }
+
+ }
+
+ try {
+ responseMsgCtx = outMsgCtx.getOperationContext().
+ getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
+ // fix for RM to work because of a soapAction and wsaAction conflict
+ if (responseMsgCtx != null) {
+ responseMsgCtx.setSoapAction("");
+ }
+ } catch (AxisFault af) {
+ log.error("Error getting IN message context from the operation context", af);
+ return;
+ }
+
+ if (responseMsgCtx == null) {
+ if (outMsgCtx.getOperationContext().isComplete()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Error getting IN message context from the operation context. " +
+ "Possibly an RM terminate sequence message");
+ }
+ return;
+
+ }
+ responseMsgCtx = new MessageContext();
+ responseMsgCtx.setOperationContext(outMsgCtx.getOperationContext());
+ }
+
+ // copy the important properties from the original message context
+ responseMsgCtx.setProperty(PassThroughConstants.PASS_THROUGH_SOURCE_CONNECTION,
+ outMsgCtx.getProperty(PassThroughConstants.PASS_THROUGH_SOURCE_CONNECTION));
+ responseMsgCtx.setProperty(PassThroughConstants.PASS_THROUGH_SOURCE_CONFIGURATION,
+ outMsgCtx.getProperty(PassThroughConstants.PASS_THROUGH_SOURCE_CONFIGURATION));
+
+ responseMsgCtx.setServerSide(true);
+ responseMsgCtx.setDoingREST(outMsgCtx.isDoingREST());
+ responseMsgCtx.setProperty(MessageContext.TRANSPORT_IN, outMsgCtx
+ .getProperty(MessageContext.TRANSPORT_IN));
+ responseMsgCtx.setTransportIn(outMsgCtx.getTransportIn());
+ responseMsgCtx.setTransportOut(outMsgCtx.getTransportOut());
+
+ // set any transport headers received
+ Set<Map.Entry<String, String>> headerEntries = response.getHeaders().entrySet();
+ Map<String, String> headerMap = new TreeMap<String, String>(new Comparator<String>() {
+ public int compare(String o1, String o2) {
+ return o1.compareToIgnoreCase(o2);
+ }
+ });
+
+ for (Map.Entry<String, String> headerEntry : headerEntries) {
+ headerMap.put(headerEntry.getKey(), headerEntry.getValue());
+ }
+ responseMsgCtx.setProperty(MessageContext.TRANSPORT_HEADERS, headerMap);
+
+ if (response.getStatus() == 202) {
+ responseMsgCtx.setProperty(AddressingConstants.
+ DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.TRUE);
+ responseMsgCtx.setProperty(PassThroughConstants.MESSAGE_BUILDER_INVOKED, Boolean.TRUE);
+ responseMsgCtx.setProperty(NhttpConstants.SC_ACCEPTED, Boolean.TRUE);
+ }
+
+ responseMsgCtx.setAxisMessage(outMsgCtx.getOperationContext().getAxisOperation().
+ getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
+ responseMsgCtx.setOperationContext(outMsgCtx.getOperationContext());
+ responseMsgCtx.setConfigurationContext(outMsgCtx.getConfigurationContext());
+ responseMsgCtx.setTo(null);
+
+ responseMsgCtx.setProperty(PassThroughConstants.PASS_THROUGH_PIPE, response.getPipe());
+ responseMsgCtx.setProperty(PassThroughConstants.PASS_THROUGH_TARGET_RESPONSE, response);
+ responseMsgCtx.setProperty(PassThroughConstants.PASS_THROUGH_TARGET_CONNECTION,
+ response.getConnection());
+ }
+
+ public void run() {
+ if (responseMsgCtx == null) {
+ return;
+ }
+
+ try {
+ if (expectEntityBody) {
+ String cType = response.getHeader(HTTP.CONTENT_TYPE);
+ String contentType;
+ if (cType != null) {
+ // This is the most common case - Most of the time servers send the Content-Type
+ contentType = cType;
+ } else {
+ // Server hasn't sent the header - Try to infer the content type
+ contentType = inferContentType();
+ }
+
+ responseMsgCtx.setProperty(Constants.Configuration.CONTENT_TYPE, contentType);
+
+ String charSetEnc = BuilderUtil.getCharSetEncoding(contentType);
+ if (charSetEnc == null) {
+ charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
+ }
+
+ responseMsgCtx.setProperty(
+ Constants.Configuration.CHARACTER_SET_ENCODING,
+ contentType.indexOf(HTTP.CHARSET_PARAM) > 0 ?
+ charSetEnc : MessageContext.DEFAULT_CHAR_SET_ENCODING);
+
+ responseMsgCtx.setServerSide(false);
+ SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
+ SOAPEnvelope envelope = fac.getDefaultEnvelope();
+ try {
+ responseMsgCtx.setEnvelope(envelope);
+ } catch (AxisFault axisFault) {
+ log.error("Error setting SOAP envelope", axisFault);
+ }
+
+ responseMsgCtx.setServerSide(true);
+ } else {
+ // there is no response entity-body
+ responseMsgCtx.setProperty(PassThroughConstants.NO_ENTITY_BODY, Boolean.TRUE);
+ responseMsgCtx.setEnvelope(new SOAP11Factory().getDefaultEnvelope());
+ }
+
+ // copy the HTTP status code as a message context property with the key HTTP_SC to be
+ // used at the sender to set the proper status code when passing the message
+ int statusCode = this.response.getStatus();
+ responseMsgCtx.setProperty(PassThroughConstants.HTTP_SC, statusCode);
+ if (statusCode >= 400) {
+ responseMsgCtx.setProperty(PassThroughConstants.FAULT_MESSAGE,
+ PassThroughConstants.TRUE);
+ } /*else if (statusCode == 202 && responseMsgCtx.getOperationContext().isComplete()) {
+ // Handle out-only invocation scenario
+ responseMsgCtx.setProperty(PassThroughConstants.MESSAGE_BUILDER_INVOKED, Boolean.TRUE);
+ }*/
+ responseMsgCtx.setProperty(PassThroughConstants.NON_BLOCKING_TRANSPORT, true);
+
+ // process response received
+ try {
+ AxisEngine.receive(responseMsgCtx);
+ } catch (AxisFault af) {
+ log.error("Fault processing response message through Axis2", af);
+ }
+
+ } catch (AxisFault af) {
+ log.error("Fault creating response SOAP envelope", af);
+ } catch (IOException e) {
+ log.error("Error closing input stream from which message was read", e);
+ }
+ }
+
+ private String inferContentType() {
+ // Try to get the content type from the message context
+ Object cTypeProperty = responseMsgCtx.getProperty(PassThroughConstants.CONTENT_TYPE);
+ if (cTypeProperty != null) {
+ return cTypeProperty.toString();
+ }
+ // Try to get the content type from the axis configuration
+ Parameter cTypeParam = cfgCtx.getAxisConfiguration().getParameter(
+ PassThroughConstants.CONTENT_TYPE);
+ if (cTypeParam != null) {
+ return cTypeParam.getValue().toString();
+ }
+ // Unable to determine the content type - Return default value
+ return PassThroughConstants.DEFAULT_CONTENT_TYPE;
+ }
+
+}
Added: synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ConnectCallback.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ConnectCallback.java?rev=1502663&view=auto
==============================================================================
--- synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ConnectCallback.java (added)
+++ synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ConnectCallback.java Fri Jul 12 19:25:40 2013
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.synapse.transport.passthru;
+
+import org.apache.http.nio.reactor.SessionRequestCallback;
+import org.apache.http.nio.reactor.SessionRequest;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.transport.passthru.connections.HostConnections;
+
+public class ConnectCallback implements SessionRequestCallback {
+
+ private static Log log = LogFactory.getLog(ConnectCallback.class);
+
+ /** The agent used for delivering requests */
+ private DeliveryAgent deliveryAgent;
+
+ /**
+ * Create the callback for the handling events on a given connection
+ */
+ public ConnectCallback() {
+
+ }
+
+ public void completed(SessionRequest request) {
+ HostConnections pool = (HostConnections) request.getAttachment();
+ pool.pendingConnectionSucceeded();
+ if (log.isDebugEnabled()) {
+ if (request.getSession() != null &&
+ request.getSession().getLocalAddress() != null) {
+ log.debug("Connected to remote address: " +
+ request.getSession().getRemoteAddress() +
+ " from local address: " + request.getSession().getLocalAddress());
+ }
+ }
+ }
+
+ public void failed(SessionRequest request) {
+ HostConnections pool = (HostConnections) request.getAttachment();
+ pool.pendingConnectionFailed();
+
+ deliveryAgent.errorConnecting(pool.getHost(), pool.getPort(),
+ ErrorCodes.CONNECTION_FAILED, "Connection Failed");
+
+ handleError("Connection refused or failed for : " + request.getRemoteAddress());
+ }
+
+ public void timeout(SessionRequest request) {
+ HostConnections pool = (HostConnections) request.getAttachment();
+ pool.pendingConnectionFailed();
+
+ deliveryAgent.errorConnecting(pool.getHost(), pool.getPort(),
+ ErrorCodes.CONNECT_TIMEOUT, "Connection Timeout");
+
+ handleError("Timeout connecting to : " + request.getRemoteAddress());
+ request.cancel();
+ }
+
+ public void cancelled(SessionRequest request) {
+ HostConnections pool = (HostConnections) request.getAttachment();
+ pool.pendingConnectionFailed();
+
+ deliveryAgent.errorConnecting(pool.getHost(), pool.getPort(),
+ ErrorCodes.CONNECT_CANCEL, "Connection Cancel");
+
+ handleError("Connection cancelled for : " + request.getRemoteAddress());
+ }
+
+ private void handleError(String errorMessage) {
+ log.warn(errorMessage);
+ }
+
+ public void setDeliveryAgent(DeliveryAgent deliveryAgent) {
+ this.deliveryAgent = deliveryAgent;
+ }
+}
Added: synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/DeliveryAgent.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/DeliveryAgent.java?rev=1502663&view=auto
==============================================================================
--- synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/DeliveryAgent.java (added)
+++ synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/DeliveryAgent.java Fri Jul 12 19:25:40 2013
@@ -0,0 +1,252 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.synapse.transport.passthru;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.nio.NHttpClientConnection;
+import org.apache.synapse.transport.passthru.config.TargetConfiguration;
+import org.apache.synapse.transport.passthru.connections.TargetConnections;
+import org.apache.synapse.transport.passthru.util.TargetRequestFactory;
+
+import java.io.OutputStream;
+import java.util.Queue;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * This class acts as a gateway for differed delivery of the messages. When a message is to be
+ * delivered it is submitted to this class. If a connection is available to the target this
+ * class will try to deliver the message immediately over that connection. If a connection is
+ * not available it will queue the message and request a connection from the pool. When a new
+ * connection is available a queued message will be sent through it.
+ */
+public class DeliveryAgent {
+
+ private static final Log log = LogFactory.getLog(DeliveryAgent.class);
+
+ /**
+ * This Map holds the messages that need to be delivered. But at the moment maximum
+ * number of connections to the host:pair is being used. So these messages has to wait
+ * until a new connection is available.
+ */
+ private Map<String, Queue<MessageContext>> waitingMessages =
+ new ConcurrentHashMap<String, Queue<MessageContext>>();
+
+ /** The connection management */
+ private TargetConnections targetConnections;
+
+ /** Configuration of the sender */
+ private TargetConfiguration targetConfiguration;
+
+ /** The maximum number of messages that can wait for a connection */
+ private int maxWaitingMessages = Integer.MAX_VALUE;
+
+ private TargetErrorHandler targetErrorHandler;
+
+ /** Lock for synchronizing access */
+ private Lock lock = new ReentrantLock();
+
+ /**
+ * Create a delivery agent with the target configuration and connection management.
+ *
+ * @param targetConfiguration configuration of the sender
+ * @param targetConnections connection management
+ */
+ public DeliveryAgent(TargetConfiguration targetConfiguration,
+ TargetConnections targetConnections) {
+ this.targetConfiguration = targetConfiguration;
+ this.targetConnections = targetConnections;
+ this.targetErrorHandler = new TargetErrorHandler(targetConfiguration);
+ }
+
+
+ /**
+ * This method queues the message for delivery. If a connection is already existing for
+ * the destination epr, the message will be delivered immediately. Otherwise message has
+ * to wait until a connection is established. In this case this method will inform the
+ * system about the need for a connection.
+ *
+ * @param msgContext the message context to be sent
+ * @param epr the endpoint to which the message should be sent
+ * @throws AxisFault if an error occurs
+ */
+ public void submit(MessageContext msgContext, EndpointReference epr)
+ throws AxisFault {
+ try {
+ URL url = new URL(epr.getAddress());
+ String host = url.getHost();
+ int port = url.getPort();
+ if (port == -1) {
+ // use default
+ if ("http".equals(url.getProtocol())) {
+ port = 80;
+ } else if ("https".equals(url.getProtocol())) {
+ port = 443;
+ }
+ }
+
+ String key = host + ":" + port;
+
+ // first we queue the message
+ Queue<MessageContext> queue = null;
+ lock.lock();
+ try {
+ queue = waitingMessages.get(key);
+ if (queue == null) {
+ queue = new ConcurrentLinkedQueue<MessageContext>();
+ waitingMessages.put(key, queue);
+ }
+ if (queue.size() == maxWaitingMessages) {
+ MessageContext msgCtx = queue.poll();
+
+ targetErrorHandler.handleError(msgCtx,
+ ErrorCodes.CONNECTION_TIMEOUT,
+ "Error connecting to the back end",
+ null,
+ ProtocolState.REQUEST_READY);
+ }
+
+ queue.add(msgContext);
+ } finally {
+ lock.unlock();
+ }
+
+ NHttpClientConnection conn = targetConnections.getConnection(host, port);
+ if (conn != null) {
+ conn.resetInput();
+ conn.resetOutput();
+ MessageContext messageContext = queue.poll();
+
+ if (messageContext != null) {
+ tryNextMessage(messageContext, conn);
+ }
+ }
+
+ } catch (MalformedURLException e) {
+ handleException("Malformed URL in the target EPR", e);
+ }
+ }
+
+ public void errorConnecting(String host, int port, int errorCode, String message) {
+ String key = host + ":" + port;
+
+ Queue<MessageContext> queue = waitingMessages.get(key);
+ if (queue != null) {
+ MessageContext msgCtx = queue.poll();
+
+ if (msgCtx != null) {
+ targetErrorHandler.handleError(msgCtx,
+ errorCode,
+ "Error connecting to the back end",
+ null,
+ ProtocolState.REQUEST_READY);
+ }
+ } else {
+ throw new IllegalStateException("Queue cannot be null for: " + key);
+ }
+ }
+
+ /**
+ * Notification for a connection availability. When this occurs a message in the
+ * queue for delivery will be tried.
+ *
+ * @param host name of the remote host
+ * @param port remote port number
+ */
+ public void connected(String host, int port) {
+ Queue<MessageContext> queue = null;
+ lock.lock();
+ try {
+ queue = waitingMessages.get(host + ":" + port);
+ } finally {
+ lock.unlock();
+ }
+
+ while (queue.size() > 0) {
+ NHttpClientConnection conn = targetConnections.getConnection(host, port);
+ if (conn != null) {
+ MessageContext messageContext = queue.poll();
+
+ if (messageContext != null) {
+ tryNextMessage(messageContext, conn);
+ }
+ } else {
+ break;
+ }
+ }
+ }
+
+ private void tryNextMessage(MessageContext messageContext, NHttpClientConnection conn) {
+ if (conn != null) {
+ try {
+ TargetContext.get(conn).setRequestMsgCtx(messageContext);
+
+ submitRequest(conn, messageContext);
+ } catch (AxisFault e) {
+ log.error("IO error while sending the request out", e);
+ }
+ }
+ }
+
+ private void submitRequest(NHttpClientConnection conn, MessageContext msgContext) throws AxisFault {
+ if (log.isDebugEnabled()) {
+ log.debug("Submitting new request to the connection: " + conn);
+ }
+
+ TargetRequest request = TargetRequestFactory.create(msgContext, targetConfiguration);
+ TargetContext.setRequest(conn, request);
+
+ Pipe pipe = (Pipe) msgContext.getProperty(PassThroughConstants.PASS_THROUGH_PIPE);
+ if (pipe != null) {
+ pipe.attachConsumer(conn);
+ request.connect(pipe);
+ if (Boolean.TRUE.equals(msgContext.getProperty(PassThroughConstants.MESSAGE_BUILDER_INVOKED))) {
+ synchronized (msgContext) {
+ OutputStream out = pipe.getOutputStream();
+ msgContext.setProperty("GET_ME_OUT", out);
+ msgContext.setProperty("READY2ROCK", Boolean.TRUE);
+ msgContext.notifyAll();
+ }
+ return;
+ }
+ }
+
+ conn.requestOutput();
+ }
+
+ /**
+ * Throws an AxisFault if an error occurs at this level
+ * @param s a message describing the error
+ * @param e original exception leads to the error condition
+ * @throws AxisFault wrapping the original exception
+ */
+ private void handleException(String s, Exception e) throws AxisFault {
+ log.error(s, e);
+ throw new AxisFault(s, e);
+ }
+}
Added: synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ErrorCodes.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ErrorCodes.java?rev=1502663&view=auto
==============================================================================
--- synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ErrorCodes.java (added)
+++ synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ErrorCodes.java Fri Jul 12 19:25:40 2013
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.synapse.transport.passthru;
+
+/**
+ * Error codes exposed by this transport.
+ */
+public class ErrorCodes {
+ public static final int SND_IO_ERROR = 101500;
+
+ public static final int SND_HTTP_ERROR = 102510;
+
+ public static final int SND_INVALID_STATE = 102510;
+
+ public static final int CONNECTION_FAILED = 101503;
+
+ public static final int CONNECTION_TIMEOUT = 101504;
+
+ public static final int CONNECTION_CLOSED = 101505;
+
+ public static final int PROTOCOL_VIOLATION = 101506;
+
+ public static final int CONNECT_CANCEL = 101507;
+
+ public static final int CONNECT_TIMEOUT = 101508;
+}
\ No newline at end of file
Added: synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/HostnameVerifier.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/HostnameVerifier.java?rev=1502663&view=auto
==============================================================================
--- synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/HostnameVerifier.java (added)
+++ synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/HostnameVerifier.java Fri Jul 12 19:25:40 2013
@@ -0,0 +1,577 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+/**
+ * ************************************************************************
+ * Copied from the not-yet-commons-ssl project at http://juliusdavies.ca/commons-ssl/
+ * As the above project is accepted into Apache and its JARs become available in
+ * the Maven 2 repos, we will have to switch to using the JARs instead
+ * ************************************************************************
+ * <p/>
+ * Interface for checking if a hostname matches the names stored inside the
+ * server's X.509 certificate. Correctly implements
+ * javax.net.ssl.HostnameVerifier, but that interface is not recommended.
+ * Instead we added several check() methods that take SSLSocket,
+ * or X509Certificate, or ultimately (they all end up calling this one),
+ * String. (It's easier to supply JUnit with Strings instead of mock
+ * SSLSession objects!)
+ * </p><p>Our check() methods throw exceptions if the name is
+ * invalid, whereas javax.net.ssl.HostnameVerifier just returns true/false.
+ * <p/>
+ * We provide the HostnameVerifier.DEFAULT, HostnameVerifier.STRICT, and
+ * HostnameVerifier.ALLOW_ALL implementations. We also provide the more
+ * specialized HostnameVerifier.DEFAULT_AND_LOCALHOST, as well as
+ * HostnameVerifier.STRICT_IE6. But feel free to define your own
+ * implementations!
+ * <p/>
+ * Inspired by Sebastian Hauer's original StrictSSLProtocolSocketFactory in the
+ * HttpClient "contrib" repository.
+ *
+ * @author Julius Davies
+ * @author <a href="mailto:hauer@psicode.com">Sebastian Hauer</a>
+ * @since 8-Dec-2006
+ */
+
+package org.apache.synapse.transport.passthru;
+
+import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLPeerUnverifiedException;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSocket;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateParsingException;
+import java.security.cert.X509Certificate;
+import java.util.*;
+
+public interface HostnameVerifier extends javax.net.ssl.HostnameVerifier {
+
+ boolean verify(String host, SSLSession session);
+
+ void check(String host, SSLSocket ssl) throws IOException;
+
+ void check(String host, X509Certificate cert) throws SSLException;
+
+ void check(String host, String[] cns, String[] subjectAlts)
+ throws SSLException;
+
+ void check(String[] hosts, SSLSocket ssl) throws IOException;
+
+ void check(String[] hosts, X509Certificate cert) throws SSLException;
+
+
+ /**
+ * Checks to see if the supplied hostname matches any of the supplied CNs
+ * or "DNS" Subject-Alts. Most implementations only look at the first CN,
+ * and ignore any additional CNs. Most implementations do look at all of
+ * the "DNS" Subject-Alts. The CNs or Subject-Alts may contain wildcards
+ * according to RFC 2818.
+ *
+ * @param cns CN fields, in order, as extracted from the X.509
+ * certificate.
+ * @param subjectAlts Subject-Alt fields of type 2 ("DNS"), as extracted
+ * from the X.509 certificate.
+ * @param hosts The array of hostnames to verify.
+ * @throws SSLException If verification failed.
+ */
+ void check(String[] hosts, String[] cns, String[] subjectAlts)
+ throws SSLException;
+
+
+ /**
+ * The DEFAULT HostnameVerifier works the same way as Curl and Firefox.
+ * <p/>
+ * The hostname must match either the first CN, or any of the subject-alts.
+ * A wildcard can occur in the CN, and in any of the subject-alts.
+ * <p/>
+ * The only difference between DEFAULT and STRICT is that a wildcard (such
+ * as "*.foo.com") with DEFAULT matches all subdomains, including
+ * "a.b.foo.com".
+ */
+ public final static HostnameVerifier DEFAULT =
+ new AbstractVerifier() {
+ public final void check(final String[] hosts, final String[] cns,
+ final String[] subjectAlts)
+ throws SSLException {
+ check(hosts, cns, subjectAlts, false, false);
+ }
+
+ public final String toString() {
+ return "DEFAULT";
+ }
+ };
+
+
+ /**
+ * The DEFAULT_AND_LOCALHOST HostnameVerifier works like the DEFAULT
+ * one with one additional relaxation: a host of "localhost",
+ * "localhost.localdomain", "127.0.0.1", "::1" will always pass, no matter
+ * what is in the server's certificate.
+ */
+ public final static HostnameVerifier DEFAULT_AND_LOCALHOST =
+ new AbstractVerifier() {
+ public final void check(final String[] hosts, final String[] cns,
+ final String[] subjectAlts)
+ throws SSLException {
+ if (isLocalhost(hosts[0])) {
+ return;
+ }
+ check(hosts, cns, subjectAlts, false, false);
+ }
+
+ public final String toString() {
+ return "DEFAULT_AND_LOCALHOST";
+ }
+ };
+
+ /**
+ * The STRICT HostnameVerifier works the same way as java.net.URL in Sun
+ * Java 1.4, Sun Java 5, Sun Java 6. It's also pretty close to IE6.
+ * This implementation appears to be compliant with RFC 2818 for dealing
+ * with wildcards.
+ * <p/>
+ * The hostname must match either the first CN, or any of the subject-alts.
+ * A wildcard can occur in the CN, and in any of the subject-alts. The
+ * one divergence from IE6 is how we only check the first CN. IE6 allows
+ * a match against any of the CNs present. We decided to follow in
+ * Sun Java 1.4's footsteps and only check the first CN.
+ * <p/>
+ * A wildcard such as "*.foo.com" matches only subdomains in the same
+ * level, for example "a.foo.com". It does not match deeper subdomains
+ * such as "a.b.foo.com".
+ */
+ public final static HostnameVerifier STRICT =
+ new AbstractVerifier() {
+ public final void check(final String[] host, final String[] cns,
+ final String[] subjectAlts)
+ throws SSLException {
+ check(host, cns, subjectAlts, false, true);
+ }
+
+ public final String toString() {
+ return "STRICT";
+ }
+ };
+
+ /**
+ * The STRICT_IE6 HostnameVerifier works just like the STRICT one with one
+ * minor variation: the hostname can match against any of the CN's in the
+ * server's certificate, not just the first one. This behaviour is
+ * identical to IE6's behaviour.
+ */
+ public final static HostnameVerifier STRICT_IE6 =
+ new AbstractVerifier() {
+ public final void check(final String[] host, final String[] cns,
+ final String[] subjectAlts)
+ throws SSLException {
+ check(host, cns, subjectAlts, true, true);
+ }
+
+ public final String toString() {
+ return "STRICT_IE6";
+ }
+ };
+
+ /**
+ * The ALLOW_ALL HostnameVerifier essentially turns hostname verification
+ * off. This implementation is a no-op, and never throws the SSLException.
+ */
+ public final static HostnameVerifier ALLOW_ALL =
+ new AbstractVerifier() {
+ public final void check(final String[] host, final String[] cns,
+ final String[] subjectAlts) {
+ // Allow everything - so never blowup.
+ }
+
+ public final String toString() {
+ return "ALLOW_ALL";
+ }
+ };
+
+ abstract class AbstractVerifier implements HostnameVerifier {
+
+ /**
+ * This contains a list of 2nd-level domains that aren't allowed to
+ * have wildcards when combined with country-codes.
+ * For example: [*.co.uk].
+ * <p/>
+ * The [*.co.uk] problem is an interesting one. Should we just hope
+ * that CA's would never foolishly allow such a certificate to happen?
+ * Looks like we're the only implementation guarding against this.
+ * Firefox, Curl, Sun Java 1.4, 5, 6 don't bother with this check.
+ */
+ private final static String[] BAD_COUNTRY_2LDS =
+ {"ac", "co", "com", "ed", "edu", "go", "gouv", "gov", "info",
+ "lg", "ne", "net", "or", "org"};
+
+ private final static String[] LOCALHOSTS = {"::1", "127.0.0.1",
+ "localhost",
+ "localhost.localdomain"};
+
+
+ static {
+ // Just in case developer forgot to manually sort the array. :-)
+ Arrays.sort(BAD_COUNTRY_2LDS);
+ Arrays.sort(LOCALHOSTS);
+ }
+
+ protected AbstractVerifier() {
+ }
+
+ /**
+ * The javax.net.ssl.HostnameVerifier contract.
+ *
+ * @param host 'hostname' we used to create our socket
+ * @param session SSLSession with the remote server
+ * @return true if the host matched the one in the certificate.
+ */
+ public boolean verify(String host, SSLSession session) {
+ try {
+ Certificate[] certs = session.getPeerCertificates();
+ X509Certificate x509 = (X509Certificate) certs[0];
+ check(new String[]{host}, x509);
+ return true;
+ }
+ catch (SSLException e) {
+ return false;
+ }
+ }
+
+ public void check(String host, SSLSocket ssl) throws IOException {
+ check(new String[]{host}, ssl);
+ }
+
+ public void check(String host, X509Certificate cert)
+ throws SSLException {
+ check(new String[]{host}, cert);
+ }
+
+ public void check(String host, String[] cns, String[] subjectAlts)
+ throws SSLException {
+ check(new String[]{host}, cns, subjectAlts);
+ }
+
+ public void check(String host[], SSLSocket ssl)
+ throws IOException {
+ if (host == null) {
+ throw new NullPointerException("host to verify is null");
+ }
+
+ SSLSession session = ssl.getSession();
+ if (session == null) {
+ // In our experience this only happens under IBM 1.4.x when
+ // spurious (unrelated) certificates show up in the server'
+ // chain. Hopefully this will unearth the real problem:
+ InputStream in = ssl.getInputStream();
+ in.available();
+ /*
+ If you're looking at the 2 lines of code above because
+ you're running into a problem, you probably have two
+ options:
+
+ #1. Clean up the certificate chain that your server
+ is presenting (e.g. edit "/etc/apache2/server.crt"
+ or wherever it is your server's certificate chain
+ is defined).
+
+ OR
+
+ #2. Upgrade to an IBM 1.5.x or greater JVM, or switch
+ to a non-IBM JVM.
+ */
+
+ // If ssl.getInputStream().available() didn't cause an
+ // exception, maybe at least now the session is available?
+ session = ssl.getSession();
+ if (session == null) {
+ // If it's still null, probably a startHandshake() will
+ // unearth the real problem.
+ ssl.startHandshake();
+
+ // Okay, if we still haven't managed to cause an exception,
+ // might as well go for the NPE. Or maybe we're okay now?
+ session = ssl.getSession();
+ }
+ }
+ Certificate[] certs;
+ try {
+ certs = session.getPeerCertificates();
+ } catch (SSLPeerUnverifiedException spue) {
+ InputStream in = ssl.getInputStream();
+ in.available();
+ // Didn't trigger anything interesting? Okay, just throw
+ // original.
+ throw spue;
+ }
+ X509Certificate x509 = (X509Certificate) certs[0];
+ check(host, x509);
+ }
+
+ public void check(String[] host, X509Certificate cert)
+ throws SSLException {
+
+ String[] cns = Certificates.getCNs(cert);
+ String[] subjectAlts = Certificates.getDNSSubjectAlts(cert);
+ check(host, cns, subjectAlts);
+
+ }
+
+ public void check(final String[] hosts, final String[] cns,
+ final String[] subjectAlts, final boolean ie6,
+ final boolean strictWithSubDomains)
+ throws SSLException {
+ // Build up lists of allowed hosts For logging/debugging purposes.
+ StringBuffer buf = new StringBuffer(32);
+ buf.append('<');
+ for (int i = 0; i < hosts.length; i++) {
+ String h = hosts[i];
+ h = h != null ? h.trim().toLowerCase() : "";
+ hosts[i] = h;
+ if (i > 0) {
+ buf.append('/');
+ }
+ buf.append(h);
+ }
+ buf.append('>');
+ String hostnames = buf.toString();
+ // Build the list of names we're going to check. Our DEFAULT and
+ // STRICT implementations of the HostnameVerifier only use the
+ // first CN provided. All other CNs are ignored.
+ // (Firefox, wget, curl, Sun Java 1.4, 5, 6 all work this way).
+ TreeSet names = new TreeSet();
+ if (cns != null && cns.length > 0 && cns[0] != null) {
+ names.add(cns[0]);
+ if (ie6) {
+ for (int i = 1; i < cns.length; i++) {
+ names.add(cns[i]);
+ }
+ }
+ }
+ if (subjectAlts != null) {
+ for (int i = 0; i < subjectAlts.length; i++) {
+ if (subjectAlts[i] != null) {
+ names.add(subjectAlts[i]);
+ }
+ }
+ }
+ if (names.isEmpty()) {
+ String msg = "Certificate for " + hosts[0] + " doesn't contain CN or DNS subjectAlt";
+ throw new SSLException(msg);
+ }
+
+ // StringBuffer for building the error message.
+ buf = new StringBuffer();
+
+ boolean match = false;
+ out:
+ for (Iterator it = names.iterator(); it.hasNext();) {
+ // Don't trim the CN, though!
+ String cn = (String) it.next();
+ cn = cn.toLowerCase();
+ // Store CN in StringBuffer in case we need to report an error.
+ buf.append(" <");
+ buf.append(cn);
+ buf.append('>');
+ if (it.hasNext()) {
+ buf.append(" OR");
+ }
+
+ // The CN better have at least two dots if it wants wildcard
+ // action. It also can't be [*.co.uk] or [*.co.jp] or
+ // [*.org.uk], etc...
+ boolean doWildcard = cn.startsWith("*.") &&
+ cn.lastIndexOf('.') >= 0 &&
+ !isIP4Address(cn) &&
+ acceptableCountryWildcard(cn);
+
+ for (int i = 0; i < hosts.length; i++) {
+ final String hostName = hosts[i].trim().toLowerCase();
+ if (doWildcard) {
+ match = hostName.endsWith(cn.substring(1));
+ if (match && strictWithSubDomains) {
+ // If we're in strict mode, then [*.foo.com] is not
+ // allowed to match [a.b.foo.com]
+ match = countDots(hostName) == countDots(cn);
+ }
+ } else {
+ match = hostName.equals(cn);
+ }
+ if (match) {
+ break out;
+ }
+ }
+ }
+ if (!match) {
+ throw new SSLException("hostname in certificate didn't match: " + hostnames + " !=" + buf);
+ }
+ }
+
+ public static boolean isIP4Address(final String cn) {
+ boolean isIP4 = true;
+ String tld = cn;
+ int x = cn.lastIndexOf('.');
+ // We only bother analyzing the characters after the final dot
+ // in the name.
+ if (x >= 0 && x + 1 < cn.length()) {
+ tld = cn.substring(x + 1);
+ }
+ for (int i = 0; i < tld.length(); i++) {
+ if (!Character.isDigit(tld.charAt(0))) {
+ isIP4 = false;
+ break;
+ }
+ }
+ return isIP4;
+ }
+
+ public static boolean acceptableCountryWildcard(final String cn) {
+ int cnLen = cn.length();
+ if (cnLen >= 7 && cnLen <= 9) {
+ // Look for the '.' in the 3rd-last position:
+ if (cn.charAt(cnLen - 3) == '.') {
+ // Trim off the [*.] and the [.XX].
+ String s = cn.substring(2, cnLen - 3);
+ // And test against the sorted array of bad 2lds:
+ int x = Arrays.binarySearch(BAD_COUNTRY_2LDS, s);
+ return x < 0;
+ }
+ }
+ return true;
+ }
+
+ public static boolean isLocalhost(String host) {
+ host = host != null ? host.trim().toLowerCase() : "";
+ if (host.startsWith("::1")) {
+ int x = host.lastIndexOf('%');
+ if (x >= 0) {
+ host = host.substring(0, x);
+ }
+ }
+ int x = Arrays.binarySearch(LOCALHOSTS, host);
+ return x >= 0;
+ }
+
+ /**
+ * Counts the number of dots "." in a string.
+ *
+ * @param s string to count dots from
+ * @return number of dots
+ */
+ public static int countDots(final String s) {
+ int count = 0;
+ for (int i = 0; i < s.length(); i++) {
+ if (s.charAt(i) == '.') {
+ count++;
+ }
+ }
+ return count;
+ }
+ }
+
+ class Certificates {
+ public static String[] getCNs(X509Certificate cert) {
+ LinkedList cnList = new LinkedList();
+ /*
+ Sebastian Hauer's original StrictSSLProtocolSocketFactory used
+ getName() and had the following comment:
+
+ Parses a X.500 distinguished name for the value of the
+ "Common Name" field. This is done a bit sloppy right
+ now and should probably be done a bit more according to
+ <code>RFC 2253</code>.
+
+ I've noticed that toString() seems to do a better job than
+ getName() on these X500Principal objects, so I'm hoping that
+ addresses Sebastian's concern.
+
+ For example, getName() gives me this:
+ 1.2.840.113549.1.9.1=#16166a756c6975736461766965734063756362632e636f6d
+
+ whereas toString() gives me this:
+ EMAILADDRESS=juliusdavies@cucbc.com
+
+ Looks like toString() even works with non-ascii domain names!
+ I tested it with "花子.co.jp" and it worked fine.
+ */
+ String subjectPrincipal = cert.getSubjectX500Principal().toString();
+ StringTokenizer st = new StringTokenizer(subjectPrincipal, ",");
+ while (st.hasMoreTokens()) {
+ String tok = st.nextToken();
+ int x = tok.indexOf("CN=");
+ if (x >= 0) {
+ cnList.add(tok.substring(x + 3));
+ }
+ }
+ if (!cnList.isEmpty()) {
+ String[] cns = new String[cnList.size()];
+ cnList.toArray(cns);
+ return cns;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Extracts the array of SubjectAlt DNS names from an X509Certificate.
+ * Returns null if there aren't any.
+ * <p/>
+ * Note: Java doesn't appear able to extract international characters
+ * from the SubjectAlts. It can only extract international characters
+ * from the CN field.
+ * <p/>
+ * (Or maybe the version of OpenSSL I'm using to test isn't storing the
+ * international characters correctly in the SubjectAlts?).
+ *
+ * @param cert X509Certificate
+ * @return Array of SubjectALT DNS names stored in the certificate.
+ */
+ public static String[] getDNSSubjectAlts(X509Certificate cert) {
+ LinkedList subjectAltList = new LinkedList();
+ Collection c = null;
+ try {
+ c = cert.getSubjectAlternativeNames();
+ }
+ catch (CertificateParsingException cpe) {
+ // Should probably log.debug() this?
+ cpe.printStackTrace();
+ }
+ if (c != null) {
+ Iterator it = c.iterator();
+ while (it.hasNext()) {
+ List list = (List) it.next();
+ int type = ((Integer) list.get(0)).intValue();
+ // If type is 2, then we've got a dNSName
+ if (type == 2) {
+ String s = (String) list.get(1);
+ subjectAltList.add(s);
+ }
+ }
+ }
+ if (!subjectAltList.isEmpty()) {
+ String[] subjectAlts = new String[subjectAltList.size()];
+ subjectAltList.toArray(subjectAlts);
+ return subjectAlts;
+ } else {
+ return null;
+ }
+ }
+ }
+}
\ No newline at end of file
Added: synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/HttpGetRequestProcessor.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/HttpGetRequestProcessor.java?rev=1502663&view=auto
==============================================================================
--- synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/HttpGetRequestProcessor.java (added)
+++ synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/HttpGetRequestProcessor.java Fri Jul 12 19:25:40 2013
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.synapse.transport.passthru;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.nio.NHttpServerConnection;
+
+import java.io.OutputStream;
+
+/**
+ * This Passthrough transport level interface is used for plugging in different implementations for special processing of some
+ * HTTP GET requests.
+ * <p/>
+ * e.g. ?wsdl, ?wsdl2 etc.
+ * <p/>
+ * If you need to handle a special HTTP GET request, you have to write an implementation of this
+ * interface.
+ */
+public interface HttpGetRequestProcessor {
+ /**
+ * Initialize the HttpGetProcessor
+ * @param cfgCtx servers configuration context
+ * @param serverHandler dispatching handler
+ * @throws AxisFault if an error occurs
+ */
+ void init(ConfigurationContext cfgCtx, SourceHandler handler) throws AxisFault;
+
+ /**
+ * Process the HTTP GET request.
+ *
+ * @param request The HttpRequest
+ * @param response The HttpResponse
+ * @param msgContext The MessageContext
+ * @param conn The NHttpServerConnection
+ * @param os The OutputStream
+ * @param isRestDispatching Rest dispatching
+ */
+ void process(HttpRequest request,
+ HttpResponse response,
+ MessageContext msgContext,
+ NHttpServerConnection conn,
+ OutputStream os,
+ boolean isRestDispatching);
+
+}
Added: synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/PassThroughConstants.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/PassThroughConstants.java?rev=1502663&view=auto
==============================================================================
--- synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/PassThroughConstants.java (added)
+++ synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/PassThroughConstants.java Fri Jul 12 19:25:40 2013
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.synapse.transport.passthru;
+
+public class PassThroughConstants {
+
+ public static final int DEFAULT_IO_THREAD_COUNT = Runtime.getRuntime().availableProcessors();
+ public static final int DEFAULT_MAX_CONN_PER_HOST_PORT = Integer.MAX_VALUE;
+
+ public static final String REQUEST_MESSAGE_CONTEXT = "REQUEST_MESSAGE_CONTEXT";
+ public static final String CONNECTION_POOL = "CONNECTION_POOL";
+
+ public static final String TRUE = "TRUE";
+
+ public static final String FAULT_MESSAGE = "FAULT_MESSAGE"; // corresponds with BaseConstants
+ public static final String FAULTS_AS_HTTP_200 = "FAULTS_AS_HTTP_200";
+ public static final String SC_ACCEPTED = "SC_ACCEPTED";
+ public static final String HTTP_SC = "HTTP_SC";
+ public static final String FORCE_HTTP_1_0 = "FORCE_HTTP_1.0";
+ public static final String DISABLE_CHUNKING = "DISABLE_CHUNKING";
+ public static final String FULL_URI = "FULL_URI";
+ public static final String NO_KEEPALIVE = "NO_KEEPALIVE";
+ public static final String DISABLE_KEEPALIVE = "http.connection.disable.keepalive";
+ public static final String IGNORE_SC_ACCEPTED = "IGNORE_SC_ACCEPTED";
+ public static final String FORCE_SC_ACCEPTED = "FORCE_SC_ACCEPTED";
+ public static final String DISCARD_ON_COMPLETE = "DISCARD_ON_COMPLETE";
+
+ public static final String SERVICE_URI_LOCATION = "ServiceURI";
+
+ public static final String WSDL_EPR_PREFIX = "WSDLEPRPrefix";
+
+ public static final String EPR_TO_SERVICE_NAME_MAP = "service.epr.map";
+ public static final String NON_BLOCKING_TRANSPORT = "NonBlockingTransport";
+ public static final String SERIALIZED_BYTES = "SerializedBytes";
+
+ public static final String CONTENT_TYPE = "CONTENT_TYPE";
+
+ public static final String DEFAULT_CONTENT_TYPE = "application/octet-stream";
+
+ public static final String HIDDEN_SERVICE_PARAM_NAME = "hiddenService";
+
+ /** An Axis2 message context property indicating a transport send failure */
+ public static final String SENDING_FAULT = "SENDING_FAULT";
+ /** The message context property name which holds the error code for the last encountered exception */
+ public static final String ERROR_CODE = "ERROR_CODE";
+ /** The MC property name which holds the error message for the last encountered exception */
+ public static final String ERROR_MESSAGE = "ERROR_MESSAGE";
+ /** The message context property name which holds the error detail (stack trace) for the last encountered exception */
+ public static final String ERROR_DETAIL = "ERROR_DETAIL";
+ /** The message context property name which holds the exception (if any) for the last encountered exception */
+ public static final String ERROR_EXCEPTION = "ERROR_EXCEPTION";
+
+ // ********** DO NOT CHANGE THESE UNLESS CORRESPONDING SYNAPSE CONSTANT ARE CHANGED ************
+
+ public static final String REST_URL_POSTFIX = "REST_URL_POSTFIX";
+ public static final String SERVICE_PREFIX = "SERVICE_PREFIX";
+ public static final String NO_ENTITY_BODY = "NO_ENTITY_BODY";
+
+ protected static final String PASS_THROUGH_TRANSPORT_WORKER_POOL =
+ "PASS_THROUGH_TRANSPORT_WORKER_POOL";
+ protected static final String PASS_THROUGH_SOURCE_CONFIGURATION =
+ "PASS_THROUGH_SOURCE_CONFIGURATION";
+ protected static final String PASS_THROUGH_SOURCE_CONNECTION = "pass-through.Source-Connection";
+ protected static final String PASS_THROUGH_SOURCE_REQUEST = "pass-through.Source-Request";
+
+ protected static final String PASS_THROUGH_TARGET_CONNECTION = "pass-through.Target-Connection";
+ protected static final String PASS_THROUGH_TARGET_RESPONSE = "pass-through.Target-Response";
+
+ public static final String PASS_THROUGH_PIPE = "pass-through.pipe";
+
+ // used to define the default content type as a parameter in the axis2.xml
+ public static final String REQUEST_CONTENT_TYPE = "DEFAULT_REQUEST_CONTENT_TYPE";
+
+ // This is a workaround for axis2 RestUtils behaviour
+ public static final String REST_REQUEST_CONTENT_TYPE = "synapse.internal.rest.contentType";
+
+ public static final String MESSAGE_BUILDER_INVOKED = "message.builder.invoked";
+
+ public static final String CLONE_PASS_THROUGH_PIPE_REQUEST = "clone_pass-through.pipe_connected";
+
+ /**
+ * Name of the .mar file
+ */
+ public final static String SECURITY_MODULE_NAME = "rampart";
+
+ public final static String REST_GET_DELETE_INVOKE ="rest_get_delete_invoke";
+
+ public final static String PASS_THROUGH_MESSAGE_LENGTH ="PASS_THROUGH_MESSAGE_LENGTH";
+
+ public static final String CONF_LOCATION = "conf.location";
+
+ public static final String LOCATION = "Location";
+
+ public static final String BUFFERED_INPUT_STREAM = "bufferedInputStream";
+
+ //JMX statistic calculation Constants
+ public static final String REQ_ARRIVAL_TIME = "REQ_ARRIVAL_TIME";
+ public static final String REQ_DEPARTURE_TIME = "REQ_DEPARTURE_TIME";
+ public static final String RES_ARRIVAL_TIME = "RES_ARRIVAL_TIME";
+ public static final String RES_HEADER_ARRIVAL_TIME = "RES_HEADER_ARRIVAL_TIME";
+ public static final String RES_DEPARTURE_TIME = "RES_DEPARTURE_TIME";
+
+ public static final String MESSAGE_OUTPUT_FORMAT = "MESSAGE_OUTPUT_FORMAT";
+
+ public static final String FORCE_SOAP_FAULT = "FORCE_SOAP_FAULT";
+
+ public static final String FORCE_PASS_THROUGH_BUILDER = "force.passthrough.builder";
+
+ public static final String WSDL_GEN_HANDLED = "WSDL_GEN_HANDLED";
+
+
+}