Sonar Fixes, Formatting
[aaf/authz.git] / auth / auth-service / src / main / java / org / onap / aaf / auth / service / AuthzService.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;
23
24 import java.util.Date;
25
26 import javax.servlet.http.HttpServletRequest;
27
28 import org.onap.aaf.auth.dao.DAOException;
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.service.mapper.Mapper;
33
34 public interface AuthzService<NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS,CERTS,KEYS,REQUEST,HISTORY,ERR,APPROVALS> {
35     public Mapper<NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS,CERTS,KEYS,REQUEST,HISTORY,ERR,APPROVALS> mapper();
36
37 /***********************************
38  * NAMESPACE
39  ***********************************/
40     /**
41      *
42      * @param trans
43      * @param user
44      * @param ns
45      * @return
46      * @throws DAOException
47      * @throws
48      */
49     public Result<Void> createNS(AuthzTrans trans, REQUEST request, NsType type);
50
51     /**
52      *
53      * @param trans
54      * @param ns
55      * @return
56      */
57     public Result<Void> addAdminNS(AuthzTrans trans, String ns, String id);
58
59     /**
60      *
61      * @param trans
62      * @param ns
63      * @return
64      */
65     public Result<Void> delAdminNS(AuthzTrans trans, String ns, String id);
66
67     /**
68      *
69      * @param trans
70      * @param ns
71      * @param id
72      * @return
73      */
74     public Result<Void> addResponsibleNS(AuthzTrans trans, String ns, String id);
75
76     /**
77      *
78      * @param trans
79      * @param ns
80      * @param id
81      * @return
82      */
83     public Result<Void> delResponsibleNS(AuthzTrans trans, String ns, String id);
84
85     /**
86      *
87      * @param trans
88      * @param ns
89      * @param key
90      * @param value
91      * @return
92      */
93     public Result<Void> createNsAttrib(AuthzTrans trans, String ns, String key, String value);
94
95     /**
96      *
97      * @param trans
98      * @param ns
99      * @param key
100      * @param value
101      * @return
102      */
103     public Result<?> updateNsAttrib(AuthzTrans trans, String ns, String key, String value);
104
105     /**
106      *
107      * @param trans
108      * @param ns
109      * @param key
110      * @return
111      */
112     public Result<Void> deleteNsAttrib(AuthzTrans trans, String ns, String key);
113
114     /**
115      *
116      * @param trans
117      * @param ns
118      * @param key
119      * @return
120      */
121     public Result<KEYS> readNsByAttrib(AuthzTrans trans, String key);
122
123
124     /**
125      *
126      * @param trans
127      * @param ns
128      * @return
129      */
130     public Result<NSS> getNSbyName(AuthzTrans trans, String ns, boolean full);
131
132     /**
133      *
134      * @param trans
135      * @param user
136      * @return
137      */
138     public Result<NSS> getNSbyAdmin(AuthzTrans trans, String user, boolean full);
139
140     /**
141      *
142      * @param trans
143      * @param user
144      * @return
145      */
146     public Result<NSS> getNSbyResponsible(AuthzTrans trans, String user, boolean full);
147
148     /**
149      *
150      * @param trans
151      * @param user
152      * @return
153      */
154     public Result<NSS> getNSbyEither(AuthzTrans trans, String user, boolean full);
155
156     /**
157      *
158      * @param trans
159      * @param parent
160      * @return
161      */
162     public Result<NSS> getNSsChildren(AuthzTrans trans, String parent);
163
164     /**
165      *
166      * @param trans
167      * @param req
168      * @return
169      */
170     public Result<Void> updateNsDescription(AuthzTrans trans, REQUEST req);
171
172     /**
173      *
174      * @param trans
175      * @param ns
176      * @param user
177      * @return
178      * @throws DAOException
179      */
180     public Result<Void> deleteNS(AuthzTrans trans, String ns);
181
182 /***********************************
183  * PERM
184  ***********************************/
185     /**
186      *
187      * @param trans
188      * @param rreq
189      * @return
190      * @throws DAOException
191      * @throws MappingException
192      */
193     public Result<Void> createPerm(AuthzTrans trans, REQUEST rreq);
194
195     /**
196      *
197      * @param trans
198      * @param childPerm
199      * @return
200      * @throws DAOException
201      */
202     public Result<PERMS> getPermsByType(AuthzTrans trans, String perm);
203
204     /**
205      *
206      * @param trans
207      * @param type
208      * @param instance
209      * @param action
210      * @return
211      */
212     public Result<PERMS> getPermsByName(AuthzTrans trans, String type,
213             String instance, String action);
214
215     /**
216      * Gets all the permissions for a user across all the roles it is assigned to
217      * @param userName
218      * @return
219      * @throws Exception
220      * @throws Exception
221      */
222     public Result<PERMS> getPermsByUser(AuthzTrans trans, String userName);
223
224     /**
225      * Gets all the permissions for a user across all the roles it is assigned to, filtered by NS (Scope)
226      *
227      * @param trans
228      * @param user
229      * @param scopes
230      * @return
231      */
232     public Result<PERMS> getPermsByUserScope(AuthzTrans trans, String user, String[] scopes);
233
234
235     /**
236      * Gets all the permissions for a user across all the roles it is assigned to
237      *
238      * Add AAF Perms representing the "MayUser" calls if
239      *     1) Allowed
240      *  2) User has equivalent permission
241      *
242      * @param userName
243      * @return
244      * @throws Exception
245      * @throws Exception
246      */
247     public Result<PERMS> getPermsByUser(AuthzTrans trans, PERMS perms, String userName);
248
249     /**
250      *
251      * Gets all the permissions for a user across all the roles it is assigned to
252      *
253      * @param roleName
254      * @return
255      * @throws Exception
256      */
257     public Result<PERMS> getPermsByRole(AuthzTrans trans, String roleName);
258
259     /**
260      *
261      * @param trans
262      * @param ns
263      * @return
264      */
265     public Result<PERMS> getPermsByNS(AuthzTrans trans, String ns);
266
267     /**
268      * rename permission
269      *
270      * @param trans
271      * @param rreq
272      * @param isRename
273      * @param origType
274      * @param origInstance
275      * @param origAction
276      * @return
277      */
278     public Result<Void> renamePerm(AuthzTrans trans, REQUEST rreq, String origType, String origInstance, String origAction);
279
280     /**
281      *
282      * @param trans
283      * @param req
284      * @return
285      */
286     public Result<Void> updatePermDescription(AuthzTrans trans, REQUEST req);
287
288     /**
289      *
290      * @param trans
291      * @param from
292      * @return
293      */
294     public Result<Void> resetPermRoles(AuthzTrans trans, REQUEST from);
295
296     /**
297      *
298      * @param trans
299      * @param from
300      * @return
301      * @throws Exception
302      */
303     public Result<Void> deletePerm(AuthzTrans trans, REQUEST from);
304
305     /**
306      *
307      * @param trans
308      * @param user
309      * @param perm
310      * @param type
311      * @param action
312      * @return
313      * @throws Exception
314      */
315     Result<Void> deletePerm(AuthzTrans trans, String perm, String type, String action);
316
317 /***********************************
318  * ROLE
319  ***********************************/
320     /**
321      *
322      * @param trans
323      * @param user
324      * @param role
325      * @param approvers
326      * @return
327      * @throws DAOException
328      * @throws Exception
329      */
330     public Result<Void> createRole(AuthzTrans trans, REQUEST req);
331
332     /**
333      *
334      * @param trans
335      * @param role
336      * @return
337      */
338     public Result<ROLES> getRolesByName(AuthzTrans trans, String role);
339
340     /**
341      *
342      * @param trans
343      * @param user
344      * @return
345      * @throws DAOException
346      */
347     public Result<ROLES> getRolesByUser(AuthzTrans trans, String user);
348
349     /**
350      *
351      * @param trans
352      * @param user
353      * @return
354      */
355     public Result<ROLES> getRolesByNS(AuthzTrans trans, String user);
356
357     /**
358      *
359      * @param trans
360      * @param name
361      * @return
362      */
363     public Result<ROLES> getRolesByNameOnly(AuthzTrans trans, String name);
364
365     /**
366      *
367      * @param trans
368      * @param type
369      * @param instance
370      * @param action
371      * @return
372      */
373     public Result<ROLES> getRolesByPerm(AuthzTrans trans, String type, String instance, String action);
374
375     /**
376      *
377      * @param trans
378      * @param req
379      * @return
380      */
381     public Result<Void> updateRoleDescription(AuthzTrans trans, REQUEST req);
382
383     /**
384      *
385      * @param trans
386      * @param rreq
387      * @return
388      * @throws DAOException
389      */
390     public Result<Void> addPermToRole(AuthzTrans trans, REQUEST rreq);
391
392
393     /**
394      *
395      * @param trans
396      * @param rreq
397      * @return
398      * @throws DAOException
399      */
400     Result<Void> delPermFromRole(AuthzTrans trans, REQUEST rreq);
401
402     /**
403      *  Itemized key delete
404      * @param trans
405      * @param role
406      * @param type
407      * @param instance
408      * @param action
409      * @return
410      */
411     public Result<Void> delPermFromRole(AuthzTrans trans, String role, String type, String instance, String action);
412
413     /**
414      *
415      * @param trans
416      * @param user
417      * @param role
418      * @return
419      * @throws DAOException
420      * @throws MappingException
421      */
422     public Result<Void> deleteRole(AuthzTrans trans, String role);
423
424     /**
425      *
426      * @param trans
427      * @param req
428      * @return
429      */
430     public Result<Void> deleteRole(AuthzTrans trans, REQUEST req);
431
432 /***********************************
433  * CRED
434  ***********************************/
435
436     /**
437      *
438      * @param trans
439      * @param from
440      * @return
441      */
442     Result<Void> createUserCred(AuthzTrans trans, REQUEST from);
443
444     /**
445      *
446      * @param trans
447      * @param from
448      * @return
449      */
450     Result<Void> resetUserCred(AuthzTrans trans, REQUEST from);
451
452     /**
453      *
454      * @param trans
455      * @param from
456      * @param days
457      * @return
458      */
459     Result<Void> extendUserCred(AuthzTrans trans, REQUEST from, String days);
460
461     /**
462      *
463      * @param trans
464      * @param ns
465      * @return
466      */
467     public Result<USERS> getCredsByNS(AuthzTrans trans, String ns);
468
469     /**
470      *
471      * @param trans
472      * @param id
473      * @return
474      */
475     public Result<USERS> getCredsByID(AuthzTrans trans, String id);
476
477     /**
478      *
479      * @param trans
480      * @param req
481      * @param id
482      * @return
483      */
484     public Result<CERTS> getCertInfoByID(AuthzTrans trans, HttpServletRequest req, String id);
485
486     /**
487      *
488      * @param trans
489      * @param credReq
490      * @return
491      */
492     public Result<Void> deleteUserCred(AuthzTrans trans, REQUEST credReq);
493
494     /**
495      *
496      * @param trans
497      * @param user
498      * @return
499      * @throws Exception
500      */
501     public Result<Date> doesCredentialMatch(AuthzTrans trans, REQUEST credReq);
502
503     /**
504      *
505      * @param trans
506      * @param basicAuth
507      * @return
508      */
509     public Result<Date> validateBasicAuth(AuthzTrans trans, String basicAuth);
510
511     /**
512      *
513      * @param trans
514      * @param role
515      * @return
516      */
517     public Result<USERS> getUsersByRole(AuthzTrans trans, String role);
518
519     /**
520      *
521      * @param trans
522      * @param role
523      * @return
524      */
525     public Result<USERS> getUserInRole(AuthzTrans trans, String user, String role);
526
527     /**
528      *
529      * @param trans
530      * @param type
531      * @param instance
532      * @param action
533      * @return
534      */
535     public Result<USERS> getUsersByPermission(AuthzTrans trans,String type, String instance, String action);
536
537
538
539
540 /***********************************
541  * USER-ROLE
542  ***********************************/
543     /**
544      *
545      * @param trans
546      * @param user
547      * @param request
548      * @return
549      * @throws Exception
550      */
551     public Result<Void> createUserRole(AuthzTrans trans, REQUEST request);
552
553     /**
554      *
555      * @param trans
556      * @param role
557      * @return
558      */
559     public Result<USERROLES> getUserRolesByRole(AuthzTrans trans, String role);
560
561     /**
562      *
563      * @param trans
564      * @param role
565      * @return
566      */
567     public Result<USERROLES> getUserRolesByUser(AuthzTrans trans, String user);
568
569     /*
570      * Note: Removed "resetRolesForUsers" because it was too dangerous, and
571      *       removed "resetUsersForRoles" because it was being misused.
572      */
573
574     /**
575      *
576      * @param trans
577      * @param user
578      * @param role
579      * @return
580      */
581     public Result<Void> extendUserRole(AuthzTrans trans, String user,
582     String role);
583
584     /**
585      *
586      * @param trans
587      * @param user
588      * @param usr
589      * @param role
590      * @return
591      * @throws DAOException
592      */
593     public Result<Void> deleteUserRole(AuthzTrans trans, String usr, String role);
594
595
596
597 /***********************************
598  * HISTORY
599  ***********************************/
600     /**
601      *
602      * @param trans
603      * @param user
604      * @param yyyymm
605      * @return
606      */
607     public Result<HISTORY> getHistoryByUser(AuthzTrans trans, String user, int[] yyyymm, int sort);
608
609     /**
610      *
611      * @param trans
612      * @param subj
613      * @param yyyymm
614      * @param sort
615      * @return
616      */
617     public Result<HISTORY> getHistoryByRole(AuthzTrans trans, String subj, int[] yyyymm, int sort);
618
619     /**
620      *
621      * @param trans
622      * @param subj
623      * @param yyyymm
624      * @param sort
625      * @return
626      */
627     public Result<HISTORY> getHistoryByPerm(AuthzTrans trans, String subj, int[] yyyymm, int sort);
628
629     /**
630      *
631      * @param trans
632      * @param subj
633      * @param yyyymm
634      * @param sort
635      * @return
636      */
637     public Result<HISTORY> getHistoryByNS(AuthzTrans trans, String subj, int[] yyyymm, int sort);
638
639     /**
640      *
641      * @param trans
642      * @param target
643      * @param yyyymm
644      * @param sort
645      * @return
646      */
647     public Result<HISTORY> getHistoryBySubject(AuthzTrans trans, String subject, String target, int[] yyyymm, int sort);
648
649 /***********************************
650  * DELEGATE
651  ***********************************/
652     /**
653      *
654      * @param trans
655      * @param delegates
656      * @return
657      * @throws Exception
658      */
659     public Result<Void> createDelegate(AuthzTrans trans, REQUEST reqDelegate);
660
661     /**
662      *
663      * @param trans
664      * @param delegates
665      * @return
666      * @throws Exception
667      */
668     public Result<Void> updateDelegate(AuthzTrans trans, REQUEST reqDelegate);
669
670     /**
671      *
672      * @param trans
673      * @param userName
674      * @param delegate
675      * @return
676      * @throws Exception
677      */
678     public Result<Void> deleteDelegate(AuthzTrans trans, REQUEST reqDelegate);
679
680     /**
681      *
682      * @param trans
683      * @param userName
684      * @return
685      */
686     public Result<Void> deleteDelegate(AuthzTrans trans, String userName);
687
688     /**
689      *
690      * @param trans
691      * @param user
692      * @return
693      * @throws Exception
694      */
695     public Result<DELGS> getDelegatesByUser(AuthzTrans trans, String user);
696
697
698     /**
699      *
700      * @param trans
701      * @param delegate
702      * @return
703      */
704     public Result<DELGS> getDelegatesByDelegate(AuthzTrans trans, String delegate);
705
706 /***********************************
707  * APPROVAL
708  ***********************************/
709     /**
710      *
711      * @param trans
712      * @param user
713      * @param approver
714      * @param status
715      * @return
716      */
717     public Result<Void> updateApproval(AuthzTrans trans, APPROVALS approvals);
718
719     /**
720      *
721      * @param trans
722      * @param user
723      * @return
724      */
725     public Result<APPROVALS> getApprovalsByUser(AuthzTrans trans, String user);
726
727     /**
728      *
729      * @param trans
730      * @param ticket
731      * @return
732      */
733     public Result<APPROVALS> getApprovalsByTicket(AuthzTrans trans, String ticket);
734
735     /**
736      *
737      * @param trans
738      * @param approver
739      * @return
740      */
741     public Result<APPROVALS> getApprovalsByApprover(AuthzTrans trans, String approver);
742
743     /**
744      *
745      * @param trans
746      * @param cname
747      * @return
748      */
749     public Result<Void> cacheClear(AuthzTrans trans, String cname);
750
751     /**
752      *
753      * @param trans
754      * @param cname
755      * @param segment
756      * @return
757      */
758     public Result<Void> cacheClear(AuthzTrans trans, String cname, int[] segment);
759
760     /**
761      *
762      * @param trans
763      */
764     public void dbReset(AuthzTrans trans);
765
766 }