Skip to main content
summaryrefslogtreecommitdiffstats
blob: 4b627f6eb424628111bddc1b7df44660d9622a7a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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