Skip to content

Package: OSGiAuthFilter

OSGiAuthFilter

nameinstructionbranchcomplexitylinemethod
OSGiAuthFilter(HttpContext)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
destroy()
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
doFilter(ServletRequest, ServletResponse, FilterChain)
M: 13 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
init(FilterConfig)
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 2009, 2020 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16:
17: package org.glassfish.grizzly.osgi.httpservice;
18:
19: import java.io.IOException;
20:
21: import org.osgi.service.http.HttpContext;
22:
23: import jakarta.servlet.Filter;
24: import jakarta.servlet.FilterChain;
25: import jakarta.servlet.FilterConfig;
26: import jakarta.servlet.ServletException;
27: import jakarta.servlet.ServletRequest;
28: import jakarta.servlet.ServletResponse;
29: import jakarta.servlet.http.HttpServletRequest;
30: import jakarta.servlet.http.HttpServletResponse;
31:
32: /**
33: * OSGi Authentication filter.
34: *
35: * @author Hubert Iwaniuk
36: */
37: public class OSGiAuthFilter implements Filter {
38: private final HttpContext httpContext;
39:
40: public OSGiAuthFilter(final HttpContext httpContext) {
41: this.httpContext = httpContext;
42: }
43:
44: /**
45: * {@inheritDoc}
46: */
47: @Override
48: public void init(final FilterConfig filterConfig) throws ServletException {
49: // nothing to do here
50: }
51:
52: /**
53: * OSGi integration. Relies on {@link HttpContext#handleSecurity(HttpServletRequest, HttpServletResponse)}.
54: * <p/>
55: * If {@link HttpContext#handleSecurity(HttpServletRequest, HttpServletResponse)} returns <code>true</code> proceed to
56: * next {@link Filter} in {@link FilterChain}, else do nothing so processing stops here.
57: * <p/>
58: * {@inheritDoc}
59: */
60: @Override
61: public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException {
62:• if (httpContext.handleSecurity((HttpServletRequest) request, (HttpServletResponse) response)) {
63: chain.doFilter(request, response);
64: }
65: }
66:
67: /**
68: * {@inheritDoc}
69: */
70: @Override
71: public void destroy() {
72: // nothing to do here
73: }
74: }