Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 51246f5b579d021cf1c3bcaf371c9451a83d4291 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*******************************************************************************
 * Copyright (c) Jan. 27, 2019 Liferay, Inc.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *    Liferay, Inc. - initial API and implementation and/or initial
 *                    documentation
 ******************************************************************************/

package org.eclipse.equinox.http.servlet.internal.context;

import java.io.IOException;
import java.net.URL;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.equinox.http.servlet.internal.DefaultServletContextHelper;
import org.osgi.framework.Bundle;
import org.osgi.service.http.HttpContext;

public class WrappedHttpContext extends DefaultServletContextHelper {

	private final HttpContext httpContext;
	private final Bundle bundle;

	public WrappedHttpContext(HttpContext httpContext, Bundle bundle) {
		super(bundle);
		this.httpContext = httpContext;
		this.bundle = bundle;
	}

	@Override
	public boolean handleSecurity(
		HttpServletRequest request, HttpServletResponse response)
		throws IOException {
		return httpContext.handleSecurity(request, response);
	}

	@Override
	public URL getResource(String name) {
		return httpContext.getResource(name);
	}

	@Override
	public String getMimeType(String name) {
		return httpContext.getMimeType(name);
	}

	@Override
	public Set<String> getResourcePaths(String path) {
		if ((path == null) || (bundle == null)) {
			return null;
		}

		final Enumeration<URL> enumeration = bundle.findEntries(
			path, null, false);

		if (enumeration == null) {
			return null;
		}

		final Set<String> result = new HashSet<String>();

		while (enumeration.hasMoreElements()) {
			result.add(enumeration.nextElement().getPath());
		}

		return result;
	}
}

Back to the top