X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-service%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fservice%2Fapi%2FAPI_Perms.java;h=d65304ca67add3b97ccd27875aca0b32d59e47af;hb=1296352d8eafee57f982a4342ad79ada4aa56d28;hp=04654d47eba073b4b33405959398841b679e5bc9;hpb=1aba148a7ff88c8f43762da19fa4c757c62732c5;p=aaf%2Fauthz.git diff --git a/auth/auth-service/src/main/java/org/onap/aaf/auth/service/api/API_Perms.java b/auth/auth-service/src/main/java/org/onap/aaf/auth/service/api/API_Perms.java index 04654d47..d65304ca 100644 --- a/auth/auth-service/src/main/java/org/onap/aaf/auth/service/api/API_Perms.java +++ b/auth/auth-service/src/main/java/org/onap/aaf/auth/service/api/API_Perms.java @@ -7,9 +7,9 @@ * 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. @@ -44,15 +44,15 @@ import org.onap.aaf.misc.env.util.Split; public class API_Perms { public static void timeSensitiveInit(AAF_Service authzAPI, AuthzFacade facade) throws Exception { - /** + /** * gets all permissions by user name */ authzAPI.route(GET, "/authz/perms/user/:user", API.PERMS, new Code(facade,"Get Permissions by User",true) { public void handle( - AuthzTrans trans, + AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - + String scopes = req.getParameter("scopes"); Result r; if (scopes==null) { @@ -61,8 +61,8 @@ public class API_Perms { r = context.getPermsByUserScope(trans, resp, pathParam(req, "user"),Split.split(':', scopes)); } switch(r.status) { - case OK: - resp.setStatus(HttpStatus.OK_200); + case OK: + resp.setStatus(HttpStatus.OK_200); break; default: context.error(trans,resp,r); @@ -70,20 +70,20 @@ public class API_Perms { } }); - - /** + + /** * gets all permissions by user name */ authzAPI.route(POST, "/authz/perms/user/:user", API.PERMS, new Code(facade,"Get Permissions by User, Query AAF Perms",true) { public void handle( - AuthzTrans trans, + AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - + Result r = context.getPermsByUserWithAAFQuery(trans, req, resp, pathParam(req, "user")); switch(r.status) { - case OK: - resp.setStatus(HttpStatus.OK_200); + case OK: + resp.setStatus(HttpStatus.OK_200); break; default: context.error(trans,resp,r); @@ -101,14 +101,14 @@ public class API_Perms { */ authzAPI.route(POST,"/authz/perm",API.PERM_REQ,new Code(facade,"Create a Permission",true) { public void handle( - AuthzTrans trans, + AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - + Result r = context.createPerm(trans, req, resp); switch(r.status) { - case OK: - resp.setStatus(HttpStatus.CREATED_201); + case OK: + resp.setStatus(HttpStatus.CREATED_201); break; default: context.error(trans,resp,r); @@ -116,22 +116,22 @@ public class API_Perms { } }); - /** + /** * get details of Permission */ authzAPI.route(GET, "/authz/perms/:type/:instance/:action", API.PERMS, new Code(facade,"Get Permissions by Key",true) { public void handle( - AuthzTrans trans, + AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - - Result r = context.getPermsByName(trans, resp, + + Result r = context.getPermsByName(trans, resp, pathParam(req, "type"), URLDecoder.decode(pathParam(req, "instance"),Config.UTF_8), pathParam(req, "action")); switch(r.status) { - case OK: - resp.setStatus(HttpStatus.OK_200); + case OK: + resp.setStatus(HttpStatus.OK_200); break; default: context.error(trans,resp,r); @@ -139,20 +139,20 @@ public class API_Perms { } }); - - /** + + /** * get children of Permission */ authzAPI.route(GET, "/authz/perms/:type", API.PERMS, new Code(facade,"Get Permissions by Type",true) { public void handle( - AuthzTrans trans, + AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - + Result r = context.getPermsByType(trans, resp, pathParam(req, "type")); switch(r.status) { - case OK: - resp.setStatus(HttpStatus.OK_200); + case OK: + resp.setStatus(HttpStatus.OK_200); break; default: context.error(trans,resp,r); @@ -161,20 +161,20 @@ public class API_Perms { }); - + /** * gets all permissions by role name */ authzAPI.route(GET,"/authz/perms/role/:role",API.PERMS,new Code(facade,"Get Permissions by Role",true) { public void handle( - AuthzTrans trans, + AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - + Result r = context.getPermsForRole(trans, resp, pathParam(req, "role")); switch(r.status) { - case OK: - resp.setStatus(HttpStatus.OK_200); + case OK: + resp.setStatus(HttpStatus.OK_200); break; default: context.error(trans,resp,r); @@ -187,78 +187,78 @@ public class API_Perms { */ authzAPI.route(GET,"/authz/perms/ns/:ns",API.PERMS,new Code(facade,"Get PermsByNS",true) { public void handle( - AuthzTrans trans, + AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - + Result r = context.getPermsByNS(trans, resp, pathParam(req, "ns")); switch(r.status) { - case OK: - resp.setStatus(HttpStatus.OK_200); + case OK: + resp.setStatus(HttpStatus.OK_200); break; default: context.error(trans,resp,r); } } }); - + /** * Set a perm's description */ authzAPI.route(PUT,"/authz/perm",API.PERM_REQ,new Code(facade,"Set Description for Permission",true) { @Override public void handle( - AuthzTrans trans, + AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - + Result r = context.updatePermDescription(trans, req, resp); switch(r.status) { - case OK: - resp.setStatus(HttpStatus.OK_200); + case OK: + resp.setStatus(HttpStatus.OK_200); break; default: context.error(trans,resp,r); } } - }); - + }); + /** * Update a permission with a rename */ authzAPI.route(PUT,"/authz/perm/:type/:instance/:action",API.PERM_REQ,new Code(facade,"Update a Permission",true) { public void handle( - AuthzTrans trans, + AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - - Result r = context.renamePerm(trans, req, resp, - pathParam(req, "type"), - URLDecoder.decode(pathParam(req, "instance"),Config.UTF_8), + + Result r = context.renamePerm(trans, req, resp, + pathParam(req, "type"), + URLDecoder.decode(pathParam(req, "instance"),Config.UTF_8), pathParam(req, "action")); switch(r.status) { - case OK: - resp.setStatus(HttpStatus.OK_200); + case OK: + resp.setStatus(HttpStatus.OK_200); break; default: context.error(trans,resp,r); } } - }); - + }); + /** * Delete a Permission */ authzAPI.route(DELETE,"/authz/perm",API.PERM_REQ,new Code(facade,"Delete a Permission",true) { public void handle( - AuthzTrans trans, + AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - + Result r = context.deletePerm(trans,req, resp); switch(r.status) { - case OK: - resp.setStatus(HttpStatus.OK_200); + case OK: + resp.setStatus(HttpStatus.OK_200); break; default: context.error(trans,resp,r); @@ -266,25 +266,25 @@ public class API_Perms { } }); - - + + /** * Delete a Permission */ authzAPI.route(DELETE,"/authz/perm/:name/:type/:action",API.PERM_KEY,new Code(facade,"Delete a Permission",true) { public void handle( - AuthzTrans trans, + AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - + Result r = context.deletePerm(trans, resp, pathParam(req, ":name"), pathParam(req, ":type"), pathParam(req, ":action")); switch(r.status) { - case OK: - resp.setStatus(HttpStatus.OK_200); + case OK: + resp.setStatus(HttpStatus.OK_200); break; default: context.error(trans,resp,r);