AT&T 2.0.19 Code drop, stage 3
[aaf/authz.git] / auth / auth-service / src / main / java / org / onap / aaf / auth / service / facade / AuthzFacade.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.auth.service.facade;
23
24 import java.util.Date;
25
26 import javax.servlet.http.HttpServletRequest;
27 import javax.servlet.http.HttpServletResponse;
28
29 import org.onap.aaf.auth.dao.cass.NsType;
30 import org.onap.aaf.auth.env.AuthzTrans;
31 import org.onap.aaf.auth.layer.Result;
32 import org.onap.aaf.auth.rserv.RServlet;
33
34 /**
35  * AuthzFacade
36  *   This layer is responsible for covering the Incoming Messages, be they XML, JSON or just entries on the URL,
37  *   and converting them to data that can be called on the Service Layer.
38  *   
39  *   Upon response, this layer, because it knew the incoming Data Formats (i.e. XML/JSON), the HTTP call types
40  *   are set on "ContentType" on Response.
41  *   
42  *   Finally, we wrap the call in Time Stamps with explanation of what is happing for Audit trails.
43  *   
44  * @author Jonathan
45  *
46  */
47 public interface AuthzFacade {
48         public static final int PERM_DEPEND_424 = -1000;
49         public static final int ROLE_DEPEND_424 = -1001;
50
51         /*
52          * Namespaces
53          */
54         public abstract Result<Void> requestNS(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, NsType type);
55         
56         public abstract Result<Void> getNSsByName(AuthzTrans trans, HttpServletResponse resp, String ns);
57         
58         public abstract Result<Void> getNSsByAdmin(AuthzTrans trans, HttpServletResponse resp, String user, boolean full);
59         
60         public abstract Result<Void> getNSsByResponsible(AuthzTrans trans, HttpServletResponse resp, String user, boolean full);
61         
62         public abstract Result<Void> getNSsByEither(AuthzTrans trans, HttpServletResponse resp, String user, boolean full);
63
64         public abstract Result<Void> getNSsChildren(AuthzTrans trans, HttpServletResponse resp, String pathParam);
65
66         public abstract Result<Void> addAdminToNS(AuthzTrans trans, HttpServletResponse resp, String ns, String id);
67
68         public abstract Result<Void> delAdminFromNS(AuthzTrans trans, HttpServletResponse resp, String ns, String id);
69
70         public abstract Result<Void> addResponsibilityForNS(AuthzTrans trans, HttpServletResponse resp, String ns, String id);
71
72         public abstract Result<Void> delResponsibilityForNS(AuthzTrans trans, HttpServletResponse resp, String ns, String id);
73         
74         public abstract Result<Void> updateNsDescription(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
75
76         public abstract Result<Void> deleteNS(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, String ns);
77
78         // NS Attribs
79         public abstract Result<Void> createAttribForNS(AuthzTrans trans, HttpServletResponse resp, String ns, String key, String value);
80
81         public abstract Result<Void> readNsByAttrib(AuthzTrans trans, HttpServletResponse resp, String key);
82
83         public abstract Result<Void> updAttribForNS(AuthzTrans trans, HttpServletResponse resp, String ns, String key, String value);
84
85         public abstract Result<Void> delAttribForNS(AuthzTrans trans, HttpServletResponse resp, String ns, String key);
86
87         /*
88          * Permissions
89          */
90         public abstract Result<Void> createPerm(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);    
91         
92         public abstract Result<Void> getPermsByName(AuthzTrans trans, HttpServletResponse resp, 
93                         String type, String instance, String action);
94
95         public abstract Result<Void> getPermsByUser(AuthzTrans trans, HttpServletResponse response, String user);
96
97         public abstract Result<Void> getPermsByUserScope(AuthzTrans trans, HttpServletResponse resp, String user, String[] scopes);
98         
99         public abstract Result<Void> getPermsByUserWithAAFQuery(AuthzTrans trans, HttpServletRequest request, HttpServletResponse response, String user);
100         
101         public abstract Result<Void> getPermsByType(AuthzTrans trans, HttpServletResponse resp, String type);
102
103         public abstract Result<Void> getPermsForRole(AuthzTrans trans, HttpServletResponse response, String roleName);
104
105         public abstract Result<Void> getPermsByNS(AuthzTrans trans, HttpServletResponse response, String ns);
106         
107         public abstract Result<Void> renamePerm(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp,
108                         String type, String instance, String action);
109         
110         public abstract Result<Void> updatePermDescription(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
111         
112         public abstract Result<Void> resetPermRoles(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
113
114         public abstract Result<Void> deletePerm(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
115
116         public abstract Result<Void> deletePerm(AuthzTrans trans,       HttpServletResponse resp, 
117                         String perm, String type, String action);
118
119         /*
120          * Roles
121          */
122         public abstract Result<Void> createRole(AuthzTrans trans, HttpServletRequest req, HttpServletResponse response);
123         
124         public abstract Result<Void> getRolesByName(AuthzTrans trans,HttpServletResponse resp, String name);
125
126         public abstract Result<Void> getRolesByNS(AuthzTrans trans, HttpServletResponse resp, String ns);
127
128         public abstract Result<Void> getRolesByNameOnly(AuthzTrans trans, HttpServletResponse resp, String nameOnly);
129
130         public abstract Result<Void> getRolesByUser(AuthzTrans trans, HttpServletResponse resp, String user);
131
132         public abstract Result<Void> getRolesByPerm(AuthzTrans trans, HttpServletResponse resp, String type, String instance, String action);
133
134         public abstract Result<Void> updateRoleDescription(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
135         
136         public abstract Result<Void> addPermToRole(AuthzTrans trans,HttpServletRequest req, HttpServletResponse resp);
137         
138         public abstract Result<Void> delPermFromRole(AuthzTrans trans,HttpServletRequest req, HttpServletResponse resp);
139
140         public abstract Result<Void> delPermFromRole(AuthzTrans trans, HttpServletResponse resp, 
141                         String role, String type, String instance, String action);
142
143         public abstract Result<Void> deleteRole(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
144
145         public abstract Result<Void> deleteRole(AuthzTrans trans, HttpServletResponse resp, String role);
146
147         /*
148          * Users
149          */
150         
151         public abstract Result<Void> getUsersByRole(AuthzTrans trans, HttpServletResponse resp, String role);
152         
153         public abstract Result<Void> getUsersByPermission(AuthzTrans trans, HttpServletResponse resp, 
154                         String type, String instance, String action);
155
156
157
158         /*
159          * Delegates
160          */
161         public abstract Result<Void> createDelegate(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
162         
163         public abstract Result<Void> updateDelegate(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
164         
165         public abstract Result<Void> deleteDelegate(AuthzTrans trans,  HttpServletRequest req, HttpServletResponse resp);
166         
167         public abstract Result<Void> deleteDelegate(AuthzTrans trans,  String user);
168         
169         public abstract Result<Void> getDelegatesByUser(AuthzTrans trans, String userName, HttpServletResponse resp);
170
171         public abstract Result<Void> getDelegatesByDelegate(AuthzTrans trans, String userName, HttpServletResponse resp);
172
173         /*
174          * Credentials
175          */
176         public abstract Result<Void> createUserCred(AuthzTrans trans, HttpServletRequest req);
177
178         public abstract Result<Void> changeUserCred(AuthzTrans trans, HttpServletRequest req);
179
180         public abstract Result<Void> extendUserCred(AuthzTrans trans, HttpServletRequest req, String days);
181
182         public abstract Result<Void> getCredsByNS(AuthzTrans trans,     HttpServletResponse resp, String ns);
183
184         public abstract Result<Void> getCredsByID(AuthzTrans trans, HttpServletResponse resp, String id);
185
186         public abstract Result<Void> deleteUserCred(AuthzTrans trans, HttpServletRequest req);
187
188         public abstract Result<Void> validBasicAuth(AuthzTrans trans, HttpServletResponse resp, String basicAuth);
189
190         public abstract Result<Date> doesCredentialMatch(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
191
192         /*
193          * Miscellaneous
194          */
195         /**
196          * Place Standard Messages based on HTTP Code onto Error Data Structure, and write to OutputStream
197          * Log message
198          */
199         public abstract void error(AuthzTrans trans, HttpServletResponse response, Result<?> result);
200
201         /*
202          * UserRole
203          */
204         public abstract Result<Void> requestUserRole(AuthzTrans trans,HttpServletRequest req, HttpServletResponse resp);
205         
206         public abstract Result<Void> getUserInRole(AuthzTrans trans, HttpServletResponse resp, String user, String role);
207         
208         public abstract Result<Void> getUserRolesByRole(AuthzTrans trans, HttpServletResponse resp, String role);
209         
210         public abstract Result<Void> getUserRolesByUser(AuthzTrans trans, HttpServletResponse resp, String user);
211
212         public abstract Result<Void> deleteUserRole(AuthzTrans trans, HttpServletResponse resp, String user, String role);
213         
214         public abstract Result<Void> resetUsersForRole(AuthzTrans trans, HttpServletResponse resp, HttpServletRequest req);
215
216         public abstract Result<Void> resetRolesForUser(AuthzTrans trans, HttpServletResponse resp, HttpServletRequest req);
217         
218         public abstract Result<Void> extendUserRoleExpiration(AuthzTrans trans, HttpServletResponse resp, String user,
219         String role);
220
221         /*
222          * Approval 
223          */
224         public abstract Result<Void> updateApproval(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
225         
226         public abstract Result<Void> getApprovalsByUser(AuthzTrans trans, HttpServletResponse resp, String user);
227         
228         public abstract Result<Void> getApprovalsByTicket(AuthzTrans trans, HttpServletResponse resp, String ticket);
229         
230         public abstract Result<Void> getApprovalsByApprover(AuthzTrans trans, HttpServletResponse resp, String approver);
231
232
233         /*
234          * History
235          */
236         public abstract Result<Void> getHistoryByUser(AuthzTrans trans, HttpServletResponse resp, String user, int[] yyyymm, final int sort);
237         
238         public abstract Result<Void> getHistoryByRole(AuthzTrans trans, HttpServletResponse resp, String subject, int[] yyyymm, final int sort);
239
240         public abstract Result<Void> getHistoryByPerm(AuthzTrans trans, HttpServletResponse resp, String subject, int[] yyyymm, final int sort);
241
242         public abstract Result<Void> getHistoryByNS(AuthzTrans trans,   HttpServletResponse resp, String subject, int[] yyyymm, final int sort);
243
244         /*
245          * Cache 
246          */
247         public abstract Result<Void> cacheClear(AuthzTrans trans, String pathParam);
248
249         public abstract Result<Void> cacheClear(AuthzTrans trans, String string,String segments);
250         
251         public abstract void dbReset(AuthzTrans trans);
252
253
254
255         /*
256          * API
257          */
258         public Result<Void> getAPI(AuthzTrans trans, HttpServletResponse resp, RServlet<AuthzTrans> rservlet);
259
260         public abstract Result<Void> getAPIExample(AuthzTrans trans, HttpServletResponse resp, String typeCode, boolean optional);
261
262         public abstract Result<Void> getCertInfoByID(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, String id);
263
264
265
266
267
268
269 }