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 7492d91140f..d9808c2ba61 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.1-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.annotations - 1.2.7-SNAPSHOT + 2.0.1-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 5c7eb8ec890..d9166908114 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.1-SNAPSHOT ../pom.xml 4.0.0 - 1.2.7-SNAPSHOT + 2.0.1-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 c851c9225ec..27ed943fb5c 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.1-SNAPSHOT ../pom.xml 4.0.0 - 1.2.7-SNAPSHOT + 2.0.1-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 fb513728a8e..7e2fe80ee04 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.1-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.webapp.publisher - 1.2.7-SNAPSHOT + 2.0.1-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 6727a33c55a..88f24464a0e 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.1-SNAPSHOT ../../pom.xml 4.0.0 apimgt-extensions - 1.2.7-SNAPSHOT + 2.0.1-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 50ad1c0eff6..6e47a927e1f 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.1-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 11118cbb14b..58f6270b470 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.1-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 8594f9e2650..47f1880d32c 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.1-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.certificate.mgt.core - 1.2.7-SNAPSHOT + 2.0.1-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 4493b841070..052b4dc55b1 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.1-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt certificate-mgt - 1.2.7-SNAPSHOT + 2.0.1-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 17f3fbef32d..bbcbae134ac 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.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAO.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAO.java index 49d500ee0e0..79d60be5da5 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAO.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAO.java @@ -228,7 +228,7 @@ public class DeviceTypePluginDAO { } private String getDeviceTableColumnNamesForUpdateQuery() { - return StringUtils.join(deviceDAODefinition.getColumnNames(), "= ?,"); + return StringUtils.join(deviceDAODefinition.getColumnNames(), "= ?,") + "= ?"; } private String getPreparedInputString(int length) { diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/feature/ConfigurationBasedFeatureManager.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/feature/ConfigurationBasedFeatureManager.java index fb100be94b9..7e53718442b 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/feature/ConfigurationBasedFeatureManager.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/feature/ConfigurationBasedFeatureManager.java @@ -42,10 +42,6 @@ public class ConfigurationBasedFeatureManager implements FeatureManager { private static final String QUERY_PARAMS = "queryParams"; private static final String FORM_PARAMS = "formParams"; private static final Pattern PATH_PARAM_REGEX = Pattern.compile("\\{(.*?)\\}"); - private List pathParams = new ArrayList<>(); - private List queryParams = new ArrayList<>(); - private List formParams = new ArrayList<>(); - public ConfigurationBasedFeatureManager( List features) { @@ -59,7 +55,10 @@ public class ConfigurationBasedFeatureManager implements FeatureManager { Map apiParams = new HashMap<>(); apiParams.put(METHOD, operation.getMethod().toUpperCase()); apiParams.put(URI, operation.getContext()); - setPathParams(operation.getContext()); + List pathParams = new ArrayList<>(); + List queryParams = new ArrayList<>(); + List formParams = new ArrayList<>(); + setPathParams(operation.getContext(), pathParams); apiParams.put(PATH_PARAMS, pathParams); if (operation.getQueryParameters() != null) { queryParams = operation.getQueryParameters().getParameter(); @@ -116,7 +115,7 @@ public class ConfigurationBasedFeatureManager implements FeatureManager { return false; } - private void setPathParams(String context) { + private void setPathParams(String context, List pathParams) { Matcher regexMatcher = PATH_PARAM_REGEX.matcher(context); while (regexMatcher.find()) { pathParams.add(regexMatcher.group(1)); 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 9962be5acf9..370a58d83a9 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.1-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 f894ab64e78..7f2670a29e9 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.1-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 cc1e5ded827..a3ade1cd136 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.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 1bd0826100f..5cbae04fca7 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.1-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 0da056f737e..93048c62d29 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.1-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 dcd4afb1827..7f3d9171c8a 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.1-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 5c8aa8bceae..b4000440d90 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.1-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 6dd76e1823a..75fd081d96d 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 06569d21cf6..845cf11b823 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 ed0264feda8..90208d4409e 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 8fc57a0c891..96d0cf2c128 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 c72c9e3202f..6f4c7d3297d 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.1-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 63af6546f34..f59b7f9fc2b 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.1-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 362a2dbaaa6..639285bc712 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.1-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 e66303d3a71..120df7a66d1 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.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index 7cda3b7391b..6eaf99a8ef6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -5,10 +5,11 @@ "httpsURL" : "%https.ip%", "httpURL" : "%http.ip%", "httpsWebURL" : "%https.ip%", - "wssURL" : "https://localhost:9444", + "wssURL" : "https://localhost:9445", "wsURL" : "%http.ip%", "dashboardServerURL" : "%https.ip%", - "enrollmentDir": "/emm-web-agent/enrollment", + "androidEnrollmentDir": "/android-web-agent/enrollment", + "windowsEnrollmentDir": "/windows-web-agent/enrollment", "iOSConfigRoot" : "%https.ip%/ios-enrollment/", "iOSAPIRoot" : "%https.ip%/ios/", "adminService": "%https.ip%", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js index c34cc04302c..f072a27d5bc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js @@ -45,16 +45,6 @@ var operationModule = function () { var feature; for (var i = 0; i < features.length; i++) { feature = {}; - var analyticStreams = utility.getDeviceTypeConfig(deviceType)["analyticStreams"]; - if (analyticStreams) { - for (var stream in analyticStreams) { - if (analyticStreams[stream].name == features[i].name) { - feature.ui_unit = analyticStreams[stream].ui_unit; - break; - } - } - } - feature["operation"] = features[i].code; feature["name"] = features[i].name; feature["description"] = features[i].description; @@ -80,10 +70,17 @@ var operationModule = function () { publicMethods.getControlOperations = function (deviceType) { var operations = privateMethods.getOperationsFromFeatures(deviceType, "operation"); + var features = utility.getDeviceTypeConfig(deviceType).deviceType.features; for (var op in operations) { - var iconPath = utility.getOperationIcon(deviceType, operations[op].operation); - if (iconPath) { - operations[op]["icon"] = iconPath; + var iconIdentifier = operations[op].operation; + if (features && features[iconIdentifier]) { + var icon = features[iconIdentifier].icon; + if (icon) { + operations[op]["iconFont"] = icon; + } else if (iconPath) { + var iconPath = utility.getOperationIcon(deviceType, iconIdentifier); + operations[op]["icon"] = iconPath; + } } } return operations; 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 950b9158bcc..0283fd214d2 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 1c367b38f5c..bf5f26cac84 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 b225f9c9834..7cf43cc2af9 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 @@
+
+ + + +
+