View Javadoc
1   /*
2    * SPDX-License-Identifier: MIT
3    * See LICENSE file for details.
4    *
5    * Copyright 2010-2026 The Waffle Project Contributors: https://github.com/Waffle/waffle/graphs/contributors
6    */
7   package waffle.servlet.spi;
8   
9   import jakarta.servlet.http.HttpServletRequest;
10  import jakarta.servlet.http.HttpServletResponse;
11  
12  import java.io.IOException;
13  
14  import waffle.windows.auth.IWindowsIdentity;
15  
16  /**
17   * A security filter provider.
18   */
19  public interface SecurityFilterProvider {
20  
21      /**
22       * Add authentication method headers.
23       *
24       * @param response
25       *            Http Response.
26       */
27      void sendUnauthorized(HttpServletResponse response);
28  
29      /**
30       * Returns true if despite having a principal authentication needs to happen.
31       *
32       * @param request
33       *            Http Request.
34       *
35       * @return True if authentication is required.
36       */
37      boolean isPrincipalException(HttpServletRequest request);
38  
39      /**
40       * Execute filter.
41       *
42       * @param request
43       *            Http Servlet Request.
44       * @param response
45       *            Http Servlet Response.
46       *
47       * @return A Windows identity in case authentication completed or NULL if not. Thrown exceptions should be caught
48       *         and processed as 401 Access Denied.
49       *
50       * @throws IOException
51       *             on doFilter.
52       */
53      IWindowsIdentity doFilter(HttpServletRequest request, HttpServletResponse response) throws IOException;
54  
55      /**
56       * Tests whether a specific security package is supported.
57       *
58       * @param securityPackage
59       *            Security package.
60       *
61       * @return True if the security package is supported, false otherwise.
62       */
63      boolean isSecurityPackageSupported(String securityPackage);
64  
65      /**
66       * Init a parameter.
67       *
68       * @param parameterName
69       *            Parameter name.
70       * @param parameterValue
71       *            Parameter value.
72       */
73      void initParameter(String parameterName, String parameterValue);
74  }