diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml index 7492d91140..cc3d003843 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml @@ -22,13 +22,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.annotations - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT bundle WSO2 Carbon - API Management Annotations WSO2 Carbon - API Management Custom Annotation Module diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml index 5c7eb8ec89..7469b172be 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml @@ -21,12 +21,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../pom.xml 4.0.0 - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT org.wso2.carbon.apimgt.application.extension.api war WSO2 Carbon - API Application Management API diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml index c851c9225e..b71705808b 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml @@ -22,12 +22,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../pom.xml 4.0.0 - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT org.wso2.carbon.apimgt.application.extension bundle WSO2 Carbon - API Application Management diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index fb513728a8..b85790089b 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -22,13 +22,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.webapp.publisher - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT bundle WSO2 Carbon - API Management Webapp Publisher WSO2 Carbon - API Management Webapp Publisher diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 6727a33c55..d734329cec 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../../pom.xml 4.0.0 apimgt-extensions - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT pom WSO2 Carbon - API Management Extensions Component http://wso2.org diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml index 50ad1c0eff..8603e1ac78 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml index 11118cbb14..5245431429 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml index 8594f9e265..04ca8b0c84 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml @@ -21,13 +21,13 @@ org.wso2.carbon.devicemgt certificate-mgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.certificate.mgt.core - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT bundle WSO2 Carbon - Certificate Management Core WSO2 Carbon - Certificate Management Core diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 4493b84107..e65e494b53 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt certificate-mgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT pom WSO2 Carbon - Certificate Management Component http://wso2.org diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml index 17f3fbef32..4d6b932103 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml index 9962be5acf..1760aa3839 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index f894ab64e7..de9b40921f 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index cc1e5ded82..a2839ae6ae 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 1bd0826100..e968075a43 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml index 0da056f737..89f572ce7e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml @@ -3,7 +3,7 @@ org.wso2.carbon.devicemgt device-mgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml index dcd4afb182..4cddb27001 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml index 5c8aa8bcea..b93eac947c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java index 6dd76e1823..75fd081d96 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java @@ -35,6 +35,7 @@ import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceGroupShare; import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceGroupUsersList; import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; +import org.wso2.carbon.device.mgt.jaxrs.beans.RoleInfo; import javax.validation.Valid; import javax.ws.rs.Consumes; @@ -467,6 +468,65 @@ public interface GroupManagementService { required = true) @PathParam("groupId") int groupId); + + @Path("id/{groupId}/roles/create") + @POST + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HTTPConstants.HEADER_GET, + value = "Create a group sharing role to a device group.", + notes = "Group sharing is done through a group sharing role.", + tags = "Device Group Management") + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK. \n Successfully created the role.", + response = DeviceGroupUsersList.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource has been modified the last time.\n" + + "Used by caches, or in conditional requests."), + }), + @ApiResponse( + code = 304, + message = "Not Modified. \n Empty body because the client has already the latest version of " + + "the requested resource."), + @ApiResponse( + code = 404, + message = "No groups found.", + response = ErrorResponse.class), + @ApiResponse( + code = 406, + message = "Not Acceptable.\n The requested media type is not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while creating the role.", + response = ErrorResponse.class) + }) + @Permission(name = "Create roles", permission = "/device-mgt/groups/roles/create") + Response createGroupSharingRole( + @ApiParam( + name = "groupId", + value = "ID of the group.", + required = true) + @PathParam("groupId") int groupId, + @ApiParam( + name = "userName", + value = "User name of the current user.", + required = false) + @QueryParam("userName") String userName, + @ApiParam( + name = "roleInfo", + value = "Group role information with permissions and users", + required = true) + @Valid RoleInfo roleInfo); + @Path("/id/{groupId}/roles") @GET @ApiOperation( @@ -621,7 +681,7 @@ public interface GroupManagementService { required = true) @PathParam("groupId") int groupId); - @Path("/id/{groupId}/devices") + @Path("/id/{groupId}/devices/add") @POST @ApiOperation( produces = MediaType.APPLICATION_JSON, @@ -672,8 +732,8 @@ public interface GroupManagementService { required = true) @Valid List deviceIdentifiers); - @Path("/id/{groupId}/devices") - @DELETE + @Path("/id/{groupId}/devices/remove") + @POST @ApiOperation( produces = MediaType.APPLICATION_JSON, httpMethod = HTTPConstants.HEADER_DELETE, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java index 06569d21cf..845cf11b82 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java @@ -408,6 +408,40 @@ public interface UserManagementService { @Permission(name = "View Users", permission = "/device-mgt/users/view") Response getUserCount(); + @GET + @Path("/checkUser") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "Getting the User existence status", + notes = "Check if the user exists in the user store.", + tags = "User Management") + @ApiResponses(value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully fetched user exist status.", + response = BasicUserInfoList.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body") + }), + @ApiResponse( + code = 406, + message = "Not Acceptable.\n The requested media type is not supported", + response = ErrorResponse.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while fetching the total user exist status.", + response = ErrorResponse.class) + }) + @Permission(name = "View Users", permission = "/device-mgt/users/view") + Response isUserExists(@ApiParam( + name = "username", + value = "The username of the user.", + required = true) + @QueryParam("username") String userName); + @GET @Path("/search/usernames") @ApiOperation( diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GroupManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GroupManagementServiceImpl.java index ed0264feda..90208d4409 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GroupManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GroupManagementServiceImpl.java @@ -38,7 +38,8 @@ import org.wso2.carbon.device.mgt.jaxrs.beans.*; import org.wso2.carbon.device.mgt.jaxrs.service.api.GroupManagementService; import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil; import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; -import org.wso2.carbon.user.core.UserStoreException; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.user.api.UserStoreManager; import org.wso2.carbon.user.core.multiplecredentials.UserDoesNotExistException; import javax.ws.rs.core.Response; @@ -200,11 +201,32 @@ public class GroupManagementServiceImpl implements GroupManagementService { } } + @Override + public Response createGroupSharingRole(int groupId, String userName, RoleInfo roleInfo) { + try { + DeviceMgtAPIUtils.getGroupManagementProviderService() + .addGroupSharingRole(userName, groupId, roleInfo.getRoleName(), roleInfo.getPermissions()); + return Response.status(Response.Status.CREATED).build(); + } catch (GroupManagementException e) { + String msg = "Error occurred while creating group sharing role."; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + @Override public Response getRolesOfGroup(int groupId, String userName) { try { List groupRoles; if(userName != null) { + UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); + if (!userStoreManager.isExistingUser(userName)) { + // returning response with bad request state + return Response.status(Response.Status.CONFLICT).entity( + new ErrorResponse.ErrorResponseBuilder().setMessage("User by username: " + + userName + " doesn't exists. Therefore, request made to get user " + + "was refused.").build()).build(); + } groupRoles = DeviceMgtAPIUtils.getGroupManagementProviderService().getRoles(userName, groupId); } else { groupRoles = DeviceMgtAPIUtils.getGroupManagementProviderService().getRoles(groupId); @@ -275,8 +297,7 @@ public class GroupManagementServiceImpl implements GroupManagementService { } } - @Override - public Response removeDevicesFromGroup(int groupId, List deviceIdentifiers) { + @Override public Response removeDevicesFromGroup(int groupId, List deviceIdentifiers) { try { DeviceMgtAPIUtils.getGroupManagementProviderService().removeDevice(groupId, deviceIdentifiers); return Response.status(Response.Status.OK).build(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java index 8fc57a0c89..96d0cf2c12 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java @@ -359,6 +359,25 @@ public class UserManagementServiceImpl implements UserManagementService { } } + @GET + @Path("/checkUser") + @Override public Response isUserExists(@QueryParam("username") String userName) { + try { + UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); + boolean userExists = false; + if (userStoreManager.isExistingUser(userName)) { + userExists = true; + return Response.status(Response.Status.OK).entity(userExists).build(); + } else { + return Response.status(Response.Status.OK).entity(userExists).build(); + } + } catch (UserStoreException e) { + String msg = "Error while retrieving the user."; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + @GET @Path("/search/usernames") @Override diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml index c72c9e3202..79aa326da7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt org.wso2.carbon.devicemgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index 63af6546f3..1a890b5cd2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml index 362a2dbaaa..a49c5af89d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml index e66303d3a7..62a095cb70 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 1.2.7-SNAPSHOT + 2.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js index 950b9158bc..0283fd214d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js @@ -76,6 +76,27 @@ var userModule = function () { } }; + /** + * Build default user claims. + * + * @param firstname First name of the user + * @param lastname Last name of the user + * @param emailAddress Email address of the user + * + * @returns {Object} Default user claims to be provided + */ + privateMethods.buildDefaultUserClaims = function (firstname, lastname, emailAddress) { + var defaultUserClaims = { + "http://wso2.org/claims/givenname": firstname, + "http://wso2.org/claims/lastname": lastname, + "http://wso2.org/claims/emailaddress": emailAddress + }; + if (log.isDebugEnabled()) { + log.debug("ClaimMap created for new user : " + stringify(defaultUserClaims)); + } + return defaultUserClaims; + }; + /** * Register user to dc-user-store. * @@ -512,9 +533,33 @@ var userModule = function () { if (publicMethods.isAuthorized("/permission/admin/device-mgt/users/add")) { permissions["ADD_USER"] = true; } + if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/devices/add")) { + permissions["ADD_GROUP_DEVICES"] = true; + } + if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/devices/remove")) { + permissions["REMOVE_GROUP_DEVICES"] = true; + } + if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/devices/view")) { + permissions["VIEW_GROUP_DEVICES"] = true; + } + if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/roles/create")) { + permissions["CREATE_GROUP_ROLES"] = true; + } + if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/roles/view")) { + permissions["VIEW_GROUP_ROLES"] = true; + } + if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/update")) { + permissions["UPDATE_GROUP"] = true; + } + if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/share")) { + permissions["SHARE_GROUP"] = true; + } if (publicMethods.isAuthorized("/permission/admin/device-mgt/users/remove")) { permissions["REMOVE_USER"] = true; } + if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/remove")) { + permissions["REMOVE_GROUP"] = true; + } if (publicMethods.isAuthorized("/permission/admin/device-mgt/roles/add")) { permissions["ADD_ROLE"] = true; } @@ -537,6 +582,30 @@ var userModule = function () { return permissions; }; + /** + * Add new role with permissions. + * + * @param roleName Name of the role + * @param users List of users to assign the role + * @param permissions List of permissions + */ + publicMethods.addRole = function (roleName, users, permissions) { + var carbon = require('carbon'); + var tenantId = carbon.server.tenantId(); + var url = carbon.server.address('https') + "/admin/services"; + var server = new carbon.server.Server(url); + var userManager = new carbon.user.UserManager(server, tenantId); + try { + if (!userManager.roleExists(roleName)) { + userManager.addRole(roleName, users, permissions); + } else { + log.info("Role exist with name: " + roleName); + } + } catch (e) { + throw e; + } + }; + publicMethods.addPermissions = function (permissionList, path, init) { var registry, carbon = require("carbon"); var carbonServer = application.get("carbonServer"); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js index 1c367b38f5..bf5f26cac8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js @@ -19,7 +19,6 @@ var carbonModule = require("carbon"); var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; -var utility = require("/app/modules/utility.js")["utility"]; //noinspection JSUnresolvedFunction Server var carbonServer = new carbonModule.server.Server({ @@ -29,9 +28,12 @@ var carbonServer = new carbonModule.server.Server({ application.put("carbonServer", carbonServer); -//var permissions = { -// "/permission/admin/device-mgt/user": ["ui.execute"], -// "/permission/admin/manage/api/subscribe": ["ui.execute"] -//}; +var permissions = { + "/permission/admin/device-mgt/devices": ["ui.execute"], + "/permission/admin/device-mgt/groups": ["ui.execute"], + "/permission/admin/device-mgt/notifications": ["ui.execute"], + "/permission/admin/device-mgt/policies": ["ui.execute"], + "/permission/admin/manage/api/subscribe": ["ui.execute"] +}; -//userModule.addRole("internal/devicemgt-user", ["admin"], permissions); +userModule.addRole("internal/devicemgt-user", ["admin"], permissions); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs index b225f9c983..7cf43cc2af 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs @@ -190,21 +190,39 @@ {{/if}}
- @@ -273,6 +291,25 @@
+
+ + + +
+