1 /*
2 * MIT License
3 *
4 * Copyright (c) 2010-2024 The Waffle Project Contributors: https://github.com/Waffle/waffle/graphs/contributors
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24 package waffle.servlet.spi;
25
26 import jakarta.servlet.http.HttpServletRequest;
27 import jakarta.servlet.http.HttpServletResponse;
28
29 import java.io.IOException;
30
31 import waffle.windows.auth.IWindowsIdentity;
32
33 /**
34 * A security filter provider.
35 */
36 public interface SecurityFilterProvider {
37
38 /**
39 * Add authentication method headers.
40 *
41 * @param response
42 * Http Response.
43 */
44 void sendUnauthorized(HttpServletResponse response);
45
46 /**
47 * Returns true if despite having a principal authentication needs to happen.
48 *
49 * @param request
50 * Http Request.
51 *
52 * @return True if authentication is required.
53 */
54 boolean isPrincipalException(HttpServletRequest request);
55
56 /**
57 * Execute filter.
58 *
59 * @param request
60 * Http Servlet Request.
61 * @param response
62 * Http Servlet Response.
63 *
64 * @return A Windows identity in case authentication completed or NULL if not. Thrown exceptions should be caught
65 * and processed as 401 Access Denied.
66 *
67 * @throws IOException
68 * on doFilter.
69 */
70 IWindowsIdentity doFilter(HttpServletRequest request, HttpServletResponse response) throws IOException;
71
72 /**
73 * Tests whether a specific security package is supported.
74 *
75 * @param securityPackage
76 * Security package.
77 *
78 * @return True if the security package is supported, false otherwise.
79 */
80 boolean isSecurityPackageSupported(String securityPackage);
81
82 /**
83 * Init a parameter.
84 *
85 * @param parameterName
86 * Parameter name.
87 * @param parameterValue
88 * Parameter value.
89 */
90 void initParameter(String parameterName, String parameterValue);
91 }