Improve Batches
[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> changeUserCred(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      * 
571      * @param trans
572      * @param from
573      * @return
574      */
575     public Result<Void> resetRolesForUser(AuthzTrans trans, REQUEST from);
576     
577     /**
578      * 
579      * @param trans
580      * @param from
581      * @return
582      */
583     public Result<Void> resetUsersForRole(AuthzTrans trans, REQUEST from);
584     
585     /**
586      * 
587      * @param trans
588      * @param user
589      * @param role
590      * @return
591      */
592     public Result<Void> extendUserRole(AuthzTrans trans, String user,
593     String role);
594
595     /**
596      * 
597      * @param trans
598      * @param user
599      * @param usr
600      * @param role
601      * @return
602      * @throws DAOException 
603      */
604     public Result<Void> deleteUserRole(AuthzTrans trans, String usr, String role);
605
606
607
608 /***********************************
609  * HISTORY 
610  ***********************************/    
611     /**
612      * 
613      * @param trans
614      * @param user
615      * @param yyyymm
616      * @return
617      */
618     public Result<HISTORY> getHistoryByUser(AuthzTrans trans, String user, int[] yyyymm, int sort);
619
620     /**
621      * 
622      * @param trans
623      * @param subj
624      * @param yyyymm
625      * @param sort
626      * @return
627      */
628     public Result<HISTORY> getHistoryByRole(AuthzTrans trans, String subj, int[] yyyymm, int sort);
629
630     /**
631      * 
632      * @param trans
633      * @param subj
634      * @param yyyymm
635      * @param sort
636      * @return
637      */
638     public Result<HISTORY> getHistoryByPerm(AuthzTrans trans, String subj, int[] yyyymm, int sort);
639
640     /**
641      * 
642      * @param trans
643      * @param subj
644      * @param yyyymm
645      * @param sort
646      * @return
647      */
648     public Result<HISTORY> getHistoryByNS(AuthzTrans trans, String subj, int[] yyyymm, int sort);
649
650 /***********************************
651  * DELEGATE 
652  ***********************************/
653     /**
654      * 
655      * @param trans
656      * @param delegates
657      * @return
658      * @throws Exception
659      */
660     public Result<Void> createDelegate(AuthzTrans trans, REQUEST reqDelegate);
661     
662     /**
663      * 
664      * @param trans
665      * @param delegates
666      * @return
667      * @throws Exception
668      */
669     public Result<Void> updateDelegate(AuthzTrans trans, REQUEST reqDelegate);
670     
671     /**
672      * 
673      * @param trans
674      * @param userName
675      * @param delegate
676      * @return
677      * @throws Exception
678      */
679     public Result<Void> deleteDelegate(AuthzTrans trans, REQUEST reqDelegate);
680     
681     /**
682      * 
683      * @param trans
684      * @param userName
685      * @return
686      */
687     public Result<Void> deleteDelegate(AuthzTrans trans, String userName);
688
689     /**
690      * 
691      * @param trans
692      * @param user
693      * @return
694      * @throws Exception
695      */
696     public Result<DELGS> getDelegatesByUser(AuthzTrans trans, String user);
697     
698
699     /**
700      * 
701      * @param trans
702      * @param delegate
703      * @return
704      */
705     public Result<DELGS> getDelegatesByDelegate(AuthzTrans trans, String delegate);
706
707 /***********************************
708  * APPROVAL 
709  ***********************************/
710     /**
711      * 
712      * @param trans
713      * @param user
714      * @param approver
715      * @param status
716      * @return
717      */
718     public Result<Void> updateApproval(AuthzTrans trans, APPROVALS approvals);
719
720     /**
721      * 
722      * @param trans
723      * @param user
724      * @return
725      */
726     public Result<APPROVALS> getApprovalsByUser(AuthzTrans trans, String user);
727
728     /**
729      * 
730      * @param trans
731      * @param ticket
732      * @return
733      */
734     public Result<APPROVALS> getApprovalsByTicket(AuthzTrans trans, String ticket);
735
736     /**
737      * 
738      * @param trans
739      * @param approver
740      * @return
741      */
742     public Result<APPROVALS> getApprovalsByApprover(AuthzTrans trans, String approver);
743
744     /**
745      * 
746      * @param trans
747      * @param cname
748      * @return
749      */
750     public Result<Void> cacheClear(AuthzTrans trans, String cname);
751
752     /**
753      * 
754      * @param trans
755      * @param cname
756      * @param segment
757      * @return
758      */
759     public Result<Void> cacheClear(AuthzTrans trans, String cname, int[] segment);
760
761     /**
762      * 
763      * @param trans
764      */
765     public void dbReset(AuthzTrans trans);
766
767
768
769
770 }