2 * ============LICENSE_START====================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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====================================================
22 package org.onap.aaf.auth.service.facade;
24 import java.util.Date;
26 import javax.servlet.http.HttpServletRequest;
27 import javax.servlet.http.HttpServletResponse;
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;
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.
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.
42 * Finally, we wrap the call in Time Stamps with explanation of what is happing for Audit trails.
47 public interface AuthzFacade {
48 public static final int PERM_DEPEND_424 = -1000;
49 public static final int ROLE_DEPEND_424 = -1001;
54 public abstract Result<Void> requestNS(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, NsType type);
56 public abstract Result<Void> getNSsByName(AuthzTrans trans, HttpServletResponse resp, String ns);
58 public abstract Result<Void> getNSsByAdmin(AuthzTrans trans, HttpServletResponse resp, String user, boolean full);
60 public abstract Result<Void> getNSsByResponsible(AuthzTrans trans, HttpServletResponse resp, String user, boolean full);
62 public abstract Result<Void> getNSsByEither(AuthzTrans trans, HttpServletResponse resp, String user, boolean full);
64 public abstract Result<Void> getNSsChildren(AuthzTrans trans, HttpServletResponse resp, String pathParam);
66 public abstract Result<Void> addAdminToNS(AuthzTrans trans, HttpServletResponse resp, String ns, String id);
68 public abstract Result<Void> delAdminFromNS(AuthzTrans trans, HttpServletResponse resp, String ns, String id);
70 public abstract Result<Void> addResponsibilityForNS(AuthzTrans trans, HttpServletResponse resp, String ns, String id);
72 public abstract Result<Void> delResponsibilityForNS(AuthzTrans trans, HttpServletResponse resp, String ns, String id);
74 public abstract Result<Void> updateNsDescription(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
76 public abstract Result<Void> deleteNS(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, String ns);
79 public abstract Result<Void> createAttribForNS(AuthzTrans trans, HttpServletResponse resp, String ns, String key, String value);
81 public abstract Result<Void> readNsByAttrib(AuthzTrans trans, HttpServletResponse resp, String key);
83 public abstract Result<Void> updAttribForNS(AuthzTrans trans, HttpServletResponse resp, String ns, String key, String value);
85 public abstract Result<Void> delAttribForNS(AuthzTrans trans, HttpServletResponse resp, String ns, String key);
90 public abstract Result<Void> createPerm(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
92 public abstract Result<Void> getPermsByName(AuthzTrans trans, HttpServletResponse resp,
93 String type, String instance, String action);
95 public abstract Result<Void> getPermsByUser(AuthzTrans trans, HttpServletResponse response, String user);
97 public abstract Result<Void> getPermsByUserScope(AuthzTrans trans, HttpServletResponse resp, String user, String[] scopes);
99 public abstract Result<Void> getPermsByUserWithAAFQuery(AuthzTrans trans, HttpServletRequest request, HttpServletResponse response, String user);
101 public abstract Result<Void> getPermsByType(AuthzTrans trans, HttpServletResponse resp, String type);
103 public abstract Result<Void> getPermsForRole(AuthzTrans trans, HttpServletResponse response, String roleName);
105 public abstract Result<Void> getPermsByNS(AuthzTrans trans, HttpServletResponse response, String ns);
107 public abstract Result<Void> renamePerm(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp,
108 String type, String instance, String action);
110 public abstract Result<Void> updatePermDescription(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
112 public abstract Result<Void> resetPermRoles(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
114 public abstract Result<Void> deletePerm(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
116 public abstract Result<Void> deletePerm(AuthzTrans trans, HttpServletResponse resp,
117 String perm, String type, String action);
122 public abstract Result<Void> createRole(AuthzTrans trans, HttpServletRequest req, HttpServletResponse response);
124 public abstract Result<Void> getRolesByName(AuthzTrans trans,HttpServletResponse resp, String name);
126 public abstract Result<Void> getRolesByNS(AuthzTrans trans, HttpServletResponse resp, String ns);
128 public abstract Result<Void> getRolesByNameOnly(AuthzTrans trans, HttpServletResponse resp, String nameOnly);
130 public abstract Result<Void> getRolesByUser(AuthzTrans trans, HttpServletResponse resp, String user);
132 public abstract Result<Void> getRolesByPerm(AuthzTrans trans, HttpServletResponse resp, String type, String instance, String action);
134 public abstract Result<Void> updateRoleDescription(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
136 public abstract Result<Void> addPermToRole(AuthzTrans trans,HttpServletRequest req, HttpServletResponse resp);
138 public abstract Result<Void> delPermFromRole(AuthzTrans trans,HttpServletRequest req, HttpServletResponse resp);
140 public abstract Result<Void> delPermFromRole(AuthzTrans trans, HttpServletResponse resp,
141 String role, String type, String instance, String action);
143 public abstract Result<Void> deleteRole(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
145 public abstract Result<Void> deleteRole(AuthzTrans trans, HttpServletResponse resp, String role);
151 public abstract Result<Void> getUsersByRole(AuthzTrans trans, HttpServletResponse resp, String role);
153 public abstract Result<Void> getUsersByPermission(AuthzTrans trans, HttpServletResponse resp,
154 String type, String instance, String action);
161 public abstract Result<Void> createDelegate(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
163 public abstract Result<Void> updateDelegate(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
165 public abstract Result<Void> deleteDelegate(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
167 public abstract Result<Void> deleteDelegate(AuthzTrans trans, String user);
169 public abstract Result<Void> getDelegatesByUser(AuthzTrans trans, String userName, HttpServletResponse resp);
171 public abstract Result<Void> getDelegatesByDelegate(AuthzTrans trans, String userName, HttpServletResponse resp);
176 public abstract Result<Void> createUserCred(AuthzTrans trans, HttpServletRequest req);
178 public abstract Result<Void> changeUserCred(AuthzTrans trans, HttpServletRequest req);
180 public abstract Result<Void> extendUserCred(AuthzTrans trans, HttpServletRequest req, String days);
182 public abstract Result<Void> getCredsByNS(AuthzTrans trans, HttpServletResponse resp, String ns);
184 public abstract Result<Void> getCredsByID(AuthzTrans trans, HttpServletResponse resp, String id);
186 public abstract Result<Void> deleteUserCred(AuthzTrans trans, HttpServletRequest req);
188 public abstract Result<Void> validBasicAuth(AuthzTrans trans, HttpServletResponse resp, String basicAuth);
190 public abstract Result<Date> doesCredentialMatch(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
196 * Place Standard Messages based on HTTP Code onto Error Data Structure, and write to OutputStream
199 public abstract void error(AuthzTrans trans, HttpServletResponse response, Result<?> result);
204 public abstract Result<Void> requestUserRole(AuthzTrans trans,HttpServletRequest req, HttpServletResponse resp);
206 public abstract Result<Void> getUserInRole(AuthzTrans trans, HttpServletResponse resp, String user, String role);
208 public abstract Result<Void> getUserRolesByRole(AuthzTrans trans, HttpServletResponse resp, String role);
210 public abstract Result<Void> getUserRolesByUser(AuthzTrans trans, HttpServletResponse resp, String user);
212 public abstract Result<Void> deleteUserRole(AuthzTrans trans, HttpServletResponse resp, String user, String role);
214 public abstract Result<Void> resetUsersForRole(AuthzTrans trans, HttpServletResponse resp, HttpServletRequest req);
216 public abstract Result<Void> resetRolesForUser(AuthzTrans trans, HttpServletResponse resp, HttpServletRequest req);
218 public abstract Result<Void> extendUserRoleExpiration(AuthzTrans trans, HttpServletResponse resp, String user,
224 public abstract Result<Void> updateApproval(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
226 public abstract Result<Void> getApprovalsByUser(AuthzTrans trans, HttpServletResponse resp, String user);
228 public abstract Result<Void> getApprovalsByTicket(AuthzTrans trans, HttpServletResponse resp, String ticket);
230 public abstract Result<Void> getApprovalsByApprover(AuthzTrans trans, HttpServletResponse resp, String approver);
236 public abstract Result<Void> getHistoryByUser(AuthzTrans trans, HttpServletResponse resp, String user, int[] yyyymm, final int sort);
238 public abstract Result<Void> getHistoryByRole(AuthzTrans trans, HttpServletResponse resp, String subject, int[] yyyymm, final int sort);
240 public abstract Result<Void> getHistoryByPerm(AuthzTrans trans, HttpServletResponse resp, String subject, int[] yyyymm, final int sort);
242 public abstract Result<Void> getHistoryByNS(AuthzTrans trans, HttpServletResponse resp, String subject, int[] yyyymm, final int sort);
247 public abstract Result<Void> cacheClear(AuthzTrans trans, String pathParam);
249 public abstract Result<Void> cacheClear(AuthzTrans trans, String string,String segments);
251 public abstract void dbReset(AuthzTrans trans);
258 public Result<Void> getAPI(AuthzTrans trans, HttpServletResponse resp, RServlet<AuthzTrans> rservlet);
260 public abstract Result<Void> getAPIExample(AuthzTrans trans, HttpServletResponse resp, String typeCode, boolean optional);
262 public abstract Result<Void> getCertInfoByID(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, String id);