Document and validate web-api constructs
[aaa.git] / web / api / src / main / java / org / opendaylight / aaa / web / WebContextSecurer.java
1 /*
2  * Copyright (c) 2018 Red Hat, Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.aaa.web;
9
10 /**
11  * Secures a {@link WebContext.Builder}.
12  *
13  * @author Michael Vorburger.ch
14  */
15 public interface WebContextSecurer {
16     /**
17      * Configure the WebContext to require auth for specified URLs.
18      *
19      * <p>
20      * Configure the WebContext so that it requires authentication to access the
21      * given URL Patterns. Typically, this will be done by adding a {@code javax.servlet.Filter} (or several, and
22      * whatever else they need).
23      *
24      * @param webContextBuilder builder to secure
25      * @param asyncSupported true if asynchronous communication should also be supported
26      * @param urlPatterns URL patterns that require authentication
27      */
28     void requireAuthentication(WebContext.Builder webContextBuilder, boolean asyncSupported, String... urlPatterns);
29
30     /**
31      * Configure the WebContext to require auth for specified URLs.
32      *
33      * <p>
34      * Configures the WebContext so that it requires authentication to access the
35      * given URL Patterns. Typically, this will be done by adding a {@code javax.servlet.Filter} (or several, and
36      * whatever else they need).
37      *
38      * <p>
39      * This method is equivalent to {@code requireAuthentication(webContextBuilder, false, urlPatterns}.
40      *
41      * @param webContextBuilder builder to secure
42      * @param urlPatterns URL patterns that require authentication
43      */
44     default void requireAuthentication(final WebContext.Builder webContextBuilder, final String... urlPatterns) {
45         requireAuthentication(webContextBuilder, false, urlPatterns);
46     }
47
48     /**
49      * Configure the WebContext to require auth all URLs.
50      *
51      * <p>
52      * Configures the WebContext so that all its URL patterns ({@code/**}) require authentication.
53      *
54      * @param webContextBuilder builder to secure
55      * @see #requireAuthentication(WebContext.Builder, String...)
56      */
57     default void requireAuthentication(final WebContext.Builder webContextBuilder) {
58         requireAuthentication(webContextBuilder, "/*");
59     }
60 }