Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Lindberg2009-05-18 16:46:02 -0400
committerHenrik Lindberg2009-05-18 16:46:02 -0400
commitc06840203020ba351efa7fdd3187f3c4188992e0 (patch)
treeedd03ff318f81ef0975e540b1560b16f3ca9bc40 /bundles/org.eclipse.equinox.p2.testserver
parentd2272862659ba951038b5b1f87fab33be9fb8442 (diff)
downloadrt.equinox.p2-c06840203020ba351efa7fdd3187f3c4188992e0.tar.gz
rt.equinox.p2-c06840203020ba351efa7fdd3187f3c4188992e0.tar.xz
rt.equinox.p2-c06840203020ba351efa7fdd3187f3c4188992e0.zip
New testserver version with /proxy3/aprivate and /proxy4/aprivate mounted and where all URLs containing "features/" or "plugins/" requires authentication.
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.testserver')
-rw-r--r--bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/Activator.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/SecuredArtifactsContext.java41
2 files changed, 46 insertions, 3 deletions
diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/Activator.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/Activator.java
index 277f0afb8..3a9860e89 100644
--- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/Activator.java
+++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/Activator.java
@@ -34,6 +34,7 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
private static BundleContext context;
private ServiceTracker httpTracker;
private SecureContext secureHttpContext;
+ private SecuredArtifactsContext artifactSecuredHttpContext;
private static Activator instance;
private HttpService httpService;
private AlwaysFailContext alwaysFail;
@@ -41,6 +42,7 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
private static final String SITE = "http://download.eclipse.org/eclipse/updates/3.4"; //$NON-NLS-1$
private static final String SITE2 = "http://www.eclipse.org/equinox/p2/testing/updateSite"; //$NON-NLS-1$
+ private static final String SITE3 = "http://download.eclipse.org/eclipse/updates/3.5-I-builds/"; //$NON-NLS-1$
public void start(BundleContext aContext) throws Exception {
context = aContext;
@@ -58,6 +60,7 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
public Object addingService(ServiceReference reference) {
httpService = (HttpService) context.getService(reference);
secureHttpContext = new SecureContext(httpService.createDefaultHttpContext());
+ artifactSecuredHttpContext = new SecuredArtifactsContext(httpService.createDefaultHttpContext());
alwaysFail = new AlwaysFailContext(httpService.createDefaultHttpContext());
flipFlop = new FlipFlopFailContext(httpService.createDefaultHttpContext());
@@ -79,9 +82,8 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
addProxyServices(httpService, SITE, "/proxy/"); //$NON-NLS-1$
addProxyServices(httpService, SITE2, "/proxy2/"); //$NON-NLS-1$
- httpService.registerServlet("/proxy3/aprivate/plugins", new BasicResourceDelivery("/proxy3/aprivate/plugins", URI.create(SITE2 + "/plugins")), null, secureHttpContext); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- httpService.registerServlet("/proxy3/aprivate/features", new BasicResourceDelivery("/proxy3/aprivate/features", URI.create(SITE2 + "/features")), null, secureHttpContext); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- httpService.registerServlet("/proxy3/aprivate", new BasicResourceDelivery("/proxy3/aprivate", URI.create(SITE2)), null, null); //$NON-NLS-1$//$NON-NLS-2$
+ httpService.registerServlet("/proxy3/aprivate", new BasicResourceDelivery("/proxy3/aprivate", URI.create(SITE2)), null, artifactSecuredHttpContext); //$NON-NLS-1$//$NON-NLS-2$
+ httpService.registerServlet("/proxy4/aprivate", new BasicResourceDelivery("/proxy4/aprivate", URI.create(SITE3)), null, artifactSecuredHttpContext); //$NON-NLS-1$//$NON-NLS-2$
} catch (NamespaceException e) {
// TODO Auto-generated catch block
diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/SecuredArtifactsContext.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/SecuredArtifactsContext.java
new file mode 100644
index 000000000..4b627f6eb
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/SecuredArtifactsContext.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2009, Cloudsmith Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cloudsmith Inc. - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.equinox.p2.testserver;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.osgi.service.http.HttpContext;
+
+/**
+ * The SecureContext can be used to add basic authentication to a path.
+ * This implementation requires the user "Aladdin" to log in with the password "open sesame".
+ */
+public class SecuredArtifactsContext extends SecureContext {
+
+ public SecuredArtifactsContext(HttpContext defaultContext) {
+ super(defaultContext);
+ }
+
+ public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) {
+ String path = request.getRequestURI();
+ if (path == null)
+ return true;
+
+ if (path.indexOf("features/") != -1 //$NON-NLS-1$
+ || path.indexOf("plugins/") != -1 //$NON-NLS-1$
+ || path.indexOf("binaries/") != -1) //$NON-NLS-1$
+ return super.handleSecurity(request, response);
+
+ return true;
+ }
+
+}

Back to the top