--- /dev/null
+/*******************************************************************************\r
+ * ============LICENSE_START====================================================\r
+ * * org.onap.aaf\r
+ * * ===========================================================================\r
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * * ===========================================================================\r
+ * * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * * you may not use this file except in compliance with the License.\r
+ * * You may obtain a copy of the License at\r
+ * * \r
+ * * http://www.apache.org/licenses/LICENSE-2.0\r
+ * * \r
+ * * Unless required by applicable law or agreed to in writing, software\r
+ * * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * * See the License for the specific language governing permissions and\r
+ * * limitations under the License.\r
+ * * ============LICENSE_END====================================================\r
+ * *\r
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * *\r
+ ******************************************************************************/\r
+package org.onap.aaf.authz.service.api;\r
+\r
+import static org.onap.aaf.authz.layer.Result.OK;\r
+import static org.onap.aaf.cssa.rserv.HttpMethods.GET;\r
+\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import org.onap.aaf.authz.env.AuthzTrans;\r
+import org.onap.aaf.authz.facade.AuthzFacade;\r
+import org.onap.aaf.authz.layer.Result;\r
+import org.onap.aaf.authz.service.AuthAPI;\r
+import org.onap.aaf.authz.service.Code;\r
+import org.onap.aaf.authz.service.mapper.Mapper.API;\r
+\r
+import com.att.aft.dme2.internal.jetty.http.HttpStatus;\r
+\r
+/**\r
+ * User Role APIs\r
+ *\r
+ */\r
+public class API_User {\r
+ /**\r
+ * Normal Init level APIs\r
+ * \r
+ * @param authzAPI\r
+ * @param facade\r
+ * @throws Exception\r
+ */\r
+ public static void init(final AuthAPI authzAPI, AuthzFacade facade) throws Exception {\r
+ /**\r
+ * get all Users who have Permission X\r
+ */\r
+ authzAPI.route(GET,"/authz/users/perm/:type/:instance/:action",API.USERS,new Code(facade,"Get Users By Permission", true) {\r
+ @Override\r
+ public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {\r
+// trans.checkpoint(pathParam(req,"type") + " " \r
+// + pathParam(req,"instance") + " " \r
+// + pathParam(req,"action"));\r
+//\r
+ Result<Void> r = context.getUsersByPermission(trans, resp,\r
+ pathParam(req, ":type"),\r
+ pathParam(req, ":instance"),\r
+ pathParam(req, ":action"));\r
+ switch(r.status) {\r
+ case OK:\r
+ resp.setStatus(HttpStatus.OK_200); \r
+ break;\r
+ default:\r
+ context.error(trans,resp,r);\r
+ }\r
+ }\r
+ });\r
+\r
+\r
+ /**\r
+ * get all Users who have Role X\r
+ */\r
+ authzAPI.route(GET,"/authz/users/role/:role",API.USERS,new Code(facade,"Get Users By Role", true) {\r
+ @Override\r
+ public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {\r
+ Result<Void> r = context.getUsersByRole(trans, resp, pathParam(req, ":role"));\r
+ switch(r.status) {\r
+ case OK:\r
+ resp.setStatus(HttpStatus.OK_200); \r
+ break;\r
+ default:\r
+ context.error(trans,resp,r);\r
+ }\r
+ }\r
+ });\r
+ \r
+ /**\r
+ * Get User Role if exists\r
+ * @deprecated\r
+ */\r
+ authzAPI.route(GET,"/authz/userRole/:user/:role",API.USERS,new Code(facade,"Get if User is In Role", true) {\r
+ @Override\r
+ public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {\r
+ Result<Void> r = context.getUserInRole(trans, resp, pathParam(req,":user"),pathParam(req,":role"));\r
+ switch(r.status) {\r
+ case OK:\r
+ resp.setStatus(HttpStatus.OK_200); \r
+ break;\r
+ default:\r
+ context.error(trans,resp,r);\r
+ }\r
+ }\r
+ });\r
+\r
+ /**\r
+ * Get User Role if exists\r
+ */\r
+ authzAPI.route(GET,"/authz/users/:user/:role",API.USERS,new Code(facade,"Get if User is In Role", true) {\r
+ @Override\r
+ public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {\r
+ Result<Void> r = context.getUserInRole(trans, resp, pathParam(req,":user"),pathParam(req,":role"));\r
+ switch(r.status) {\r
+ case OK:\r
+ resp.setStatus(HttpStatus.OK_200); \r
+ break;\r
+ default:\r
+ context.error(trans,resp,r);\r
+ }\r
+ }\r
+ });\r
+ \r
+\r
+\r
+ }\r
+ \r
+}\r