mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Merge branch 'master' of https://github.com/geethkokila/product-cdm
This commit is contained in:
commit
6082f1eaae
@ -65,7 +65,7 @@ public interface DeviceManagerService {
|
|||||||
* @return Status of enrollment
|
* @return Status of enrollment
|
||||||
* @throws DeviceManagementException If some unusual behaviour is observed while enrolling a device
|
* @throws DeviceManagementException If some unusual behaviour is observed while enrolling a device
|
||||||
*/
|
*/
|
||||||
boolean isRegistered(DeviceIdentifier deviceId) throws DeviceManagementException;
|
boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to retrieve the status of a particular device.
|
* Method to retrieve the status of a particular device.
|
||||||
|
|||||||
@ -84,10 +84,10 @@ public class DeviceManager implements DeviceManagerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRegistered(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
DeviceManagerService dms =
|
DeviceManagerService dms =
|
||||||
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
||||||
return dms.isRegistered(deviceId);
|
return dms.isEnrolled(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -46,8 +46,8 @@ public class DeviceManagementService implements DeviceManagerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRegistered(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
return DeviceManagementDataHolder.getInstance().getDeviceManager().isRegistered(deviceId);
|
return DeviceManagementDataHolder.getInstance().getDeviceManager().isEnrolled(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -50,7 +50,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRegistered(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,7 @@ public class IOSDeviceManagerService implements DeviceManagerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRegistered(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,7 @@ public class WindowsDeviceManagerService implements DeviceManagerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRegistered(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,10 +19,10 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.wso2.carbon</groupId>
|
<groupId>org.wso2.cdmserver</groupId>
|
||||||
<artifactId>wso2cdm-parent</artifactId>
|
<artifactId>wso2cdmserver-product</artifactId>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<relativePath>../../../../../pom.xml</relativePath>
|
<relativePath>../../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@ -47,7 +47,7 @@
|
|||||||
<artifactId>maven-war-plugin</artifactId>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
<version>2.2</version>
|
<version>2.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<!--<packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>-->
|
<packagingExcludes>WEB-INF/lib/*cxf*.jar</packagingExcludes>
|
||||||
<warName>${project.artifactId}</warName>
|
<warName>${project.artifactId}</warName>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|||||||
@ -21,10 +21,12 @@ import com.google.gson.JsonObject;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.context.CarbonContext;
|
import org.wso2.carbon.context.CarbonContext;
|
||||||
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
|
||||||
|
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
|
||||||
|
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
@ -36,66 +38,133 @@ import javax.ws.rs.core.Response;
|
|||||||
public class Enrollment {
|
public class Enrollment {
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(Enrollment.class);
|
private static Log log = LogFactory.getLog(Enrollment.class);
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
public Response enrollDevice() {
|
public Response enrollDevice() {
|
||||||
JsonObject result = new JsonObject();
|
boolean result = false;
|
||||||
result.addProperty("senderId","jwwfowrjwqporqwrpqworpq");
|
int status = 0;
|
||||||
CarbonContext context = CarbonContext.getThreadLocalCarbonContext();
|
String msg = "";
|
||||||
DeviceManagementService dmService = (DeviceManagementService) context.getOSGiService(DeviceManagementService.class,null);
|
DeviceManagementService dmService;
|
||||||
Device device = AndroidAPIUtil.convertToDeviceObject(result);
|
|
||||||
try {
|
try {
|
||||||
dmService.enrollDevice(device);
|
PrivilegedCarbonContext.startTenantFlow();
|
||||||
} catch (DeviceManagementException e) {
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
String msg = "Error occurred while enrolling the device";
|
ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
|
||||||
log.error(msg, e);
|
ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
|
||||||
|
|
||||||
|
dmService = (DeviceManagementService) ctx
|
||||||
|
.getOSGiService(DeviceManagementService.class, null);
|
||||||
|
} finally {
|
||||||
|
PrivilegedCarbonContext.endTenantFlow();
|
||||||
}
|
}
|
||||||
return Response.status(201).entity("Registration Successful").build();
|
Device device = AndroidAPIUtil.convertToDeviceObject(null);
|
||||||
|
try {
|
||||||
|
result = dmService.enrollDevice(device);
|
||||||
|
status = 1;
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
msg = "Error occurred while enrolling the device";
|
||||||
|
log.error(msg, e);
|
||||||
|
status = -1;
|
||||||
|
}
|
||||||
|
switch (status) {
|
||||||
|
case 1:
|
||||||
|
if (result) {
|
||||||
|
return Response.status(201).entity("Registration Successful").build();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
return Response.status(500).entity(msg).build();
|
||||||
|
}
|
||||||
|
return Response.status(400).entity("Registration Failed").build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
public Response isEnrolled(@PathParam("id") String id) {
|
public Response isEnrolled(@PathParam("id") String id) {
|
||||||
boolean status = false;
|
boolean result = false;
|
||||||
|
int status = 0;
|
||||||
|
String msg = "";
|
||||||
CarbonContext context = CarbonContext.getThreadLocalCarbonContext();
|
CarbonContext context = CarbonContext.getThreadLocalCarbonContext();
|
||||||
DeviceManagementService dmService = (DeviceManagementService) context.getOSGiService(DeviceManagementService.class,null);
|
DeviceManagementService dmService = (DeviceManagementService) context
|
||||||
|
.getOSGiService(DeviceManagementService.class, null);
|
||||||
try {
|
try {
|
||||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtil.convertToDeviceIdentifierObject(id);
|
DeviceIdentifier deviceIdentifier = AndroidAPIUtil.convertToDeviceIdentifierObject(id);
|
||||||
status = dmService.isRegistered(deviceIdentifier);
|
result = dmService.isEnrolled(deviceIdentifier);
|
||||||
|
status = 1;
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
String msg = "Error occurred while checking enrollment of the device";
|
msg = "Error occurred while checking enrollment of the device";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
|
status = -1;
|
||||||
}
|
}
|
||||||
return Response.status(200).entity(status).build();
|
switch (status) {
|
||||||
|
case 1:
|
||||||
|
if (result) {
|
||||||
|
return Response.status(200).entity(result).build();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
return Response.status(500).entity(msg).build();
|
||||||
|
}
|
||||||
|
return Response.status(404).entity(result).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Consumes("application/json")
|
@Consumes("application/json")
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
public Response modifyEnrollment(@PathParam("id") String id) {
|
public Response modifyEnrollment(@PathParam("id") String id) {
|
||||||
boolean status = false;
|
boolean result = false;
|
||||||
|
int status = 0;
|
||||||
|
String msg = "";
|
||||||
CarbonContext context = CarbonContext.getThreadLocalCarbonContext();
|
CarbonContext context = CarbonContext.getThreadLocalCarbonContext();
|
||||||
DeviceManagementService dmService = (DeviceManagementService) context.getOSGiService(DeviceManagementService.class,null);
|
DeviceManagementService dmService = (DeviceManagementService) context
|
||||||
|
.getOSGiService(DeviceManagementService.class, null);
|
||||||
|
Device device = AndroidAPIUtil.convertToDeviceObject(null);
|
||||||
try {
|
try {
|
||||||
status = dmService.isRegistered(null);
|
result = dmService.modifyEnrollment(device);
|
||||||
|
status = 1;
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
String msg = "Error occurred while modifying enrollment of the device";
|
msg = "Error occurred while modifying enrollment of the device";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
|
status = -1;
|
||||||
}
|
}
|
||||||
return Response.status(201).entity(status).build();
|
switch (status) {
|
||||||
|
case 1:
|
||||||
|
if (result) {
|
||||||
|
return Response.status(200).entity("Device information modified").build();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
return Response.status(500).entity(msg).build();
|
||||||
|
}
|
||||||
|
return Response.status(400).entity("Update enrollment failed").build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
public Response disenrollDevice(@PathParam("id") String id) {
|
public Response disenrollDevice(@PathParam("id") String id) {
|
||||||
boolean status = false;
|
boolean result = false;
|
||||||
|
int status = 0;
|
||||||
|
String msg = "";
|
||||||
CarbonContext context = CarbonContext.getThreadLocalCarbonContext();
|
CarbonContext context = CarbonContext.getThreadLocalCarbonContext();
|
||||||
DeviceManagementService dmService = (DeviceManagementService) context.getOSGiService(DeviceManagementService.class,null);
|
DeviceManagementService dmService = (DeviceManagementService) context
|
||||||
|
.getOSGiService(DeviceManagementService.class, null);
|
||||||
try {
|
try {
|
||||||
status = dmService.isRegistered(null);
|
DeviceIdentifier deviceIdentifier = AndroidAPIUtil.convertToDeviceIdentifierObject(id);
|
||||||
|
result = dmService.disenrollDevice(deviceIdentifier);
|
||||||
|
status = 1;
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
String msg = "Error occurred while disenrolling the device";
|
msg = "Error occurred while disenrolling the device";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
|
status = -1;
|
||||||
}
|
}
|
||||||
return Response.status(201).entity(status).build();
|
switch (status) {
|
||||||
|
case 1:
|
||||||
|
if (result) {
|
||||||
|
return Response.status(200).entity(result).build();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
return Response.status(500).entity(msg).build();
|
||||||
|
}
|
||||||
|
return Response.status(404).entity("Device not found").build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -323,12 +323,12 @@
|
|||||||
<outputDirectory>wso2cdm-${project.version}/repository/conf/multitenancy/</outputDirectory>
|
<outputDirectory>wso2cdm-${project.version}/repository/conf/multitenancy/</outputDirectory>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
</file>
|
</file>
|
||||||
<file>
|
<!--<file>
|
||||||
<source>src/repository/conf/axis2/axis2.xml</source>
|
<source>src/repository/conf/axis2/axis2.xml</source>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/conf/axis2/</outputDirectory>
|
<outputDirectory>wso2cdm-${project.version}/repository/conf/axis2/</outputDirectory>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
<fileMode>644</fileMode>
|
<fileMode>644</fileMode>
|
||||||
</file>
|
</file>-->
|
||||||
<file>
|
<file>
|
||||||
<source>src/repository/conf/application-authenticators.xml</source>
|
<source>src/repository/conf/application-authenticators.xml</source>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/conf/security/</outputDirectory>
|
<outputDirectory>wso2cdm-${project.version}/repository/conf/security/</outputDirectory>
|
||||||
|
|||||||
@ -34,6 +34,7 @@
|
|||||||
<name>WSO2 Connected Device Manager (CDM) - Parent</name>
|
<name>WSO2 Connected Device Manager (CDM) - Parent</name>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
<!--<module>modules/agents/android/jax-rs</module>-->
|
||||||
<module>modules/p2-profile-gen</module>
|
<module>modules/p2-profile-gen</module>
|
||||||
<module>modules/distribution</module>
|
<module>modules/distribution</module>
|
||||||
<module>modules/integration</module>
|
<module>modules/integration</module>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user