AT&T 2.0.19 Code drop, stage 3
[aaf/authz.git] / auth / auth-service / src / main / java / org / onap / aaf / auth / service / mapper / Mapper.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.mapper;
23
24 import java.util.Collection;
25 import java.util.List;
26
27 import org.onap.aaf.auth.dao.Bytification;
28 import org.onap.aaf.auth.dao.cass.ApprovalDAO;
29 import org.onap.aaf.auth.dao.cass.CertDAO;
30 import org.onap.aaf.auth.dao.cass.CredDAO;
31 import org.onap.aaf.auth.dao.cass.DelegateDAO;
32 import org.onap.aaf.auth.dao.cass.FutureDAO;
33 import org.onap.aaf.auth.dao.cass.HistoryDAO;
34 import org.onap.aaf.auth.dao.cass.Namespace;
35 import org.onap.aaf.auth.dao.cass.PermDAO;
36 import org.onap.aaf.auth.dao.cass.RoleDAO;
37 import org.onap.aaf.auth.dao.cass.UserRoleDAO;
38 import org.onap.aaf.auth.env.AuthzTrans;
39 import org.onap.aaf.auth.layer.Result;
40 import org.onap.aaf.auth.service.MayChange;
41 import org.onap.aaf.misc.rosetta.Marshal;
42
43 public interface Mapper<
44         NSS,
45         PERMS,
46         PERMKEY,
47         ROLES,
48         USERS,
49         USERROLES,
50         DELGS,
51         CERTS,
52         KEYS,
53         REQUEST,
54         HISTORY,
55         ERROR,
56         APPROVALS>
57 {
58         enum API{NSS,NS_REQ,    
59                          PERMS,PERM_KEY,PERM_REQ,
60                          ROLES,ROLE,ROLE_REQ,ROLE_PERM_REQ,
61                          USERS,USER_ROLE_REQ,USER_ROLES,
62                          CRED_REQ,CERTS,
63                          APPROVALS,
64                          DELGS,DELG_REQ,
65                          KEYS,
66                          HISTORY,
67                          ERROR,
68                          API,
69                          VOID};
70         public Class<?> getClass(API api);
71         public<A> Marshal<A> getMarshal(API api);
72         public<A> A newInstance(API api);
73
74         public Result<PermDAO.Data> permkey(AuthzTrans trans, PERMKEY from);
75         public Result<PermDAO.Data> perm(AuthzTrans trans, REQUEST from);
76         public Result<RoleDAO.Data> role(AuthzTrans trans, REQUEST from);
77         public Result<Namespace> ns(AuthzTrans trans, REQUEST from);
78         public Result<CredDAO.Data> cred(AuthzTrans trans, REQUEST from, boolean requiresPass);
79         public Result<USERS> cred(List<CredDAO.Data> lcred, USERS to);
80         public Result<CERTS> cert(List<CertDAO.Data> lcert, CERTS to);
81         public Result<DelegateDAO.Data> delegate(AuthzTrans trans, REQUEST from);
82         public Result<DELGS> delegate(List<DelegateDAO.Data> lDelg);
83         public Result<APPROVALS> approvals(List<ApprovalDAO.Data> lAppr);
84         public Result<List<ApprovalDAO.Data>> approvals(APPROVALS apprs);
85         public Result<List<PermDAO.Data>> perms(AuthzTrans trans, PERMS perms);
86         
87         public Result<UserRoleDAO.Data> userRole(AuthzTrans trans, REQUEST from);
88         public Result<PermDAO.Data> permFromRPRequest(AuthzTrans trans, REQUEST from);
89         public REQUEST ungrantRequest(AuthzTrans trans, String role, String type, String instance, String action);
90         public Result<RoleDAO.Data> roleFromRPRequest(AuthzTrans trans, REQUEST from);
91         
92         /*
93          * Check Requests of varying sorts for Future fields set
94          */
95         public Result<FutureDAO.Data> future(AuthzTrans trans, String table, REQUEST from, Bytification content, boolean enableApproval, Memo memo, MayChange mc);
96
97         public Result<NSS> nss(AuthzTrans trans, Namespace from, NSS to);
98
99         // Note: Prevalidate if NS given is allowed to be seen before calling
100         public Result<NSS> nss(AuthzTrans trans, Collection<Namespace> from, NSS to);
101 //      public Result<NSS> ns_attrib(AuthzTrans trans, Set<String> from, NSS to);
102         public Result<PERMS> perms(AuthzTrans trans, List<PermDAO.Data> from, PERMS to, boolean filter);
103         public Result<PERMS> perms(AuthzTrans trans, List<PermDAO.Data> from, PERMS to, String[] scopes, boolean filter);
104         public Result<ROLES> roles(AuthzTrans trans, List<RoleDAO.Data> from, ROLES roles, boolean filter);
105         // Note: Prevalidate if NS given is allowed to be seen before calling
106         public Result<USERS> users(AuthzTrans trans, Collection<UserRoleDAO.Data> from, USERS to);
107         public Result<USERROLES> userRoles(AuthzTrans trans, Collection<UserRoleDAO.Data> from, USERROLES to);
108         public Result<KEYS> keys(Collection<String> from);
109
110         public Result<HISTORY> history(AuthzTrans trans, List<HistoryDAO.Data> history, final int sort);
111         
112         public ERROR errorFromMessage(StringBuilder holder, String msgID, String text, String... detail);
113         
114         /*
115          * A Memo Creator... Use to avoid creating superfluous Strings until needed.
116          */
117         public static interface Memo {
118                 public String get();
119         }
120
121
122
123 }