Sonar Fixes, Formatting
[aaf/authz.git] / cadi / core / src / main / java / org / onap / aaf / cadi / Lur.java
1 /**
2  * ============LICENSE_START====================================================
3  * org.onap.aaf
4  * ===========================================================================
5  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6  * ===========================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END====================================================
19  *
20  */
21
22 package org.onap.aaf.cadi;
23
24 import java.security.Principal;
25 import java.util.List;
26
27
28
29 /**
30  * LUR: Local User Registry
31  *
32  * Concept by Robert Garskof, Implementation by Jonathan Gathman
33  *
34  * Where we can keep local copies of users and roles for faster Authorization when asked.
35  *
36  * Note: Author cannot resist the mental image of using a Fishing Lure to this LUR pattern
37  *
38  * @author Jonathan
39  *
40  */
41 public interface Lur {
42     /**
43      * Allow the Lur, which has correct Permission access, to create and hand back.
44      */
45     public Permission createPerm(String p);
46
47     /**
48      * Fish for Principals in a Pond
49      *
50      *   or more boringly, is the User identified within a named collection representing permission.
51      *
52      * @param principalName
53      * @return
54      */
55     public boolean fish(Principal bait, Permission ... pond);
56
57     /**
58      * Fish all the Principals out a Pond
59      *
60      *   For additional humor, pronounce the following with a Southern Drawl, "FishOil"
61      *
62      *   or more boringly, load the List with Permissions found for Principal
63      *
64      * @param principalName
65      * @return
66      */
67     public void fishAll(Principal bait, List<Permission> permissions);
68
69     /**
70      * Allow implementations to disconnect, or cleanup resources if unneeded
71      */
72     public void destroy();
73
74     /**
75      * Does this LUR handle this pond exclusively?  Important for EpiLUR to determine whether
76      * to try another (more expensive) LUR
77      * @param pond
78      * @return
79      */
80     public boolean handlesExclusively(Permission ... pond);
81
82     /**
83      *  Does the LUR support a particular kind of Principal
84      *  This can be used to check name's domain, like above, or Principal type
85      */
86     public boolean handles(Principal principal);
87
88     /**
89      * Clear: Clear any Caching, if exists
90      */
91     public void clear(Principal p, StringBuilder report);
92 }