Merge remote-tracking branch 'upstream/master' into carbon-kernel-4.4.7

# Conflicts:
#	components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java
revert-70aa11f8
Ace 8 years ago
commit 33d8829540

@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.API; import org.wso2.carbon.apimgt.annotations.api.API;
import org.wso2.carbon.apimgt.annotations.api.Permission; import org.wso2.carbon.apimgt.annotations.api.Permission;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import org.wso2.carbon.device.mgt.jaxrs.beans.ActivityList; import org.wso2.carbon.device.mgt.jaxrs.beans.ActivityList;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
@ -93,7 +92,7 @@ public interface ActivityInfoProviderService {
message = "Internal Server Error. \n Server error occurred while fetching activity data.", message = "Internal Server Error. \n Server error occurred while fetching activity data.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Activities", permission = "/device-mgt/devices/owning/view") @Permission(name = "View Activities", permission = "/device-mgt/devices/owning-device/view")
Response getActivity( Response getActivity(
@ApiParam( @ApiParam(
name = "id", name = "id",
@ -154,7 +153,7 @@ public interface ActivityInfoProviderService {
message = "Internal Server Error. \n Server error occurred while fetching activity data.", message = "Internal Server Error. \n Server error occurred while fetching activity data.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Activities", permission = "/device-mgt/devices/owning/view") @Permission(name = "View Activities", permission = "/device-mgt/devices/owning-device/view")
Response getActivities( Response getActivities(
@ApiParam( @ApiParam(
name = "since", name = "since",

@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.API; import org.wso2.carbon.apimgt.annotations.api.API;
import org.wso2.carbon.apimgt.annotations.api.Permission; import org.wso2.carbon.apimgt.annotations.api.Permission;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
@ -82,7 +81,7 @@ public interface ConfigurationManagementService {
"platform configuration.", "platform configuration.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Configurations", permission = "/device-mgt/configurations/view") @Permission(name = "View Configurations", permission = "/device-mgt/platform-configurations/view")
Response getConfiguration( Response getConfiguration(
@ApiParam( @ApiParam(
name = "If-Modified-Since", name = "If-Modified-Since",
@ -128,7 +127,7 @@ public interface ConfigurationManagementService {
"Server error occurred while modifying general platform configuration.", "Server error occurred while modifying general platform configuration.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "Manage configurations", permission = "/device-mgt/configurations/manage") @Permission(name = "Manage configurations", permission = "/device-mgt/platform-configurations/manage")
Response updateConfiguration( Response updateConfiguration(
@ApiParam( @ApiParam(
name = "configuration", name = "configuration",

@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.API; import org.wso2.carbon.apimgt.annotations.api.API;
import org.wso2.carbon.apimgt.annotations.api.Permission; import org.wso2.carbon.apimgt.annotations.api.Permission;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.app.mgt.Application;
@ -93,7 +92,7 @@ public interface DeviceManagementService {
message = "Internal Server Error. \n Server error occurred while fetching the device list.", message = "Internal Server Error. \n Server error occurred while fetching the device list.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Devices", permission = "/device-mgt/devices/owning/view") @Permission(name = "View Devices", permission = "/device-mgt/devices/owning-device/view")
Response getDevices( Response getDevices(
@ApiParam( @ApiParam(
name = "name", name = "name",
@ -200,7 +199,7 @@ public interface DeviceManagementService {
"Server error occurred while retrieving information requested device.", "Server error occurred while retrieving information requested device.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Devices", permission = "/device-mgt/devices/owning/view") @Permission(name = "View Devices", permission = "/device-mgt/devices/owning-device/view")
Response getDevice( Response getDevice(
@ApiParam( @ApiParam(
name = "type", name = "type",
@ -282,7 +281,7 @@ public interface DeviceManagementService {
"Server error occurred while retrieving feature list of the device.", "Server error occurred while retrieving feature list of the device.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Devices", permission = "/device-mgt/devices/owning/view") @Permission(name = "View Devices", permission = "/device-mgt/devices/owning-device/view")
Response getFeaturesOfDevice( Response getFeaturesOfDevice(
@ApiParam( @ApiParam(
name = "type", name = "type",
@ -358,7 +357,7 @@ public interface DeviceManagementService {
"Server error occurred while enrolling the device.", "Server error occurred while enrolling the device.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Devices", permission = "/device-mgt/devices/owning/view") @Permission(name = "View Devices", permission = "/device-mgt/devices/owning-device/view")
Response searchDevices( Response searchDevices(
@ApiParam( @ApiParam(
name = "offset", name = "offset",
@ -437,7 +436,7 @@ public interface DeviceManagementService {
"Server error occurred while retrieving installed application list of the device.", "Server error occurred while retrieving installed application list of the device.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Devices", permission = "/device-mgt/devices/owning/view") @Permission(name = "View Devices", permission = "/device-mgt/devices/owning-device/view")
Response getInstalledApplications( Response getInstalledApplications(
@ApiParam( @ApiParam(
name = "type", name = "type",
@ -533,7 +532,7 @@ public interface DeviceManagementService {
"Server error occurred while retrieving operation list scheduled for the device.", "Server error occurred while retrieving operation list scheduled for the device.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Devices", permission = "/device-mgt/devices/owning/view") @Permission(name = "View Devices", permission = "/device-mgt/devices/owning-device/view")
Response getDeviceOperations( Response getDeviceOperations(
@ApiParam( @ApiParam(
name = "type", name = "type",
@ -631,7 +630,7 @@ public interface DeviceManagementService {
response = ErrorResponse.class) response = ErrorResponse.class)
} }
) )
@Permission(name = "View Devices", permission = "/device-mgt/devices/owning/view") @Permission(name = "View Devices", permission = "/device-mgt/devices/owning-device/view")
Response getEffectivePolicyOfDevice( Response getEffectivePolicyOfDevice(
@ApiParam( @ApiParam(
name = "type", name = "type",
@ -683,7 +682,7 @@ public interface DeviceManagementService {
response = ErrorResponse.class) response = ErrorResponse.class)
} }
) )
@Permission(name = "View Devices", permission = "/device-mgt/devices/owning/view") @Permission(name = "View Devices", permission = "/device-mgt/devices/owning-device/view")
Response getComplianceDataOfDevice( Response getComplianceDataOfDevice(
@ApiParam( @ApiParam(
name = "type", name = "type",

@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.API; import org.wso2.carbon.apimgt.annotations.api.API;
import org.wso2.carbon.apimgt.annotations.api.Permission; import org.wso2.carbon.apimgt.annotations.api.Permission;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceTypeList; import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceTypeList;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
@ -79,7 +78,7 @@ public interface DeviceTypeManagementService {
response = ErrorResponse.class) response = ErrorResponse.class)
} }
) )
@Permission(name = "View Device Types", permission = "/device-mgt/devices/owning/view") @Permission(name = "View Device Types", permission = "/device-mgt/devices/owning-device/view")
Response getDeviceTypes( Response getDeviceTypes(
@ApiParam( @ApiParam(
name = "If-Modified-Since", name = "If-Modified-Since",

@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.API; import org.wso2.carbon.apimgt.annotations.api.API;
import org.wso2.carbon.apimgt.annotations.api.Permission; import org.wso2.carbon.apimgt.annotations.api.Permission;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.device.mgt.jaxrs.beans.*; import org.wso2.carbon.device.mgt.jaxrs.beans.*;
import javax.ws.rs.*; import javax.ws.rs.*;
@ -471,7 +470,7 @@ public interface UserManagementService {
"Server error occurred while updating credentials of the user.", "Server error occurred while updating credentials of the user.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Users", permission = "/device-mgt/users/view") @Permission(name = "Reset user password", permission = "/login")
Response resetPassword( Response resetPassword(
@ApiParam( @ApiParam(
name = "username", name = "username",

@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api.admin;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.API; import org.wso2.carbon.apimgt.annotations.api.API;
import org.wso2.carbon.apimgt.annotations.api.Permission; import org.wso2.carbon.apimgt.annotations.api.Permission;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
@ -86,7 +85,7 @@ public interface DeviceManagementAdminService {
message = "Internal Server Error. \n Server error occurred while fetching the device list.", message = "Internal Server Error. \n Server error occurred while fetching the device list.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Devices", permission = "/device-mgt/devices/owning/view") @Permission(name = "View Devices", permission = "/device-mgt/devices/owning-device/view")
Response getDevicesByName( Response getDevicesByName(
@ApiParam( @ApiParam(
name = "name", name = "name",

@ -25,6 +25,8 @@ import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.common.search.SearchContext; import org.wso2.carbon.device.mgt.common.search.SearchContext;
@ -78,6 +80,13 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
// RequestValidationUtil.validateSelectionCriteria(type, user, roleName, ownership, status); // RequestValidationUtil.validateSelectionCriteria(type, user, roleName, ownership, status);
RequestValidationUtil.validatePaginationParameters(offset, limit); RequestValidationUtil.validatePaginationParameters(offset, limit);
DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService(); DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService();
DeviceAccessAuthorizationService deviceAccessAuthorizationService =
DeviceMgtAPIUtils.getDeviceAccessAuthorizationService();
if (deviceAccessAuthorizationService == null) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage("Device access authorization service is " +
"failed").build()).build();
}
PaginationRequest request = new PaginationRequest(offset, limit); PaginationRequest request = new PaginationRequest(offset, limit);
PaginationResult result; PaginationResult result;
DeviceList devices = new DeviceList(); DeviceList devices = new DeviceList();
@ -100,6 +109,30 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
request.setStatus(status); request.setStatus(status);
} }
// this is the user who initiates the request
String authorizedUser = CarbonContext.getThreadLocalCarbonContext().getUsername();
// check whether the user is device-mgt admin
if (deviceAccessAuthorizationService.isDeviceAdminUser()) {
if (user != null && !user.isEmpty()) {
request.setOwner(user);
}
} else {
if (user != null && !user.isEmpty()) {
if (user.equals(authorizedUser)) {
request.setOwner(user);
} else {
String msg = "User '" + authorizedUser + "' is not authorized to retrieve devices of '" + user
+ "' user";
log.error(msg);
return Response.status(Response.Status.UNAUTHORIZED).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(401l).setMessage(msg).build()).build();
}
} else {
request.setOwner(authorizedUser);
}
}
if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) { if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) {
Date sinceDate; Date sinceDate;
SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z"); SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
@ -149,6 +182,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
log.error(msg, e); log.error(msg, e);
return Response.serverError().entity( return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred while checking device access authorization";
log.error(msg, e);
return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} }
} }
@ -186,17 +224,52 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@PathParam("type") @Size(max = 45) String type, @PathParam("type") @Size(max = 45) String type,
@PathParam("id") @Size(max = 45) String id, @PathParam("id") @Size(max = 45) String id,
@HeaderParam("If-Modified-Since") String ifModifiedSince) { @HeaderParam("If-Modified-Since") String ifModifiedSince) {
Device device; Device device = null;
try { try {
RequestValidationUtil.validateDeviceIdentifier(type, id); RequestValidationUtil.validateDeviceIdentifier(type, id);
DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService(); DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService();
DeviceAccessAuthorizationService deviceAccessAuthorizationService =
DeviceMgtAPIUtils.getDeviceAccessAuthorizationService();
// this is the user who initiates the request
String authorizedUser = CarbonContext.getThreadLocalCarbonContext().getUsername();
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(id, type);
// check whether the user is authorized
if (!deviceAccessAuthorizationService.isUserAuthorized(deviceIdentifier, authorizedUser)) {
String msg = "User '" + authorizedUser + "' is not authorized to retrieve the given device id '" + id;
log.error(msg);
return Response.status(Response.Status.UNAUTHORIZED).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(401l).setMessage(msg).build()).build();
}
if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) {
Date sinceDate;
SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
try {
sinceDate = format.parse(ifModifiedSince);
} catch (ParseException e) {
return Response.status(Response.Status.BAD_REQUEST).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage("Invalid date " +
"string is provided in 'If-Modified-Since' header").build()).build();
}
device = dms.getDevice(new DeviceIdentifier(id, type), sinceDate);
if (device == null) {
return Response.status(Response.Status.NOT_MODIFIED).entity("No device is modified " +
"after the timestamp provided in 'If-Modified-Since' header").build();
}
} else {
device = dms.getDevice(new DeviceIdentifier(id, type)); device = dms.getDevice(new DeviceIdentifier(id, type));
}
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error occurred while fetching the device information."; String msg = "Error occurred while fetching the device information.";
log.error(msg, e); log.error(msg, e);
return Response.serverError().entity( return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred while checking the device authorization.";
log.error(msg, e);
return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} }
if (device == null) { if (device == null) {
return Response.status(Response.Status.NOT_FOUND).entity( return Response.status(Response.Status.NOT_FOUND).entity(
@ -217,7 +290,6 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
DeviceManagementProviderService dms; DeviceManagementProviderService dms;
try { try {
RequestValidationUtil.validateDeviceIdentifier(type, id); RequestValidationUtil.validateDeviceIdentifier(type, id);
dms = DeviceMgtAPIUtils.getDeviceManagementService(); dms = DeviceMgtAPIUtils.getDeviceManagementService();
FeatureManager fm = dms.getFeatureManager(type); FeatureManager fm = dms.getFeatureManager(type);
if (fm == null) { if (fm == null) {

@ -24,6 +24,7 @@ import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.analytics.dashboard.GadgetDataService; import org.wso2.carbon.device.mgt.analytics.dashboard.GadgetDataService;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService;
@ -104,6 +105,18 @@ public class DeviceMgtAPIUtils {
return deviceManagementProviderService; return deviceManagementProviderService;
} }
public static DeviceAccessAuthorizationService getDeviceAccessAuthorizationService() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
DeviceAccessAuthorizationService deviceAccessAuthorizationService =
(DeviceAccessAuthorizationService) ctx.getOSGiService(DeviceAccessAuthorizationService.class, null);
if (deviceAccessAuthorizationService == null) {
String msg = "DeviceAccessAuthorization service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg);
}
return deviceAccessAuthorizationService;
}
public static GroupManagementProviderService getGroupManagementProviderService() { public static GroupManagementProviderService getGroupManagementProviderService() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
GroupManagementProviderService groupManagementProviderService = GroupManagementProviderService groupManagementProviderService =

@ -115,6 +115,14 @@ public interface DeviceAccessAuthorizationService {
boolean isUserAuthorized(DeviceIdentifier deviceIdentifier, String username) throws boolean isUserAuthorized(DeviceIdentifier deviceIdentifier, String username) throws
DeviceAccessAuthorizationException; DeviceAccessAuthorizationException;
/**
* This method will check whether the authenticated user has the admin permissions.
*
* @return Boolean authorization result.
* @throws DeviceAccessAuthorizationException if something goes wrong when checking the authorization.
*/
boolean isDeviceAdminUser() throws DeviceAccessAuthorizationException;
/** /**
* This method will check whether the given user has the access to the devices identified by the given * This method will check whether the given user has the access to the devices identified by the given
* DeviceIdentifier list. * DeviceIdentifier list.

@ -62,6 +62,11 @@ public class Notification {
required = false) required = false)
private String deviceIdentifier; private String deviceIdentifier;
@JsonProperty(value = "deviceName", required = false)
@ApiModelProperty(name = "deviceName", value = "Defines the device Name related to the notification.",
required = false)
private String deviceName;
@JsonProperty(value = "devieType", required = false) @JsonProperty(value = "devieType", required = false)
@ApiModelProperty(name = "devieType", value = "Defines the device type related to the notification.", @ApiModelProperty(name = "devieType", value = "Defines the device type related to the notification.",
required = false) required = false)
@ -107,7 +112,15 @@ public class Notification {
this.deviceIdentifier = deviceIdentifier; this.deviceIdentifier = deviceIdentifier;
} }
public String getDevcieType() { public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getDeviceType() {
return deviceType; return deviceType;
} }
@ -123,6 +136,7 @@ public class Notification {
", description='" + description + '\'' + ", description='" + description + '\'' +
", operationId='" + operationId + '\'' + ", operationId='" + operationId + '\'' +
", deviceIdentifier='" + deviceIdentifier + '\'' + ", deviceIdentifier='" + deviceIdentifier + '\'' +
", deviceName='" + deviceName + '\'' +
", deviceType='" + deviceType + '\'' + ", deviceType='" + deviceType + '\'' +
'}'; '}';
} }

@ -47,7 +47,7 @@ import java.util.Map;
*/ */
public class DeviceAccessAuthorizationServiceImpl implements DeviceAccessAuthorizationService { public class DeviceAccessAuthorizationServiceImpl implements DeviceAccessAuthorizationService {
private final static String CDM_ADMIN_PERMISSION = "/device-mgt/devices/any/permitted-actions-upon-owning-device"; private final static String CDM_ADMIN_PERMISSION = "/device-mgt/devices/any-device/permitted-actions-under-owning-device";
private final static String CDM_ADMIN = "Device Management Administrator"; private final static String CDM_ADMIN = "Device Management Administrator";
private static Log log = LogFactory.getLog(DeviceAccessAuthorizationServiceImpl.class); private static Log log = LogFactory.getLog(DeviceAccessAuthorizationServiceImpl.class);
@ -106,6 +106,18 @@ public class DeviceAccessAuthorizationServiceImpl implements DeviceAccessAuthori
return isUserAuthorized(deviceIdentifier, this.getUserName(), null); return isUserAuthorized(deviceIdentifier, this.getUserName(), null);
} }
@Override
public boolean isDeviceAdminUser() throws DeviceAccessAuthorizationException {
String username = this.getUserName();
int tenantId = this.getTenantId();
try {
return isAdminUser(username, tenantId);
} catch (UserStoreException e) {
throw new DeviceAccessAuthorizationException("Unable to check the admin permissions of user : " +
username + " in tenant : " + tenantId, e);
}
}
@Override @Override
public DeviceAuthorizationResult isUserAuthorized(List<DeviceIdentifier> deviceIdentifiers, String username, public DeviceAuthorizationResult isUserAuthorized(List<DeviceIdentifier> deviceIdentifiers, String username,
String[] groupPermissions) String[] groupPermissions)

@ -25,6 +25,7 @@ import org.wso2.carbon.device.mgt.common.EnrolmentInfo.Status;
import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -124,6 +125,18 @@ public interface DeviceDAO {
*/ */
Device getDevice(DeviceIdentifier deviceIdentifier, int tenantId) throws DeviceManagementDAOException; Device getDevice(DeviceIdentifier deviceIdentifier, int tenantId) throws DeviceManagementDAOException;
/**
* This method is used to retrieve a device of a given device-identifier and tenant-id.
*
* @param deviceIdentifier device id.
* @param ifModifiedSince last modified time.
* @param tenantId tenant id.
* @return returns the device object.
* @throws DeviceManagementDAOException
*/
Device getDevice(DeviceIdentifier deviceIdentifier, Date ifModifiedSince, int tenantId) throws
DeviceManagementDAOException;
/** /**
* This method is used to retrieve a device of a given device-identifier, enrollment status and tenant-id. * This method is used to retrieve a device of a given device-identifier, enrollment status and tenant-id.
* *

@ -128,7 +128,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
stmt.setInt(4, tenantId); stmt.setInt(4, tenantId);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
if (rs.next()) { if (rs.next()) {
device = DeviceManagementDAOUtil.loadMatchingDevice(rs); device = DeviceManagementDAOUtil.loadMatchingDevice(rs, false);
} }
} catch (SQLException e) { } catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while listing devices for type " + throw new DeviceManagementDAOException("Error occurred while listing devices for type " +
@ -139,6 +139,41 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
return device; return device;
} }
@Override
public Device getDevice(DeviceIdentifier deviceIdentifier, Date since, int tenantId)
throws DeviceManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
Device device = null;
try {
conn = this.getConnection();
String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " +
"d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " +
"t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_DETAIL dt " +
"WHERE t.NAME = ? AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ? AND dt.DEVICE_ID = d.ID " +
"AND dt.UPDATE_TIMESTAMP > ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?" ;
stmt = conn.prepareStatement(sql);
int paramIdx = 1;
stmt.setString(paramIdx++, deviceIdentifier.getType());
stmt.setString(paramIdx++, deviceIdentifier.getId());
stmt.setInt(paramIdx++, tenantId);
stmt.setLong(paramIdx++, since.getTime());
stmt.setInt(paramIdx, tenantId);
rs = stmt.executeQuery();
if (rs.next()) {
device = DeviceManagementDAOUtil.loadMatchingDevice(rs, true);
}
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while listing device for type " +
"'" + deviceIdentifier.getType() + "'", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
return device;
}
@Override @Override
public Device getDevice(DeviceIdentifier deviceIdentifier, EnrolmentInfo.Status status, int tenantId) throws public Device getDevice(DeviceIdentifier deviceIdentifier, EnrolmentInfo.Status status, int tenantId) throws
DeviceManagementDAOException { DeviceManagementDAOException {

@ -160,14 +160,21 @@ public final class DeviceManagementDAOUtil {
//This method will retrieve most appropriate device information when there are multiple device enrollments for //This method will retrieve most appropriate device information when there are multiple device enrollments for
//a single device. We'll give the highest priority to active devices. //a single device. We'll give the highest priority to active devices.
public static Device loadMatchingDevice(ResultSet rs) throws SQLException { public static Device loadMatchingDevice(ResultSet rs, boolean deviceInfoIncluded) throws SQLException {
Map<EnrolmentInfo.Status, Device> deviceMap = new HashMap<>(); Map<EnrolmentInfo.Status, Device> deviceMap = new HashMap<>();
Device device = loadDevice(rs); Device device = loadDevice(rs);
if (deviceInfoIncluded) {
device.setDeviceInfo(loadDeviceInfo(rs));
}
if (EnrolmentInfo.Status.ACTIVE.equals(device.getEnrolmentInfo().getStatus())) { if (EnrolmentInfo.Status.ACTIVE.equals(device.getEnrolmentInfo().getStatus())) {
return device; return device;
} }
while (rs.next()) { while (rs.next()) {
device = loadDevice(rs); device = loadDevice(rs);
if (deviceInfoIncluded) {
device.setDeviceInfo(loadDeviceInfo(rs));
}
if (EnrolmentInfo.Status.ACTIVE.equals(device.getEnrolmentInfo().getStatus())) { if (EnrolmentInfo.Status.ACTIVE.equals(device.getEnrolmentInfo().getStatus())) {
return device; return device;
} }

@ -156,7 +156,7 @@ public abstract class AbstractNotificationDAOImpl implements NotificationDAO {
conn = NotificationManagementDAOFactory.getConnection(); conn = NotificationManagementDAOFactory.getConnection();
String sql = String sql =
"SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS, n1.DESCRIPTION," + "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS, n1.DESCRIPTION," +
" d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT " + " d.DEVICE_IDENTIFICATION, d.NAME as DEVICE_NAME, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT " +
"NOTIFICATION_ID, DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " + "NOTIFICATION_ID, DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " +
"TENANT_ID = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID AND TENANT_ID = ?"; "TENANT_ID = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID AND TENANT_ID = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
@ -226,7 +226,7 @@ public abstract class AbstractNotificationDAOImpl implements NotificationDAO {
try { try {
conn = NotificationManagementDAOFactory.getConnection(); conn = NotificationManagementDAOFactory.getConnection();
String sql = "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS," + String sql = "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS," +
" n1.DESCRIPTION, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM " + " n1.DESCRIPTION, d.DEVICE_IDENTIFICATION, d.NAME as DEVICE_NAME, t.NAME AS DEVICE_TYPE FROM " +
"DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT NOTIFICATION_ID, DEVICE_ID, " + "DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT NOTIFICATION_ID, DEVICE_ID, " +
"OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " + "OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " +
"TENANT_ID = ? AND STATUS = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID " + "TENANT_ID = ? AND STATUS = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID " +

@ -47,7 +47,7 @@ public class GenericNotificationDAOImpl extends AbstractNotificationDAOImpl {
conn = NotificationManagementDAOFactory.getConnection(); conn = NotificationManagementDAOFactory.getConnection();
String sql = String sql =
"SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS, n1.DESCRIPTION," + "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS, n1.DESCRIPTION," +
" d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT " + " d.DEVICE_IDENTIFICATION, d.NAME as DEVICE_NAME, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT " +
"NOTIFICATION_ID, DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " + "NOTIFICATION_ID, DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " +
"TENANT_ID = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID AND TENANT_ID = ?"; "TENANT_ID = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID AND TENANT_ID = ?";
@ -86,7 +86,7 @@ public class GenericNotificationDAOImpl extends AbstractNotificationDAOImpl {
try { try {
conn = NotificationManagementDAOFactory.getConnection(); conn = NotificationManagementDAOFactory.getConnection();
String sql = "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS," + String sql = "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS," +
" n1.DESCRIPTION, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM " + " n1.DESCRIPTION, d.DEVICE_IDENTIFICATION, d.NAME as DEVICE_NAME, t.NAME AS DEVICE_TYPE FROM " +
"DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT NOTIFICATION_ID, DEVICE_ID, " + "DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT NOTIFICATION_ID, DEVICE_ID, " +
"OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " + "OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " +
"TENANT_ID = ? AND STATUS = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID " + "TENANT_ID = ? AND STATUS = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID " +

@ -47,7 +47,7 @@ public class OracleNotificationDAOImpl extends AbstractNotificationDAOImpl {
conn = NotificationManagementDAOFactory.getConnection(); conn = NotificationManagementDAOFactory.getConnection();
String sql = String sql =
"SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS, n1.DESCRIPTION," + "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS, n1.DESCRIPTION," +
" d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT " + " d.DEVICE_IDENTIFICATION, d.NAME as DEVICE_NAME, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT " +
"NOTIFICATION_ID, DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " + "NOTIFICATION_ID, DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " +
"TENANT_ID = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID AND TENANT_ID = ?"; "TENANT_ID = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID AND TENANT_ID = ?";
@ -86,7 +86,7 @@ public class OracleNotificationDAOImpl extends AbstractNotificationDAOImpl {
try { try {
conn = NotificationManagementDAOFactory.getConnection(); conn = NotificationManagementDAOFactory.getConnection();
String sql = "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS," + String sql = "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS," +
" n1.DESCRIPTION, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM " + " n1.DESCRIPTION, d.DEVICE_IDENTIFICATION, d.NAME as DEVICE_NAME, t.NAME AS DEVICE_TYPE FROM " +
"DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT NOTIFICATION_ID, DEVICE_ID, " + "DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT NOTIFICATION_ID, DEVICE_ID, " +
"OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " + "OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " +
"TENANT_ID = ? AND STATUS = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID " + "TENANT_ID = ? AND STATUS = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID " +

@ -47,7 +47,7 @@ public class PostgreSQLNotificationDAOImpl extends AbstractNotificationDAOImpl {
conn = NotificationManagementDAOFactory.getConnection(); conn = NotificationManagementDAOFactory.getConnection();
String sql = String sql =
"SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS, n1.DESCRIPTION," + "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS, n1.DESCRIPTION," +
" d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT " + " d.DEVICE_IDENTIFICATION, d.NAME as DEVICE_NAME, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT " +
"NOTIFICATION_ID, DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " + "NOTIFICATION_ID, DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " +
"TENANT_ID = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID AND TENANT_ID = ?"; "TENANT_ID = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID AND TENANT_ID = ?";
@ -86,7 +86,7 @@ public class PostgreSQLNotificationDAOImpl extends AbstractNotificationDAOImpl {
try { try {
conn = NotificationManagementDAOFactory.getConnection(); conn = NotificationManagementDAOFactory.getConnection();
String sql = "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS," + String sql = "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS," +
" n1.DESCRIPTION, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM " + " n1.DESCRIPTION, d.DEVICE_IDENTIFICATION, d.NAME as DEVICE_NAME, t.NAME AS DEVICE_TYPE FROM " +
"DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT NOTIFICATION_ID, DEVICE_ID, " + "DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT NOTIFICATION_ID, DEVICE_ID, " +
"OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " + "OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " +
"TENANT_ID = ? AND STATUS = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID " + "TENANT_ID = ? AND STATUS = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID " +

@ -47,7 +47,7 @@ public class SQLServerNotificationDAOImpl extends AbstractNotificationDAOImpl {
conn = NotificationManagementDAOFactory.getConnection(); conn = NotificationManagementDAOFactory.getConnection();
String sql = String sql =
"SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS, n1.DESCRIPTION," + "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS, n1.DESCRIPTION," +
" d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT " + " d.DEVICE_IDENTIFICATION, d.NAME as DEVICE_NAME, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT " +
"NOTIFICATION_ID, DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " + "NOTIFICATION_ID, DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " +
"TENANT_ID = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID AND TENANT_ID = ?"; "TENANT_ID = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID AND TENANT_ID = ?";
@ -86,7 +86,7 @@ public class SQLServerNotificationDAOImpl extends AbstractNotificationDAOImpl {
try { try {
conn = NotificationManagementDAOFactory.getConnection(); conn = NotificationManagementDAOFactory.getConnection();
String sql = "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS," + String sql = "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS," +
" n1.DESCRIPTION, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM " + " n1.DESCRIPTION, d.DEVICE_IDENTIFICATION, d.NAME as DEVICE_NAME, t.NAME AS DEVICE_TYPE FROM " +
"DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT NOTIFICATION_ID, DEVICE_ID, " + "DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT NOTIFICATION_ID, DEVICE_ID, " +
"OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " + "OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " +
"TENANT_ID = ? AND STATUS = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID " + "TENANT_ID = ? AND STATUS = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID " +

@ -132,6 +132,7 @@ public class NotificationDAOUtil {
notification.setDescription(rs.getString("DESCRIPTION")); notification.setDescription(rs.getString("DESCRIPTION"));
notification.setStatus(rs.getString("STATUS")); notification.setStatus(rs.getString("STATUS"));
notification.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION")); notification.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
notification.setDeviceName(rs.getString("DEVICE_NAME"));
notification.setDeviceType(rs.getString("DEVICE_TYPE")); notification.setDeviceType(rs.getString("DEVICE_TYPE"));
return notification; return notification;
} }

@ -46,9 +46,9 @@ public class SQLServerOperationDAOImpl extends GenericOperationDAOImpl {
List<Operation> operations = new ArrayList<Operation>(); List<Operation> operations = new ArrayList<Operation>();
try { try {
Connection conn = OperationManagementDAOFactory.getConnection(); Connection conn = OperationManagementDAOFactory.getConnection();
String sql = "SELECT o.ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, " + String sql = "SELECT o.ID, TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, " +
"OPERATION_CODE, om.STATUS FROM DM_OPERATION o " + "o.OPERATION_CODE, om.STATUS, om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP FROM DM_OPERATION o " +
"INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " + "INNER JOIN (SELECT dm.OPERATION_ID, dm.ID, dm.STATUS, dm.UPDATED_TIMESTAMP FROM DM_ENROLMENT_OP_MAPPING dm " +
"WHERE dm.ENROLMENT_ID = ?) om ON o.ID = om.OPERATION_ID ORDER BY o.CREATED_TIMESTAMP DESC " + "WHERE dm.ENROLMENT_ID = ?) om ON o.ID = om.OPERATION_ID ORDER BY o.CREATED_TIMESTAMP DESC " +
"OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
@ -62,18 +62,19 @@ public class SQLServerOperationDAOImpl extends GenericOperationDAOImpl {
operation.setId(rs.getInt("ID")); operation.setId(rs.getInt("ID"));
operation.setType(Operation.Type.valueOf(rs.getString("TYPE"))); operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString()); operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
if (rs.getTimestamp("RECEIVED_TIMESTAMP") == null) { if (rs.getLong("UPDATED_TIMESTAMP") == 0) {
operation.setReceivedTimeStamp(""); operation.setReceivedTimeStamp("");
} else { } else {
operation.setReceivedTimeStamp(rs.getTimestamp("RECEIVED_TIMESTAMP").toString()); operation.setReceivedTimeStamp(
new java.sql.Timestamp((rs.getLong("UPDATED_TIMESTAMP") * 1000)).toString());
} }
operation.setCode(rs.getString("OPERATION_CODE")); operation.setCode(rs.getString("OPERATION_CODE"));
operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS"))); operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
operations.add(operation); operations.add(operation);
} }
} catch (SQLException e) { } catch (SQLException e) {
throw new OperationManagementDAOException("SQL error occurred while retrieving the operation " + throw new OperationManagementDAOException("SQL error occurred while retrieving the operations " +
"available for the device'" + enrolmentId + "' with status '", e); "available for the device '" + enrolmentId + "'", e);
} finally { } finally {
OperationManagementDAOUtil.cleanupResources(stmt, rs); OperationManagementDAOUtil.cleanupResources(stmt, rs);
} }
@ -90,9 +91,9 @@ public class SQLServerOperationDAOImpl extends GenericOperationDAOImpl {
List<Operation> operations = new ArrayList<Operation>(); List<Operation> operations = new ArrayList<Operation>();
try { try {
Connection conn = OperationManagementDAOFactory.getConnection(); Connection conn = OperationManagementDAOFactory.getConnection();
String sql = "SELECT o.ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE " + String sql = "SELECT o.ID, TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.OPERATION_CODE, " +
"FROM DM_OPERATION o " + "om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP FROM DM_OPERATION o " +
"INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " + "INNER JOIN (SELECT dm.OPERATION_ID, dm.ID, dm.STATUS, dm.UPDATED_TIMESTAMP FROM DM_ENROLMENT_OP_MAPPING dm " +
"WHERE dm.ENROLMENT_ID = ? AND dm.STATUS = ?) om ON o.ID = om.OPERATION_ID ORDER BY " + "WHERE dm.ENROLMENT_ID = ? AND dm.STATUS = ?) om ON o.ID = om.OPERATION_ID ORDER BY " +
"o.CREATED_TIMESTAMP DESC OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; "o.CREATED_TIMESTAMP DESC OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
@ -107,17 +108,18 @@ public class SQLServerOperationDAOImpl extends GenericOperationDAOImpl {
operation.setId(rs.getInt("ID")); operation.setId(rs.getInt("ID"));
operation.setType(Operation.Type.valueOf(rs.getString("TYPE"))); operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString()); operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
if (rs.getTimestamp("RECEIVED_TIMESTAMP") == null) { if (rs.getLong("UPDATED_TIMESTAMP") == 0) {
operation.setReceivedTimeStamp(""); operation.setReceivedTimeStamp("");
} else { } else {
operation.setReceivedTimeStamp(rs.getTimestamp("RECEIVED_TIMESTAMP").toString()); operation.setReceivedTimeStamp(
new java.sql.Timestamp((rs.getLong("UPDATED_TIMESTAMP") * 1000)).toString());
} }
operation.setCode(rs.getString("OPERATION_CODE")); operation.setCode(rs.getString("OPERATION_CODE"));
operation.setStatus(status); operation.setStatus(status);
operations.add(operation); operations.add(operation);
} }
} catch (SQLException e) { } catch (SQLException e) {
throw new OperationManagementDAOException("SQL error occurred while retrieving the operation " + throw new OperationManagementDAOException("SQL error occurred while retrieving the operations " +
"available for the device'" + enrolmentId + "' with status '" + status.toString(), e); "available for the device'" + enrolmentId + "' with status '" + status.toString(), e);
} finally { } finally {
OperationManagementDAOUtil.cleanupResources(stmt, rs); OperationManagementDAOUtil.cleanupResources(stmt, rs);

@ -23,8 +23,9 @@ import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import java.util.HashMap; import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -205,7 +206,7 @@ public interface DeviceManagementProviderService {
Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException; Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException;
HashMap<Integer, Device> getTenantedDevice(DeviceIdentifier deviceIdentifier) throws DeviceManagementException; Device getDevice(DeviceIdentifier deviceId, Date since) throws DeviceManagementException;
Device getDevice(DeviceIdentifier deviceId, EnrolmentInfo.Status status) throws DeviceManagementException; Device getDevice(DeviceIdentifier deviceId, EnrolmentInfo.Status status) throws DeviceManagementException;

@ -831,6 +831,54 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
return device; return device;
} }
@Override
public Device getDevice(DeviceIdentifier deviceId, Date since) throws DeviceManagementException {
Device device;
try {
DeviceManagementDAOFactory.openConnection();
device = deviceDAO.getDevice(deviceId, since, this.getTenantId());
if (device == null) {
if (log.isDebugEnabled()) {
log.debug("No device is found upon the type '" + deviceId.getType() + "' and id '" +
deviceId.getId() + "'");
}
return null;
}
DeviceLocation location = deviceInfoDAO.getDeviceLocation(device.getId());
if (device.getDeviceInfo() != null) {
device.getDeviceInfo().setLocation(location);
}
List<Application> applications = applicationDAO.getInstalledApplications(device.getId());
device.setApplications(applications);
} catch (DeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while obtaining the device for id " +
"'" + deviceId.getId() + "'", e);
} catch (SQLException e) {
throw new DeviceManagementException("Error occurred while opening a connection to the data source", e);
} catch (DeviceDetailsMgtDAOException e) {
throw new DeviceManagementException("Error occurred while fetching advanced device information", e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
// The changes made here to prevent unit tests getting failed. They failed because when running the unit
// tests there is no osgi services. So getDeviceManager() returns a null.
DeviceManager deviceManager = this.getDeviceManager(deviceId.getType());
if (deviceManager == null) {
if (log.isDebugEnabled()) {
log.debug("Device Manager associated with the device type '" + deviceId.getType() + "' is null. " +
"Therefore, not attempting method 'getDevice'");
}
return device;
}
Device pluginSpecificInfo = deviceManager.getDevice(deviceId);
if (pluginSpecificInfo != null) {
device.setFeatures(pluginSpecificInfo.getFeatures());
device.setProperties(pluginSpecificInfo.getProperties());
}
return device;
}
@Override @Override
public Device getDevice(DeviceIdentifier deviceId, EnrolmentInfo.Status status) throws DeviceManagementException { public Device getDevice(DeviceIdentifier deviceId, EnrolmentInfo.Status status) throws DeviceManagementException {
Device device; Device device;

@ -15,7 +15,6 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
}} }}
{{unit "cdmf.unit.ui.title" pageTitle="Add Certificate"}} {{unit "cdmf.unit.ui.title" pageTitle="Add Certificate"}}
{{#zone "breadcrumbs"}} {{#zone "breadcrumbs"}}
@ -25,9 +24,8 @@
</a> </a>
</li> </li>
<li> <li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/certificates"> <a href="{{@app.context}}/certificates">
Certificates Certificate
</a> </a>
</li> </li>
{{/zone}} {{/zone}}
@ -35,7 +33,6 @@
{{#zone "navbarActions"}} {{#zone "navbarActions"}}
{{#if removePermitted}} {{#if removePermitted}}
<li> <li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/certificates/add"> <a href="{{@app.context}}/certificates/add">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
@ -100,7 +97,10 @@
</tr> </tr>
</thead> </thead>
<tbody id="ast-container"></tbody> <tbody id="ast-container">
<br class="c-both"/>
</tbody>
</table> </table>
</div> </div>
<br class="c-both"/> <br class="c-both"/>
@ -121,7 +121,7 @@
<a href="#" id="remove-certificate-yes-link" class="btn-operations"> <a href="#" id="remove-certificate-yes-link" class="btn-operations">
Remove Remove
</a> </a>
<a href="#" id="remove-certificate-cancel-link" class="btn-operations"> <a href="#" id="remove-certificate-cancel-link" class="btn-operations btn-default">
Cancel Cancel
</a> </a>
</div> </div>
@ -180,9 +180,9 @@
{{/zone}} {{/zone}}
{{#zone "bottomJs"}} {{#zone "bottomJs"}}
<!--suppress HtmlUnknownTarget -->
<script id="certificate-listing" data-current-user="{{@user.username}}" <script id="certificate-listing" data-current-user="{{@user.username}}"
src="{{@page.publicUri}}/templates/certificate-listing.hbs" src="{{@page.publicUri}}/templates/certificate-listing.hbs"
type="text/x-handlebars-template"></script> type="text/x-handlebars-template"></script>
{{js "/js/certificate-listing.js"}} {{js "/js/certificate-listing.js"}}
{{/zone}} {{/zone}}

@ -15,12 +15,12 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
}} }}
{{unit "cdmf.unit.ui.title" pageTitle="Dashboard"}} {{unit "cdmf.unit.ui.title" pageTitle="Resource Dashboard"}}
{{#zone "breadcrumbs"}} {{#zone "breadcrumbs"}}
<li> <li>
<a href="{{@app.context}}/"> <a href="{{@app.context}}/">
Dashboard Resource Dashboard
</a> </a>
</li> </li>
{{/zone}} {{/zone}}
@ -37,6 +37,7 @@
<div class="tile-stats"> <div class="tile-stats">
<span id="device-count">{{device_count}}</span> <span id="device-count">{{device_count}}</span>
<span class="tile-stats-free"> <span class="tile-stats-free">
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/devices"> <a href="{{@app.context}}/devices">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
@ -44,6 +45,7 @@
</span> </span>
View View
</a> </a>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/device/enroll"> <a href="{{@app.context}}/device/enroll">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
@ -66,6 +68,7 @@
<div class="tile-stats"> <div class="tile-stats">
<span id="group-count">{{group_count}}</span> <span id="group-count">{{group_count}}</span>
<span class="tile-stats-free"> <span class="tile-stats-free">
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/groups"> <a href="{{@app.context}}/groups">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
@ -73,6 +76,7 @@
</span> </span>
View View
</a> </a>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/group/add"> <a href="{{@app.context}}/group/add">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
@ -95,6 +99,7 @@
<div class="tile-stats"> <div class="tile-stats">
<span id="user-count">{{user_count}}</span> <span id="user-count">{{user_count}}</span>
<span class="tile-stats-free"> <span class="tile-stats-free">
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/users"> <a href="{{@app.context}}/users">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
@ -102,6 +107,7 @@
</span> </span>
View View
</a> </a>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/user/add"> <a href="{{@app.context}}/user/add">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
@ -124,6 +130,7 @@
<div class="tile-stats"> <div class="tile-stats">
<span id="policy-count">{{policy_count}}</span> <span id="policy-count">{{policy_count}}</span>
<span class="tile-stats-free"> <span class="tile-stats-free">
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/policies"> <a href="{{@app.context}}/policies">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
@ -131,6 +138,7 @@
</span> </span>
View View
</a> </a>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/policy/add"> <a href="{{@app.context}}/policy/add">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
@ -153,6 +161,7 @@
<div class="tile-stats"> <div class="tile-stats">
<span id="role-count">{{role_count}}</span> <span id="role-count">{{role_count}}</span>
<span class="tile-stats-free"> <span class="tile-stats-free">
<!--suppress HtmlUnknownTarget -->
<a id="device-count-view-btn" href="{{@app.context}}/roles"> <a id="device-count-view-btn" href="{{@app.context}}/roles">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
@ -160,6 +169,7 @@
</span> </span>
View View
</a> </a>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/roles/add-role"> <a href="{{@app.context}}/roles/add-role">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
@ -176,10 +186,8 @@
{{else}} {{else}}
Permission denied Permission denied
{{/if}} {{/if}}
</div> </div>
<div id="qr-code-modal" data-enrollment-url="{{enrollmentURL}}" class="hidden"> <div id="qr-code-modal" data-enrollment-url="{{enrollmentURL}}" class="hidden">
<div class="content"> <div class="content">
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
@ -189,7 +197,6 @@
<h4> <h4>
Please scan the QR code using your mobile device to retrieve enrollment URL. Please scan the QR code using your mobile device to retrieve enrollment URL.
</h4> </h4>
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-body col-centered "> <div class="panel-body col-centered ">
<div class="qr-code"></div> <div class="qr-code"></div>

@ -15,6 +15,27 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--> -->
{{#zone "breadcrumbs"}}
<li>
<a href="{{@app.context}}/">
<i class="icon fw fw-home"></i>
</a>
</li>
<li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/devices">
Devices
</a>
</li>
<li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/devices/search">
Search
</a>
</li>
{{/zone}}
{{#zone "content"}} {{#zone "content"}}
<!-- content/body --> <!-- content/body -->
<div class="row"> <div class="row">

@ -199,7 +199,7 @@
&nbsp;&nbsp;&nbsp;&nbsp;Assign&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Assign&nbsp;&nbsp;&nbsp;&nbsp;
</a> </a>
&nbsp;&nbsp; &nbsp;&nbsp;
<a href="#" id="group-device-cancel-link" class="btn-operations"> <a href="#" id="group-device-cancel-link" class="btn-operations btn-default">
&nbsp;&nbsp;&nbsp;&nbsp;Cancel&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Cancel&nbsp;&nbsp;&nbsp;&nbsp;
</a> </a>
</div> </div>

@ -109,7 +109,7 @@
&nbsp;&nbsp;&nbsp;&nbsp;Next&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Next&nbsp;&nbsp;&nbsp;&nbsp;
</a> </a>
&nbsp;&nbsp; &nbsp;&nbsp;
<a href="#" id="share-group-w1-cancel-link" class="btn-operations"> <a href="#" id="share-group-w1-cancel-link" class="btn-operations btn-default">
&nbsp;&nbsp;&nbsp;&nbsp;Cancel&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Cancel&nbsp;&nbsp;&nbsp;&nbsp;
</a> </a>
</div> </div>
@ -130,7 +130,7 @@
&nbsp;&nbsp;&nbsp;&nbsp;OK&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;OK&nbsp;&nbsp;&nbsp;&nbsp;
</a> </a>
&nbsp;&nbsp; &nbsp;&nbsp;
<a href="#" id="share-group-w2-cancel-link" class="btn-operations"> <a href="#" id="share-group-w2-cancel-link" class="btn-operations btn-default">
&nbsp;&nbsp;&nbsp;&nbsp;Cancel&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Cancel&nbsp;&nbsp;&nbsp;&nbsp;
</a> </a>
</div> </div>
@ -160,7 +160,7 @@
&nbsp;&nbsp;&nbsp;&nbsp;Yes&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Yes&nbsp;&nbsp;&nbsp;&nbsp;
</a> </a>
&nbsp;&nbsp; &nbsp;&nbsp;
<a href="#" id="remove-group-cancel-link" class="btn-operations"> <a href="#" id="remove-group-cancel-link" class="btn-operations btn-default">
&nbsp;&nbsp;&nbsp;&nbsp;Cancel&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Cancel&nbsp;&nbsp;&nbsp;&nbsp;
</a> </a>
</div> </div>
@ -203,7 +203,7 @@
&nbsp;&nbsp;&nbsp;&nbsp;Update&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Update&nbsp;&nbsp;&nbsp;&nbsp;
</a> </a>
&nbsp;&nbsp; &nbsp;&nbsp;
<a href="#" id="edit-group-cancel-link" class="btn-operations"> <a href="#" id="edit-group-cancel-link" class="btn-operations btn-default">
&nbsp;&nbsp;&nbsp;&nbsp;Cancel&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Cancel&nbsp;&nbsp;&nbsp;&nbsp;
</a> </a>
</div> </div>

@ -268,7 +268,7 @@
Remove Remove
</a> </a>
<a href="#" id="remove-policy-cancel-link" class="btn-operations"> <a href="#" id="remove-policy-cancel-link" class="btn-operations btn-default">
Cancel Cancel
</a> </a>
</div> </div>
@ -337,7 +337,7 @@
<div class="modal-footer"> <div class="modal-footer">
<div class="buttons"> <div class="buttons">
<a href="#" id="publish-policy-yes-link" class="btn-operations">Yes</a> <a href="#" id="publish-policy-yes-link" class="btn-operations">Yes</a>
<a href="#" id="publish-policy-cancel-link" class="btn-operations">No</a> <a href="#" id="publish-policy-cancel-link" class="btn-operations btn-default">No</a>
</div> </div>
</div> </div>
</div> </div>
@ -390,7 +390,7 @@
Yes Yes
</a> </a>
<a href="#" id="unpublish-policy-cancel-link" class="btn-operations"> <a href="#" id="unpublish-policy-cancel-link" class="btn-operations btn-default">
No No
</a> </a>
</div> </div>
@ -479,7 +479,7 @@
Yes Yes
</a> </a>
<a href="#" id="change-policy-cancel-link" class="btn-operations"> <a href="#" id="change-policy-cancel-link" class="btn-operations btn-default">
No No
</a> </a>
</div> </div>

@ -99,12 +99,9 @@ function formatRepo (user) {
var markup = '<div class="clearfix">' + var markup = '<div class="clearfix">' +
'<div class="col-sm-8">' + '<div class="col-sm-8">' +
'<div class="clearfix">' + '<div class="clearfix">' +
'<div class="col-sm-3">User : ' + user.username + '</div>'; '<div class="col-sm-4">' + user.username + '</div>';
if (user.name) { if (user.name || user.name != undefined) {
markup += '<div class="col-sm-3"> ' + user.name + '</div>'; markup += '<div class="col-sm-8"> ( ' + user.name + ' )</div>';
}
if (user.emailAddress) {
markup += '<div class="col-sm-3"> ' + user.emailAddress + '</div>';
} }
markup += '</div></div></div>'; markup += '</div></div></div>';
return markup; return markup;
@ -140,8 +137,9 @@ $(document).ready(function () {
var user = {}; var user = {};
user.id = value.username; user.id = value.username;
user.username = value.username; user.username = value.username;
if(value.firstname && value.lastname) {
user.name = value.firstname + " " + value.lastname; user.name = value.firstname + " " + value.lastname;
user.emailAddress = value.emailAddress; }
newData.push(user); newData.push(user);
}); });
return { return {

@ -114,7 +114,7 @@ function loadRoles() {
class: "remove-padding icon-only content-fill", class: "remove-padding icon-only content-fill",
data: null, data: null,
defaultContent: "<div class='thumbnail icon'>" + defaultContent: "<div class='thumbnail icon'>" +
"<i class='square-element text fw fw-bookmark' style='font-size: 30px;'></i>" + "<i class='square-element text fw fw-bookmark' style='font-size: 74px;'></i>" +
"</div>" "</div>"
}, },
{ {

@ -101,30 +101,32 @@ under the License.
<div id="remove-role-modal-content" class="hide"> <div id="remove-role-modal-content" class="hide">
<div class="content"> <div class="modal-header">
<div class="row"> <h3 class="pull-left modal-title">Do you really want to remove this role ?</h3>
<div class="col-lg-5 col-md-6 col-centered"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
<h3>Do you really want to remove this role ?</h3> </div>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
</div>
<div class="modal-footer">
<div class="buttons"> <div class="buttons">
<a href="#" id="remove-role-yes-link" class="btn-operations"> <a href="#" id="remove-role-yes-link" class="btn-operations">
Remove Remove
</a> </a>
<a href="#" id="remove-role-cancel-link" class="btn-operations"> <a href="#" id="remove-role-cancel-link" class="btn-operations btn-default">
Cancel Cancel
</a> </a>
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
<div id="remove-role-success-content" class="hide"> <div id="remove-role-success-content" class="hide">
<div class="content"> <div class="modal-header">
<div class="row"> <h3 class="pull-left modal-title">Done. Role was successfully removed.</h3>
<div class="col-lg-5 col-md-6 col-centered"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
<h3>Done. Role was successfully removed.</h3> </div>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
</div>
<div class="modal-footer">
<div class="buttons"> <div class="buttons">
<a href="#" id="remove-role-success-link" class="btn-operations"> <a href="#" id="remove-role-success-link" class="btn-operations">
Ok Ok
@ -132,15 +134,15 @@ under the License.
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
<div id="remove-role-error-content" class="hide"> <div id="remove-role-error-content" class="hide">
<div class="content"> <div class="modal-header">
<div class="row"> <h3 class="pull-left modal-title">An unexpected error occurred. Please try again later.</h3>
<div class="col-lg-5 col-md-6 col-centered"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
<h3>An unexpected error occurred. Please try again later.</h3> </div>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
</div>
<div class="modal-footer">
<div class="buttons"> <div class="buttons">
<a href="#" id="remove-role-error-link" class="btn-operations"> <a href="#" id="remove-role-error-link" class="btn-operations">
Ok Ok
@ -148,8 +150,6 @@ under the License.
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
{{/zone}} {{/zone}}
{{#zone "bottomJs"}} {{#zone "bottomJs"}}

@ -234,13 +234,8 @@ $(document).ready(function () {
addUserAPI, addUserAPI,
addUserFormData, addUserFormData,
function (data, textStatus, jqXHR) { function (data, textStatus, jqXHR) {
if (jqXHR.status == 201) { if (jqXHR.status == 200) {
// Clearing user input fields. // Clearing user input fields.
$("input#username").val("");
$("input#firstname").val("");
$("input#lastname").val("");
$("input#email").val("");
$("select#roles").select2("val", "");
// Refreshing with success message // Refreshing with success message
$("#user-create-form").addClass("hidden"); $("#user-create-form").addClass("hidden");
$("#user-created-msg").removeClass("hidden"); $("#user-created-msg").removeClass("hidden");

@ -273,7 +273,7 @@ function loadUsers() {
class: "remove-padding icon-only content-fill", class: "remove-padding icon-only content-fill",
data: null, data: null,
defaultContent: '<div class="thumbnail icon">' + defaultContent: '<div class="thumbnail icon">' +
'<i class="square-element text fw fw-user" style="font-size: 30px;"></i>' + '<i class="square-element text fw fw-user" style="font-size: 74px;"></i>' +
'</div>' '</div>'
}, },
{ {

@ -113,7 +113,7 @@
<div class="modal-footer"> <div class="modal-footer">
<div class="buttons"> <div class="buttons">
<a href="#" id="invite-user-yes-link" class="btn-operations">yes</a> <a href="#" id="invite-user-yes-link" class="btn-operations">yes</a>
<a href="#" id="invite-user-cancel-link" class="btn-operations">No</a> <a href="#" id="invite-user-cancel-link" class="btn-operations btn-default">No</a>
</div> </div>
</div> </div>
</div> </div>
@ -174,7 +174,7 @@
<div class="modal-footer"> <div class="modal-footer">
<div class="buttons"> <div class="buttons">
<a href="#" id="remove-user-yes-link" class="btn-operations">Remove</a> <a href="#" id="remove-user-yes-link" class="btn-operations">Remove</a>
<a href="#" id="remove-user-cancel-link" class="btn-operations">Cancel</a> <a href="#" id="remove-user-cancel-link" class="btn-operations btn-default">Cancel</a>
</div> </div>
</div> </div>
</div> </div>
@ -297,7 +297,7 @@
Save Save
</a> </a>
<a href="#" id="reset-password-cancel-link" class="btn-operations"> <a href="#" id="reset-password-cancel-link" class="btn-operations btn-default">
Cancel Cancel
</a> </a>
</div> </div>

@ -80,7 +80,9 @@ var operationModule = function () {
"AUTO_TIME" : "AUTO_TIME", "AUTO_TIME" : "AUTO_TIME",
"SET_SCREEN_CAPTURE_DISABLED" : "SET_SCREEN_CAPTURE_DISABLED", "SET_SCREEN_CAPTURE_DISABLED" : "SET_SCREEN_CAPTURE_DISABLED",
"SET_STATUS_BAR_DISABLED" : "SET_STATUS_BAR_DISABLED", "SET_STATUS_BAR_DISABLED" : "SET_STATUS_BAR_DISABLED",
"APPLICATION_OPERATION_CODE":"APP-RESTRICTION" "APPLICATION_OPERATION_CODE":"APP-RESTRICTION",
"SYSTEM_UPDATE_POLICY_CODE": "SYSTEM_UPDATE_POLICY",
"KIOSK_APPS_CODE": "KIOSK_APPS"
}; };
// Constants to define Windows Operation Constants // Constants to define Windows Operation Constants
@ -893,7 +895,7 @@ var operationModule = function () {
"ALLOW_PARENT_PROFILE_APP_LINKING" : operationData["disallowParentProfileAppLinking"], "ALLOW_PARENT_PROFILE_APP_LINKING" : operationData["disallowParentProfileAppLinking"],
"ENSURE_VERIFY_APPS" : operationData["ensureVerifyApps"], "ENSURE_VERIFY_APPS" : operationData["ensureVerifyApps"],
"AUTO_TIME" : operationData["enableAutoTime"], "AUTO_TIME" : operationData["enableAutoTime"],
"SET_SCREEN_CAPTURE_DISABLED" : operationData["diableScreenCapture"], "SET_SCREEN_CAPTURE_DISABLED" : operationData["disableScreenCapture"],
"SET_STATUS_BAR_DISABLED" : operationData["disableStatusBar"] "SET_STATUS_BAR_DISABLED" : operationData["disableStatusBar"]
} }
}; };
@ -1012,6 +1014,32 @@ var operationModule = function () {
} }
}; };
break; break;
case androidOperationConstants["SYSTEM_UPDATE_POLICY_CODE"]:
operationType = operationTypeConstants["PROFILE"];
if (operationData["cosuSystemUpdatePolicyType"] != "window") {
payload = {
"operation": {
"type": operationData["cosuSystemUpdatePolicyType"]
}
};
} else {
payload = {
"operation": {
"type": operationData["cosuSystemUpdatePolicyType"],
"startTime": operationData["cosuSystemUpdatePolicyWindowStartTime"],
"endTime": operationData["cosuSystemUpdatePolicyWindowEndTime"]
}
};
}
break;
case androidOperationConstants["KIOSK_APPS_CODE"]:
operationType = operationTypeConstants["PROFILE"];
payload = {
"operation": {
"whitelistedApplications": operationData["cosuWhitelistedApplications"]
}
};
break;
default: default:
// If the operation is neither of above, it is a command operation // If the operation is neither of above, it is a command operation
operationType = operationTypeConstants["COMMAND"]; operationType = operationTypeConstants["COMMAND"];
@ -1158,29 +1186,13 @@ var operationModule = function () {
publicMethods.getWindowsServiceEndpoint = function (operationCode) { publicMethods.getWindowsServiceEndpoint = function (operationCode) {
var featureMap = { var featureMap = {
"CAMERA": "camera", "DEVICE_LOCK": "lock-devices",
"DEVICE_LOCK": "lock", "DEVICE_RING": "ring-devices",
"DEVICE_LOCATION": "location", "LOCK_RESET": "lock-reset-devices",
"CLEAR_PASSWORD": "clear-password", "WIPE_DATA": "wipe-devices"
"APPLICATION_LIST": "get-application-list",
"DEVICE_RING": "ring-device",
"DEVICE_REBOOT": "reboot-device",
"UPGRADE_FIRMWARE": "upgrade-firmware",
"DEVICE_MUTE": "mute",
"LOCK_RESET": "lock-reset",
"NOTIFICATION": "notification",
"ENCRYPT_STORAGE": "encrypt",
"CHANGE_LOCK_CODE": "change-lock-code",
"WEBCLIP": "webclip",
"INSTALL_APPLICATION": "install-application",
"UNINSTALL_APPLICATION": "uninstall-application",
"BLACKLIST_APPLICATIONS": "blacklist-applications",
"PASSCODE_POLICY": "password-policy",
"ENTERPRISE_WIPE": "enterprise-wipe",
"WIPE_DATA": "wipe-data",
"DISENROLL": "disenroll"
}; };
return "/mdm-windows-agent/services/windows/operation/" + featureMap[operationCode]; //return "/mdm-windows-agent/services/windows/operation/" + featureMap[operationCode];
return "/api/device-mgt/windows/v1.0/admin/devices/" + featureMap[operationCode];
}; };
/** /**
* Get the icon for the featureCode * Get the icon for the featureCode
@ -1213,15 +1225,9 @@ var operationModule = function () {
publicMethods.getWindowsIconForFeature = function (operationCode) { publicMethods.getWindowsIconForFeature = function (operationCode) {
var featureMap = { var featureMap = {
"DEVICE_LOCK": "fw-lock", "DEVICE_LOCK": "fw-lock",
"DEVICE_LOCATION": "fw-map-location",
"DISENROLL": "fw-delete",
"WIPE_DATA": "fw-clear",
"DEVICE_RING": "fw-dial-up", "DEVICE_RING": "fw-dial-up",
"DEVICE_REBOOT": "fw-refresh", "LOCK_RESET": "fw-key",
"UPGRADE_FIRMWARE": "fw-up-arrow", "WIPE_DATA": "fw-clear"
"DEVICE_MUTE": "fw-incoming-call",
"NOTIFICATION": "fw-message",
"LOCK_RESET": "fw-key"
}; };
return featureMap[operationCode]; return featureMap[operationCode];
}; };
@ -1272,12 +1278,18 @@ var operationModule = function () {
var key = operationDataObj.data("key"); var key = operationDataObj.data("key");
var value; var value;
if (operationDataObj.is(":text") || operationDataObj.is("textarea") || if (operationDataObj.is(":text") || operationDataObj.is("textarea") ||
operationDataObj.is(":password") || operationDataObj.is(":hidden")) { operationDataObj.is(":password") || operationDataObj.is("input[type=hidden]")) {
value = operationDataObj.val(); value = operationDataObj.val();
operationData[key] = value;
} else if (operationDataObj.is(":checkbox")) { } else if (operationDataObj.is(":checkbox")) {
value = operationDataObj.is(":checked"); value = operationDataObj.is(":checked");
operationData[key] = value;
} else if (operationDataObj.is(":radio") && operationDataObj.is(":checked")) {
value = operationDataObj.val();
operationData[key] = value;
} else if (operationDataObj.is("select")) { } else if (operationDataObj.is("select")) {
value = operationDataObj.find("option:selected").attr("value"); value = operationDataObj.find("option:selected").attr("value");
operationData[key] = value;
} else if (operationDataObj.hasClass("grouped-array-input")) { } else if (operationDataObj.hasClass("grouped-array-input")) {
value = []; value = [];
var childInput; var childInput;
@ -1286,7 +1298,7 @@ var operationModule = function () {
$(".child-input", this).each(function () { $(".child-input", this).each(function () {
childInput = $(this); childInput = $(this);
if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password") if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password")
|| childInput.is(":hidden")) { || childInput.is("input[type=hidden]")) {
childInputValue = childInput.val(); childInputValue = childInput.val();
} else if (childInput.is(":checkbox")) { } else if (childInput.is(":checkbox")) {
childInputValue = childInput.is(":checked"); childInputValue = childInput.is(":checked");
@ -1313,7 +1325,7 @@ var operationModule = function () {
$(".child-input", this).each(function () { $(".child-input", this).each(function () {
childInput = $(this); childInput = $(this);
if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password") if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password")
|| childInput.is(":hidden")) { || childInput.is("input[type=hidden]")) {
childInputValue = childInput.val(); childInputValue = childInput.val();
} else if (childInput.is(":checkbox")) { } else if (childInput.is(":checkbox")) {
childInputValue = childInput.is(":checked"); childInputValue = childInput.is(":checked");
@ -1345,7 +1357,7 @@ var operationModule = function () {
childInput = $(this); childInput = $(this);
childInputKey = childInput.data("child-key"); childInputKey = childInput.data("child-key");
if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password") if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password")
|| childInput.is(":hidden")) { || childInput.is("input[type=hidden]")) {
childInputValue = childInput.val(); childInputValue = childInput.val();
} else if (childInput.is(":checkbox")) { } else if (childInput.is(":checkbox")) {
childInputValue = childInput.is(":checked"); childInputValue = childInput.is(":checked");
@ -1369,9 +1381,9 @@ var operationModule = function () {
} }
}); });
} }
}
operationData[key] = value; operationData[key] = value;
} }
}
); );
switch (platformType) { switch (platformType) {
@ -1421,10 +1433,15 @@ var operationModule = function () {
// populating input value according to the type of input // populating input value according to the type of input
if (operationDataObj.is(":text") || if (operationDataObj.is(":text") ||
operationDataObj.is("textarea") || operationDataObj.is("textarea") ||
operationDataObj.is(":password")) { operationDataObj.is(":password") ||
operationDataObj.is("input[type=hidden]")) {
operationDataObj.val(value); operationDataObj.val(value);
} else if (operationDataObj.is(":checkbox")) { } else if (operationDataObj.is(":checkbox")) {
operationDataObj.prop("checked", value); operationDataObj.prop("checked", value);
} else if (operationDataObj.is(":radio")) {
if (operationDataObj.val() == uiPayload[key]) {
operationDataObj.attr("checked", true);
}
} else if (operationDataObj.is("select")) { } else if (operationDataObj.is("select")) {
operationDataObj.val(value); operationDataObj.val(value);
/* trigger a change of value, so that if slidable panes exist, /* trigger a change of value, so that if slidable panes exist,
@ -1447,9 +1464,9 @@ var operationModule = function () {
var childInputValue = value[childInputIndex]; var childInputValue = value[childInputIndex];
// populating extracted value in the UI according to the input type // populating extracted value in the UI according to the input type
if (childInput.is(":text") || if (childInput.is(":text") ||
childInput.is(":hidden") ||
childInput.is("textarea") || childInput.is("textarea") ||
childInput.is(":password") || childInput.is(":password") ||
childInput.is("input[type=hidden]") ||
childInput.is("select")) { childInput.is("select")) {
childInput.val(childInputValue); childInput.val(childInputValue);
} else if (childInput.is(":checkbox")) { } else if (childInput.is(":checkbox")) {
@ -1495,9 +1512,9 @@ var operationModule = function () {
} }
// populating extracted value in the UI according to the input type // populating extracted value in the UI according to the input type
if (childInput.is(":text") || if (childInput.is(":text") ||
childInput.is(":hidden") ||
childInput.is("textarea") || childInput.is("textarea") ||
childInput.is(":password") || childInput.is(":password") ||
childInput.is("input[type=hidden]") ||
childInput.is("select")) { childInput.is("select")) {
childInput.val(childInputValue); childInput.val(childInputValue);
} else if (childInput.is(":checkbox")) { } else if (childInput.is(":checkbox")) {
@ -1524,9 +1541,9 @@ var operationModule = function () {
var childInputValue = multiColumnKeyValuePair[childInputKey]; var childInputValue = multiColumnKeyValuePair[childInputKey];
// populating extracted value in the UI according to the input type // populating extracted value in the UI according to the input type
if (childInput.is(":text") || if (childInput.is(":text") ||
childInput.is(":hidden") ||
childInput.is("textarea") || childInput.is("textarea") ||
childInput.is(":password") || childInput.is(":password") ||
childInput.is("input[type=hidden]") ||
childInput.is("select")) { childInput.is("select")) {
childInput.val(childInputValue); childInput.val(childInputValue);
} else if (childInput.is(":checkbox")) { } else if (childInput.is(":checkbox")) {
@ -1697,7 +1714,7 @@ var operationModule = function () {
restrictions["enableAutoTime"] = restriction["enabled"]; restrictions["enableAutoTime"] = restriction["enabled"];
continue; continue;
} else if (featureCode == androidOperationConstants["SET_SCREEN_CAPTURE_DISABLED"]){ } else if (featureCode == androidOperationConstants["SET_SCREEN_CAPTURE_DISABLED"]){
restrictions["diableScreenCapture"] = restriction["enabled"]; restrictions["disableScreenCapture"] = restriction["enabled"];
continue; continue;
} else if (featureCode == androidOperationConstants["SET_STATUS_BAR_DISABLED"]){ } else if (featureCode == androidOperationConstants["SET_STATUS_BAR_DISABLED"]){
restrictions["disableStatusBar"] = restriction["enabled"]; restrictions["disableStatusBar"] = restriction["enabled"];

@ -1,3 +1,21 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you 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. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/** /**
* Checks if provided input is valid against RegEx input. * Checks if provided input is valid against RegEx input.
* *
@ -21,34 +39,33 @@ $(document).ready(function () {
showPopup(); showPopup();
$("a#change-password-yes-link").click(function () { $("a#change-password-yes-link").click(function () {
var oldPassword = $("#old-password").val(); var currentPassword = $("#current-password").val();
var newPassword = $("#new-password").val(); var newPassword = $("#new-password").val();
var confirmedPassword = $("#confirmed-password").val(); var retypedNewPassword = $("#retyped-new-password").val();
var user = $("#user").val(); var user = $("#user").val();
var errorMsgWrapper = "#notification-error-msg"; var errorMsgWrapper = "#change-password-error-msg";
var errorMsg = "#notification-error-msg span"; var errorMsg = "#change-password-error-msg span";
if (!oldPassword) { if (!currentPassword) {
$(errorMsg).text("Old password is a required field. It cannot be empty."); $(errorMsg).text("Typing your current password is required. It cannot be empty.");
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} else if (!newPassword) { } else if (!newPassword) {
$(errorMsg).text("New password is a required field. It cannot be empty."); $(errorMsg).text("Typing your new password is required. It cannot be empty.");
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} else if (!confirmedPassword) { } else if (!retypedNewPassword) {
$(errorMsg).text("Retyping the new password is required."); $(errorMsg).text("Confirming your new password is required. It cannot be empty.");
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} else if (confirmedPassword != newPassword) { } else if (retypedNewPassword != newPassword) {
$(errorMsg).text("New password doesn't match the confirmation."); $(errorMsg).text("Password confirmation failed. Please check.");
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} else if (!inputIsValid(/^[\S]{5,30}$/, confirmedPassword)) { } else if (!inputIsValid(/^[\S]{5,30}$/, newPassword)) {
$(errorMsg).text("Password should be minimum 5 characters long, should not include any whitespaces."); $(errorMsg).text("Password should be minimum 5 characters long and " +
"should not include any whitespaces. Please check.");
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} else { } else {
var changePasswordFormData = {}; var changePasswordFormData = {};
//changePasswordFormData.username = user; changePasswordFormData["oldPassword"] = unescape((currentPassword));
changePasswordFormData.newPassword = unescape((confirmedPassword)); changePasswordFormData["newPassword"] = unescape((newPassword));
changePasswordFormData.oldPassword = unescape((oldPassword));
var changePasswordAPI = "/api/device-mgt/v1.0/users/" + user + "/credentials"; var changePasswordAPI = "/api/device-mgt/v1.0/users/" + user + "/credentials";
@ -64,7 +81,7 @@ $(document).ready(function () {
} }
}, function (jqXHR) { }, function (jqXHR) {
if (jqXHR.status == 400) { if (jqXHR.status == 400) {
$(errorMsg).text("Old password does not match with the provided value."); $(errorMsg).text("Your current password does not match with the provided value.");
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} else { } else {
$(errorMsg).text("An unexpected error occurred. Please try again later."); $(errorMsg).text("An unexpected error occurred. Please try again later.");

@ -15,73 +15,91 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
}} }}
{{#zone "userMenu-items"}} {{#zone "userMenu-items"}}
<li> <li>
<a href="javascript:void(0)" id="change-password">Change password</a> <a href="javascript:void(0)" id="change-password">Change password</a>
</li> </li>
<li> <li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/logout">Sign out</a> <a href="{{@app.context}}/logout">Sign out</a>
</li> </li>
<div id="change-password-window" class="hide"> <div id="change-password-window" class="hide">
<input type="hidden" id="user" value="{{username}}"> <input type="hidden" id="user" value="{{username}}">
<div class="modal-header"> <div class="modal-header">
<h3 class="pull-left modal-title"> <h4 class="pull-left modal-title">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-user fw-stack-2x"></i>
<span class="fw-stack fw-move-right fw-move-bottom">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-key fw-stack-1x"></i> <i class="fw fw-circle fw-stack-2x fw-stroke text-info"></i>
<i class="fw fw-edit fw-stack-1x fw-inverse"></i>
</span>
</span> </span>
Change Password &nbsp;&nbsp;Change password
</h3> </h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
</div> </div>
<hr>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x"> <div class="modal-body add-margin-top-2x add-margin-bottom-2x">
<div id="notification-error-msg" class="alert alert-danger hidden" role="alert"> <div id="change-password-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span> <i class="icon fw fw-error"></i><span></span>
</div> </div>
<h3> <h5>
Enter old password * Type your current password *
<br><br> <br><br>
<div> <div>
<input type="password" class="form-control modal-input operationDataKeys" id="old-password" data-key="message"/> <input id="current-password" type="password" class="form-control modal-input"/>
</div> </div>
<br> <br><br>
Enter new password * Type a new password *
<br><br> <br><br>
<div> <div>
<input type="password" class="form-control modal-input operationDataKeys" id="new-password" data-key="message"/> <input id="new-password" type="password" class="form-control modal-input"
placeholder="[ Password should be in minimum 5 characters long and should not include any whitespaces ]"/>
</div> </div>
<br> <br><br>
Retype new password * Reconfirm your new password *
<br><br> <br><br>
<div> <div>
<input type="password" class="form-control modal-input operationDataKeys" id="confirmed-password" data-key="message"/> <input id="retyped-new-password" type="password" class="form-control modal-input"/>
</div> </div>
<br> <br><br>
</h3> </h5>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<div class="buttons"> <div class="buttons">
<a href="#" id="change-password-yes-link" class="btn-operations">Update</a> <a href="#" id="change-password-yes-link" class="btn-operations">Change</a>
<a href="#" id="change-password-cancel-link" class="btn-operations">Cancel</a> <a href="#" id="change-password-cancel-link" class="btn-operations">Cancel</a>
</div> </div>
</div> </div>
</div> </div>
<div id="change-password-success-content" class="hide"> <div id="change-password-success-content" class="hide">
<div class="content"> <div class="modal-header">
<div class="row"> <h4 class="pull-left modal-title">
<div class="col-lg-5 col-md-6 col-centered"> <span class="fw-stack fw-move-right fw-move-bottom">
<h3>Password change is successful.</h3> <i class="fw fw-circle fw-stack-2x fw-stroke text-success"></i>
<div class="buttons"> <i class="fw fw-check fw-stack-1x fw-inverse"></i>
<a href="#" id="change-password-success-link" class="btn-operations">Ok</a> </span>
&nbsp;&nbsp;Password has been successfully updated
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
</div> </div>
<hr>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
<h5 class="text-center">
You can now try to login using your new password.
</h5>
</div> </div>
<div class="modal-footer">
<div class="buttons">
<a href="#" id="change-password-success-link" class="btn-operations">Ok</a>
</div> </div>
</div> </div>
</div> </div>
{{/zone}} {{/zone}}
{{#zone "bottomJs"}} {{#zone "bottomJs"}}
<script src="{{@unit.publicUri}}/js/user-menu.js"></script> {{js "/js/user-menu.js"}}
{{/zone}} {{/zone}}

@ -1,3 +1,21 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you 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. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function onRequest() { function onRequest() {
var constants = require("/app/modules/constants.js"); var constants = require("/app/modules/constants.js");
return session.get(constants["USER_SESSION_KEY"]); return session.get(constants["USER_SESSION_KEY"]);

@ -105,7 +105,7 @@
data-offset-top="80"> data-offset-top="80">
<ul class="sidebar-messages"> <ul class="sidebar-messages">
</ul> </ul>
<div class="text-center"><a href="{{appContext}}notification-listing" class="btn btn-primary">Show all notifications</a></div> <div class="text-center"><a href="{{appContext}}notification-listing" class="btn btn-primary">Show All Notifications</a></div>
</div> </div>
{{/zone}} {{/zone}}
{{#zone "bottomJs"}} {{#zone "bottomJs"}}

@ -102,23 +102,28 @@ function loadNewNotifications() {
if (responsePayload.count > 0) { if (responsePayload.count > 0) {
$(messageSideBar).html(template(viewModel)); $(messageSideBar).html(template(viewModel));
} else { } else {
$(messageSideBar).html("<h4 class='text-center'>No new notifications found...</h4>"); $(messageSideBar).html(
"<h4 class='text-center'>No New Notifications</h4>" +
"<h5 class='text-center text-muted'>" +
"Check this section for error notifications<br>related to device operations" +
"</h5>"
);
} }
} else { } else {
$(messageSideBar).html("<h4 class ='message-danger'>Unexpected error occurred while loading new notifications.</h4>"); $(messageSideBar).html("<h4 class ='message-danger text-center'>Unexpected error occurred while loading new notifications</h4>");
} }
} }
}; };
var errorCallback = function (jqXHR) { var errorCallback = function (jqXHR) {
if (jqXHR.status = 500) { if (jqXHR.status = 500) {
$(messageSideBar).html("<h4 class ='message-danger'>Unexpected error occurred while trying " + $(messageSideBar).html("<h4 class ='message-danger text-center'>Unexpected error occurred while trying " +
"to retrieve any new notifications.</h4>"); "to retrieve any new notifications</h4>");
} }
}; };
invokerUtil.get(serviceURL, successCallback, errorCallback); invokerUtil.get(serviceURL, successCallback, errorCallback);
}); });
} else { } else {
$(messageSideBar).html("<h4 class ='message-danger'>You are not authorized to view notifications</h4>"); $(messageSideBar).html("<h4 class ='message-danger text-center'>You are not authorized to view notifications</h4>");
} }
} }

@ -3369,7 +3369,7 @@ span.ico-sort-desc {
} }
.wr-input-label { .wr-input-label {
font-weight:100; font-weight:300;
font-size:14px; font-size:14px;
color:#555; color:#555;
} }
@ -4060,7 +4060,7 @@ a.wr-side-panel-toggle-btn.selected {
.wr-input-control.switch .text { .wr-input-control.switch .text {
display: none; display: none;
margin-left: 5px; margin-left: 5px;
font-weight: 100; font-weight: 400;
} }
.wr-input-control.switch input[type="checkbox"]:checked + .helper + .text { .wr-input-control.switch input[type="checkbox"]:checked + .helper + .text {
@ -4606,28 +4606,26 @@ a.wr-side-panel-toggle-btn.selected {
} }
.wr-hidden-operations-content .panel-body { .wr-hidden-operations-content .panel-body {
margin: 5px; padding: 0px 20px 20px;
/*border: 1px solid #e8e8e8;*/
padding: 5px 20px 30px;
background: #ffffff; background: #ffffff;
} }
.wr-hidden-operations-content .panel-body hr{
margin:0px;
margin-bottom:20px;
}
.wr-advance-operations.wizard-content .panel-title .fw-stack { .wr-advance-operations.wizard-content .panel-title .fw-stack {
width: 5px; width: 5px;
} }
.wr-hidden-operations-content .sub-title { .wr-hidden-operations-content .sub-title {
font-size: 16px; font-size: 18px;
} }
.wr-hidden-operations-content .panel-title { .wr-hidden-operations-content .panel-title {
margin-left: 5px;
margin-top: 5px;
margin-right: 5px;
/*border: 1px solid #e8e8e8;*/
padding: 20px; padding: 20px;
background: #ffffff; background: #ffffff;
color: #555; color: #555;
font-weight:400;
} }
.panel-title hr{ .panel-title hr{
@ -4635,10 +4633,13 @@ a.wr-side-panel-toggle-btn.selected {
} }
.wr-hidden-operations-content .panel-title-description { .wr-hidden-operations-content .panel-title-description {
padding-right: 20px; font-size: 16px;
padding:0px 20px;
background: #ffffff; background: #ffffff;
color: #555; color: #555;
line-height: 140%; line-height: 140%;
font-weight:300;
text-align:justify;
} }
.wr-hidden-operations-content .panel-title a { .wr-hidden-operations-content .panel-title a {

@ -5195,6 +5195,7 @@ button.list-group-item-danger.active:focus {
color: #333333; color: #333333;
background-color: #f5f5f5; background-color: #f5f5f5;
border-color: #ddd; border-color: #ddd;
border:none;
} }
.panel-default > .panel-heading + .panel-collapse > .panel-body { .panel-default > .panel-heading + .panel-collapse > .panel-body {
border-top-color: #ddd; border-top-color: #ddd;
@ -8084,7 +8085,7 @@ a.list-group-item:hover {
* ======================================================================== */ * ======================================================================== */
.switch { .switch {
display: inline-block; display: inline-block;
width: 40px; width: 90px;
cursor: pointer; cursor: pointer;
position: relative; position: relative;
margin-top: -4px; margin-top: -4px;

@ -35,7 +35,7 @@
@base-dark-color: #222; @base-dark-color: #222;
@base-light-color: #ffffff; @base-light-color: #ffffff;
@base-success-color: #5cb85c; @base-success-color: #5cb85c;
@base-info-color: #009DA7; @base-info-color: #526A84;
@base-warning-color: #f0ad4e; @base-warning-color: #f0ad4e;
@base-danger-color: #d9534f; @base-danger-color: #d9534f;

Loading…
Cancel
Save