X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fweb%2Froot%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fweb%2FDaylightWebAdmin.java;h=524cb62b3a2175d24596f4b5727a5d7a57310005;hp=46b8d4e0fe5e0329299a5671a6440ae801fbc853;hb=65c9b2ea72201b67ece5d6e5e210857d69df743c;hpb=60ba2f16a5cfa1bc7bcfa0089df544225c70a4cd diff --git a/opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWebAdmin.java b/opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWebAdmin.java index 46b8d4e0fe..524cb62b3a 100644 --- a/opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWebAdmin.java +++ b/opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWebAdmin.java @@ -17,7 +17,7 @@ import org.opendaylight.controller.sal.utils.ServiceHelper; import org.opendaylight.controller.sal.utils.Status; import org.opendaylight.controller.sal.utils.StatusCode; import org.opendaylight.controller.usermanager.IUserManager; -import org.opendaylight.controller.usermanager.internal.UserConfig; +import org.opendaylight.controller.usermanager.UserConfig; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -30,6 +30,9 @@ import com.google.gson.Gson; @Controller @RequestMapping("/admin") public class DaylightWebAdmin { + + + @RequestMapping("/users") @ResponseBody public List getUsers() { @@ -69,7 +72,11 @@ public class DaylightWebAdmin { Status result = (action.equals("add")) ? userManager .addLocalUser(config) : userManager.removeLocalUser(config); - + if(result.getCode().equals(StatusCode.SUCCESS)) { + String userAction=(action.equals("add")) ? "added":"removed"; + DaylightWebUtil.auditlog("User", request.getUserPrincipal().getName(), userAction, config.getUser()); + return "Success"; + } return result.getDescription(); } @@ -93,9 +100,14 @@ public class DaylightWebAdmin { return "Operation not permitted"; } - return userManager.removeLocalUser(userName).getDescription(); + Status result = userManager.removeLocalUser(userName); + if(result.getCode().equals(StatusCode.SUCCESS)) { + DaylightWebUtil.auditlog("User", request.getUserPrincipal().getName(), "removed", userName); + return "Success"; + } + return result.getDescription(); } - + @RequestMapping(value = "/users/password/{username}", method = RequestMethod.POST) @ResponseBody public Status changePassword(@PathVariable("username") String username, HttpServletRequest request, @@ -105,23 +117,25 @@ public class DaylightWebAdmin { if (userManager == null) { return new Status(StatusCode.GONE, "User Manager not found"); } - + if (!authorize(userManager, UserLevel.NETWORKADMIN, request)) { return new Status(StatusCode.FORBIDDEN, "Operation not permitted"); } - + if (newPassword.isEmpty()) { return new Status(StatusCode.BADREQUEST, "Empty passwords not allowed"); } - + Status status = userManager.changeLocalUserPassword(username, currentPassword, newPassword); - + if(status.isSuccess()){ + DaylightWebUtil.auditlog("User", request.getUserPrincipal().getName(), "changed password for", username); + } return status; } /** * Is the operation permitted for the given level - * + * * @param level */ private boolean authorize(IUserManager userManager, UserLevel level,