summaryrefslogtreecommitdiffstats
path: root/auth/auth-service/src/main/java/org/onap/aaf/auth/service/facade/AuthzFacade.java
blob: 463de35f7ffea0305bc1a381db1b63325b579465 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
/**
 * ============LICENSE_START====================================================
 * org.onap.aaf
 * ===========================================================================
 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
 * ===========================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END====================================================
 *
 */

package org.onap.aaf.auth.service.facade;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.onap.aaf.auth.dao.cass.NsType;
import org.onap.aaf.auth.env.AuthzTrans;
import org.onap.aaf.auth.layer.Result;
import org.onap.aaf.auth.rserv.RServlet;

/**
 * AuthzFacade
 *   This layer is responsible for covering the Incoming Messages, be they XML, JSON or just entries on the URL,
 *   and converting them to data that can be called on the Service Layer.
 *   
 *   Upon response, this layer, because it knew the incoming Data Formats (i.e. XML/JSON), the HTTP call types
 *   are set on "ContentType" on Response.
 *   
 *   Finally, we wrap the call in Time Stamps with explanation of what is happing for Audit trails.
 *   
 * @author Jonathan
 *
 */
public interface AuthzFacade {
    public static final int PERM_DEPEND_424 = -1000;
    public static final int ROLE_DEPEND_424 = -1001;

    /*
     * Namespaces
     */
    public abstract Result<Void> requestNS(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, NsType type);
    
    public abstract Result<Void> getNSsByName(AuthzTrans trans, HttpServletResponse resp, String ns, boolean full);
    
    public abstract Result<Void> getNSsByAdmin(AuthzTrans trans, HttpServletResponse resp, String user, boolean full);
    
    public abstract Result<Void> getNSsByResponsible(AuthzTrans trans, HttpServletResponse resp, String user, boolean full);
    
    public abstract Result<Void> getNSsByEither(AuthzTrans trans, HttpServletResponse resp, String user, boolean full);

    public abstract Result<Void> getNSsChildren(AuthzTrans trans, HttpServletResponse resp, String pathParam);

    public abstract Result<Void> addAdminToNS(AuthzTrans trans, HttpServletResponse resp, String ns, String id);

    public abstract Result<Void> delAdminFromNS(AuthzTrans trans, HttpServletResponse resp, String ns, String id);

    public abstract Result<Void> addResponsibilityForNS(AuthzTrans trans, HttpServletResponse resp, String ns, String id);

    public abstract Result<Void> delResponsibilityForNS(AuthzTrans trans, HttpServletResponse resp, String ns, String id);
    
    public abstract Result<Void> updateNsDescription(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);

    public abstract Result<Void> deleteNS(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, String ns);

    // NS Attribs
    public abstract Result<Void> createAttribForNS(AuthzTrans trans, HttpServletResponse resp, String ns, String key, String value);

    public abstract Result<Void> readNsByAttrib(AuthzTrans trans, HttpServletResponse resp, String key);

    public abstract Result<Void> updAttribForNS(AuthzTrans trans, HttpServletResponse resp, String ns, String key, String value);

    public abstract Result<Void> delAttribForNS(AuthzTrans trans, HttpServletResponse resp, String ns, String key);

    /*
     * Permissions
     */
    public abstract Result<Void> createPerm(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);    
    
    public abstract Result<Void> getPermsByName(AuthzTrans trans, HttpServletResponse resp, 
            String type, String instance, String action);

    public abstract Result<Void> getPermsByUser(AuthzTrans trans, HttpServletResponse response, String user);

    public abstract Result<Void> getPermsByUserScope(AuthzTrans trans, HttpServletResponse resp, String user, String[] scopes);
    
    public abstract Result<Void> getPermsByUserWithAAFQuery(AuthzTrans trans, HttpServletRequest request, HttpServletResponse response, String user);
    
    public abstract Result<Void> getPermsByType(AuthzTrans trans, HttpServletResponse resp, String type);

    public abstract Result<Void> getPermsForRole(AuthzTrans trans, HttpServletResponse response, String roleName);

    public abstract Result<Void> getPermsByNS(AuthzTrans trans, HttpServletResponse response, String ns);
    
    public abstract Result<Void> renamePerm(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp,
            String type, String instance, String action);
    
    public abstract Result<Void> updatePermDescription(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
    
    public abstract Result<Void> resetPermRoles(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);

    public abstract Result<Void> deletePerm(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);

    public abstract Result<Void> deletePerm(AuthzTrans trans,    HttpServletResponse resp, 
            String perm, String type, String action);

    /*
     * Roles
     */
    public abstract Result<Void> createRole(AuthzTrans trans, HttpServletRequest req, HttpServletResponse response);
    
    public abstract Result<Void> getRolesByName(AuthzTrans trans,HttpServletResponse resp, String name);

    public abstract Result<Void> getRolesByNS(AuthzTrans trans, HttpServletResponse resp, String ns);

    public abstract Result<Void> getRolesByNameOnly(AuthzTrans trans, HttpServletResponse resp, String nameOnly);

    public abstract Result<Void> getRolesByUser(AuthzTrans trans, HttpServletResponse resp, String user);

    public abstract Result<Void> getRolesByPerm(AuthzTrans trans, HttpServletResponse resp, String type, String instance, String action);

    public abstract Result<Void> updateRoleDescription(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
    
    public abstract Result<Void> addPermToRole(AuthzTrans trans,HttpServletRequest req, HttpServletResponse resp);
    
    public abstract Result<Void> delPermFromRole(AuthzTrans trans,HttpServletRequest req, HttpServletResponse resp);

    public abstract Result<Void> delPermFromRole(AuthzTrans trans, HttpServletResponse resp, 
            String role, String type, String instance, String action);

    public abstract Result<Void> deleteRole(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);

    public abstract Result<Void> deleteRole(AuthzTrans trans, HttpServletResponse resp, String role);

    /*
     * Users
     */
    
    public abstract Result<Void> getUsersByRole(AuthzTrans trans, HttpServletResponse resp, String role);
    
    public abstract Result<Void> getUsersByPermission(AuthzTrans trans, HttpServletResponse resp, 
            String type, String instance, String action);



    /*
     * Delegates
     */
    public abstract Result<Void> createDelegate(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
    
    public abstract Result<Void> updateDelegate(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
    
    public abstract Result<Void> deleteDelegate(AuthzTrans trans,  HttpServletRequest req, HttpServletResponse resp);
    
    public abstract Result<Void> deleteDelegate(AuthzTrans trans,  String user);
    
    public abstract Result<Void> getDelegatesByUser(AuthzTrans trans, String userName, HttpServletResponse resp);

    public abstract Result<Void> getDelegatesByDelegate(AuthzTrans trans, String userName, HttpServletResponse resp);

    /*
     * Credentials
     */
    public abstract Result<Void> createUserCred(AuthzTrans trans, HttpServletRequest req);

    public abstract Result<Void> changeUserCred(AuthzTrans trans, HttpServletRequest req);

    public abstract Result<Void> extendUserCred(AuthzTrans trans, HttpServletRequest req, String days);

    public abstract Result<Void> getCredsByNS(AuthzTrans trans,    HttpServletResponse resp, String ns);

    public abstract Result<Void> getCredsByID(AuthzTrans trans, HttpServletResponse resp, String id);

    public abstract Result<Void> deleteUserCred(AuthzTrans trans, HttpServletRequest req);

    public abstract Result<Void> validBasicAuth(AuthzTrans trans, HttpServletResponse resp, String basicAuth);

    public abstract Result<Date> doesCredentialMatch(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);

    /*
     * Miscellaneous
     */
    /**
     * Place Standard Messages based on HTTP Code onto Error Data Structure, and write to OutputStream
     * Log message
     */
    public abstract void error(AuthzTrans trans, HttpServletResponse response, Result<?> result);

    /*
     * UserRole
     */
    public abstract Result<Void> requestUserRole(AuthzTrans trans,HttpServletRequest req, HttpServletResponse resp);
    
    public abstract Result<Void> getUserInRole(AuthzTrans trans, HttpServletResponse resp, String user, String role);
    
    public abstract Result<Void> getUserRolesByRole(AuthzTrans trans, HttpServletResponse resp, String role);
    
    public abstract Result<Void> getUserRolesByUser(AuthzTrans trans, HttpServletResponse resp, String user);

    public abstract Result<Void> deleteUserRole(AuthzTrans trans, HttpServletResponse resp, String user, String role);

    /*
     * resetUsersForRoles and resetRolesForUsers is too dangerous and not helpful.
     */
    
    public abstract Result<Void> extendUserRoleExpiration(AuthzTrans trans, HttpServletResponse resp, String user,
    String role);

    /*
     * Approval 
     */
    public abstract Result<Void> updateApproval(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
    
    public abstract Result<Void> getApprovalsByUser(AuthzTrans trans, HttpServletResponse resp, String user);
    
    public abstract Result<Void> getApprovalsByTicket(AuthzTrans trans, HttpServletResponse resp, String ticket);
    
    public abstract Result<Void> getApprovalsByApprover(AuthzTrans trans, HttpServletResponse resp, String approver);


    /*
     * History
     */
    public abstract Result<Void> getHistoryByUser(AuthzTrans trans,    HttpServletResponse resp, String user, int[] yyyymm, final int sort);
    
    public abstract Result<Void> getHistoryByRole(AuthzTrans trans,    HttpServletResponse resp, String subject, int[] yyyymm, final int sort);

    public abstract Result<Void> getHistoryByPerm(AuthzTrans trans,    HttpServletResponse resp, String subject, int[] yyyymm, final int sort);

    public abstract Result<Void> getHistoryByNS(AuthzTrans trans,    HttpServletResponse resp, String subject, int[] yyyymm, final int sort);

    /*
     * Cache 
     */
    public abstract Result<Void> cacheClear(AuthzTrans trans, String pathParam);

    public abstract Result<Void> cacheClear(AuthzTrans trans, String string,String segments);
    
    public abstract void dbReset(AuthzTrans trans);



    /*
     * API
     */
    public Result<Void> getAPI(AuthzTrans trans, HttpServletResponse resp, RServlet<AuthzTrans> rservlet);

    public abstract Result<Void> getAPIExample(AuthzTrans trans, HttpServletResponse resp, String typeCode, boolean optional);

    public abstract Result<Void> getCertInfoByID(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, String id);






}