proxy: switch to stubbed out version that logs error that it's no longer supported by BlazeDS (and throws if invoked)
diff --git a/distribution/pom.xml b/distribution/pom.xml
index f3279dd..e363579 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -91,21 +91,13 @@
</dependency>
<dependency>
<groupId>org.apache.flex.blazeds</groupId>
+ <artifactId>flex-messaging-proxy</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.flex.blazeds</groupId>
<artifactId>flex-messaging-remoting</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
-
- <profiles>
- <profile>
- <id>with-proxy</id>
- <dependencies>
- <dependency>
- <groupId>org.apache.flex.blazeds</groupId>
- <artifactId>flex-messaging-proxy</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
</project>
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 9377ef6..d0b694b 100755
--- a/pom.xml
+++ b/pom.xml
@@ -73,6 +73,7 @@
<module>archetypes</module>
<module>common</module>
<module>core</module>
+ <module>proxy</module>
<module>remoting</module>
<module>opt</module>
</modules>
@@ -341,12 +342,6 @@
</modules>
</profile>
<profile>
- <id>with-proxy</id>
- <modules>
- <module>proxy</module>
- </modules>
- </profile>
- <profile>
<id>with-owasp</id>
<build>
<plugins>
diff --git a/proxy/pom.xml b/proxy/pom.xml
index 92b0c1b..35b36ed 100755
--- a/proxy/pom.xml
+++ b/proxy/pom.xml
@@ -36,11 +36,11 @@
</dependency>
<!-- TODO: This is the latest version of commons-httpclient, however there are CVEs reported for this, the replacement is org.apache.httpcomponents:httpclient however changing to this requires quite some refactoring of the code -->
- <dependency>
+ <!-- <dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
- </dependency>
+ </dependency> -->
<!--dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
diff --git a/proxy/src/main/java/flex/management/runtime/messaging/services/HTTPProxyServiceControl.java b/proxy/src/main/java/flex/management/runtime/messaging/services/HTTPProxyServiceControl.java
deleted file mode 100755
index 6a08170..0000000
--- a/proxy/src/main/java/flex/management/runtime/messaging/services/HTTPProxyServiceControl.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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 flex.management.runtime.messaging.services;
-
-import flex.management.BaseControl;
-import flex.messaging.services.HTTPProxyService;
-
-/**
- * The <code>HTTPProxyServiceControl</code> class is the MBean implementation
- * for monitoring and managing a <code>HTTPProxyService</code> at runtime.
- */
-public class HTTPProxyServiceControl extends ServiceControl implements
- HTTPProxyServiceControlMBean {
- private static final String TYPE = "HTTPProxyService";
-
- /**
- * Constructs a <code>HTTPProxyServiceControl</code>, assigning its id, managed
- * HTTP proxy service and parent MBean.
- *
- * @param service The <code>HTTPProxyService</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public HTTPProxyServiceControl(HTTPProxyService service, BaseControl parent) {
- super(service, parent);
- }
-
-
- /**
- * (non-Javadoc)
- *
- * @see flex.management.BaseControlMBean#getType()
- */
- public String getType() {
- return TYPE;
- }
-}
diff --git a/proxy/src/main/java/flex/management/runtime/messaging/services/HTTPProxyServiceControlMBean.java b/proxy/src/main/java/flex/management/runtime/messaging/services/HTTPProxyServiceControlMBean.java
deleted file mode 100755
index 351c7b2..0000000
--- a/proxy/src/main/java/flex/management/runtime/messaging/services/HTTPProxyServiceControlMBean.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * 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 flex.management.runtime.messaging.services;
-
-/**
- * Defines the runtime monitoring and management interface for managed HTTP proxy services.
- */
-public interface HTTPProxyServiceControlMBean extends ServiceControlMBean {
- // Empty
-}
\ No newline at end of file
diff --git a/proxy/src/main/java/flex/management/runtime/messaging/services/http/HTTPProxyAdapterControl.java b/proxy/src/main/java/flex/management/runtime/messaging/services/http/HTTPProxyAdapterControl.java
deleted file mode 100755
index f65d37b..0000000
--- a/proxy/src/main/java/flex/management/runtime/messaging/services/http/HTTPProxyAdapterControl.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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 flex.management.runtime.messaging.services.http;
-
-import flex.management.BaseControl;
-import flex.management.runtime.messaging.services.ServiceAdapterControl;
-import flex.messaging.services.http.HTTPProxyAdapter;
-
-/**
- * The <code>HTTPProxyAdapterControl</code> class is the MBean implemenation
- * for monitoring and managing <code>HTTPProxyAdapter</code>s at runtime.
- */
-public class HTTPProxyAdapterControl extends ServiceAdapterControl implements
- HTTPProxyAdapterControlMBean {
- private static final String TYPE = "HTTPProxyAdapter";
-
- /**
- * Constructs a <code>HTTPProxyAdapterControl</code>, assigning its id, managed
- * <code>HTTPProxyAdapter</code> and parent MBean.
- *
- * @param serviceAdapter The <code>HTTPProxyAdapter</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public HTTPProxyAdapterControl(HTTPProxyAdapter serviceAdapter, BaseControl parent) {
- super(serviceAdapter, parent);
- }
-
- /**
- * (non-Javadoc)
- *
- * @see flex.management.BaseControlMBean#getType()
- */
- public String getType() {
- return TYPE;
- }
-}
diff --git a/proxy/src/main/java/flex/management/runtime/messaging/services/http/HTTPProxyAdapterControlMBean.java b/proxy/src/main/java/flex/management/runtime/messaging/services/http/HTTPProxyAdapterControlMBean.java
deleted file mode 100755
index 6d42688..0000000
--- a/proxy/src/main/java/flex/management/runtime/messaging/services/http/HTTPProxyAdapterControlMBean.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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 flex.management.runtime.messaging.services.http;
-
-import flex.management.runtime.messaging.services.ServiceAdapterControlMBean;
-
-/**
- * Defines the runtime monitoring and management interface for managed HTTP
- * proxy adapters.
- */
-public interface HTTPProxyAdapterControlMBean extends
- ServiceAdapterControlMBean {
- // Empty for now.
-}
diff --git a/proxy/src/main/java/flex/management/runtime/messaging/services/http/HTTPProxyDestinationControl.java b/proxy/src/main/java/flex/management/runtime/messaging/services/http/HTTPProxyDestinationControl.java
deleted file mode 100755
index 5f41d89..0000000
--- a/proxy/src/main/java/flex/management/runtime/messaging/services/http/HTTPProxyDestinationControl.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * 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 flex.management.runtime.messaging.services.http;
-
-import java.util.Date;
-
-import flex.management.BaseControl;
-import flex.management.runtime.AdminConsoleTypes;
-import flex.management.runtime.messaging.DestinationControl;
-import flex.messaging.services.http.HTTPProxyDestination;
-
-/**
- * The <code>HTTPProxyDestinationControl</code> class is the MBean implementation for
- * monitoring and managing a <code>HTTPProxyDestination</code> at runtime.
- */
-public class HTTPProxyDestinationControl extends DestinationControl
- implements HTTPProxyDestinationControlMBean {
- private static final String TYPE = "HTTPProxyDestination";
-
- private int invokeSOAPCount = 0;
- private Date lastInvokeSOAPTimestamp;
- private long invokeSOAPStart;
- private int invokeHTTPCount = 0;
- private Date lastInvokeHTTPTimestamp;
- private long invokeHTTPStart;
-
- /**
- * Constructs a new <code>HTTPProxyDestinationControl</code> instance.
- *
- * @param destination The <code>HTTPProxyDestination</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public HTTPProxyDestinationControl(HTTPProxyDestination destination, BaseControl parent) {
- super(destination, parent);
- invokeSOAPStart = System.currentTimeMillis();
- invokeHTTPStart = invokeSOAPStart;
- }
-
- /**
- * {@inheritDoc}
- */
- protected void onRegistrationComplete() {
- super.onRegistrationComplete();
-
- String name = this.getObjectName().getCanonicalName();
-
- String[] pollablePerInterval = {"InvokeHTTPCount", "InvokeSOAPCount"};
- String[] pollableGeneral = {"InvokeHTTPFrequency", "InvokeSOAPFrequency"};
- String[] destinationGeneral = {"LastInvokeHTTPTimestamp", "LastInvokeSOAPTimestamp"};
-
- getRegistrar().registerObjects(
- new int[]{AdminConsoleTypes.DESTINATION_POLLABLE, AdminConsoleTypes.GRAPH_BY_POLL_INTERVAL},
- name, pollablePerInterval);
- getRegistrar().registerObjects(AdminConsoleTypes.DESTINATION_POLLABLE, name,
- pollableGeneral);
- getRegistrar().registerObjects(AdminConsoleTypes.DESTINATION_GENERAL, name,
- destinationGeneral);
- }
-
- /**
- * (non-Javadoc)
- *
- * @see flex.management.runtime.HTTPProxyServiceControlMBean#getInvokeSOAPCount()
- */
- public Integer getInvokeSOAPCount() {
- return new Integer(invokeSOAPCount);
- }
-
- /**
- * (non-Javadoc)
- *
- * @see flex.management.runtime.HTTPProxyServiceControlMBean#resetInvokeSOAPCount()
- */
- public void resetInvokeSOAPCount() {
- invokeSOAPStart = System.currentTimeMillis();
- invokeSOAPCount = 0;
- lastInvokeSOAPTimestamp = null;
- }
-
- /**
- * Increments the count of Soap invocations.
- */
- public void incrementInvokeSOAPCount() {
- ++invokeSOAPCount;
- lastInvokeSOAPTimestamp = new Date();
- }
-
- /**
- * (non-Javadoc)
- *
- * @see flex.management.runtime.HTTPProxyServiceControlMBean#getLastInvokeSOAPTimestamp()
- */
- public Date getLastInvokeSOAPTimestamp() {
- return lastInvokeSOAPTimestamp;
- }
-
- /**
- * (non-Javadoc)
- *
- * @see flex.management.runtime.HTTPProxyServiceControlMBean#getInvokeSOAPFrequency()
- */
- public Double getInvokeSOAPFrequency() {
- if (invokeSOAPCount > 0) {
- double runtime = differenceInMinutes(invokeSOAPStart, System.currentTimeMillis());
- return new Double(invokeSOAPCount / runtime);
- } else {
- return new Double(0);
- }
- }
-
- /**
- * (non-Javadoc)
- *
- * @see flex.management.runtime.HTTPProxyServiceControlMBean#getInvokeHTTPCount()
- */
- public Integer getInvokeHTTPCount() {
- return new Integer(invokeHTTPCount);
- }
-
- /**
- * (non-Javadoc)
- *
- * @see flex.management.runtime.HTTPProxyServiceControlMBean#resetInvokeHTTPCount()
- */
- public void resetInvokeHTTPCount() {
- invokeHTTPStart = System.currentTimeMillis();
- invokeHTTPCount = 0;
- lastInvokeHTTPTimestamp = null;
- }
-
- /**
- * Increments the count of HTTP invocations.
- */
- public void incrementInvokeHTTPCount() {
- ++invokeHTTPCount;
- lastInvokeHTTPTimestamp = new Date();
- }
-
- /**
- * (non-Javadoc)
- *
- * @see flex.management.runtime.HTTPProxyServiceControlMBean#getLastInvokeHTTPTimestamp()
- */
- public Date getLastInvokeHTTPTimestamp() {
- return lastInvokeHTTPTimestamp;
- }
-
- /**
- * (non-Javadoc)
- *
- * @see flex.management.runtime.HTTPProxyServiceControlMBean#getInvokeHTTPFrequency()
- */
- public Double getInvokeHTTPFrequency() {
- if (invokeHTTPCount > 0) {
- double runtime = differenceInMinutes(invokeHTTPStart, System.currentTimeMillis());
- return new Double(invokeHTTPCount / runtime);
- } else {
- return new Double(0);
- }
- }
-
- /**
- * (non-Javadoc)
- *
- * @see flex.management.BaseControlMBean#getType()
- */
- public String getType() {
- return TYPE;
- }
-}
diff --git a/proxy/src/main/java/flex/management/runtime/messaging/services/http/HTTPProxyDestinationControlMBean.java b/proxy/src/main/java/flex/management/runtime/messaging/services/http/HTTPProxyDestinationControlMBean.java
deleted file mode 100755
index 0de0595..0000000
--- a/proxy/src/main/java/flex/management/runtime/messaging/services/http/HTTPProxyDestinationControlMBean.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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 flex.management.runtime.messaging.services.http;
-
-import java.io.IOException;
-import java.util.Date;
-
-import flex.management.runtime.messaging.DestinationControlMBean;
-
-/**
- * Defines the runtime monitoring and management interface for managed
- * <code>HTTPProxyDestination</code>s.
- */
-public interface HTTPProxyDestinationControlMBean extends
- DestinationControlMBean {
- /**
- * Returns the number of SOAP invocations the HTTP proxy service has processed.
- *
- * @return The number of SOAP invocations the HTTP proxy service has processed.
- * @throws IOException Throws IOException.
- */
- Integer getInvokeSOAPCount() throws IOException;
-
- /**
- * Resets the count of SOAP invocations.
- *
- * @throws IOException Throws IOException.
- */
- void resetInvokeSOAPCount() throws IOException;
-
- /**
- * Returns the timestamp of the most recent SOAP invocation processed by the
- * HTTP proxy service.
- *
- * @return The timestamp for the most recent SOAP invocation.
- * @throws IOException Throws IOException.
- */
- Date getLastInvokeSOAPTimestamp() throws IOException;
-
- /**
- * Returns the number of SOAP invocations per minute.
- *
- * @return The number of SOAP invocations per minute.
- * @throws IOException Throws IOException.
- */
- Double getInvokeSOAPFrequency() throws IOException;
-
- /**
- * Returns the number of HTTP invocations the HTTP proxy service has processed.
- *
- * @return The number of HTTP invocations the HTTP proxy service has processed.
- * @throws IOException Throws IOException.
- */
- Integer getInvokeHTTPCount() throws IOException;
-
- /**
- * Resets the count of HTTP invocations.
- *
- * @throws IOException Throws IOException.
- */
- void resetInvokeHTTPCount() throws IOException;
-
- /**
- * Returns the timestamp of the most recent HTTP invocation processed by the
- * HTTP proxy service.
- *
- * @return The timestamp for the most recent HTTP invocation.
- * @throws IOException Throws IOException.
- */
- Date getLastInvokeHTTPTimestamp() throws IOException;
-
- /**
- * Returns the number of HTTP invocations per minute.
- *
- * @return The number of HTTP invocations per minute.
- * @throws IOException Throws IOException.
- */
- Double getInvokeHTTPFrequency() throws IOException;
-}
diff --git a/proxy/src/main/java/flex/management/runtime/messaging/services/http/SOAPProxyAdapterControl.java b/proxy/src/main/java/flex/management/runtime/messaging/services/http/SOAPProxyAdapterControl.java
deleted file mode 100755
index 3535d7a..0000000
--- a/proxy/src/main/java/flex/management/runtime/messaging/services/http/SOAPProxyAdapterControl.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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 flex.management.runtime.messaging.services.http;
-
-import flex.management.BaseControl;
-import flex.messaging.services.http.SOAPProxyAdapter;
-
-/**
- * The <code>SOAPProxyAdapterControl</code> class is the MBean implementation
- * for monitoring and managing <code>SOAPProxyAdapter</code>s at runtime.
- */
-public class SOAPProxyAdapterControl extends HTTPProxyAdapterControl implements
- SOAPProxyAdapterControlMBean {
- private static final String TYPE = "SOAPProxyAdapter";
-
- /**
- * Constructs a <code>SOAPProxyAdapterControl</code>, assigning its id, managed
- * <code>SOAPProxyAdapter</code> and parent MBean.
- *
- * @param serviceAdapter The <code>SOAPProxyAdapter</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public SOAPProxyAdapterControl(SOAPProxyAdapter serviceAdapter, BaseControl parent) {
- super(serviceAdapter, parent);
- }
-
- /**
- * (non-Javadoc)
- *
- * @see flex.management.BaseControlMBean#getType()
- */
- public String getType() {
- return TYPE;
- }
-}
diff --git a/proxy/src/main/java/flex/management/runtime/messaging/services/http/SOAPProxyAdapterControlMBean.java b/proxy/src/main/java/flex/management/runtime/messaging/services/http/SOAPProxyAdapterControlMBean.java
deleted file mode 100755
index da0152b..0000000
--- a/proxy/src/main/java/flex/management/runtime/messaging/services/http/SOAPProxyAdapterControlMBean.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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 flex.management.runtime.messaging.services.http;
-
-
-/**
- * Defines the runtime monitoring and management interface for managed SOAP
- * proxy adapters.
- */
-public interface SOAPProxyAdapterControlMBean extends
- HTTPProxyAdapterControlMBean {
- // Empty for now.
-}
diff --git a/proxy/src/main/java/flex/management/runtime/messaging/services/http/package-info.java b/proxy/src/main/java/flex/management/runtime/messaging/services/http/package-info.java
deleted file mode 100755
index 212ef6b..0000000
--- a/proxy/src/main/java/flex/management/runtime/messaging/services/http/package-info.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * 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 flex.management.runtime.messaging.services.http;
\ No newline at end of file
diff --git a/proxy/src/main/java/flex/messaging/services/HTTPProxyService.java b/proxy/src/main/java/flex/messaging/services/HTTPProxyService.java
index 31d1e21..4738bc9 100755
--- a/proxy/src/main/java/flex/messaging/services/HTTPProxyService.java
+++ b/proxy/src/main/java/flex/messaging/services/HTTPProxyService.java
@@ -16,25 +16,12 @@
*/
package flex.messaging.services;
-import flex.management.runtime.messaging.services.HTTPProxyServiceControl;
-import flex.management.runtime.messaging.services.http.HTTPProxyDestinationControl;
import flex.messaging.Destination;
-import flex.messaging.FlexRemoteCredentials;
import flex.messaging.MessageBroker;
-import flex.messaging.MessageException;
-import flex.messaging.FlexContext;
-import flex.messaging.messages.HTTPMessage;
-import flex.messaging.messages.Message;
-import flex.messaging.messages.SOAPMessage;
-import flex.messaging.services.http.HTTPProxyDestination;
-import flex.messaging.services.http.proxy.ProxyException;
-import flex.messaging.util.SettingsReplaceUtil;
-import flex.messaging.util.StringUtils;
-import flex.messaging.log.LogCategories;
import flex.messaging.log.Log;
-
-import java.util.List;
-import javax.servlet.http.HttpServletRequest;
+import flex.messaging.log.LogCategories;
+import flex.messaging.messages.Message;
+import flex.messaging.services.http.HTTPProxyDestination;
/**
* The HttpProxyService replaces the Flex 1.5 Proxy. It decouples
@@ -50,13 +37,6 @@
*/
public static final String LOG_CATEGORY = LogCategories.SERVICE_HTTP;
- // Errors
- private static final int DOT_DOT_NOT_ALLOWED = 10700;
- private static final int MULTIPLE_DOMAIN_PORT = 10701;
- private static final int DYNAMIC_NOT_CONFIGURED = 10702;
-
- private HTTPProxyServiceControl controller;
-
//--------------------------------------------------------------------------
//
// Constructor
@@ -78,6 +58,7 @@
*/
public HTTPProxyService(boolean enableManagement) {
super(enableManagement);
+ Log.getLogger(getLogCategory()).error("flex.messaging.services.HTTPProxyService is no longer supported by BlazeDS");
}
//--------------------------------------------------------------------------
@@ -132,50 +113,9 @@
*/
@Override
public Object serviceMessage(Message msg) {
- if (!(msg instanceof HTTPMessage)) {
- // The 'HTTPProxy' Service can only process messages of type 'HTTPMessage'.
- ServiceException e = new ServiceException();
- e.setMessage(UNKNOWN_MESSAGE_TYPE, new Object[]{"HTTPProxy", "HTTPMessage"});
- throw e;
- }
-
- HTTPMessage message = (HTTPMessage) msg;
-
- String destination = message.getDestination();
- HTTPProxyDestination dest = (HTTPProxyDestination) destinations.get(destination);
-
- //use the remote settings if the message didn't specify them
- FlexRemoteCredentials remoteCredentials =
- FlexContext.getFlexSession().getRemoteCredentials(getId(), destination);
- if (remoteCredentials != null) {
- message.setRemoteUsername(remoteCredentials.getUsername());
- message.setRemotePassword((String) remoteCredentials.getCredentials());
- } else if (dest.getRemoteUsername() != null && dest.getRemotePassword() != null) {
- message.setRemoteUsername(dest.getRemoteUsername());
- message.setRemotePassword(dest.getRemotePassword());
- }
-
- ServiceAdapter adapter = dest.getAdapter();
-
- Object result;
-
- if (message instanceof SOAPMessage) {
- result = invokeSoap(adapter, (SOAPMessage) message, dest);
- } else {
- result = invokeHttp(adapter, message, dest);
- }
-
- if (Log.isDebug()) {
- String debugResult =
- StringUtils.prettifyString(String.valueOf(result));
- Log.getLogger(getLogCategory()).debug
- ("HTTP request: " +
- message + StringUtils.NEWLINE +
- " response: " + StringUtils.NEWLINE +
- debugResult + StringUtils.NEWLINE);
- }
-
- return result;
+ ServiceException e = new ServiceException();
+ e.setMessage("flex.messaging.services.HTTPProxyService is no longer supported by BlazeDS");
+ throw e;
}
//--------------------------------------------------------------------------
@@ -184,91 +124,6 @@
//
//--------------------------------------------------------------------------
- protected Object invokeSoap(ServiceAdapter adapter, SOAPMessage message, HTTPProxyDestination destination) {
- if (isManaged()) {
- HTTPProxyDestinationControl destinationControl = (HTTPProxyDestinationControl) destination.getControl();
- if (destinationControl != null)
- destinationControl.incrementInvokeSOAPCount();
- }
-
- String dynamicUrl = message.getUrl();
-
- String contextPath = null;
- String serverName = null;
- String serverPort = null;
- String protocol = null;
- HttpServletRequest req = FlexContext.getHttpRequest();
- if (req != null) {
- contextPath = req.getContextPath();
- protocol = req.getScheme();
- serverName = req.getServerName();
- int port = req.getServerPort();
- if (port != 0) {
- serverPort = Integer.valueOf(req.getServerPort()).toString();
- }
- }
-
- if (dynamicUrl != null && dynamicUrl.length() > 0) {
- checkUrl(dynamicUrl, contextPath, destination, serverName, serverPort, protocol, message.getRemoteUsername() != null);
- } else {
- //TODO: QUESTION: Pete Support default soap endpoints?
- //String url = settings.getParsedDefaultUrl(contextPath);
- //message.setUrl(url);
-
- // FIXME: Need a better error here!
- throw new MessageException("A SOAP endpoint was not provided.");
- }
-
- return adapter.invoke(message);
- }
-
- protected void checkUrl(String url, String contextPath, HTTPProxyDestination destination, String serverName,
- String serverPort, String serverProtocol, boolean authSupplied) {
- String originalUrl = url;
-
- String defaultUrl = destination.getParsedDefaultUrl(contextPath, serverName, serverPort, serverProtocol);
- List dynamicUrls = destination.getParsedDynamicUrls(contextPath);
-
- //If we find ".." in a URL provided by the client, someone's likely
- //trying to trick us. Ask them to do it another way if so.
-
- int i = url.indexOf("/..");
- while (i != -1) {
- if (i == (url.length() - 3) || url.charAt(i + 3) == '/') {
- throw new ProxyException(DOT_DOT_NOT_ALLOWED);
- }
- i = url.indexOf("/..", i + 1);
- }
-
- //Next, check if the URL is exactly the default URL
- url = url.toLowerCase();
-
- // In IPv6, update to long form, if required.
- url = SettingsReplaceUtil.updateIPv6(url);
-
- if (defaultUrl != null && defaultUrl.equalsIgnoreCase(url))
- return;
-
- char[] urlChars = url.toCharArray();
-
- // Next, check that the URL matches a dynamic URL pattern
- for (i = 0; i < dynamicUrls.size(); i++) {
- char[] pattern = (char[]) dynamicUrls.get(i);
- boolean matches = StringUtils.findMatchWithWildcard(urlChars, pattern);
-
- if (matches) {
- if (!authSupplied || destination.allowsDynamicAuthentication())
- return;
- throw new ProxyException(MULTIPLE_DOMAIN_PORT);
- }
- }
-
- ProxyException exception = new ProxyException();
- exception.setMessage
- (DYNAMIC_NOT_CONFIGURED, new Object[]{originalUrl, destination.getId()});
- throw exception;
- }
-
/**
* Returns the log category of the <code>HTTPProxyService</code>.
*
@@ -279,41 +134,6 @@
return LOG_CATEGORY;
}
- protected Object invokeHttp(ServiceAdapter adapter, HTTPMessage message, HTTPProxyDestination destination) {
- if (isManaged()) {
- HTTPProxyDestinationControl destinationControl = (HTTPProxyDestinationControl) destination.getControl();
- if (destinationControl != null)
- destinationControl.incrementInvokeHTTPCount();
- }
-
- String dynamicUrl = message.getUrl();
-
- String contextPath = null;
- String serverName = null;
- String serverPort = null;
- String protocol = null;
- HttpServletRequest req = FlexContext.getHttpRequest();
-
- if (req != null) {
- contextPath = req.getContextPath();
- protocol = req.getScheme();
- serverName = req.getServerName();
- int port = req.getServerPort();
- if (port != 0) {
- serverPort = Integer.toString(req.getServerPort());
- }
- }
-
- if (dynamicUrl != null && !"".equals(dynamicUrl)) {
- checkUrl(dynamicUrl, contextPath, destination, serverName, serverPort, protocol, message.getRemoteUsername() != null);
- } else {
- String url = destination.getParsedDefaultUrl(contextPath, serverName, serverPort, protocol);
- message.setUrl(url);
- }
-
- return adapter.invoke(message);
- }
-
/**
* This method is invoked to allow the <code>HTTPProxyService</code> to instantiate and register its
* MBean control.
@@ -322,8 +142,5 @@
*/
@Override
protected void setupServiceControl(MessageBroker broker) {
- controller = new HTTPProxyServiceControl(this, broker.getControl());
- controller.register();
- setControl(controller);
}
}
diff --git a/proxy/src/main/java/flex/messaging/services/http/HTTPConnectionManagerSettings.java b/proxy/src/main/java/flex/messaging/services/http/HTTPConnectionManagerSettings.java
index 7149da9..b1e5fec 100755
--- a/proxy/src/main/java/flex/messaging/services/http/HTTPConnectionManagerSettings.java
+++ b/proxy/src/main/java/flex/messaging/services/http/HTTPConnectionManagerSettings.java
@@ -18,8 +18,6 @@
import java.util.List;
-import org.apache.commons.httpclient.cookie.CookiePolicy;
-
/**
* Establishes the settings used to construct an Apache Commons HTTPClient
* HttpConnectionManager for the Proxy Service.
@@ -87,7 +85,7 @@
* Creates a default <code>HTTPConnectionManagerSettings</code> instance.
*/
public HTTPConnectionManagerSettings() {
- cookiePolicy = CookiePolicy.DEFAULT;
+ cookiePolicy = "default";
defaultMaxConnectionsPerHost = DEFAULT_MAX_CONNECTIONS_HOST;
maxTotalConnections = DEFAULT_MAX_TOTAL_CONNECTIONS;
linger = -1;
diff --git a/proxy/src/main/java/flex/messaging/services/http/HTTPProxyAdapter.java b/proxy/src/main/java/flex/messaging/services/http/HTTPProxyAdapter.java
index 990cee0..d6eb6b3 100755
--- a/proxy/src/main/java/flex/messaging/services/http/HTTPProxyAdapter.java
+++ b/proxy/src/main/java/flex/messaging/services/http/HTTPProxyAdapter.java
@@ -16,43 +16,15 @@
*/
package flex.messaging.services.http;
-import flex.management.runtime.messaging.services.http.HTTPProxyAdapterControl;
-import flex.messaging.Destination;
-import flex.messaging.FlexContext;
-import flex.messaging.MessageException;
-import flex.messaging.config.ConfigMap;
-import flex.messaging.messages.AcknowledgeMessage;
-import flex.messaging.messages.HTTPMessage;
-import flex.messaging.messages.Message;
-import flex.messaging.messages.SOAPMessage;
-import flex.messaging.services.ServiceAdapter;
-import flex.messaging.services.http.proxy.AccessFilter;
-import flex.messaging.services.http.proxy.ErrorFilter;
-import flex.messaging.services.http.proxy.ProxyContext;
-import flex.messaging.services.http.proxy.ProxyContextFilter;
-import flex.messaging.services.http.proxy.ProxyFilter;
-import flex.messaging.services.http.proxy.RequestFilter;
-import flex.messaging.services.http.proxy.ResponseFilter;
-import flex.messaging.services.http.proxy.SecurityFilter;
-import flex.messaging.services.http.proxy.Target;
-import flex.messaging.util.ClassUtil;
-import org.apache.commons.httpclient.HostConfiguration;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.NTCredentials;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.commons.httpclient.cookie.CookiePolicy;
-import org.apache.commons.httpclient.params.HostParams;
-import org.apache.commons.httpclient.params.HttpClientParams;
-import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
-import org.apache.commons.httpclient.protocol.Protocol;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
+
+import flex.messaging.config.ConfigMap;
+import flex.messaging.messages.Message;
+import flex.messaging.services.ServiceAdapter;
+import flex.messaging.services.ServiceException;
+import flex.messaging.util.ClassUtil;
/**
* Adapter class for proxy services.
@@ -84,14 +56,6 @@
protected ExternalProxySettings externalProxy;
protected HTTPConnectionManagerSettings connectionManagerSettings;
- // HTTPProxyAdapter internal
- protected HttpConnectionManager connectionManager;
- protected HttpConnectionManagerParams connectionParams;
- protected ProxyFilter filterChain;
- protected UsernamePasswordCredentials proxyCredentials;
-
- private HTTPProxyAdapterControl controller;
-
//--------------------------------------------------------------------------
//
// Constructor
@@ -114,7 +78,6 @@
public HTTPProxyAdapter(boolean enableManagement) {
super(enableManagement);
- createFilterChain();
externalProxy = new ExternalProxySettings();
connectionManagerSettings = new HTTPConnectionManagerSettings();
}
@@ -182,69 +145,42 @@
if (conn != null) {
// Cookie policy.
if (conn.getProperty(HTTPConnectionManagerSettings.COOKIE_POLICY) != null) {
- connectionManagerSettings.setCookiePolicy(conn.getPropertyAsString(HTTPConnectionManagerSettings.COOKIE_POLICY,
- CookiePolicy.DEFAULT));
}
// Max Connections Total
if (conn.getProperty(HTTPConnectionManagerSettings.MAX_TOTAL_CONNECTIONS) != null) {
- int maxTotal = conn.getPropertyAsInt(HTTPConnectionManagerSettings.MAX_TOTAL_CONNECTIONS,
- MultiThreadedHttpConnectionManager.DEFAULT_MAX_TOTAL_CONNECTIONS);
- connectionManagerSettings.setMaxTotalConnections(maxTotal);
}
// Default Max Connections Per Host
- int defaultMaxConnsPerHost = MultiThreadedHttpConnectionManager.DEFAULT_MAX_HOST_CONNECTIONS;
if (conn.getProperty(HTTPConnectionManagerSettings.DEFAULT_MAX_CONNECTIONS_PER_HOST) != null) {
- defaultMaxConnsPerHost = conn.getPropertyAsInt(HTTPConnectionManagerSettings.DEFAULT_MAX_CONNECTIONS_PER_HOST,
- MultiThreadedHttpConnectionManager.DEFAULT_MAX_HOST_CONNECTIONS);
- connectionManagerSettings.setDefaultMaxConnectionsPerHost(defaultMaxConnsPerHost);
}
// Connection Timeout
if (conn.getProperty(HTTPConnectionManagerSettings.CONNECTION_TIMEOUT) != null) {
- int timeout = conn.getPropertyAsInt(HTTPConnectionManagerSettings.CONNECTION_TIMEOUT, 0);
- if (timeout >= 0)
- connectionManagerSettings.setConnectionTimeout(timeout);
}
// Socket Timeout
if (conn.getProperty(HTTPConnectionManagerSettings.SOCKET_TIMEOUT) != null) {
- int timeout = conn.getPropertyAsInt(HTTPConnectionManagerSettings.SOCKET_TIMEOUT, 0);
- if (timeout >= 0)
- connectionManagerSettings.setSocketTimeout(timeout);
}
// Stale Checking
if (conn.getProperty(HTTPConnectionManagerSettings.STALE_CHECKING_ENABLED) != null) {
- boolean staleCheck = conn.getPropertyAsBoolean(HTTPConnectionManagerSettings.STALE_CHECKING_ENABLED, true);
- connectionManagerSettings.setStaleCheckingEnabled(staleCheck);
}
// Send Buffer Size
if (conn.getProperty(HTTPConnectionManagerSettings.SEND_BUFFER_SIZE) != null) {
- int bufferSize = conn.getPropertyAsInt(HTTPConnectionManagerSettings.SEND_BUFFER_SIZE, 0);
- if (bufferSize > 0)
- connectionManagerSettings.setSendBufferSize(bufferSize);
}
// Send Receive Size
if (conn.getProperty(HTTPConnectionManagerSettings.RECEIVE_BUFFER_SIZE) != null) {
- int bufferSize = conn.getPropertyAsInt(HTTPConnectionManagerSettings.RECEIVE_BUFFER_SIZE, 0);
- if (bufferSize > 0)
- connectionManagerSettings.setReceiveBufferSize(bufferSize);
}
// TCP No Delay (Nagel's Algorithm)
if (conn.getProperty(HTTPConnectionManagerSettings.TCP_NO_DELAY) != null) {
- boolean noNagel = conn.getPropertyAsBoolean(HTTPConnectionManagerSettings.TCP_NO_DELAY, true);
- connectionManagerSettings.setTcpNoDelay(noNagel);
}
// Linger
if (conn.getProperty(HTTPConnectionManagerSettings.LINGER) != null) {
- int linger = conn.getPropertyAsInt(HTTPConnectionManagerSettings.LINGER, -1);
- connectionManagerSettings.setLinger(linger);
}
// Max Connections Per Host
@@ -258,9 +194,6 @@
// max-connections
if (maxPerHost.getProperty(HostConfigurationSettings.MAX_CONNECTIONS) != null) {
- int maxConn = maxPerHost.getPropertyAsInt(HostConfigurationSettings.MAX_CONNECTIONS,
- defaultMaxConnsPerHost);
- hostConfig.setMaximumConnections(maxConn);
}
// host
@@ -322,161 +255,26 @@
if (hostSettings.size() > 0)
connectionManagerSettings.setMaxConnectionsPerHost(hostSettings);
}
- setConnectionManagerSettings(connectionManagerSettings);
}
// Cookie Limit
if (properties.getProperty(COOKIE_LIMIT) != null) {
- int cl = properties.getPropertyAsInt(COOKIE_LIMIT, DEFAULT_COOKIE_LIMIT);
- setCookieLimit(cl);
}
// Allow Lax SSL
if (properties.getProperty(ALLOW_LAX_SSL) != null) {
- boolean lax = properties.getPropertyAsBoolean(ALLOW_LAX_SSL, false);
- setAllowLaxSSL(lax);
}
// Content Chunked
if (properties.getProperty(CONTENT_CHUNKED) != null) {
- boolean ch = properties.getPropertyAsBoolean(CONTENT_CHUNKED, false);
- setContentChunked(ch);
}
// External Proxy
ConfigMap extern = properties.getPropertyAsMap(ExternalProxySettings.EXTERNAL_PROXY, null);
if (extern != null) {
- ExternalProxySettings proxy = new ExternalProxySettings();
-
- String proxyServer = extern.getPropertyAsString(ExternalProxySettings.SERVER, null);
- proxy.setProxyServer(proxyServer);
- int proxyPort = extern.getPropertyAsInt(ExternalProxySettings.PORT, ExternalProxySettings.DEFAULT_PROXY_PORT);
- proxy.setProxyPort(proxyPort);
- String ntdomain = extern.getPropertyAsString(ExternalProxySettings.NT_DOMAIN, null);
- proxy.setNTDomain(ntdomain);
- String username = extern.getPropertyAsString(ExternalProxySettings.USERNAME, null);
- proxy.setUsername(username);
- String password = extern.getPropertyAsString(ExternalProxySettings.PASSWORD, null);
- proxy.setPassword(password);
-
- setExternalProxySettings(proxy);
}
}
- //--------------------------------------------------------------------------
- //
- // Public Getters and Setters for Destination properties
- //
- //--------------------------------------------------------------------------
-
- /**
- * Returns <code>allow-lax-ssl</code> property.
- *
- * @return <code>true</code> if <code>allow-lax-ssl</code> property is
- * <code>true</code>; otherwise <code>false</code>.
- */
- public boolean isAllowLaxSSL() {
- return allowLaxSSL;
- }
-
- /**
- * Sets <code>allow-lax-ssl</code> property which determines if self-signed
- * certificates are allowed; should not be used in production.
- * Default <code>false</code>.
- *
- * @param allowLaxSSL Whether lax SSL should be allowed.
- */
- public void setAllowLaxSSL(boolean allowLaxSSL) {
- this.allowLaxSSL = allowLaxSSL;
- }
-
- /**
- * Returns the <code>content-chunked</code> property.
- *
- * @return <code>true</code> if <code>content-chunked</code> property is
- * <code>true</code>; otherwise <code>false</code>.
- */
- public boolean isContentChunked() {
- return contentChunked;
- }
-
- /**
- * Sets the <code>content-chunked</code> property. Default <code>false</code>.
- *
- * @param contentChunked The <code>content-chunked</code> property.
- */
- public void setContentChunked(boolean contentChunked) {
- this.contentChunked = contentChunked;
- }
-
- /**
- * Returns the <code>cookie-limit</code> property.
- *
- * @return The <code>cookie-limit</code> property.
- */
- public int getCookieLimit() {
- return cookieLimit;
- }
-
- /**
- * Sets the <code>cookie-limit</code> property. Default 200.
- *
- * @param cookieLimit The cookie limit for the proxy.
- */
- public void setCookieLimit(int cookieLimit) {
- this.cookieLimit = cookieLimit;
- }
-
- /**
- * Casts the <code>Destination</code> into <code>HTTPProxyDestination</code>
- * and calls super.setDestination.
- *
- * @param destination The HTTP proxy destination.
- */
- public void setDestination(Destination destination) {
- Destination dest = (HTTPProxyDestination) destination;
- super.setDestination(dest);
- }
-
- /**
- * Returns <code>ExternalProxySettings</code>.
- *
- * @return the <code>ExternalProxySettings</code>
- */
- public ExternalProxySettings getExternalProxySettings() {
- return externalProxy;
- }
-
- /**
- * Sets <code>ExternalProxySettings</code>.
- *
- * @param externalProxy The external proxy settings.
- */
- public void setExternalProxySettings(ExternalProxySettings externalProxy) {
- this.externalProxy = externalProxy;
- initExternalProxy(externalProxy);
- }
-
- /**
- * Returns <code>HTTPConnectionManagerSettings</code>.
- *
- * @return the <code>HTTPConnectionManagerSettings</code>
- */
- public HTTPConnectionManagerSettings getConnectionManagerSettings() {
- return connectionManagerSettings;
- }
-
- /**
- * Sets <code>HTTPConnectionManagerSettings</code>.
- *
- * @param connectionManagerSettings The connection manager settings.
- */
- public void setConnectionManagerSettings(HTTPConnectionManagerSettings connectionManagerSettings) {
- this.connectionManagerSettings = connectionManagerSettings;
- initHttpConnectionManagerParams(connectionManagerSettings);
- connectionManager = new MultiThreadedHttpConnectionManager();
- connectionManager.setParams(connectionParams);
- }
//--------------------------------------------------------------------------
//
@@ -488,219 +286,8 @@
* {@inheritDoc}
*/
public Object invoke(Message msg) {
- HTTPMessage message = (HTTPMessage) msg;
-
- ProxyContext context = new ProxyContext();
-
- // SOAPMessages should be sent through the SOAPProxyAdapter, but
- // the default destination may be just to the HTTPProxyAdapter.
- // We'll update the context just in case....
- if (message instanceof SOAPMessage)
- context.setSoapRequest(true);
- else
- context.setSoapRequest(false);
-
- setupContext(context, message);
-
- try {
- filterChain.invoke(context);
-
- //TODO: Do we want a return type that encapsulates the response data?
-
- // OUTPUT
- AcknowledgeMessage ack = new AcknowledgeMessage();
- ack.setBody(context.getResponse());
- ack.setHeader(Message.STATUS_CODE_HEADER, context.getStatusCode());
-
- if (context.getRecordHeaders()) {
- ack.setHeader(REQUEST_HEADERS, context.getRequestHeaders());
- ack.setHeader(RESPONSE_HEADERS, context.getResponseHeaders());
- }
-
- return ack;
- } catch (MessageException ex) {
- throw ex;
- } catch (Throwable t) {
- // this should never happen- ErrorFilter should catch everything
- t.printStackTrace();
- throw new MessageException(t.toString());
- }
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected/private APIs
- //
- //--------------------------------------------------------------------------
-
- protected void setupContext(ProxyContext context, HTTPMessage message) {
- Target target = new Target();
- context.setTarget(target);
-
- context.setExternalProxySettings(externalProxy);
- context.setProxyCredentials(proxyCredentials);
- context.setConnectionManager(connectionManager);
- context.setAllowLaxSSL(allowLaxSSL);
- context.setContentChunked(contentChunked);
- context.setRecordHeaders(message.getRecordHeaders());
- context.setCookieLimit(cookieLimit);
- context.setHttpRequest(FlexContext.getHttpRequest() != null);
-
- //TODO: QUESTION: Pete, Send HTTPHeaders as real headers
-
- // INPUT
- String url = message.getUrl();
- context.setUrl(url);
-
- Map httpHeaders = message.getHttpHeaders();
- context.setHeaders(httpHeaders);
-
- String method = message.getMethod();
- context.setMethod(method);
-
- String contentType = message.getContentType();
- context.setContentType(contentType);
-
- Object body = message.getBody();
- context.setBody(body);
-
- target.setRemoteUsername(message.getRemoteUsername());
- target.setRemotePassword(message.getRemotePassword());
-
- HTTPProxyDestination destination = (HTTPProxyDestination) getDestination();
- target.setUseCustomAuthentication(destination.isUseCustomAuthentication());
-
- if (destination.getProtocolFactory() != null) {
- ProtocolFactory protocolFactory = destination.getProtocolFactory();
- context.setProtocol(protocolFactory.getProtocol());
- }
- }
-
- /**
- * Invoked automatically to allow the <code>HTTPProxyAdapter</code> to setup its corresponding
- * MBean control.
- *
- * @param destination The <code>Destination</code> that manages this <code>HTTPProxyAdapter</code>.
- */
- protected void setupAdapterControl(Destination destination) {
- controller = new HTTPProxyAdapterControl(this, destination.getControl());
- controller.register();
- setControl(controller);
- }
-
- /**
- * Create default filter chain or return current one if already present.
- */
- private ProxyFilter createFilterChain() {
- if (filterChain == null) {
- // catch-all error filter
- ErrorFilter errorFilter = new ErrorFilter();
- // check proxy access
- AccessFilter accessFilter = new AccessFilter();
- // set up ProxyContext
- ProxyContextFilter contextFilter = new ProxyContextFilter();
- // sends out response after further filters
- ResponseFilter responseFilter = new ResponseFilter();
- // deals with credentials
- SecurityFilter securityFilter = new SecurityFilter();
- // sends out the request
- RequestFilter requestFilter = new RequestFilter();
-
- errorFilter.setNext(accessFilter);
- accessFilter.setNext(contextFilter);
- contextFilter.setNext(responseFilter);
- responseFilter.setNext(securityFilter);
- securityFilter.setNext(requestFilter);
-
- filterChain = errorFilter;
- }
- return filterChain;
- }
-
- private void initExternalProxy(ExternalProxySettings ep) {
- if (externalProxy != null) {
-
- String proxyServer = externalProxy.getProxyServer();
- String proxyUsername = externalProxy.getUsername();
-
- if (proxyUsername != null) {
- String proxyPassword = externalProxy.getPassword();
- String proxyDomain = externalProxy.getNTDomain();
- if (proxyDomain != null) {
- proxyCredentials = new NTCredentials(proxyUsername, proxyPassword, proxyServer, proxyDomain);
- } else {
- proxyCredentials = new UsernamePasswordCredentials(proxyUsername, proxyPassword);
- }
- }
- }
- }
-
- private void initHttpConnectionManagerParams(HTTPConnectionManagerSettings settings) {
- connectionParams = new HttpConnectionManagerParams();
- connectionParams.setMaxTotalConnections(settings.getMaxTotalConnections());
- connectionParams.setDefaultMaxConnectionsPerHost(settings.getDefaultMaxConnectionsPerHost());
-
- if (!settings.getCookiePolicy().equals(CookiePolicy.DEFAULT)) {
- HttpClientParams httpClientParams = (HttpClientParams) connectionParams.getDefaults();
- httpClientParams.setCookiePolicy(settings.getCookiePolicy());
- }
-
- if (settings.getConnectionTimeout() >= 0)
- connectionParams.setConnectionTimeout(settings.getConnectionTimeout());
-
- if (settings.getSocketTimeout() >= 0)
- connectionParams.setSoTimeout(settings.getSocketTimeout());
-
- connectionParams.setStaleCheckingEnabled(settings.isStaleCheckingEnabled());
-
- if (settings.getSendBufferSize() > 0)
- connectionParams.setSendBufferSize(settings.getSendBufferSize());
-
- if (settings.getReceiveBufferSize() > 0)
- connectionParams.setReceiveBufferSize(settings.getReceiveBufferSize());
-
- connectionParams.setTcpNoDelay(settings.isTcpNoDelay());
- connectionParams.setLinger(settings.getLinger());
-
- if (settings.getMaxConnectionsPerHost() != null) {
- Iterator it = settings.getMaxConnectionsPerHost().iterator();
- while (it.hasNext()) {
- HostConfigurationSettings hcs = (HostConfigurationSettings) it.next();
- HostConfiguration hostConfig = new HostConfiguration();
-
- if (hcs.getProtocol() != null) {
- Protocol protocol = Protocol.getProtocol(hcs.getProtocol());
- hostConfig.setHost(hcs.getHost(), hcs.getPort(), protocol);
- } else if (hcs.getProtocolFactory() != null) {
- Protocol protocol = hcs.getProtocolFactory().getProtocol();
- if (hcs.getPort() > 0)
- hostConfig.setHost(hcs.getHost(), hcs.getPort(), protocol);
- else
- hostConfig.setHost(hcs.getHost(), protocol.getDefaultPort(), protocol);
- } else {
- if (hcs.getPort() > 0)
- hostConfig.setHost(hcs.getHost(), hcs.getPort());
- else
- hostConfig.setHost(hcs.getHost());
- }
-
- if (hcs.getVirtualHost() != null) {
- HostParams params = hostConfig.getParams();
- if (params != null)
- params.setVirtualHost(hcs.getVirtualHost());
- }
-
- if (hcs.getProxyHost() != null) {
- hostConfig.setProxy(hcs.getProxyHost(), hcs.getProxyPort());
- }
-
- try {
- InetAddress addr = InetAddress.getByName(hcs.getLocalAddress());
- hostConfig.setLocalAddress(addr);
- } catch (UnknownHostException ex) {
- }
- connectionParams.setMaxConnectionsPerHost(hostConfig, hcs.getMaximumConnections());
- }
- }
+ ServiceException e = new ServiceException();
+ e.setMessage("flex.messaging.services.http.HTTPProxyAdapter is no longer supported by BlazeDS");
+ throw e;
}
}
diff --git a/proxy/src/main/java/flex/messaging/services/http/HTTPProxyDestination.java b/proxy/src/main/java/flex/messaging/services/http/HTTPProxyDestination.java
index 103279d..39c9b29 100755
--- a/proxy/src/main/java/flex/messaging/services/http/HTTPProxyDestination.java
+++ b/proxy/src/main/java/flex/messaging/services/http/HTTPProxyDestination.java
@@ -16,7 +16,13 @@
*/
package flex.messaging.services.http;
-import flex.management.runtime.messaging.services.http.HTTPProxyDestinationControl;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
import flex.messaging.Destination;
import flex.messaging.config.ConfigMap;
import flex.messaging.log.LogCategories;
@@ -25,13 +31,6 @@
import flex.messaging.util.ClassUtil;
import flex.messaging.util.SettingsReplaceUtil;
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Set;
-
/**
* Subclass of Destination which provides HTTP Proxy-specific destination functionality.
*/
@@ -69,8 +68,6 @@
protected String parsedDefaultUrl;
protected List parsedDynamicUrls;
- private HTTPProxyDestinationControl controller;
-
//--------------------------------------------------------------------------
//
// Constructor
@@ -443,16 +440,4 @@
protected String getLogCategory() {
return LOG_CATEGORY;
}
-
- /**
- * Invoked automatically to allow the <code>HTTPProxyDestination</code> to setup its corresponding
- * MBean control.
- *
- * @param service The <code>Service</code> that manages this <code>HTTPProxyDestination</code>.
- */
- protected void setupDestinationControl(Service service) {
- controller = new HTTPProxyDestinationControl(this, service.getControl());
- controller.register();
- setControl(controller);
- }
}
diff --git a/proxy/src/main/java/flex/messaging/services/http/ProtocolFactory.java b/proxy/src/main/java/flex/messaging/services/http/ProtocolFactory.java
index 9da70b5..2e67b3f 100755
--- a/proxy/src/main/java/flex/messaging/services/http/ProtocolFactory.java
+++ b/proxy/src/main/java/flex/messaging/services/http/ProtocolFactory.java
@@ -16,8 +16,6 @@
*/
package flex.messaging.services.http;
-import org.apache.commons.httpclient.protocol.Protocol;
-
import flex.messaging.FlexConfigurable;
/**
@@ -41,5 +39,5 @@
*
* @return An implementation of org.apache.commons.httpclient.protocol.Protocol.
*/
- Protocol getProtocol();
+ Object getProtocol();
}
diff --git a/proxy/src/main/java/flex/messaging/services/http/SOAPProxyAdapter.java b/proxy/src/main/java/flex/messaging/services/http/SOAPProxyAdapter.java
index 22b4cb6..2dacf99 100755
--- a/proxy/src/main/java/flex/messaging/services/http/SOAPProxyAdapter.java
+++ b/proxy/src/main/java/flex/messaging/services/http/SOAPProxyAdapter.java
@@ -16,20 +16,14 @@
*/
package flex.messaging.services.http;
-import flex.management.runtime.messaging.services.http.SOAPProxyAdapterControl;
import flex.messaging.messages.Message;
-import flex.messaging.messages.SOAPMessage;
-import flex.messaging.messages.HTTPMessage;
-import flex.messaging.services.http.proxy.ProxyContext;
-import flex.messaging.Destination;
-import flex.messaging.MessageException;
+import flex.messaging.services.ServiceException;
/**
* A Soap specific subclass of HttpProxyAdapter to
* allow for future web services features.
*/
public class SOAPProxyAdapter extends HTTPProxyAdapter {
- private SOAPProxyAdapterControl controller;
//--------------------------------------------------------------------------
//
@@ -64,42 +58,8 @@
* {@inheritDoc}
*/
public Object invoke(Message msg) {
- HTTPMessage message = (HTTPMessage) msg;
- ProxyContext context = new ProxyContext();
-
- if (message instanceof SOAPMessage) {
- context.setSoapRequest(true);
- }
-
- setupContext(context, message);
-
- try {
- filterChain.invoke(context);
- return context.getResponse();
- } catch (MessageException ex) {
- throw ex;
- } catch (Throwable t) {
- // this should never happen- ErrorFilter should catch everything
- t.printStackTrace();
- throw new MessageException(t.toString());
- }
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected/private APIs
- //
- //--------------------------------------------------------------------------
-
- /**
- * Invoked automatically to allow the <code>SOAPProxyAdapter</code> to setup its corresponding
- * MBean control.
- *
- * @param broker The <code>Destination</code> that manages this <code>SOAPProxyAdapter</code>.
- */
- protected void setupAdapterControl(Destination destination) {
- controller = new SOAPProxyAdapterControl(this, destination.getControl());
- controller.register();
- setControl(controller);
+ ServiceException e = new ServiceException();
+ e.setMessage("flex.messaging.services.http.SOAPProxyAdapter is no longer supported by BlazeDS");
+ throw e;
}
}
diff --git a/proxy/src/main/java/flex/messaging/services/http/httpclient/EasySSLProtocolSocketFactory.java b/proxy/src/main/java/flex/messaging/services/http/httpclient/EasySSLProtocolSocketFactory.java
deleted file mode 100755
index 6970a66..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/httpclient/EasySSLProtocolSocketFactory.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * $Header: /home/cvspublic/jakarta-commons/httpclient/src/contrib/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java,v 1.7 2004/06/11 19:26:27 olegk Exp $
- * $Revision: 1.7 $
- * $Date: 2004/06/11 19:26:27 $
- *
- * ====================================================================
- *
- * Copyright 2002-2004 The Apache Software Foundation
- *
- * Licensed 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-/*
- * This file has been modified by Adobe (Adobe Systems Incorporated).
- * Date: Mar 27, 2008 onwards.
- * Reason(s): Fixed a few checkstyle warnings.
- */
-
-package flex.messaging.services.http.httpclient;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-
-import org.apache.commons.httpclient.ConnectTimeoutException;
-import org.apache.commons.httpclient.HttpClientError;
-import org.apache.commons.httpclient.params.HttpConnectionParams;
-import org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory;
-import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.UnknownHostException;
-
-import flex.messaging.util.Trace;
-
-/**
- * <p>
- * EasySSLProtocolSocketFactory can be used to creats SSL {@link Socket}s
- * that accept self-signed certificates.
- * </p>
- * <p>
- * This socket factory SHOULD NOT be used for productive systems
- * due to security reasons, unless it is a concious decision and
- * you are perfectly aware of security implications of accepting
- * self-signed certificates
- * </p>
- * <p>
- * Example of using custom protocol socket factory for a specific host:
- * <pre>
- * Protocol easyhttps =
- * new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
- * </pre>
- * </p>
- * <p>
- * <pre>
- * HttpClient client = new HttpClient();
- * client.getHostConfiguration().setHost("localhost", 443, easyhttps);
- * // use relative url only
- * GetMethod httpget = new GetMethod("/");
- * client.executeMethod(httpget);
- * </pre>
- * </p>
- * <p>
- * Example of using custom protocol socket factory per default instead of the standard one:
- * <pre>
- * Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
- * Protocol.registerProtocol("https", easyhttps);
- * HttpClient client = new HttpClient();
- * GetMethod httpget = new GetMethod("https://localhost/");
- * client.executeMethod(httpget);
- * </pre>
- * </p>
- *
- * <p>
- * DISCLAIMER: HttpClient developers DO NOT actively support this component.
- * The component is provided as a reference material, which may be inappropriate
- * for use without additional customization.
- * </p>
- */
-public class EasySSLProtocolSocketFactory implements SecureProtocolSocketFactory {
- private SSLContext sslcontext = null;
-
- /**
- * Constructor for EasySSLProtocolSocketFactory.
- */
- public EasySSLProtocolSocketFactory() {
- super();
- }
-
- private static SSLContext createEasySSLContext() {
- try {
- SSLContext context = SSLContext.getInstance("SSL");
- context.init(null,
- new TrustManager[]{new EasyX509TrustManager(null)},
- null);
- return context;
- } catch (Exception e) {
- if (Trace.ssl) {
- Trace.trace(e.getMessage());
- }
- throw new HttpClientError(e.toString());
- }
- }
-
- private SSLContext getSSLContext() {
- if (this.sslcontext == null) {
- this.sslcontext = createEasySSLContext();
- }
- return this.sslcontext;
- }
-
- /**
- * {@inheritDoc}
- */
- public Socket createSocket(String host,
- int port,
- InetAddress clientHost,
- int clientPort)
- throws IOException {
-
- return getSSLContext().getSocketFactory().createSocket(host,
- port,
- clientHost,
- clientPort);
- }
-
- /**
- * Attempts to get a new socket connection to the given host within the given time limit.
- * <p>
- * To circumvent the limitations of older JREs that do not support connect timeout a
- * controller thread is executed. The controller thread attempts to create a new socket
- * within the given limit of time. If socket constructor does not return until the
- * timeout expires, the controller terminates and throws an {@link ConnectTimeoutException}
- * </p>
- *
- * @param host the host name/IP
- * @param port the port on the host
- * @param localAddress the local host name/IP to bind the socket to
- * @param localPort the port on the local machine
- * @param params {@link HttpConnectionParams Http connection parameters}
- * @return Socket a new socket
- * @throws IOException if an I/O error occurs while creating the socket
- * @throws UnknownHostException if the IP address of the host cannot be
- * determined
- */
- public Socket createSocket(final String host,
- final int port,
- final InetAddress localAddress,
- final int localPort,
- final HttpConnectionParams params) throws IOException {
- if (params == null) {
- throw new IllegalArgumentException("Parameters may not be null");
- }
- int timeout = params.getConnectionTimeout();
- if (timeout == 0) {
- return createSocket(host, port, localAddress, localPort);
- } else {
- // To be eventually deprecated when migrated to Java 1.4 or above
- return ControllerThreadSocketFactory.createSocket(this, host, port, localAddress, localPort, timeout);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Socket createSocket(String host, int port)
- throws IOException {
- return getSSLContext().getSocketFactory().createSocket(host,
- port);
- }
-
- /**
- * {@inheritDoc}
- */
- public Socket createSocket(Socket socket,
- String host,
- int port,
- boolean autoClose)
- throws IOException {
- return getSSLContext().getSocketFactory().createSocket(socket,
- host,
- port,
- autoClose);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean equals(Object obj) {
- return ((obj != null) && obj.getClass().equals(EasySSLProtocolSocketFactory.class));
- }
-
- /**
- * Return hash code of this object.
- *
- * @return int hash code of this object
- */
- public int hashCode() {
- return EasySSLProtocolSocketFactory.class.hashCode();
- }
-
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/httpclient/EasyX509TrustManager.java b/proxy/src/main/java/flex/messaging/services/http/httpclient/EasyX509TrustManager.java
deleted file mode 100755
index 88803e1..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/httpclient/EasyX509TrustManager.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * ====================================================================
- *
- * Copyright 2002-2004 The Apache Software Foundation
- *
- * Licensed 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-/*
- * This file has been modified by Adobe (Adobe Systems Incorporated).
- * Date: Oct 24, 2008 onwards.
- * Reason(s): Fixed the following issues:
- * BLZ-269 - Add support to proxy service for IBM X509
- * checkstyle warnings
- */
-
-package flex.messaging.services.http.httpclient;
-
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
-import javax.net.ssl.X509TrustManager;
-
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-
-import flex.messaging.util.Trace;
-
-/**
- * <p>
- * EasyX509TrustManager unlike default {@link javax.net.ssl.X509TrustManager} accepts
- * self-signed certificates.
- * </p>
- * <p>
- * This trust manager SHOULD NOT be used for productive systems
- * due to security reasons, unless it is a concious decision and
- * you are perfectly aware of security implications of accepting
- * self-signed certificates
- * </p>
- *
- * <p>
- * DISCLAIMER: HttpClient developers DO NOT actively support this component.
- * The component is provided as a reference material, which may be inappropriate
- * use without additional customization.
- * </p>
- */
-public class EasyX509TrustManager implements X509TrustManager {
- private X509TrustManager standardTrustManager = null;
-
- private boolean trustStore;
-
- /**
- * Constructor for EasyX509TrustManager.
- *
- * @param keystore the KeyStore to use
- * @throws NoSuchAlgorithmException, KeyStoreException if the construction process failed
- */
- public EasyX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException {
- super();
- TrustManagerFactory factory = null;
- try {
- factory = TrustManagerFactory.getInstance("SunX509");
- } catch (NoSuchAlgorithmException nsae) {
- // Fallback attempt - try for an IbmX509 factory in case we're running in WAS with no Sun providers registered.
- try {
- factory = TrustManagerFactory.getInstance("IbmX509");
- } catch (NoSuchAlgorithmException nsae2) {
- throw new NoSuchAlgorithmException("Neither SunX509 nor IbmX509 trust manager supported.");
- }
- }
- factory.init(keystore);
- TrustManager[] trustmanagers = factory.getTrustManagers();
- if (trustmanagers.length == 0) {
-
- factory.init(keystore);
- trustmanagers = factory.getTrustManagers();
-
- // If we still have no trust managers, throw.
- if (trustmanagers.length == 0)
- throw new NoSuchAlgorithmException("Neither SunX509 nor IbmX509 trust manager supported.");
- }
- this.standardTrustManager = (X509TrustManager) trustmanagers[0];
-
- // very lax settings must be used if flex.trustStore is being used
- trustStore = (System.getProperty("flex.trustStore") != null);
- }
-
- /*
- * (non-Javadoc)
- * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[] x509Certificates, String authType)
- */
- public void checkClientTrusted(X509Certificate[] certificates, String authType) throws CertificateException {
- if (trustStore) {
- return;
- }
- standardTrustManager.checkServerTrusted(certificates, authType);
- }
-
- /*
- * (non-Javadoc)
- * @see com.sun.net.ssl.X509TrustManager#isServerTrusted(X509Certificate[])
- */
- public void checkServerTrusted(X509Certificate[] certificates, String authType) throws CertificateException {
- if (trustStore) {
- return;
- }
- if (certificates != null) {
- if (Trace.ssl) {
- Trace.trace("Server certificate chain:");
- for (int i = 0; i < certificates.length; i++) {
- Trace.trace("X509Certificate[" + i + "]=" + certificates[i]);
- }
- }
- }
- if ((certificates != null) && (certificates.length == 1)) {
- X509Certificate certificate = certificates[0];
- try {
- certificate.checkValidity();
- } catch (CertificateException e) {
- if (Trace.ssl) {
- Trace.trace(e.toString());
- }
- throw e;
- }
- } else {
- standardTrustManager.checkServerTrusted(certificates, authType);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see com.sun.net.ssl.X509TrustManager#getAcceptedIssuers()
- */
- public X509Certificate[] getAcceptedIssuers() {
- return this.standardTrustManager.getAcceptedIssuers();
- }
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/httpclient/FlexGetMethod.java b/proxy/src/main/java/flex/messaging/services/http/httpclient/FlexGetMethod.java
deleted file mode 100755
index e2b0fe6..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/httpclient/FlexGetMethod.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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 flex.messaging.services.http.httpclient;
-
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HeaderElement;
-import org.apache.commons.httpclient.NameValuePair;
-import org.apache.commons.httpclient.methods.GetMethod;
-
-/**
- * Simple wrapper around PostMethod that exposes one method for ProxyServlet.
- */
-public class FlexGetMethod extends GetMethod {
- public FlexGetMethod(String str) {
- super(str);
- }
-
- public void setConnectionForced(boolean bool) {
- setConnectionCloseForced(bool);
- }
-
- protected String getContentCharSet(Header contentheader) {
- String charset = null;
- if (contentheader != null) {
- HeaderElement values[] = contentheader.getElements();
- if (values.length == 1) {
- NameValuePair param = values[0].getParameterByName("charset");
- if (param != null) {
- charset = param.getValue();
- }
- }
- }
- if (charset == null) {
- charset = "UTF-8";
- }
- return charset;
- }
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/httpclient/FlexPostMethod.java b/proxy/src/main/java/flex/messaging/services/http/httpclient/FlexPostMethod.java
deleted file mode 100755
index 688784d..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/httpclient/FlexPostMethod.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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 flex.messaging.services.http.httpclient;
-
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HeaderElement;
-import org.apache.commons.httpclient.NameValuePair;
-import org.apache.commons.httpclient.methods.PostMethod;
-
-/**
- * Simple wrapper around PostMethod that exposes one method for ProxyServlet.
- */
-public class FlexPostMethod extends PostMethod {
- public FlexPostMethod(String str) {
- super(str);
- }
-
- public void setConnectionForced(boolean bool) {
- setConnectionCloseForced(bool);
- }
-
- protected String getContentCharSet(Header contentheader) {
- String charset = null;
- if (contentheader != null) {
- HeaderElement values[] = contentheader.getElements();
- if (values.length == 1) {
- NameValuePair param = values[0].getParameterByName("charset");
- if (param != null) {
- charset = param.getValue();
- }
- }
- }
- if (charset == null) {
- charset = "UTF-8";
- }
- return charset;
- }
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/httpclient/package-info.java b/proxy/src/main/java/flex/messaging/services/http/httpclient/package-info.java
deleted file mode 100755
index b75db59..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/httpclient/package-info.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * 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 flex.messaging.services.http.httpclient;
\ No newline at end of file
diff --git a/proxy/src/main/java/flex/messaging/services/http/proxy/AccessFilter.java b/proxy/src/main/java/flex/messaging/services/http/proxy/AccessFilter.java
deleted file mode 100755
index e3a0715..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/proxy/AccessFilter.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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 flex.messaging.services.http.proxy;
-
-import flex.messaging.FlexContext;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Determines whether overall access to the proxy is allowed for a request.
- */
-public class AccessFilter extends ProxyFilter {
- private static final int TOO_MANY_COOKIES = 10703;
-
- /**
- * Invokes the filter with the context.
- *
- * @param context The proxy context.
- */
- public void invoke(ProxyContext context) {
- HttpServletRequest clientRequest = FlexContext.getHttpRequest();
-
- // as requested by @stake, limit the number of cookies that can be sent from the endpoint to prevent
- // as denial of service attack. It seems our processing of Flex-mangled cookies bogs down the server.
- // We set the cookie limit to 200, but it can be changed via -Dflex.cookieLimit
- if (clientRequest != null) {
- javax.servlet.http.Cookie[] cookies = clientRequest.getCookies();
- if (cookies != null && cookies.length > context.getCookieLimit()) {
- ProxyException e = new ProxyException();
- e.setMessage(TOO_MANY_COOKIES, new Object[]{"" + cookies.length});
- throw e;
- }
- }
-
- if (next != null) {
- next.invoke(context);
- }
- }
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/proxy/CookieInfo.java b/proxy/src/main/java/flex/messaging/services/http/proxy/CookieInfo.java
deleted file mode 100755
index 6097859..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/proxy/CookieInfo.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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 flex.messaging.services.http.proxy;
-
-/**
- *
- */
-public class CookieInfo {
- public String clientName;
- public String domain;
- public String name;
- public String value;
- public String path;
- // for Java
- public int maxAge;
- // for .NET
- public Object maxAgeObj;
- public boolean secure;
-
- public CookieInfo(String clientName, String domain, String name, String value, String path,
- int maxAge, Object maxAgeObj, boolean secure) {
- this.clientName = clientName;
- this.domain = domain;
- this.name = name;
- this.value = value;
- this.path = path;
- this.maxAge = maxAge;
- this.maxAgeObj = maxAgeObj;
- this.secure = secure;
- }
-
- public String toString() {
- return "domain = '" + domain +
- "', path = '" + path +
- "', client name = '" + clientName +
- "', endpoint name = '" + name +
- "', value = '" + value;
- }
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/proxy/ErrorFilter.java b/proxy/src/main/java/flex/messaging/services/http/proxy/ErrorFilter.java
deleted file mode 100755
index e196fd9..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/proxy/ErrorFilter.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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 flex.messaging.services.http.proxy;
-
-import flex.messaging.services.http.httpclient.FlexGetMethod;
-import flex.messaging.services.http.httpclient.FlexPostMethod;
-import flex.messaging.util.Assert;
-import flex.messaging.util.Trace;
-import flex.messaging.MessageException;
-
-/**
- * Wraps filters with exception handling.
- */
-public class ErrorFilter extends ProxyFilter {
- /**
- * Invokes the filter with the context.
- *
- * @param context The proxy context.
- */
- public void invoke(ProxyContext context) {
- try {
- if (next != null) {
- next.invoke(context);
- }
- } catch (MessageException ex) {
- throw ex;
- } catch (Throwable ex) {
- throw new MessageException(ex);
- } finally {
- try {
- if (context.getHttpMethod() != null) {
-
- // we don't want to keep the connection open if authentication info was sent
- if (context.hasAuthorization()) {
- if (context.getHttpMethod() instanceof FlexGetMethod) {
- ((FlexGetMethod) context.getHttpMethod()).setConnectionForced(true);
- } else if (context.getHttpMethod() instanceof FlexPostMethod) {
- ((FlexPostMethod) context.getHttpMethod()).setConnectionForced(true);
- } else {
- Assert.testAssertion(false, "Should have custom Flex method: " + context.getHttpMethod().getClass());
- }
- }
- context.getHttpMethod().releaseConnection();
- }
- } catch (Exception e) {
- if (Trace.error)
- e.printStackTrace();
- }
- }
- }
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/proxy/ProxyConstants.java b/proxy/src/main/java/flex/messaging/services/http/proxy/ProxyConstants.java
deleted file mode 100755
index 655b42f..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/proxy/ProxyConstants.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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 flex.messaging.services.http.proxy;
-
-/**
- * Contants related to the proxy (shared with .NET).
- */
-public class ProxyConstants {
- public static final String METHOD_GET = "GET";
- public static final String METHOD_HEAD = "HEAD";
- public static final String METHOD_OPTIONS = "OPTIONS";
- public static final String METHOD_DELETE = "DELETE";
- public static final String METHOD_PUT = "PUT";
- public static final String METHOD_TRACE = "TRACE";
- public static final String METHOD_CONNECT = "CONNECT";
-
- public static final String HEADER_CONTENT_TYPE = "Content-Type";
- public static final String COOKIE_PREFIX = "FLEX";
- public static final String COOKIE_SEPARATOR = "_";
- public static String HEADER_CREDENTIALS = "credentials";
- public static String HEADER_AUTHENTICATE = "WWW-Authenticate";
-
- public static final String HTTP_AUTHENTICATION_ERROR = "%%401%%";
- public static final String HTTP_AUTHORIZATION_ERROR = "%%403%%Authorization failed at the remote url.";
- public static final String DOMAIN_ERROR = "The Flex proxy and the specified endpoint do not have the same domain, " +
- "and so basic authentication cannot be used. Please specify use-custom-authentication or run-as for services not located " +
- "on the same domain as the Flex proxy.";
-
- public static final String PROXY_SECURITY = "PROXY SECURITY : ";
- public static final String NO_HTTPS_VIA_HTTP = "Invalid URL - can't access HTTPS URLs when accessing proxy via HTTP.";
- public static final String ONLY_HTTP_HTTPS = "Invalid URL - only HTTP or HTTPS URLs allowed";
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/proxy/ProxyContext.java b/proxy/src/main/java/flex/messaging/services/http/proxy/ProxyContext.java
deleted file mode 100755
index d0f1eb3..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/proxy/ProxyContext.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * 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 flex.messaging.services.http.proxy;
-
-import flex.messaging.services.http.ExternalProxySettings;
-import flex.messaging.services.http.HTTPProxyAdapter;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.commons.httpclient.protocol.Protocol;
-
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.httpclient.Cookie;
-
-/**
- * Store all the information needed for a proxy request.
- */
-public class ProxyContext extends SharedProxyContext {
- private HttpMethodBase httpMethod;
- private HttpClient httpClient;
-
- private String contentType;
- private String url;
- private Target target;
- private Object body;
- private Map headers;
-
- private ExternalProxySettings externalProxySettings;
- private int cookieLimit = HTTPProxyAdapter.DEFAULT_COOKIE_LIMIT;
- private boolean allowLaxSSL;
- private boolean contentChunked;
-
- private String credentialsHeader;
-
- // set up by ProxtContextFilter
- private UsernamePasswordCredentials proxyCredentials;
- private HttpConnectionManager connectionManager;
- private Protocol protocol;
-
- // the status code from the response
- private int statusCode = 200;
-
- // TODO: Decide whether responses will always be Strings
- private boolean streamResponseToClient;
- private boolean recordHeaders;
- private Map requestHeaders;
- private Map responseHeaders;
- private Object response;
-
- // We need to record the request cookies
-
- private Set requestCookies;
-
-
- /* PROXY COMMUNICATION */
-
- public HttpConnectionManager getConnectionManager() {
- return connectionManager;
- }
-
- public void setConnectionManager(HttpConnectionManager connectionManager) {
- this.connectionManager = connectionManager;
- }
-
- public HttpMethodBase getHttpMethod() {
- return httpMethod;
- }
-
- public void setHttpMethod(HttpMethodBase httpMethod) {
- this.httpMethod = httpMethod;
- }
-
- public HttpClient getHttpClient() {
- return httpClient;
- }
-
- public void setHttpClient(HttpClient httpClient) {
- this.httpClient = httpClient;
- }
-
-
- /* INPUT */
-
- public Map getHeaders() {
- return headers;
- }
-
- public void setHeaders(Map headers) {
- this.headers = headers;
- }
-
- public String getContentType() {
- return contentType;
- }
-
- public void setContentType(String type) {
- contentType = type;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String s) {
- url = s;
- }
-
- public Target getTarget() {
- return target;
- }
-
- public void setTarget(Target target) {
- this.target = target;
- }
-
- public Protocol getProtocol() {
- return protocol;
- }
-
- public void setProtocol(Protocol protocol) {
- this.protocol = protocol;
- }
-
- public Object getBody() {
- return body;
- }
-
- public void setBody(Object body) {
- this.body = body;
- }
-
- public String getCredentialsHeader() {
- return credentialsHeader;
- }
-
- public void setCredentialsHeader(String credentialsHeader) {
- this.credentialsHeader = credentialsHeader;
- }
-
- public UsernamePasswordCredentials getProxyCredentials() {
- return proxyCredentials;
- }
-
- public void setProxyCredentials(UsernamePasswordCredentials proxyCredentials) {
- this.proxyCredentials = proxyCredentials;
- }
-
- public int getCookieLimit() {
- return cookieLimit;
- }
-
- public void setCookieLimit(int cookieLimit) {
- this.cookieLimit = cookieLimit;
- }
-
- public boolean allowLaxSSL() {
- return allowLaxSSL;
- }
-
- public void setAllowLaxSSL(boolean allowLaxSSL) {
- this.allowLaxSSL = allowLaxSSL;
- }
-
- public ExternalProxySettings getExternalProxySettings() {
- return externalProxySettings;
- }
-
- public void setExternalProxySettings(ExternalProxySettings externalProxySettings) {
- this.externalProxySettings = externalProxySettings;
- }
-
- public boolean getRecordHeaders() {
- return recordHeaders;
- }
-
- public void setRecordHeaders(boolean recordHeaders) {
- this.recordHeaders = recordHeaders;
- }
-
- public boolean getContentChunked() {
- return contentChunked;
- }
-
- public void setContentChunked(boolean value) {
- contentChunked = value;
- }
-
-
- /* OUTPUT */
-
- public int getStatusCode() {
- return statusCode;
- }
-
- public void setStatusCode(int originalStatusCode) {
- this.statusCode = originalStatusCode;
- }
-
- public Object getResponse() {
- return response;
- }
-
- public void setResponse(Object r) {
- response = r;
- }
-
- public boolean streamResponseToClient() {
- return streamResponseToClient;
- }
-
- public void setStreamResponseToClient(boolean s) {
- this.streamResponseToClient = s;
- }
-
- public Map getRequestHeaders() {
- return requestHeaders;
- }
-
- public void setRequestHeaders(Map requestHeaders) {
- this.requestHeaders = requestHeaders;
- }
-
- public Map getResponseHeaders() {
- return responseHeaders;
- }
-
- public void setResponseHeaders(Map responseHeaders) {
- this.responseHeaders = responseHeaders;
- }
-
- public void clearRequestCookies() {
- requestCookies = null;
- }
-
- public void addRequestCookie(Cookie cookie) {
- if (requestCookies == null)
- requestCookies = new HashSet();
- requestCookies.add(cookie);
- }
-
- public Set getRequestCookies() {
- return requestCookies;
- }
-
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/proxy/ProxyContextFilter.java b/proxy/src/main/java/flex/messaging/services/http/proxy/ProxyContextFilter.java
deleted file mode 100755
index b31c3b2..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/proxy/ProxyContextFilter.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * 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 flex.messaging.services.http.proxy;
-
-import flex.messaging.services.http.httpclient.EasySSLProtocolSocketFactory;
-import flex.messaging.services.HTTPProxyService;
-import flex.messaging.FlexContext;
-import flex.messaging.log.Log;
-import org.apache.commons.httpclient.HostConfiguration;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.URIException;
-import org.apache.commons.httpclient.protocol.Protocol;
-import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
-import org.apache.commons.httpclient.util.URIUtil;
-
-import javax.servlet.http.HttpServletRequest;
-
-import java.net.InetAddress;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.UnknownHostException;
-
-/**
- * Fills in ProxyContext data for use by ProxyFilters within HttpProxyAdapter.
- */
-public class ProxyContextFilter extends ProxyFilter {
- private static final int RELATIVE_NOT_SUPPORTED = 10704;
- private static final int INVALID_TARGET = 10705;
-
- private static final String STRING_LOCALHOST = "localhost";
-
- private Protocol myhttps = new Protocol("https", (ProtocolSocketFactory) (new EasySSLProtocolSocketFactory()), 443);
-
- /**
- * Invokes the filter with the context.
- *
- * @param context The proxy context.
- */
- public void invoke(ProxyContext context) {
- setupInitialProperties(context);
- setupTarget(context);
- logInfo(context);
-
- if (next != null) {
- next.invoke(context);
- }
- }
-
- protected void setupInitialProperties(ProxyContext context) {
- HttpServletRequest clientRequest = FlexContext.getHttpRequest();
- if (clientRequest != null) {
- String reqURL = clientRequest.getRequestURL().toString();
- int idx = reqURL.indexOf(':');
- String reqProto = reqURL.substring(0, idx);
- context.setClientHttps(reqProto.equalsIgnoreCase("https"));
-
- // set up disableCaching variable since its used in sendException
- String userAgent = clientRequest.getHeader("User-Agent");
- context.setDisableCaching(context.isClientHttps() && userAgent != null && userAgent.indexOf("MSIE") != -1);
- }
- }
-
- protected void setupTarget(ProxyContext context) {
- Target target = context.getTarget();
- String source = context.getUrl();
- HttpServletRequest clientRequest = FlexContext.getHttpRequest();
-
- try {
- target.setUrl(new URL(source));
- } catch (MalformedURLException e) {
- try {
- //[Pete] Enhancement Req. 80172 - relative URLs from webroot (not
- // webapp context root)
- if (clientRequest != null) {
- String baseurl = "http" + (clientRequest.isSecure() ? "s" : "") + "://"
- + clientRequest.getServerName() + ":" + clientRequest.getServerPort();
-
- target.setUrl(new URL(baseurl + source));
- } else {
- ProxyException pe = new ProxyException();
- pe.setMessage(RELATIVE_NOT_SUPPORTED, new Object[]{source});
- throw pe;
- }
- } catch (MalformedURLException ex) {
- target.setUrl(null);
- }
- }
-
- if (target.getUrl() == null) {
- ProxyException pe = new ProxyException();
- pe.setMessage(INVALID_TARGET, new Object[]{source});
- throw pe;
- }
-
- target.setHTTPS(target.getUrl().getProtocol().equalsIgnoreCase("https"));
- target.setEncodedPath(target.getUrl().getPath());
- String queryStr = target.getUrl().getQuery();
- if (queryStr != null) {
- target.setEncodedPath(target.getEncodedPath() + ("?" + queryStr));
- }
- try {
- target.setEncodedPath(URIUtil.encodePathQuery(target.getEncodedPath()));
- } catch (URIException e) {
- // exception is thrown if the default charset is not supported.
- // proceed with the provided URL.
- }
-
- target.setHostConfig(new HostConfiguration());
- String targetHost = target.getUrl().getHost();
- int targetPort = target.getUrl().getPort();
-
- // Check for a custom protocol
- Protocol customProtocol = context.getProtocol();
- if (customProtocol != null) {
- target.getHostConfig().setHost(targetHost, targetPort, customProtocol);
- } else if (target.isHTTPS() && context.allowLaxSSL()) {
- target.getHostConfig().setHost(targetHost, targetPort, myhttps);
- } else {
- String targetProtocol = target.getUrl().getProtocol();
- target.getHostConfig().setHost(targetHost, targetPort, targetProtocol);
- }
-
- if (context.getConnectionManager() != null) {
- context.setHttpClient(new HttpClient(context.getConnectionManager()));
- } else {
- context.setHttpClient(new HttpClient());
- }
-
- // Determine if target domain matches this proxy's domain and port
- boolean localDomain = false;
- boolean localPort = false;
- if (clientRequest != null) {
- String proxyDomain = clientRequest.getServerName().contains(STRING_LOCALHOST) ?
- getResolvedLocalhost() : clientRequest.getServerName();
- String resolvedTargetHost = targetHost.contains(STRING_LOCALHOST) ? getResolvedLocalhost() : targetHost;
- if (proxyDomain.equalsIgnoreCase(resolvedTargetHost)) {
- localDomain = true;
- int proxyPort = clientRequest.getServerPort();
- localPort = proxyPort == targetPort;
- }
- }
- context.setLocalDomain(localDomain);
- context.setLocalPort(localPort);
- }
-
- protected void logInfo(ProxyContext context) {
- if (Log.isInfo()) {
- Target target = context.getTarget();
- String prefix = "-- " + context.getMethod() + " : ";
- int targetPort = target.getUrl().getPort();
- String targetURL = target.getUrl().getProtocol() + "://" + target.getUrl().getHost() +
- (targetPort == -1 ? "" : ":" + targetPort) + target.getEncodedPath();
-
- Log.getLogger(HTTPProxyService.LOG_CATEGORY).info(prefix + targetURL);
- }
- }
-
- /**
- * Returns the IP of the localhost.
- *
- * @return The IP of the localhost.
- */
- private String getResolvedLocalhost() {
- try {
- return InetAddress.getLocalHost().getHostAddress();
- } catch (UnknownHostException e) {
- // NOWARN
- }
- return null;
- }
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/proxy/ProxyException.java b/proxy/src/main/java/flex/messaging/services/http/proxy/ProxyException.java
deleted file mode 100755
index 16bd111..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/proxy/ProxyException.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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 flex.messaging.services.http.proxy;
-
-import flex.messaging.MessageException;
-
-/**
- * Simple exception used to get back to ErrorFilter from other filters.
- */
-public class ProxyException extends MessageException {
- static final long serialVersionUID = -6516172702871227717L;
-
- public static final String CODE_SERVER_PROXY_REQUEST_FAILED = "Server.Proxy.Request.Failed";
-
- //--------------------------------------------------------------------------
- //
- // Constructors
- //
- //--------------------------------------------------------------------------
-
- /**
- * Default constructor.
- */
- public ProxyException() {
- super();
- super.setCode(CODE_SERVER_PROXY_REQUEST_FAILED);
- }
-
- /**
- * Constructor with a message.
- *
- * @param message The detailed message for the exception.
- */
- public ProxyException(int message) {
- this();
- setMessage(message);
- }
-}
\ No newline at end of file
diff --git a/proxy/src/main/java/flex/messaging/services/http/proxy/ProxyFilter.java b/proxy/src/main/java/flex/messaging/services/http/proxy/ProxyFilter.java
deleted file mode 100755
index 015edf7..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/proxy/ProxyFilter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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 flex.messaging.services.http.proxy;
-
-
-/**
- * Base filter definition that defines the filter contract.
- * Filters perform pre- and post-processing duties on the ProxyContext
- */
-public abstract class ProxyFilter {
- protected ProxyFilter next;
-
- public ProxyFilter() {
- }
-
- public ProxyFilter getNext() {
- return next;
- }
-
- public void setNext(ProxyFilter next) {
- this.next = next;
- }
-
- /**
- * The core business method.
- */
- public abstract void invoke(ProxyContext context);
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/proxy/ProxyUtil.java b/proxy/src/main/java/flex/messaging/services/http/proxy/ProxyUtil.java
deleted file mode 100755
index 872b435..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/proxy/ProxyUtil.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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 flex.messaging.services.http.proxy;
-
-import org.apache.commons.httpclient.auth.AuthScope;
-
-/**
- * Methods used by multiple proxy classes.
- */
-public class ProxyUtil {
- private static AuthScope anyAuthScope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT);
-
- /**
- * Returns the default authScope.
- *
- * @return The default authScope.
- */
- public static AuthScope getDefaultAuthScope() {
- return anyAuthScope;
- }
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/proxy/RequestFilter.java b/proxy/src/main/java/flex/messaging/services/http/proxy/RequestFilter.java
deleted file mode 100755
index 33b5ff7..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/proxy/RequestFilter.java
+++ /dev/null
@@ -1,557 +0,0 @@
-/*
- * 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 flex.messaging.services.http.proxy;
-
-import flex.messaging.FlexContext;
-import flex.messaging.FlexSession;
-import flex.messaging.io.MessageIOConstants;
-import flex.messaging.log.Log;
-import flex.messaging.log.Logger;
-import flex.messaging.services.HTTPProxyService;
-import flex.messaging.services.http.ExternalProxySettings;
-import flex.messaging.services.http.httpclient.FlexGetMethod;
-import flex.messaging.services.http.httpclient.FlexPostMethod;
-import flex.messaging.util.StringUtils;
-import flex.messaging.util.URLEncoder;
-import org.apache.commons.httpclient.Cookie;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.HttpState;
-import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.HeadMethod;
-import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
-import org.apache.commons.httpclient.methods.OptionsMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.commons.httpclient.methods.StringRequestEntity;
-import org.apache.commons.httpclient.methods.TraceMethod;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Array;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * Sends the request to the endpoint, including custom copying of headers and cookies.
- */
-public class RequestFilter extends ProxyFilter {
- private static final int CAUGHT_ERROR = 10706;
- private static final int UNKNOWN_HOST = 10707;
- private static final int INVALID_METHOD = 10719;
- private static final String STRING_JSESSIONID = "jsessionid";
-
- /**
- * Invoke the filter.
- *
- * @param context the context
- */
- public void invoke(ProxyContext context) {
- setupRequest(context);
- copyCookiesToEndpoint(context);
- copyHeadersToEndpoint(context);
- addCustomHeaders(context);
- recordRequestHeaders(context);
- sendRequest(context);
-
- if (next != null) {
- next.invoke(context);
- }
- }
-
- /**
- * Setup the request.
- *
- * @param context the context
- */
- protected void setupRequest(ProxyContext context) {
- // set the proxy to send requests through
- ExternalProxySettings externalProxy = context.getExternalProxySettings();
- if (externalProxy != null) {
- String proxyServer = externalProxy.getProxyServer();
-
- if (proxyServer != null) {
- context.getTarget().getHostConfig().setProxy(proxyServer, externalProxy.getProxyPort());
- if (context.getProxyCredentials() != null) {
- context.getHttpClient().getState().setProxyCredentials(ProxyUtil.getDefaultAuthScope(), context.getProxyCredentials());
- }
- }
- }
-
- String method = context.getMethod();
- String encodedPath = context.getTarget().getEncodedPath();
- if (MessageIOConstants.METHOD_POST.equals(method)) {
- FlexPostMethod postMethod = new FlexPostMethod(encodedPath);
- context.setHttpMethod(postMethod);
- if (context.hasAuthorization()) {
- postMethod.setConnectionForced(true);
- }
- } else if (ProxyConstants.METHOD_GET.equals(method)) {
- FlexGetMethod getMethod = new FlexGetMethod(context.getTarget().getEncodedPath());
- context.setHttpMethod(getMethod);
- if (context.hasAuthorization()) {
- getMethod.setConnectionForced(true);
- }
- } else if (ProxyConstants.METHOD_HEAD.equals(method)) {
- HeadMethod headMethod = new HeadMethod(encodedPath);
- context.setHttpMethod(headMethod);
- } else if (ProxyConstants.METHOD_PUT.equals(method)) {
- PutMethod putMethod = new PutMethod(encodedPath);
- context.setHttpMethod(putMethod);
- } else if (ProxyConstants.METHOD_OPTIONS.equals(method)) {
- OptionsMethod optionsMethod = new OptionsMethod(encodedPath);
- context.setHttpMethod(optionsMethod);
- } else if (ProxyConstants.METHOD_DELETE.equals(method)) {
- DeleteMethod deleteMethod = new DeleteMethod(encodedPath);
- context.setHttpMethod(deleteMethod);
- } else if (ProxyConstants.METHOD_TRACE.equals(method)) {
- TraceMethod traceMethod = new TraceMethod(encodedPath);
- context.setHttpMethod(traceMethod);
- } else {
- ProxyException pe = new ProxyException(INVALID_METHOD);
- pe.setDetails(INVALID_METHOD, "1", new Object[]{method});
- throw pe;
- }
-
- HttpMethodBase httpMethod = context.getHttpMethod();
- if (httpMethod instanceof EntityEnclosingMethod) {
- ((EntityEnclosingMethod) httpMethod).setContentChunked(context.getContentChunked());
- }
- }
-
- /**
- * Before calling the endpoint, set up the cookies found in the request.
- *
- * @param context the context
- */
- public static void copyCookiesToEndpoint(ProxyContext context) {
- HttpServletRequest clientRequest = FlexContext.getHttpRequest();
- context.clearRequestCookies();
- if (clientRequest != null) {
- javax.servlet.http.Cookie[] cookies = clientRequest.getCookies();
- HttpState initState = context.getHttpClient().getState();
-
- if (cookies != null) {
- // Gather up the cookies keyed on the length of the path.
- // This is done so that if we have two cookies with the same name,
- // we pass the cookie with the longest path first to the endpoint
- TreeMap cookieMap = new TreeMap();
- for (javax.servlet.http.Cookie cookie : cookies) {
- CookieInfo origCookie = new CookieInfo(cookie.getName(), cookie.getDomain(), cookie.getName(),
- cookie.getValue(), cookie.getPath(), cookie.getMaxAge(), null, cookie.getSecure());
- CookieInfo newCookie = RequestUtil.createCookie(origCookie, context, context.getTarget().getUrl().getHost(),
- context.getTarget().getUrl().getPath());
-
- if (newCookie != null) {
- Integer pathInt = Integer.valueOf(0 - newCookie.path.length());
- ArrayList list = (ArrayList) cookieMap.get(pathInt);
- if (list == null) {
- list = new ArrayList();
- cookieMap.put(pathInt, list);
- }
- list.add(newCookie);
- }
- }
-
- // loop through (in order) the cookies we've gathered
- for (Object mapValue : cookieMap.values()) {
- ArrayList list = (ArrayList) mapValue;
- for (Object aList : list) {
- CookieInfo cookieInfo = (CookieInfo) aList;
- if (Log.isInfo()) {
- String str = "-- Cookie in request: " + cookieInfo;
- Log.getLogger(HTTPProxyService.LOG_CATEGORY).debug(str);
- }
-
- Cookie cookie = new Cookie(cookieInfo.domain, cookieInfo.name, cookieInfo.value, cookieInfo.path,
- cookieInfo.maxAge, cookieInfo.secure);
-
- // If this is a session cookie and we're dealing with local domain, make sure the session
- // cookie has the latest session id. This check is needed when the session was invalidated
- // and then recreated in this request; we shouldn't be sending the old session id to the endpoint.
- if (context.isLocalDomain() && STRING_JSESSIONID.equalsIgnoreCase(cookieInfo.clientName)) {
- FlexSession flexSession = FlexContext.getFlexSession();
- if (flexSession != null && flexSession.isValid()) {
- String sessionId = flexSession.getId();
- String cookieValue = cookie.getValue();
- if (!cookieValue.contains(sessionId)) {
- int colonIndex = cookieValue.indexOf(':');
- if (colonIndex != -1) {
- // Websphere changes jsession id to the following format:
- // 4 digit cacheId + jsessionId + ":" + cloneId.
- ServletContext servletContext = FlexContext.getServletContext();
- String serverInfo = servletContext != null ? servletContext.getServerInfo() : null;
- boolean isWebSphere = serverInfo != null && serverInfo.contains("WebSphere");
- if (isWebSphere) {
- String cacheId = cookieValue.substring(0, 4);
- String cloneId = cookieValue.substring(colonIndex);
- String wsSessionId = cacheId + sessionId + cloneId;
- cookie.setValue(wsSessionId);
- } else {
- cookie.setValue(sessionId);
- }
- } else {
- cookie.setValue(sessionId);
- }
- }
- }
- }
- // finally add the cookie to the current request
- initState.addCookie(cookie);
- context.addRequestCookie(cookie);
- }
- }
- }
- }
- }
-
- /**
- * Copy HTTP request headers to the endpoint.
- *
- * @param context the context
- */
- public static void copyHeadersToEndpoint(ProxyContext context) {
- HttpServletRequest clientRequest = FlexContext.getHttpRequest();
- if (clientRequest != null) {
- Enumeration headerNames = clientRequest.getHeaderNames();
- while (headerNames.hasMoreElements()) {
- String headerName = (String) headerNames.nextElement();
- if (RequestUtil.ignoreHeader(headerName, context)) {
- continue;
- }
-
- Enumeration headers = clientRequest.getHeaders(headerName);
- while (headers.hasMoreElements()) {
- String value = (String) headers.nextElement();
- context.getHttpMethod().addRequestHeader(headerName, value);
-
- if (Log.isInfo()) {
- Log.getLogger(HTTPProxyService.LOG_CATEGORY).debug("-- Header in request: " + headerName + " : " + value);
- }
- }
- }
- }
- }
-
- /**
- * Add any custom headers.
- *
- * @param context the context
- */
- protected void addCustomHeaders(ProxyContext context) {
- HttpMethodBase httpMethod = context.getHttpMethod();
-
- String contentType = context.getContentType();
- if (contentType != null) {
- httpMethod.setRequestHeader(ProxyConstants.HEADER_CONTENT_TYPE, contentType);
- }
-
- Map customHeaders = context.getHeaders();
- if (customHeaders != null) {
- for (Object entry : customHeaders.entrySet()) {
-
- String name = (String) ((Map.Entry) entry).getKey();
- Object value = ((Map.Entry) entry).getValue();
- if (value == null) {
- httpMethod.setRequestHeader(name, "");
- }
- // Single value for the name.
- else if (value instanceof String) {
- httpMethod.setRequestHeader(name, (String) value);
- }
- // Multiple values for the name.
- else if (value instanceof List) {
- List valueList = (List) value;
- for (Object currentValue : valueList) {
- if (currentValue == null) {
- httpMethod.addRequestHeader(name, "");
- } else {
- httpMethod.addRequestHeader(name, (String) currentValue);
- }
- }
- } else if (value.getClass().isArray()) {
- Object[] valueArray = (Object[]) value;
- for (Object currentValue : valueArray) {
- if (currentValue == null) {
- httpMethod.addRequestHeader(name, "");
- } else {
- httpMethod.addRequestHeader(name, (String) currentValue);
- }
- }
- }
- }
- }
-
- if (context.isSoapRequest()) {
- // add the appropriate headers
- context.getHttpMethod().setRequestHeader(ProxyConstants.HEADER_CONTENT_TYPE, MessageIOConstants.CONTENT_TYPE_XML);
-
- // get SOAPAction, and if it doesn't exist, create it
- String soapAction = null;
-
- Header header = context.getHttpMethod().getRequestHeader(MessageIOConstants.HEADER_SOAP_ACTION);
- if (header != null) {
- soapAction = header.getValue();
- }
-
- if (soapAction == null) {
- HttpServletRequest clientRequest = FlexContext.getHttpRequest();
- if (clientRequest != null) {
- soapAction = clientRequest.getHeader(MessageIOConstants.HEADER_SOAP_ACTION);
- }
-
- // SOAPAction has to be quoted per the SOAP 1.1 spec.
- if (soapAction != null && !soapAction.startsWith("\"") && !soapAction.endsWith("\"")) {
- soapAction = "\"" + soapAction + "\"";
- }
-
- // If soapAction happens to still be null at this point, we'll end up not sending
- // one, which should generate a fault on the server side which we'll happily convey
- // back to the client.
-
- context.getHttpMethod().setRequestHeader(MessageIOConstants.HEADER_SOAP_ACTION, soapAction);
- }
- }
- }
-
- /**
- * Record the request headers in the proxy context.
- *
- * @param context the context
- */
- protected void recordRequestHeaders(ProxyContext context) {
- if (context.getRecordHeaders()) {
- Header[] headers = context.getHttpMethod().getRequestHeaders();
- if (headers != null) {
- HashMap recordedHeaders = new HashMap();
- for (Header header : headers) {
- String headerName = header.getName();
- String headerValue = header.getValue();
- Object existingHeaderValue = recordedHeaders.get(headerName);
- // Value(s) already exist for the header.
- if (existingHeaderValue != null) {
- ArrayList headerValues;
- // Only a single value exists.
- if (existingHeaderValue instanceof String) {
- headerValues = new ArrayList();
- headerValues.add(existingHeaderValue);
- headerValues.add(headerValue);
- recordedHeaders.put(headerName, headerValues);
- }
- // Multiple values exist.
- else if (existingHeaderValue instanceof ArrayList) {
- headerValues = (ArrayList) existingHeaderValue;
- headerValues.add(headerValue);
- }
- } else {
- recordedHeaders.put(headerName, headerValue);
- }
- }
- context.setRequestHeaders(recordedHeaders);
- }
- }
- }
-
- /**
- * Send the request.
- *
- * @param context the context
- */
- protected void sendRequest(ProxyContext context) {
- Target target = context.getTarget();
- String method = context.getMethod();
- HttpMethod httpMethod = context.getHttpMethod();
- final String BEGIN = "-- Begin ";
- final String END = "-- End ";
- final String REQUEST = " request --";
-
- if (httpMethod instanceof EntityEnclosingMethod) {
- Object data = processBody(context);
- Class dataClass = data.getClass();
- if (data instanceof String) {
- String requestString = (String) data;
- if (Log.isInfo()) {
- Logger logger = Log.getLogger(HTTPProxyService.LOG_CATEGORY);
- logger.debug(BEGIN + method + REQUEST);
- logger.debug(StringUtils.prettifyString(requestString));
- logger.debug(END + method + REQUEST);
- }
-
- try {
- StringRequestEntity requestEntity = new StringRequestEntity(requestString, null, "UTF-8");
- ((EntityEnclosingMethod) httpMethod).setRequestEntity(requestEntity);
- } catch (UnsupportedEncodingException ex) {
- ProxyException pe = new ProxyException(CAUGHT_ERROR);
- pe.setDetails(CAUGHT_ERROR, "1", new Object[]{ex});
- throw pe;
- }
- } else if (dataClass.isArray() && Byte.TYPE.equals(dataClass.getComponentType())) {
- byte[] dataBytes = (byte[]) data;
- ByteArrayRequestEntity requestEntity = new ByteArrayRequestEntity(dataBytes, context.getContentType());
- ((EntityEnclosingMethod) httpMethod).setRequestEntity(requestEntity);
- } else if (data instanceof InputStream) {
- InputStreamRequestEntity requestEntity = new InputStreamRequestEntity((InputStream) data, context.getContentType());
- ((EntityEnclosingMethod) httpMethod).setRequestEntity(requestEntity);
- }
- //TODO: Support multipart post
- //else
- //{
- //FIXME: Throw exception if unhandled data type
- //}
- } else if (httpMethod instanceof GetMethod) {
- Object req = processBody(context);
-
- if (req instanceof String) {
- String requestString = (String) req;
- if (Log.isInfo()) {
- Logger logger = Log.getLogger(HTTPProxyService.LOG_CATEGORY);
- logger.debug(BEGIN + method + REQUEST);
- logger.debug(StringUtils.prettifyString(requestString));
- logger.debug(END + method + REQUEST);
- }
-
- if (!"".equals(requestString)) {
- String query = context.getHttpMethod().getQueryString();
- if (query != null) {
- query += "&" + requestString;
- } else {
- query = requestString;
- }
- context.getHttpMethod().setQueryString(query);
- }
- }
- }
-
- context.getHttpClient().setHostConfiguration(target.getHostConfig());
-
- try {
- context.getHttpClient().executeMethod(context.getHttpMethod());
- } catch (UnknownHostException uhex) {
- ProxyException pe = new ProxyException();
- pe.setMessage(UNKNOWN_HOST, new Object[]{uhex.getMessage()});
- pe.setCode(ProxyException.CODE_SERVER_PROXY_REQUEST_FAILED);
- throw pe;
- } catch (Exception ex) {
- // FIXME: JRB - could be more specific by looking for timeout and sending 504 in that case.
- // rfc2616 10.5.5 504 - could get more specific if we parse the HttpException
- ProxyException pe = new ProxyException(CAUGHT_ERROR);
- pe.setDetails(CAUGHT_ERROR, "1", new Object[]{ex.getMessage()});
- pe.setCode(ProxyException.CODE_SERVER_PROXY_REQUEST_FAILED);
- throw pe;
- }
- }
-
- /**
- * Process the request body and return its content.
- *
- * @param context the context
- * @return the body content
- */
- protected Object processBody(ProxyContext context) {
- //FIXME: Should we also send on URL params that were used to contact the message broker servlet?
-
- Object body = context.getBody();
- if (body == null) {
- return "";
- } else if (body instanceof String) {
- return body;
- } else if (body instanceof Map) {
- Map params = (Map) body;
-
- StringBuffer postData = new StringBuffer();
-
- boolean formValues = false;
- for (Object entry : params.entrySet()) {
- String name = (String) ((Map.Entry) entry).getKey();
- if (!formValues) {
- formValues = true;
- } else {
- postData.append('&');
- }
-
- Object vals = ((Map.Entry) entry).getValue();
-
- if (vals == null) {
- encodeParam(postData, name, "");
- } else if (vals instanceof String) {
- String val = (String) vals;
- encodeParam(postData, name, val);
- } else if (vals instanceof List) {
- List valLists = (List) vals;
-
- for (int i = 0; i < valLists.size(); i++) {
- Object o = valLists.get(i);
- String val = "";
- if (o != null)
- val = o.toString();
-
- if (i > 0)
- postData.append('&');
-
- encodeParam(postData, name, val);
- }
- } else if (vals.getClass().isArray()) {
- for (int i = 0; i < Array.getLength(vals); i++) {
- Object o = Array.get(vals, i);
- String val = "";
- if (o != null)
- val = o.toString();
-
- if (i > 0)
- postData.append('&');
-
- encodeParam(postData, name, val);
- }
- }
- }
-
- return postData.toString();
- } else if (body.getClass().isArray()) {
- return body;
- } else if (body instanceof InputStream) {
- return body;
- } else {
- return body.toString();
- }
- }
-
- /**
- * Encode name=value in to a string buffer.
- *
- * @param buf buffer
- * @param name name
- * @param val value
- */
- protected void encodeParam(StringBuffer buf, String name, String val) {
- name = URLEncoder.encode(name);
- val = URLEncoder.encode(val);
-
- buf.append(name);
- buf.append('=');
- buf.append(val);
- }
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/proxy/RequestUtil.java b/proxy/src/main/java/flex/messaging/services/http/proxy/RequestUtil.java
deleted file mode 100755
index 2025229..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/proxy/RequestUtil.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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 flex.messaging.services.http.proxy;
-
-import flex.messaging.log.Log;
-import flex.messaging.services.HTTPProxyService;
-
-/**
- * Request methods shared by J2EE and .NET.
- */
-public class RequestUtil {
- public static CookieInfo createCookie(CookieInfo cookie, SharedProxyContext context, String targetHost,
- String targetPath) {
- String path = cookie.path;
- String name = cookie.name;
- if (path == null) {
- path = "/";
- }
- String domain = null, actualName = null;
-
- // FIXME: append domain+path to existing path instead of doing cookie hack?
-
- //Cookie name format: COOKIE_PREFIX[COOKIE_SEPARATOR]domain[COOKIE_SEPARATOR]path[COOKIE_SEPARATOR]name
- if (name.startsWith(ProxyConstants.COOKIE_PREFIX) && name.indexOf(ProxyConstants.COOKIE_SEPARATOR) != -1) {
- //use indexOf and substring instead of split or string tokenizer for performance
- int domainHash;
- int pathHash;
- int startIndex = name.indexOf(ProxyConstants.COOKIE_SEPARATOR) + 1;
- int endIndex = name.indexOf(ProxyConstants.COOKIE_SEPARATOR, startIndex);
- if (endIndex == -1) return null;
- try {
- domainHash = Integer.parseInt(name.substring(startIndex, endIndex));
- startIndex = endIndex + 1;
- endIndex = name.indexOf(ProxyConstants.COOKIE_SEPARATOR, startIndex);
- if (endIndex == -1) return null;
- pathHash = Integer.parseInt(name.substring(startIndex, endIndex));
- } catch (NumberFormatException e) {
- Log.getLogger(HTTPProxyService.LOG_CATEGORY).error("Could not parse cookie hash value in: " + name + " (may be beta cookie)");
- return null;
- }
- startIndex = endIndex + 1;
- if (name.length() <= startIndex) return null;
- actualName = name.substring(startIndex);
- //see if the context.target domain fuzzy matches the cookie's domain
- domain = targetHost;
- while (domain != null && domainHash != domain.hashCode()) {
- int dotIndex = domain.indexOf(".", 1);
- if (dotIndex != -1) {
- domain = domain.substring(dotIndex);
- } else {
- domain = null;
- }
- }
- if (domain == null) return null;
-
- //see if the context.target path fuzzy matches the cookie's path. i think this has to be done the long way
- //to make sure we match cases where the path might have ended with a / or not. perhaps
- //we could do it slightly more efficiently by testing /foo/ and /foo in one go but not testing /fo
- path = targetPath;
- while (path != null && path.length() != 0 && pathHash != path.hashCode()) {
- path = path.substring(0, path.length() - 1);
- }
- if (path == null || path.length() == 0) return null;
- } else if (context.isLocalDomain()) {
- domain = cookie.domain;
- if (domain == null) {
- domain = targetHost;
- }
- actualName = cookie.name;
- } else {
- return null;
- }
-
- CookieInfo cookieInfo = new CookieInfo(name, domain, actualName, cookie.value, path,
- cookie.maxAge, cookie.maxAgeObj, cookie.secure);
- return cookieInfo;
- }
-
- public static boolean ignoreHeader(String headerName, SharedProxyContext context) {
- boolean ignoreHeader = false;
-
- // FIXME: do we really want to disallow Host- what does this do?
- if ("Host".equalsIgnoreCase(headerName) ||
- // FIXME: we should really ALWAYS send this header and handle compression within
- // the proxy. Would save bandwidth when the endpoint could handle it
- "Accept-Encoding".equalsIgnoreCase(headerName) ||
- "Content-Length".equalsIgnoreCase(headerName) ||
- "Set-Cookie".equalsIgnoreCase(headerName) ||
- "Set-Cookie2".equalsIgnoreCase(headerName) ||
- "Cookie".equalsIgnoreCase(headerName) ||
- "Connection".equalsIgnoreCase(headerName) ||
- ProxyConstants.HEADER_CREDENTIALS.equalsIgnoreCase(headerName) ||
- ("Authorization".equalsIgnoreCase(headerName) && (context.hasAuthorization() || !context.isLocalDomain()))) {
-
- ignoreHeader = true;
- }
- return ignoreHeader;
- }
-
-
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/proxy/ResponseFilter.java b/proxy/src/main/java/flex/messaging/services/http/proxy/ResponseFilter.java
deleted file mode 100755
index 0d43257..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/proxy/ResponseFilter.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * 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 flex.messaging.services.http.proxy;
-
-import org.apache.commons.httpclient.Cookie;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.StatusLine;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.methods.OptionsMethod;
-import flex.messaging.io.MessageIOConstants;
-
-import javax.servlet.http.HttpServletResponse;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Set;
-
-import flex.messaging.FlexContext;
-import flex.messaging.services.HTTPProxyService;
-import flex.messaging.log.Log;
-
-/**
- * Send the response to the client, including custom copying of headers and cookies.
- */
-public class ResponseFilter extends ProxyFilter {
- // NOTE: any changes to this class should also be made to the corresponding version in the .NET.
- // The corresponding class is in src/dotNet/libs/FlexASPlib/Aspx/Proxy
-
- public static int RESPONSE_CHUNK = 4096;
-
- private static final int STATUS_ERROR = 10708;
- private static final int NULL_RESPONSE_STREAM = 10709;
- private static final int CANNOT_STREAM_NOT_HTTP = 10710;
- private static final int ERROR_WRITING_RESPONSE = 10711;
-
- public void invoke(ProxyContext context) {
- if (next != null) {
- next.invoke(context);
- }
-
- checkStatusCode(context);
- copyCookiesFromEndpoint(context);
- copyHeadersFromEndpoint(context);
- recordResponseHeaders(context);
- setupResponse(context);
- }
-
- protected void checkStatusCode(ProxyContext context) {
- int statusCode = context.getStatusCode();
- // FIXME: Why do this only for HTTP Proxy? Why not WebServices?
- if (statusCode >= 400 && statusCode != 401 & statusCode != 403 && !context.isSoapRequest()) {
- StatusLine statusLine = context.getHttpMethod().getStatusLine();
- String reason = null;
-
- if (statusLine != null)
- reason = statusLine.toString();
-
- if (reason == null || "".equals(reason))
- reason = String.valueOf(statusCode);
-
- ProxyException pe = new ProxyException();
- pe.setMessage(STATUS_ERROR, new Object[]{reason});
- pe.setCode(ProxyException.CODE_SERVER_PROXY_REQUEST_FAILED);
- pe.setDetails(STATUS_ERROR, "1", new Object[]{reason});
- pe.setStatusCode(statusCode);
- throw pe;
- }
- }
-
- protected void copyCookiesFromEndpoint(ProxyContext context) {
- HttpServletResponse clientResponse = FlexContext.getHttpResponse();
-
- if (clientResponse != null) {
- Cookie[] cookies = context.getHttpClient().getState().getCookies();
- // We need to filter out the request cookies, we don't need to send back to the client
- Set requestCookies = context.getRequestCookies();
- for (int i = 0; i < cookies.length; i++) {
- if (requestCookies != null && requestCookies.contains(cookies[i]) && cookies[i].getExpiryDate() == null) {
- // It means it is a request cookie and nothing changed, we need to skip it
- continue;
- }
- // Process the cookie;
- String domain = cookies[i].getDomain();
- String path = cookies[i].getPath();
- String name = cookies[i].getName();
- String value = cookies[i].getValue();
-
- String clientName = ResponseUtil.getCookieName(context, path, name, domain);
-
- if (Log.isInfo()) {
- String str = "-- Cookie in response: domain = '" + domain + "', path = '" + path +
- "', client name = '" + clientName + "', endpoint name = '" + name + "', value = '" + value;
- Log.getLogger(HTTPProxyService.LOG_CATEGORY).debug(str);
- }
-
- javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie(clientName, value);
-
- Date expiry = cookies[i].getExpiryDate();
- if (expiry != null) {
- int maxAge = (int) ((expiry.getTime() - System.currentTimeMillis()) / 1000);
- cookie.setMaxAge(maxAge);
- }
- cookie.setSecure(cookies[i].getSecure());
- cookie.setPath("/");
-
- clientResponse.addCookie(cookie);
- }
- }
- }
-
- protected void copyHeadersFromEndpoint(ProxyContext context) {
- HttpServletResponse clientResponse = FlexContext.getHttpResponse();
-
- if (clientResponse != null) {
- Header[] headers = context.getHttpMethod().getResponseHeaders();
- for (int i = 0; i < headers.length; i++) {
- Header header = headers[i];
- String name = header.getName();
- String value = header.getValue();
- if (ResponseUtil.ignoreHeader(name, context)) {
- continue;
- }
-
- if ((name != null) && (value != null)) {
- clientResponse.addHeader(name, value);
- if (Log.isInfo()) {
- Log.getLogger(HTTPProxyService.LOG_CATEGORY).debug("-- Header in response: " + name + " : " + value);
- }
- }
- }
- // set Pragma needed for ATG on HTTPS
- clientResponse.setHeader("Pragma", "public");
- }
- }
-
- protected void recordResponseHeaders(ProxyContext context) {
- String method = context.getMethod();
- if (context.getRecordHeaders() || ProxyConstants.METHOD_HEAD.equals(method)) {
- Header[] headers = context.getHttpMethod().getResponseHeaders();
- HashMap responseHeaders = new HashMap();
- for (int i = 0; i < headers.length; i++) {
- Header header = headers[i];
- String headerName = header.getName();
- String headerValue = header.getValue();
- Object existingHeaderValue = responseHeaders.get(headerName);
- // Value(s) already exist for the header.
- if (existingHeaderValue != null) {
- ArrayList headerValues;
- // Only a single value exists.
- if (existingHeaderValue instanceof String) {
- headerValues = new ArrayList();
- headerValues.add(existingHeaderValue);
- headerValues.add(headerValue);
- responseHeaders.put(headerName, headerValues);
- }
- // Multiple values exist.
- else if (existingHeaderValue instanceof ArrayList) {
- headerValues = (ArrayList) existingHeaderValue;
- headerValues.add(headerValue);
- }
- } else {
- responseHeaders.put(headerName, headerValue);
- }
- }
- context.setResponseHeaders(responseHeaders);
- }
- }
-
-
- protected void setupResponse(ProxyContext context) {
- String method = context.getMethod();
- HttpMethodBase httpMethod = context.getHttpMethod();
- if (MessageIOConstants.METHOD_POST.equals(method)) {
- writeResponse(context);
- } else if (ProxyConstants.METHOD_GET.equals(method)) {
- writeResponse(context);
- } else if (ProxyConstants.METHOD_OPTIONS.equals(method)) {
- OptionsMethod optionsMethod = (OptionsMethod) httpMethod;
- Enumeration options = optionsMethod.getAllowedMethods();
- if (options != null) {
- List ops = new ArrayList();
- while (options.hasMoreElements()) {
- Object option = options.nextElement();
- ops.add(option);
- }
- Object[] o = ops.toArray();
- context.setResponse(o);
- }
- } else if (ProxyConstants.METHOD_TRACE.equals(method)) {
- writeResponse(context);
- } else if (ProxyConstants.METHOD_DELETE.equals(method)) {
- writeResponse(context);
- } else if (ProxyConstants.METHOD_HEAD.equals(method)) {
- context.setResponse(context.getResponseHeaders());
- } else if (ProxyConstants.METHOD_PUT.equals(method)) {
- writeResponse(context);
- }
- }
-
- protected void writeResponse(ProxyContext context) {
- try {
- InputStream in = context.getHttpMethod().getResponseBodyAsStream();
-
- if (in == null) {
- throw new ProxyException(NULL_RESPONSE_STREAM);
- }
-
- int length = (int) context.getHttpMethod().getResponseContentLength();
-
- // Stream response directly to client
- if (context.streamResponseToClient()) {
- HttpServletResponse clientResponse = FlexContext.getHttpResponse();
-
- if (clientResponse != null) {
- OutputStream out = clientResponse.getOutputStream();
- if (length != -1) {
- clientResponse.setContentLength(length);
- }
-
- writeStreamedResponse(in, out, context);
- } else {
- throw new ProxyException(CANNOT_STREAM_NOT_HTTP);
- }
- } else {
- writeResponseAsString(in, length, context);
- }
- } catch (IOException ioe) {
- ProxyException pe = new ProxyException();
- pe.setMessage(ERROR_WRITING_RESPONSE, new Object[]{ioe.getMessage()});
- throw pe;
- }
- }
-
- protected void writeStreamedResponse(InputStream inStream, OutputStream out, ProxyContext context) throws IOException {
- byte[] tmp = new byte[RESPONSE_CHUNK];
- int i = 0;
-
- while ((i = inStream.read(tmp)) >= 0) {
- out.write(tmp, 0, i);
- }
- }
-
- protected void writeResponseAsString(InputStream inStream, int length, ProxyContext context)
- throws IOException {
- char[] tmp = new char[RESPONSE_CHUNK];
- //int i = 0;
- StringBuffer sb = new StringBuffer(length < 0 ? 16 : length);
- BufferedInputStream bufferedIn = new BufferedInputStream(inStream);
- String charset = context.getHttpMethod().getResponseCharSet();
-
- bufferedIn.mark(4);
-
- // Check for BOM as InputStreamReader does not strip BOM in all cases.
- boolean hasBOM = false;
- int read = bufferedIn.read();
- if (read > 0) {
- // UTF-8 BOM is EF BB BF
- if (0xEF == (read & 0xFF)) {
- read = bufferedIn.read();
- if (0xBB == (read & 0xFF)) {
- read = bufferedIn.read();
- if (0xBF == (read & 0xFF)) {
- hasBOM = true;
- charset = "UTF-8";
- }
- }
- }
- // UTF-16 Little Endian BOM is FF FE
- // UTF-32 Little Endian BOM is FF FE 00 00
- else if (0xFF == (read & 0xFF)) {
- read = bufferedIn.read();
- if (0xFE == (read & 0xFF)) {
- hasBOM = true;
- charset = "UTF16-LE";
-
- // Check two more bytes incase we have UTF-32
- bufferedIn.mark(2);
- read = bufferedIn.read();
- if (0x00 == (read & 0xFF)) {
- read = bufferedIn.read();
- if (0x00 == (read & 0xFF)) {
- charset = "UTF32-LE";
- } else {
- bufferedIn.reset();
- }
- } else {
- bufferedIn.reset();
- }
- }
- }
- // UTF-16 Big Endian BOM is FE FF
- else if (0xFE == (read & 0xFF)) {
- read = bufferedIn.read();
- if (0xFF == (read & 0xFF)) {
- hasBOM = true;
- charset = "UTF16-BE";
- }
- }
- // UTF-32 Big Endian BOM is 00 00 FE FF
- else if (0x00 == (read & 0xFF)) {
- read = bufferedIn.read();
- if (0x00 == (read & 0xFF)) {
- read = bufferedIn.read();
- if (0xFE == (read & 0xFF)) {
- read = bufferedIn.read();
- if (0xFF == (read & 0xFF)) {
- hasBOM = true;
- charset = "UTF32-BE";
- }
- }
- }
- }
-
- // If we didn't find a BOM, all bytes should contribute to the content
- if (!hasBOM)
- bufferedIn.reset();
- }
-
- BufferedReader reader = new BufferedReader(new InputStreamReader(bufferedIn, charset));
- int charactersRead = -1;
- while ((charactersRead = reader.read(tmp, 0, tmp.length)) >= 0) {
- sb.append(new String(tmp, 0, charactersRead));
- }
-
- context.setResponse(sb.toString());
- }
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/proxy/ResponseUtil.java b/proxy/src/main/java/flex/messaging/services/http/proxy/ResponseUtil.java
deleted file mode 100755
index d4f8ae6..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/proxy/ResponseUtil.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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 flex.messaging.services.http.proxy;
-
-/**
- * Response methods shared by J2EE and .NET.
- */
-public class ResponseUtil {
- public static String getCookieName(ProxyContext context, String path, String name, String domain) {
- String clientName;
- if (context.isLocalDomain() && (path == null || path.equals("/"))) {
- clientName = name;
- } else {
- //Cookie name format: COOKIE_PREFIX[COOKIE_SEPARATOR]domain[COOKIE_SEPARATOR]path[COOKIE_SEPARATOR]name
- StringBuffer nameBuf = new StringBuffer(40); //estimated length to usually avoid the buffer needing to grow
- nameBuf.append(ProxyConstants.COOKIE_PREFIX);
- nameBuf.append(ProxyConstants.COOKIE_SEPARATOR);
- nameBuf.append(domain.hashCode());
- nameBuf.append(ProxyConstants.COOKIE_SEPARATOR);
- nameBuf.append(path.hashCode());
- nameBuf.append(ProxyConstants.COOKIE_SEPARATOR);
- nameBuf.append(name);
- clientName = nameBuf.toString();
- }
- return clientName;
- }
-
-
- public static boolean ignoreHeader(String name, ProxyContext context) {
- boolean ignoreHeader = false;
- if ("Content-Length".equalsIgnoreCase(name) ||
- "Set-Cookie".equalsIgnoreCase(name) ||
- "Set-Cookie2".equalsIgnoreCase(name) ||
- "Cookie".equalsIgnoreCase(name) ||
- "Transfer-Encoding".equalsIgnoreCase(name) ||
- // cmurphy - copying "Connection" was causing problems with WebLogic 8.1
- // brian- Connection header specifies what type of connection is wanted, ie keep-alive.
- // From what I've read, it is perfectly acceptible for a proxy to ignore this header
- "Connection".equalsIgnoreCase(name) ||
- // ignore caching headers if we want to stop caching on this request
- (context.disableCaching() && ("Cache-Control".equalsIgnoreCase(name) ||
- "Expires".equalsIgnoreCase(name) || "Pragma".equalsIgnoreCase(name)))
- ) {
- ignoreHeader = true;
- }
- return ignoreHeader;
- }
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/proxy/SecurityFilter.java b/proxy/src/main/java/flex/messaging/services/http/proxy/SecurityFilter.java
deleted file mode 100755
index ff48bda..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/proxy/SecurityFilter.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * 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 flex.messaging.services.http.proxy;
-
-import flex.messaging.FlexContext;
-import flex.messaging.services.HTTPProxyService;
-import flex.messaging.log.Log;
-import flex.messaging.util.Base64;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.StatusLine;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.Enumeration;
-
-/**
- * Handles whitelist/access and authentication/authorization system for requests. Checks URL to make sure we
- * accept it. Sets credentials if needed on the request. After the request is made, changes response for
- * security info if needed
- */
-public class SecurityFilter extends ProxyFilter {
- // NOTE: any changes to this class should also be made to the corresponding version in the .NET.
- // The corresponding class is in src/dotNet/libs/FlexASPlib/Aspx/Proxy
-
- private static final int EMPTY_ERROR = 10708;
- private static final int ONLY_HTTP_HTTPS = 10712;
- private static final int NO_HTTPS_VIA_HTTP = 10713;
- private static final int NO_BASIC_NOT_HTTP = 10714;
- private static final int NO_BASIC_FOR_SOAP = 10715;
- private static final int DOMAIN_ERROR = 10716;
- private static final int LOGIN_REQUIRED = 10717;
- private static final int UNAUTHORIZED_ERROR = 10718;
-
- public void invoke(ProxyContext context) {
- checkURL(context);
- setCredentials(context);
-
- if (next != null) {
- next.invoke(context);
- }
-
- sendSecurityInfo(context);
- }
-
- private void checkURL(ProxyContext context) {
- Target target = context.getTarget();
-
- // We only allow http type urls
- if (!context.getTarget().getUrl().getProtocol().equalsIgnoreCase("http") && !target.isHTTPS()) {
- Log.getLogger(HTTPProxyService.LOG_CATEGORY).warn(ProxyConstants.PROXY_SECURITY + ProxyConstants.ONLY_HTTP_HTTPS);
- throw new ProxyException(ONLY_HTTP_HTTPS);
- }
-
- if (target.isHTTPS() && !context.isClientHttps()) {
- // Respond with error
- Log.getLogger(HTTPProxyService.LOG_CATEGORY).warn(ProxyConstants.PROXY_SECURITY + ProxyConstants.NO_HTTPS_VIA_HTTP);
-
- throw new ProxyException(NO_HTTPS_VIA_HTTP);
- }
- }
-
- private void setCredentials(ProxyContext context) {
- String user = null, password = null;
-
- // Check for credentials in runAs
- user = context.getTarget().getRemoteUsername();
- password = context.getTarget().getRemotePassword();
-
- String fromRequest = null;
- HttpServletRequest clientRequest = FlexContext.getHttpRequest();
- if (clientRequest != null) {
- // Check for credentials in parameter/header
- fromRequest = clientRequest.getHeader(ProxyConstants.HEADER_CREDENTIALS);
- }
-
- // We sometimes send the credentials as a URL parameter to work around a player/Opera issue
- if (fromRequest == null) {
- fromRequest = context.getCredentialsHeader();
- }
-
- // Add authentication header for credentials
- if (fromRequest != null) {
- Base64.Decoder decoder = new Base64.Decoder();
- decoder.decode(fromRequest);
- String decoded = new String(decoder.drain());
- int colonIdx = decoded.indexOf(":");
- if (colonIdx != -1) {
- user = decoded.substring(0, colonIdx);
- }
- password = decoded.substring(colonIdx + 1);
- }
-
- // Check for existing authentication header
- if (clientRequest != null) {
- Enumeration headers = clientRequest.getHeaders("Authorization");
- if (headers != null) {
- while (headers.hasMoreElements()) {
- String value = (String) headers.nextElement();
-
- if (value.startsWith("Basic")) {
- if (!context.isLocalDomainAndPort()) {
- if (Log.isInfo()) {
- Log.getLogger(HTTPProxyService.LOG_CATEGORY).debug("Not sending on Authentication header. Proxy domain:port of " +
- clientRequest.getServerName() + ":" + clientRequest.getServerPort() + " does not match target domain:port of " +
- context.getTarget().getUrl().getHost() + ":" + context.getTarget().getUrl().getPort());
- }
- } else {
- // Super gross hack to work around what appears to be an commons-httpclient bug
- // where headers are not resent after a 302.
- Base64.Decoder decoder = new Base64.Decoder();
- String encoded = value.substring(6);
- decoder.decode(encoded);
- String decoded = new String(decoder.drain());
- int colonIdx = decoded.indexOf(":");
- user = decoded.substring(0, colonIdx);
- password = decoded.substring(colonIdx + 1);
- }
- }
- }
- }
- }
-
- // Set up request for authentication
- if (user != null) {
- UsernamePasswordCredentials cred = new UsernamePasswordCredentials(user, password);
-
- context.getHttpClient().getState().setCredentials(ProxyUtil.getDefaultAuthScope(), cred);
- context.setAuthorization(true);
-
- if (Log.isInfo()) {
- Log.getLogger(HTTPProxyService.LOG_CATEGORY).info("-- Authentication header being sent for " + user);
- }
- }
- }
-
- private void sendSecurityInfo(ProxyContext context) {
- Target target = context.getTarget();
- String targetHost = target.getUrl().getHost();
-
- int statusCode = 200;
-
- boolean customAuth = target.useCustomAuthentication();
-
- StatusLine statusLine = context.getHttpMethod().getStatusLine();
- if (statusLine != null) {
- statusCode = statusLine.getStatusCode();
- }
-
- context.setStatusCode(statusCode);
-
- if (statusCode == 401 || statusCode == 403) {
- if (!customAuth) {
- if (!context.isHttpRequest()) {
- throw new ProxyException(NO_BASIC_NOT_HTTP);
- } else if (context.isSoapRequest()) {
- // Note: if we remove this error, must do the proxyDomain/targetHost check as done above
- throw new ProxyException(NO_BASIC_FOR_SOAP);
- } else {
- // Don't allow a 401 (and 403, although this should never happen) to be sent to the client
- // if the service is not using custom authentication and the domains do not match
-
- if (!context.isLocalDomainAndPort()) {
- HttpServletRequest clientRequest = FlexContext.getHttpRequest();
-
- String errorMessage = ProxyConstants.DOMAIN_ERROR + " . The proxy domain:port is " +
- clientRequest.getServerName() + ":" + clientRequest.getServerPort() +
- " and the target domain:port is " + targetHost + ":" + target.getUrl().getPort();
-
- Log.getLogger(HTTPProxyService.LOG_CATEGORY).error(errorMessage);
-
- throw new ProxyException(DOMAIN_ERROR);
- } else {
- //For BASIC Auth, send back the status code
- HttpServletResponse clientResponse = FlexContext.getHttpResponse();
- clientResponse.setStatus(statusCode);
- }
- }
- } else {
- String message = null;
- if (statusLine != null)
- message = statusLine.toString();
-
- if (statusCode == 401) {
- ProxyException se = new ProxyException();
- se.setCode("Client.Authentication");
- if (message == null) {
- se.setMessage(LOGIN_REQUIRED);
- } else {
- se.setMessage(EMPTY_ERROR, new Object[]{message});
- }
-
-
- Header header = context.getHttpMethod().getResponseHeader(ProxyConstants.HEADER_AUTHENTICATE);
- if (header != null)
- se.setDetails(header.getValue());
- throw se;
- } else {
- ProxyException se = new ProxyException();
- se.setCode("Client.Authentication");
- if (message == null) {
- se.setMessage(UNAUTHORIZED_ERROR);
- } else {
- se.setMessage(EMPTY_ERROR, new Object[]{message});
- }
- throw se;
- }
- }
- }
- }
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/proxy/SharedProxyContext.java b/proxy/src/main/java/flex/messaging/services/http/proxy/SharedProxyContext.java
deleted file mode 100755
index 55fe615..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/proxy/SharedProxyContext.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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 flex.messaging.services.http.proxy;
-
-/**
- * Store all the information needed for a proxy request that's used in flex.server.common.proxy.
- */
-public class SharedProxyContext {
- // POST, GET, HEAD etc
- private String method;
-
- // often-used variables describing the type of request
- private boolean isSoapRequest;
- private boolean isHttpRequest;
- private boolean isClientHttps;
-
- // whether request has custom auth or Authorization header
- private boolean hasAuthorization;
- // whether endpoint is the same domain as proxy
- private boolean localDomain;
- // whether the endpoint has the same port as the proxy (always false if localDomain is false)
- private boolean localPort;
- // whether request needs browser caching disabled
- private boolean disableCaching;
- // whether target URL came from the client
- private boolean clientTarget;
-
- public String getMethod() {
- return method;
- }
-
- public void setMethod(String method) {
- this.method = method;
- }
-
- public boolean isSoapRequest() {
- return isSoapRequest;
- }
-
- public void setSoapRequest(boolean s) {
- isSoapRequest = s;
- }
-
- public boolean isHttpRequest() {
- return isHttpRequest;
- }
-
- public void setHttpRequest(boolean h) {
- isHttpRequest = h;
- }
-
- public boolean isClientHttps() {
- return isClientHttps;
- }
-
- public void setClientHttps(boolean h) {
- isClientHttps = h;
- }
-
- public boolean hasAuthorization() {
- return hasAuthorization;
- }
-
- public void setAuthorization(boolean hasAuthorization) {
- this.hasAuthorization = hasAuthorization;
- }
-
- public boolean isLocalDomain() {
- return localDomain;
- }
-
- public void setLocalDomain(boolean localDomain) {
- this.localDomain = localDomain;
- }
-
- public boolean isLocalPort() {
- return localPort;
- }
-
- public void setLocalPort(boolean localPort) {
- this.localPort = localPort;
- }
-
- public boolean isLocalDomainAndPort() {
- return localDomain && localPort;
- }
-
- public boolean disableCaching() {
- return disableCaching;
- }
-
- public void setDisableCaching(boolean disableCaching) {
- this.disableCaching = disableCaching;
- }
-
- public boolean isClientTarget() {
- return clientTarget;
- }
-
- public void setClientTarget(boolean clientTarget) {
- this.clientTarget = clientTarget;
- }
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/proxy/Target.java b/proxy/src/main/java/flex/messaging/services/http/proxy/Target.java
deleted file mode 100755
index d25ca1b..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/proxy/Target.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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 flex.messaging.services.http.proxy;
-
-import org.apache.commons.httpclient.HostConfiguration;
-
-import java.net.URL;
-
-/**
- * Encapsulates information about a proxy target.
- */
-public class Target {
- // FIXME: this class turned out not to be as useful as originally thought. Should move this information
- // directly into ProxyContext
-
- private URL url;
- private boolean useCustomAuthentication = true;
- private boolean isHTTPS;
- private String encodedPath;
- private String remoteUsername;
- private String remotePassword;
- private HostConfiguration hostConfig;
-
- public URL getUrl() {
- return url;
- }
-
- public void setUrl(URL url) {
- this.url = url;
- }
-
- public boolean isHTTPS() {
- return isHTTPS;
- }
-
- public void setHTTPS(boolean HTTPS) {
- isHTTPS = HTTPS;
- }
-
- public String getEncodedPath() {
- return encodedPath;
- }
-
- public void setEncodedPath(String encodedPath) {
- this.encodedPath = encodedPath;
- }
-
- public HostConfiguration getHostConfig() {
- return hostConfig;
- }
-
- public void setHostConfig(HostConfiguration hostConfig) {
- this.hostConfig = hostConfig;
- }
-
- public String getRemoteUsername() {
- return remoteUsername;
- }
-
- public void setRemoteUsername(String name) {
- remoteUsername = name;
- }
-
- public String getRemotePassword() {
- return remotePassword;
- }
-
- public void setRemotePassword(String pass) {
- remotePassword = pass;
- }
-
- public boolean useCustomAuthentication() {
- return useCustomAuthentication;
- }
-
- public void setUseCustomAuthentication(boolean b) {
- useCustomAuthentication = b;
- }
-}
diff --git a/proxy/src/main/java/flex/messaging/services/http/proxy/package-info.java b/proxy/src/main/java/flex/messaging/services/http/proxy/package-info.java
deleted file mode 100755
index c74d572..0000000
--- a/proxy/src/main/java/flex/messaging/services/http/proxy/package-info.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * 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 flex.messaging.services.http.proxy;
\ No newline at end of file