mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Merging rest-api-improvements branch with master
This commit is contained in:
commit
1205d26463
@ -295,10 +295,10 @@ public class AndroidSenseServiceImpl implements AndroidSenseService {
|
|||||||
return Response.status(Response.Status.NOT_ACCEPTABLE.getStatusCode()).entity(false).build();
|
return Response.status(Response.Status.NOT_ACCEPTABLE.getStatusCode()).entity(false).build();
|
||||||
}
|
}
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
log.error(e.getErrorMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(false).build();
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(false).build();
|
||||||
} catch (ConfigurationManagementException e) {
|
} catch (ConfigurationManagementException e) {
|
||||||
log.error(e.getErrorMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(false).build();
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(false).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,7 @@
|
|||||||
<version>2.2</version>
|
<version>2.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<packagingExcludes>WEB-INF/lib/*cxf*.jar</packagingExcludes>
|
<packagingExcludes>WEB-INF/lib/*cxf*.jar</packagingExcludes>
|
||||||
<warName>mdm-android-agent</warName>
|
<warName>api#device-mgt#android#v1.0</warName>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
@ -72,7 +72,7 @@
|
|||||||
<tasks>
|
<tasks>
|
||||||
<copy todir="${basedir}/../../../repository/deployment/server/webapps" overwrite="true">
|
<copy todir="${basedir}/../../../repository/deployment/server/webapps" overwrite="true">
|
||||||
<fileset dir="${basedir}/target">
|
<fileset dir="${basedir}/target">
|
||||||
<include name="mdm-android-agent.war" />
|
<include name="api#device-mgt#android#v1.0.war" />
|
||||||
</fileset>
|
</fileset>
|
||||||
</copy>
|
</copy>
|
||||||
</tasks>
|
</tasks>
|
||||||
@ -168,12 +168,6 @@
|
|||||||
<artifactId>commons-httpclient</artifactId>
|
<artifactId>commons-httpclient</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>io.swagger</groupId>
|
|
||||||
<artifactId>swagger-annotations</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
@ -188,5 +182,28 @@
|
|||||||
<artifactId>org.wso2.carbon.analytics.api</artifactId>
|
<artifactId>org.wso2.carbon.analytics.api</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-core</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-jaxrs</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>servlet-api</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import java.io.Serializable;
|
|||||||
description = "This class carries all information related to device lock operation.")
|
description = "This class carries all information related to device lock operation.")
|
||||||
public class DeviceLock extends AndroidOperation implements Serializable {
|
public class DeviceLock extends AndroidOperation implements Serializable {
|
||||||
|
|
||||||
@ApiModelProperty(name = "message", value = "Pop up message of the lock operation.", required = true)
|
@ApiModelProperty(name = "message", value = "Pop up message of the lock operation.", required = false)
|
||||||
private String message;
|
private String message;
|
||||||
@ApiModelProperty(name = "isHardLockEnabled", value = "Hard lock enable status of the Device", required = true)
|
@ApiModelProperty(name = "isHardLockEnabled", value = "Hard lock enable status of the Device", required = true)
|
||||||
private boolean isHardLockEnabled;
|
private boolean isHardLockEnabled;
|
||||||
|
|||||||
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.mdm.services.android.bean;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@ApiModel(description = "")
|
||||||
|
public class ErrorListItem {
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private String code = null;
|
||||||
|
@NotNull
|
||||||
|
private String message = null;
|
||||||
|
|
||||||
|
@ApiModelProperty(required = true, value = "")
|
||||||
|
@JsonProperty("code")
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorListItem() {}
|
||||||
|
|
||||||
|
public ErrorListItem(String code, String msg) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description about individual errors occurred
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(required = true, value = "Description about individual errors occurred")
|
||||||
|
@JsonProperty("message")
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("errorItem {\n");
|
||||||
|
|
||||||
|
sb.append(" code: ").append(code).append("\n");
|
||||||
|
sb.append(" message: ").append(message).append("\n");
|
||||||
|
sb.append("}\n");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,193 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.mdm.services.android.bean;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@ApiModel(description = "")
|
||||||
|
public class ErrorResponse {
|
||||||
|
|
||||||
|
private Long code = null;
|
||||||
|
private String message = null;
|
||||||
|
private String description = null;
|
||||||
|
private String moreInfo = null;
|
||||||
|
private List<ErrorListItem> errorItems = new ArrayList<>();
|
||||||
|
|
||||||
|
private ErrorResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty(value = "code")
|
||||||
|
@ApiModelProperty(required = true, value = "")
|
||||||
|
public Long getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(Long code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty(value = "message")
|
||||||
|
@ApiModelProperty(required = true, value = "ErrorResponse message.")
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty(value = "description")
|
||||||
|
@ApiModelProperty(value = "A detail description about the error message.")
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty(value = "moreInfo")
|
||||||
|
@ApiModelProperty(value = "Preferably an url with more details about the error.")
|
||||||
|
public String getMoreInfo() {
|
||||||
|
return moreInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMoreInfo(String moreInfo) {
|
||||||
|
this.moreInfo = moreInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addErrorListItem(ErrorListItem item) {
|
||||||
|
this.errorItems.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If there are more than one error list them out. \nFor example, list out validation errors by each field.
|
||||||
|
*/
|
||||||
|
@JsonProperty(value = "errorItems")
|
||||||
|
@ApiModelProperty(value = "If there are more than one error list them out. \n" +
|
||||||
|
"For example, list out validation errors by each field.")
|
||||||
|
public List<ErrorListItem> getErrorItems() {
|
||||||
|
return errorItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorItems(List<ErrorListItem> error) {
|
||||||
|
this.errorItems = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
// StringBuilder sb = new StringBuilder();
|
||||||
|
// sb.append("{");
|
||||||
|
// boolean cont = false;
|
||||||
|
// if (code != null) {
|
||||||
|
// cont = true;
|
||||||
|
// sb.append(" \"code\": ").append(code);
|
||||||
|
// }
|
||||||
|
// if (message != null) {
|
||||||
|
// if (cont) {
|
||||||
|
// sb.append(",");
|
||||||
|
// }
|
||||||
|
// cont = true;
|
||||||
|
// sb.append(" \"message\": \"").append(message).append("\"");
|
||||||
|
// }
|
||||||
|
// if (description != null) {
|
||||||
|
// if (cont) {
|
||||||
|
// sb.append(",");
|
||||||
|
// }
|
||||||
|
// cont = true;
|
||||||
|
// sb.append(" \"description\": ").append(description).append("\"");
|
||||||
|
// }
|
||||||
|
// if (moreInfo != null) {
|
||||||
|
// if (cont) {
|
||||||
|
// sb.append(",");
|
||||||
|
// }
|
||||||
|
// cont = true;
|
||||||
|
// sb.append(" \"moreInfo\": \"").append(moreInfo).append("\"");
|
||||||
|
// }
|
||||||
|
// if (error != null && error.size() > 0) {
|
||||||
|
// if (cont) {
|
||||||
|
// sb.append(",");
|
||||||
|
// }
|
||||||
|
// sb.append(" \"errorItems\": ").append(error);
|
||||||
|
// }
|
||||||
|
// sb.append("}");
|
||||||
|
// return sb.toString();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ErrorResponseBuilder {
|
||||||
|
|
||||||
|
private Long code = null;
|
||||||
|
private String message = null;
|
||||||
|
private String description = null;
|
||||||
|
private String moreInfo = null;
|
||||||
|
private List<ErrorListItem> error;
|
||||||
|
|
||||||
|
|
||||||
|
public ErrorResponseBuilder() {
|
||||||
|
this.error = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponseBuilder setCode(long code) {
|
||||||
|
this.code = code;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponseBuilder setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponseBuilder setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponseBuilder setMoreInfo(String moreInfo) {
|
||||||
|
this.moreInfo = moreInfo;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponseBuilder addErrorItem(String code, String msg) {
|
||||||
|
ErrorListItem item = new ErrorListItem();
|
||||||
|
item.setCode(code);
|
||||||
|
item.setMessage(msg);
|
||||||
|
this.error.add(item);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponse build() {
|
||||||
|
ErrorResponse errorResponse = new ErrorResponse();
|
||||||
|
errorResponse.setCode(code);
|
||||||
|
errorResponse.setMessage(message);
|
||||||
|
errorResponse.setErrorItems(error);
|
||||||
|
errorResponse.setDescription(description);
|
||||||
|
errorResponse.setMoreInfo(moreInfo);
|
||||||
|
return errorResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -30,14 +30,25 @@ import java.io.Serializable;
|
|||||||
description = "Details related to notifications passed to device.")
|
description = "Details related to notifications passed to device.")
|
||||||
public class Notification extends AndroidOperation implements Serializable {
|
public class Notification extends AndroidOperation implements Serializable {
|
||||||
|
|
||||||
@ApiModelProperty(name = "message", value = "The message to be sent to the device.", required = true)
|
@ApiModelProperty(name = "messageText", value = "The message text to be sent to the device.", required = true)
|
||||||
private String message;
|
private String messageText;
|
||||||
|
|
||||||
public String getMessage() {
|
@ApiModelProperty(name = "messageTitle", value = "The message title to be sent to the device.", required = true)
|
||||||
return message;
|
private String messageTitle;
|
||||||
|
|
||||||
|
public String getMessageText() {
|
||||||
|
return messageText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessage(String message) {
|
public void setMessageText(String messageText) {
|
||||||
this.message = message;
|
this.messageText = messageText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessageTitle() {
|
||||||
|
return messageTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageTitle(String messageTitle) {
|
||||||
|
this.messageTitle = messageTitle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,24 +29,29 @@ import java.io.Serializable;
|
|||||||
@ApiModel(value = "UpgradeFirmware",
|
@ApiModel(value = "UpgradeFirmware",
|
||||||
description = "This class carries all information related to UpgradeFirmware.")
|
description = "This class carries all information related to UpgradeFirmware.")
|
||||||
public class UpgradeFirmware extends AndroidOperation implements Serializable {
|
public class UpgradeFirmware extends AndroidOperation implements Serializable {
|
||||||
@ApiModelProperty(name = "schedule", value = "Schedule of the UpgradeFirmware.")
|
|
||||||
|
@ApiModelProperty(name = "schedule", value = "Schedule of the UpgradeFirmware.", required = true)
|
||||||
private String schedule;
|
private String schedule;
|
||||||
|
|
||||||
@ApiModelProperty(name = "server", value = "Firmware package server.")
|
@ApiModelProperty(name = "server", value = "Firmware package server.")
|
||||||
private String server;
|
private String server;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public String getSchedule() {
|
public String getSchedule() {
|
||||||
return schedule;
|
return schedule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public void setSchedule(String schedule) {
|
public void setSchedule(String schedule) {
|
||||||
this.schedule = schedule;
|
this.schedule = schedule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public String getServer() {
|
public String getServer() {
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public void setServer(String server) {
|
public void setServer(String server) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,7 @@ import java.util.List;
|
|||||||
@ApiModel(value = "DeviceLockBeanWrapper",
|
@ApiModel(value = "DeviceLockBeanWrapper",
|
||||||
description = "DeviceLock related Information.")
|
description = "DeviceLock related Information.")
|
||||||
public class DeviceLockBeanWrapper {
|
public class DeviceLockBeanWrapper {
|
||||||
|
|
||||||
@ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true)
|
@ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true)
|
||||||
private List<String> deviceIDs;
|
private List<String> deviceIDs;
|
||||||
@ApiModelProperty(name = "operation", value = "Information of the Device lock operation.", required = true)
|
@ApiModelProperty(name = "operation", value = "Information of the Device lock operation.", required = true)
|
||||||
@ -50,4 +51,5 @@ public class DeviceLockBeanWrapper {
|
|||||||
public void setOperation(DeviceLock operation) {
|
public void setOperation(DeviceLock operation) {
|
||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,4 +46,5 @@ public class DisenrollmentBeanWrapper {
|
|||||||
public void setDeviceIDs(List<String> deviceIDs) {
|
public void setDeviceIDs(List<String> deviceIDs) {
|
||||||
this.deviceIDs = deviceIDs;
|
this.deviceIDs = deviceIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
@ApiModel(value = "EventBeanWrapper",
|
@ApiModel(value = "EventBeanWrapper",
|
||||||
description = "Android agent's event related Information.")
|
description = "Android agent's event related Information.")
|
||||||
public class EventBeanWrapper {
|
public class EventBeanWrapper {
|
||||||
|
|
||||||
@ApiModelProperty(name = "deviceIdentifier", value = "DeviceIdentifier to be need to retrieve/publish Event.", required = true)
|
@ApiModelProperty(name = "deviceIdentifier", value = "DeviceIdentifier to be need to retrieve/publish Event.", required = true)
|
||||||
private String deviceIdentifier;
|
private String deviceIdentifier;
|
||||||
@ApiModelProperty(name = "payload", value = "Event payload.", required = true)
|
@ApiModelProperty(name = "payload", value = "Event payload.", required = true)
|
||||||
|
|||||||
@ -51,4 +51,5 @@ public class NotificationBeanWrapper {
|
|||||||
public void setOperation(Notification operation) {
|
public void setOperation(Notification operation) {
|
||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.mdm.services.android.exception;
|
package org.wso2.carbon.mdm.services.android.exception;
|
||||||
|
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
||||||
import org.wso2.carbon.mdm.services.android.util.Message;
|
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||||
|
|
||||||
import javax.ws.rs.WebApplicationException;
|
import javax.ws.rs.WebApplicationException;
|
||||||
@ -29,8 +30,8 @@ import javax.ws.rs.core.Response;
|
|||||||
*/
|
*/
|
||||||
public class BadRequestException extends WebApplicationException {
|
public class BadRequestException extends WebApplicationException {
|
||||||
|
|
||||||
public BadRequestException(Message message, MediaType mediaType) {
|
public BadRequestException(ErrorResponse error) {
|
||||||
super(Response.status(Response.Status.BAD_REQUEST).entity(message).
|
super(Response.status(Response.Status.BAD_REQUEST).entity(error).build());
|
||||||
type(mediaType).build());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.mdm.services.android.exception;
|
||||||
|
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
||||||
|
import javax.ws.rs.WebApplicationException;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
public class NotFoundException extends WebApplicationException {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 147943572342342340L;
|
||||||
|
|
||||||
|
public NotFoundException(ErrorResponse error) {
|
||||||
|
super(Response.status(Response.Status.NOT_FOUND).entity(error).build());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.mdm.services.android.exception;
|
||||||
|
|
||||||
|
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
||||||
|
|
||||||
|
import javax.ws.rs.WebApplicationException;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
public class UnexpectedServerErrorException extends WebApplicationException {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 147943579458906890L;
|
||||||
|
|
||||||
|
public UnexpectedServerErrorException(ErrorResponse error) {
|
||||||
|
super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,319 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.mdm.services.android.services;
|
||||||
|
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
|
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
||||||
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
|
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Api(value = "Android Device Management",
|
||||||
|
description = "This carries all the resources related to Android device management functionalities")
|
||||||
|
@Path("/devices")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public interface DeviceManagementService {
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("/{id}/applications")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "PUT",
|
||||||
|
value = "Update the application list of a device",
|
||||||
|
tags = "Android Device Management"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Application list has been updated successfully",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Location",
|
||||||
|
description = "The URL of the updated application list."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description = "Date and time the resource has been modified the last time.\n" +
|
||||||
|
"Used by caches, or in conditional requests.")}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request. \n Invalid request or validation error."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "Not Found. \n Resource to be deleted does not exist."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 415,
|
||||||
|
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n " +
|
||||||
|
"Server error occurred while updating the application list.")
|
||||||
|
})
|
||||||
|
Response updateApplicationList(
|
||||||
|
@ApiParam(
|
||||||
|
name = "id",
|
||||||
|
value = "Device Identifier")
|
||||||
|
@PathParam("id") String id,
|
||||||
|
@ApiParam(
|
||||||
|
name = "applications",
|
||||||
|
value = "List of applications that need to be persisted against the device")
|
||||||
|
List<Application> applications);
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("/{id}/pending-operations")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "PUT",
|
||||||
|
value = "Get the operation list pending for the device",
|
||||||
|
responseContainer = "List",
|
||||||
|
notes = "The Android agent communicates with the server to get the operations that are queued up " +
|
||||||
|
"at the server end for a given device using via this particular resource",
|
||||||
|
response = Operation.class,
|
||||||
|
tags = "Android Device Management")
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully fetched the pending application list of the Android device.",
|
||||||
|
response = Operation.class,
|
||||||
|
responseContainer = "List",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description = "Date and time the resource has been modified the last time.\n" +
|
||||||
|
"Used by caches, or in conditional requests.")
|
||||||
|
}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 304,
|
||||||
|
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 406,
|
||||||
|
message = "Not Acceptable.\n The requested media type is not supported"),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n Server error occurred while fetching policies.")
|
||||||
|
})
|
||||||
|
Response getPendingOperations(
|
||||||
|
@ApiParam(
|
||||||
|
name = "id",
|
||||||
|
value = "Device Identifier")
|
||||||
|
@PathParam("id") String id,
|
||||||
|
@ApiParam(
|
||||||
|
name = "If-Modified-Since",
|
||||||
|
value = "Validates if the requested variant has not been modified since the time specified",
|
||||||
|
required = false)
|
||||||
|
@HeaderParam("If-Modified-Since") String ifModifiedSince,
|
||||||
|
@ApiParam(
|
||||||
|
name = "resultOperations",
|
||||||
|
value = "Device Operation Status")
|
||||||
|
List<? extends Operation> resultOperations);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Register an Android Device",
|
||||||
|
notes = "When carrying out device registration via an Android device, you need to initially install" +
|
||||||
|
" an Android Agent on the device, before being able to register the device with WSO2 EMM. Instead," +
|
||||||
|
" you can use this REST API to register an Android device with WSO2 EMM, without having to install" +
|
||||||
|
" an Android Agent on the respective device",
|
||||||
|
tags = "Android Device Management"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 201,
|
||||||
|
message = "Created. \n Device enrollment has successfully been created",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Location",
|
||||||
|
description = "URL of the added device enrollment."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "Content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description = "Date and time the resource has been modified the last time.\n" +
|
||||||
|
"Used by caches, or in conditional requests.")}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 303,
|
||||||
|
message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Location",
|
||||||
|
description = "The Source URL of the document.")}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request. \n Invalid request or validation error."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 415,
|
||||||
|
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n " +
|
||||||
|
"Server error occurred while adding a new policy.")
|
||||||
|
})
|
||||||
|
Response enrollDevice(@ApiParam(name = "device", value = "Device Information to be enroll") Device device);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/{id}/status")
|
||||||
|
@ApiOperation(
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Getting the Registration Status of an Android Device",
|
||||||
|
notes = "Use this REST API to retrieve the registration status of an Android device",
|
||||||
|
tags = "Android Device Management"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully fetched the status of the Android device enrollment.",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description = "Date and time the resource has been modified the last time.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 304,
|
||||||
|
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 406,
|
||||||
|
message = "Not Acceptable.\n The requested media type is not supported"),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n Server error occurred while fetching the enrollment status of the Android device.")
|
||||||
|
})
|
||||||
|
Response isEnrolled(
|
||||||
|
@ApiParam(
|
||||||
|
name = "id",
|
||||||
|
value = "Device Identifier")
|
||||||
|
@PathParam("id") String id,
|
||||||
|
@ApiParam(
|
||||||
|
name = "If-Modified-Since",
|
||||||
|
value = "Validates if the requested variant has not been modified since the time specified",
|
||||||
|
required = false)
|
||||||
|
@HeaderParam("If-Modified-Since") String ifModifiedSince);
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("/{id}")
|
||||||
|
@ApiOperation(
|
||||||
|
httpMethod = "PUT",
|
||||||
|
value = "Updating the Registration Details of an Android Device",
|
||||||
|
notes = "Use this REST API to update the registration details of an Android device",
|
||||||
|
tags = "Android Device Management"
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Device enrollment has been updated successfully",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Location",
|
||||||
|
description = "URL of the updated device enrollment."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "Content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description = "Date and time the resource has been modified the last time.\n" +
|
||||||
|
"Used by caches, or in conditional requests.")}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request. \n Invalid request or validation error."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "Not Found. \n Resource to be deleted does not exist."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 415,
|
||||||
|
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n " +
|
||||||
|
"Server error occurred while updating the device enrollment.")
|
||||||
|
})
|
||||||
|
Response modifyEnrollment(
|
||||||
|
@ApiParam(
|
||||||
|
name = "id",
|
||||||
|
value = "Device Identifier")
|
||||||
|
@PathParam("id") String id,
|
||||||
|
@ApiParam(
|
||||||
|
name = "device",
|
||||||
|
value = "Device information to be modify") Device device);
|
||||||
|
|
||||||
|
@DELETE
|
||||||
|
@Path("/{id}")
|
||||||
|
@ApiOperation(
|
||||||
|
httpMethod = "DELETE",
|
||||||
|
value = "Un-register an Android Device",
|
||||||
|
notes = "Use this REST API to un-register a specific Android device",
|
||||||
|
tags = "Android Device Management"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Device has successfully been dis-enrolled"),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "Not Found. \n Resource to be deleted does not exist."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n " +
|
||||||
|
"Server error occurred while dis-enrolling the device.")
|
||||||
|
})
|
||||||
|
Response disEnrollDevice(
|
||||||
|
@ApiParam(
|
||||||
|
name = "id",
|
||||||
|
value = "Device Identifier")
|
||||||
|
@PathParam("id") String id);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,179 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.mdm.services.android.services;
|
||||||
|
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
||||||
|
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
||||||
|
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
@Api(value = "Android Configuration Management", description = "This API carries all resource associated with " +
|
||||||
|
"manipulating the general configurations of Android platform")
|
||||||
|
@Path("/configuration")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public interface DeviceTypeConfigurationService {
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Getting Android Platform Configurations",
|
||||||
|
notes = "Get the Android platform configuration details using this REST API",
|
||||||
|
response = PlatformConfiguration.class,
|
||||||
|
tags = "Android Configuration Management"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully fetched Android platform configuration.",
|
||||||
|
response = PlatformConfiguration.class,
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "Content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description = "Date and time the resource has been modified the last time.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 304,
|
||||||
|
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "Not Found. \n Resource to be deleted does not exist."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 406,
|
||||||
|
message = "Not Acceptable.\n The requested media type is not supported"),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n Server error occurred while fetching Android platform configuration.")
|
||||||
|
})
|
||||||
|
Response getConfiguration(
|
||||||
|
@ApiParam(
|
||||||
|
name = "If-Modified-Since",
|
||||||
|
value = "Validates if the requested variant has not been modified since the time specified",
|
||||||
|
required = false)
|
||||||
|
@HeaderParam("If-Modified-Since") String ifModifiedSince);
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "PUT",
|
||||||
|
value = "Updating Android Platform Configuration.",
|
||||||
|
notes = "Update the Android platform configurations using this REST API.",
|
||||||
|
tags = "Android Configuration Management"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Android platform configuration has been updated successfully",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Location",
|
||||||
|
description = "URL of the updated Android platform configuration."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "Content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description = "Date and time the resource has been modified the last time.\n" +
|
||||||
|
"Used by caches, or in conditional requests.")}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request. \n Invalid request or validation error."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "Not Found. \n Resource to be deleted does not exist."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 415,
|
||||||
|
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n " +
|
||||||
|
"Server error occurred while modifying Android platform configuration.")
|
||||||
|
})
|
||||||
|
Response updateConfiguration(
|
||||||
|
@ApiParam(name = "configuration",
|
||||||
|
value = "AndroidPlatformConfiguration")
|
||||||
|
PlatformConfiguration configuration);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("license")
|
||||||
|
@Produces(MediaType.TEXT_PLAIN)
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.TEXT_PLAIN,
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Getting the License Agreement for Android Device Registration",
|
||||||
|
notes = "Use this REST API to retrieve the license agreement that is used for the Android device " +
|
||||||
|
"registration process",
|
||||||
|
response = String.class,
|
||||||
|
tags = "Android Configuration Management")
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully fetched Android license configuration.",
|
||||||
|
response = PlatformConfiguration.class,
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "Content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description = "Date and time the resource has been modified the last time.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 304,
|
||||||
|
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "Not Found. \n Resource to be deleted does not exist."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 406,
|
||||||
|
message = "Not Acceptable.\n The requested media type is not supported"),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n Server error occurred while fetching Android license configuration.")
|
||||||
|
})
|
||||||
|
Response getLicense(
|
||||||
|
@ApiParam(
|
||||||
|
name = "If-Modified-Since",
|
||||||
|
value = "Validates if the requested variant has not been modified since the time specified",
|
||||||
|
required = false)
|
||||||
|
@HeaderParam("If-Modified-Since") String ifModifiedSince) throws AndroidAgentException;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,157 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.mdm.services.android.services;
|
||||||
|
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.DeviceState;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper;
|
||||||
|
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
@Api(value = "Event Receiver", description = "Event publishing/retrieving related APIs.To enable Eventing need to" +
|
||||||
|
" configure as ref-https://docs.wso2.com/display/EMM210/Managing+Event+Publishing+with+WSO2+Data+Analytics+Server, " +
|
||||||
|
"https://docs.wso2.com/display/EMM210/Creating+a+New+Event+Stream+and+Receiver")
|
||||||
|
@Path("/events")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public interface EventReceiverService {
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/publish")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Event publishing via REST API.",
|
||||||
|
notes = "Publish events received by the EMM Android client to WSO2 DAS using this API.",
|
||||||
|
tags = "Event Receiver"
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(code = 201, message = "Created. \n Event is published successfully. Location header " +
|
||||||
|
"contains URL of newly enrolled device",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Location",
|
||||||
|
description = "The URL of the added policy."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description = "Date and time the resource has been modified the last time.\n" +
|
||||||
|
"Used by caches, or in conditional requests.")
|
||||||
|
}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 303,
|
||||||
|
message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Location",
|
||||||
|
description = "The Source URL of the document.")}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request. \n Invalid request or validation error."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 415,
|
||||||
|
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n " +
|
||||||
|
"Server error occurred while publishing events.")
|
||||||
|
})
|
||||||
|
Response publishEvents(
|
||||||
|
@ApiParam(
|
||||||
|
name = "eventBeanWrapper",
|
||||||
|
value = "Information of the agent event to be published on DAS.")
|
||||||
|
EventBeanWrapper eventBeanWrapper);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Getting event details for a given time period.",
|
||||||
|
notes = "Get the event details of a device for a given time duration using this API.Request must contain " +
|
||||||
|
"the device identifier. Optionally, both, date from and date to value should be present to get " +
|
||||||
|
"alerts between times. Based on device type and the device identifier also filtering can be done" +
|
||||||
|
"(This cannot be combined with to and from parameters).",
|
||||||
|
response = DeviceState.class,
|
||||||
|
responseContainer = "List",
|
||||||
|
tags = "Event Receiver"
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Event details of a device for a given time duration have been successfully fetched",
|
||||||
|
response = DeviceState.class, responseContainer = "List"),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 303,
|
||||||
|
message = "See Other. \n Source can be retrieved from the URL specified at" +
|
||||||
|
" the Location header.",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(name = "Content-Location", description = "Source URL of the document.")
|
||||||
|
}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 304,
|
||||||
|
message = "Not Modified. \n " +
|
||||||
|
"Empty body because the client already has the latest version of the requested resource."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request. \n Invalid request or validation error. You must provide" +
|
||||||
|
" the device identifier. Additionally, the device identifier can be combined with either the type" +
|
||||||
|
" OR date from and to."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "Not Found. \n Resource requested does not exist."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Error occurred while getting published events for specific device.")
|
||||||
|
})
|
||||||
|
Response retrieveAlerts(
|
||||||
|
@ApiParam(
|
||||||
|
name = "id",
|
||||||
|
value = "Device Identifier to be need to retrieve events.",
|
||||||
|
required = true)
|
||||||
|
@QueryParam("id") String deviceId,
|
||||||
|
@ApiParam(
|
||||||
|
name = "from",
|
||||||
|
value = "From Date.")
|
||||||
|
@QueryParam("from") long from,
|
||||||
|
@ApiParam(
|
||||||
|
name = "to",
|
||||||
|
value = "To Date.")
|
||||||
|
@QueryParam("to") long to,
|
||||||
|
@ApiParam(
|
||||||
|
name = "type",
|
||||||
|
value = "Type of the Alert to be need to retrieve events.")
|
||||||
|
@QueryParam("type") String type,
|
||||||
|
@ApiParam(
|
||||||
|
name = "If-Modified-Since",
|
||||||
|
value = "Validates if the requested variant has not been modified since the time specified",
|
||||||
|
required = false)
|
||||||
|
@HeaderParam("If-Modified-Since") String ifModifiedSince);
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,79 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.services.android.services.configuration;
|
|
||||||
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
|
||||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
|
||||||
import javax.ws.rs.*;
|
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Android Platform Configuration REST-API implementation.
|
|
||||||
* All end points supports JSON, XMl with content negotiation.
|
|
||||||
*/
|
|
||||||
@Api(value = "ConfigurationMgtService")
|
|
||||||
@Produces({"application/json", "application/xml"})
|
|
||||||
@Consumes({"application/json", "application/xml"})
|
|
||||||
public interface ConfigurationMgtService {
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Configuring Android Platform Settings",
|
|
||||||
notes = "Configure the Android platform settings using this REST API"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Android platform configuration saved successfully"),
|
|
||||||
@ApiResponse(code = 500, message = "Internal Server Error")
|
|
||||||
})
|
|
||||||
Response configureSettings(@ApiParam(name = "configuration", value = "AndroidPlatformConfiguration")
|
|
||||||
PlatformConfiguration configuration) throws AndroidAgentException;
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@ApiOperation(
|
|
||||||
httpMethod = "GET",
|
|
||||||
value = "Getting Android Platform Configurations",
|
|
||||||
notes = "Get the Android platform configuration details using this REST API",
|
|
||||||
response = PlatformConfiguration.class
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 200, message = "Get Android Configurations"),
|
|
||||||
@ApiResponse(code = 500, message = "Server Error")
|
|
||||||
})
|
|
||||||
Response getConfiguration() throws AndroidAgentException;
|
|
||||||
|
|
||||||
@PUT
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "PUT",
|
|
||||||
value = "Updating Android Platform Configurations",
|
|
||||||
notes = "Update the Android platform configurations using this REST API"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Error occurred while modifying configuration settings of " +
|
|
||||||
"Android platform")
|
|
||||||
})
|
|
||||||
Response updateConfiguration(@ApiParam(name = "configuration", value = "AndroidPlatformConfiguration")
|
|
||||||
PlatformConfiguration configuration) throws AndroidAgentException;
|
|
||||||
}
|
|
||||||
@ -1,145 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.services.android.services.devicemgt;
|
|
||||||
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
|
||||||
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
|
||||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
|
||||||
import javax.ws.rs.*;
|
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Android Device Management REST-API implementation.
|
|
||||||
* All end points supports JSON, XMl with content negotiation.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Api(value = "DeviceManagementService", description = "Android Device Management REST-API implementation.")
|
|
||||||
@Produces({"application/json", "application/xml"})
|
|
||||||
@Consumes({"application/json", "application/xml"})
|
|
||||||
public interface DeviceManagementService {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all devices.Returns list of Android devices registered in MDM.
|
|
||||||
*
|
|
||||||
* @return Device List
|
|
||||||
* @throws org.wso2.carbon.mdm.services.android.exception.AndroidAgentException
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@ApiOperation(
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "GET",
|
|
||||||
value = "Getting Details of All Android Devices",
|
|
||||||
notes = "Use this REST API to retrieve the details " +
|
|
||||||
"(e.g., the Android device type, serial number, International Mobile Station Equipment Identity " +
|
|
||||||
"(IMEI), owner, version, model etc.) of all Android devices that are registered with WSO2 EMM.",
|
|
||||||
response = Device.class,
|
|
||||||
responseContainer = "List"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 200, message = "List of Devices"),
|
|
||||||
@ApiResponse(code = 500, message = "Error occurred while fetching the device list")
|
|
||||||
})
|
|
||||||
Response getAllDevices() throws AndroidAgentException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetch Android device details of a given device Id.
|
|
||||||
*
|
|
||||||
* @param id Device Id
|
|
||||||
* @return Device
|
|
||||||
* @throws org.wso2.carbon.mdm.services.android.exception.AndroidAgentException
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@Path("{id}")
|
|
||||||
@ApiOperation(
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "GET",
|
|
||||||
value = "Getting Details of an Android Device",
|
|
||||||
notes = "Use this REST API to retrieve the details " +
|
|
||||||
"(e.g., the Android device type, serial number, International Mobile Station Equipment Identity " +
|
|
||||||
"(IMEI), owner, version, model etc.) of a specific Android device that is registered with WSO2 EMM",
|
|
||||||
response = Device.class
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 200, message = "Information of the given device"),
|
|
||||||
@ApiResponse(code = 500, message = "Error occurred while fetching the device information")
|
|
||||||
})
|
|
||||||
Response getDevice(@ApiParam(name = "id", value = "deviceIdentifier")
|
|
||||||
@PathParam("id") String id) throws AndroidAgentException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update Android device details of given device id.
|
|
||||||
*
|
|
||||||
* @param id Device Id
|
|
||||||
* @param device Device Details
|
|
||||||
* @return Message
|
|
||||||
* @throws AndroidAgentException
|
|
||||||
*/
|
|
||||||
@PUT
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "PUT",
|
|
||||||
value = "Updating the Details of an Android Device",
|
|
||||||
notes = "Use this REST API to update the details of an Android device"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 202, message = "The device enrollment details has been updated successfully"),
|
|
||||||
@ApiResponse(code = 500, message = "Error occurred while modifying the device information"),
|
|
||||||
@ApiResponse(code = 304, message = "Device not found for the update")
|
|
||||||
})
|
|
||||||
@Path("{id}")
|
|
||||||
Response updateDevice(@ApiParam(name = "id", value = "deviceIdentifier")
|
|
||||||
@PathParam("id") String id, @ApiParam(name = "device", value = "deviceIdentifier")
|
|
||||||
Device device) throws AndroidAgentException;
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Updating an ApplicationList",
|
|
||||||
notes = "Update application list in server side."
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 202, message = "Device information has modified successfully"),
|
|
||||||
@ApiResponse(code = 500, message = "Error occurred while modifying the application list")
|
|
||||||
})
|
|
||||||
Response updateApplicationList(@ApiParam(name = "id", value = "deviceIdentifier") @PathParam("id") String id,
|
|
||||||
@ApiParam(name = "applications", value = "updatable applications")
|
|
||||||
List<Application> applications) throws AndroidAgentException;
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("license")
|
|
||||||
@Produces("text/html")
|
|
||||||
@ApiOperation(
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "GET",
|
|
||||||
value = "Getting the License Agreement for Android Device Registration",
|
|
||||||
notes = "Use this REST API to retrieve the license agreement that is used for the Android device " +
|
|
||||||
"registration process",
|
|
||||||
response = String.class)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 200, message = "Licence agreement"),
|
|
||||||
@ApiResponse(code = 500, message = "Error occurred while retrieving the license configured for Android " +
|
|
||||||
"device enrolment")
|
|
||||||
})
|
|
||||||
Response getLicense() throws AndroidAgentException;
|
|
||||||
}
|
|
||||||
@ -1,179 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.services.android.services.devicemgt.impl;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
||||||
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.license.mgt.License;
|
|
||||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
|
||||||
import org.wso2.carbon.mdm.services.android.services.devicemgt.DeviceManagementService;
|
|
||||||
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
|
||||||
import org.wso2.carbon.mdm.services.android.util.Message;
|
|
||||||
import javax.ws.rs.*;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Android Device Management REST-API implementation.
|
|
||||||
* All end points supports JSON, XMl with content negotiation.
|
|
||||||
*/
|
|
||||||
@Produces({"application/json", "application/xml"})
|
|
||||||
@Consumes({"application/json", "application/xml"})
|
|
||||||
public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(DeviceManagementServiceImpl.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all devices.Returns list of Android devices registered in MDM.
|
|
||||||
*
|
|
||||||
* @return Device List
|
|
||||||
* @throws AndroidAgentException
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
public Response getAllDevices()
|
|
||||||
throws AndroidAgentException {
|
|
||||||
String msg;
|
|
||||||
List<Device> devices;
|
|
||||||
|
|
||||||
try {
|
|
||||||
devices = AndroidAPIUtils.getDeviceManagementService().
|
|
||||||
getAllDevices(DeviceManagementConstants.MobileDeviceTypes.
|
|
||||||
MOBILE_DEVICE_TYPE_ANDROID);
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
msg = "Error occurred while fetching the device list.";
|
|
||||||
log.error(msg, e);
|
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
||||||
}
|
|
||||||
return Response.status(Response.Status.OK).entity(devices).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetch Android device details of a given device Id.
|
|
||||||
*
|
|
||||||
* @param id Device Id
|
|
||||||
* @return Device
|
|
||||||
* @throws AndroidAgentException
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@Path("{id}")
|
|
||||||
public Response getDevice(@PathParam("id") String id)
|
|
||||||
throws AndroidAgentException {
|
|
||||||
|
|
||||||
String msg;
|
|
||||||
Device device;
|
|
||||||
|
|
||||||
try {
|
|
||||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
|
||||||
device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
|
|
||||||
if (device == null) {
|
|
||||||
return Response.status(Response.Status.NOT_FOUND).build();
|
|
||||||
}
|
|
||||||
} catch (DeviceManagementException deviceMgtEx) {
|
|
||||||
msg = "Error occurred while fetching the device information.";
|
|
||||||
log.error(msg, deviceMgtEx);
|
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
||||||
}
|
|
||||||
return Response.status(Response.Status.OK).entity(device).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update Android device details of given device id.
|
|
||||||
*
|
|
||||||
* @param id Device Id
|
|
||||||
* @param device Device Details
|
|
||||||
* @return Message
|
|
||||||
* @throws AndroidAgentException
|
|
||||||
*/
|
|
||||||
@PUT
|
|
||||||
@Path("{id}")
|
|
||||||
public Response updateDevice(@PathParam("id") String id, Device device)
|
|
||||||
throws AndroidAgentException {
|
|
||||||
String msg;
|
|
||||||
Message responseMessage = new Message();
|
|
||||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
|
||||||
deviceIdentifier.setId(id);
|
|
||||||
deviceIdentifier
|
|
||||||
.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
||||||
boolean result;
|
|
||||||
try {
|
|
||||||
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
||||||
result = AndroidAPIUtils.getDeviceManagementService()
|
|
||||||
.updateDeviceInfo(deviceIdentifier, device);
|
|
||||||
if (result) {
|
|
||||||
responseMessage.setResponseMessage("Device information has modified successfully.");
|
|
||||||
return Response.status(Response.Status.ACCEPTED).entity(responseMessage).build();
|
|
||||||
} else {
|
|
||||||
responseMessage.setResponseMessage("Device not found for the update.");
|
|
||||||
return Response.status(Response.Status.NOT_MODIFIED).entity(responseMessage).build();
|
|
||||||
}
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
msg = "Error occurred while modifying the device information.";
|
|
||||||
log.error(msg, e);
|
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("appList/{id}")
|
|
||||||
public Response updateApplicationList(@PathParam("id") String id, List<Application> applications)
|
|
||||||
throws
|
|
||||||
AndroidAgentException {
|
|
||||||
|
|
||||||
Message responseMessage = new Message();
|
|
||||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
|
||||||
deviceIdentifier.setId(id);
|
|
||||||
deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
||||||
try {
|
|
||||||
AndroidAPIUtils.getApplicationManagerService().
|
|
||||||
updateApplicationListInstalledInDevice(deviceIdentifier, applications);
|
|
||||||
responseMessage.setResponseMessage("Device information has modified successfully.");
|
|
||||||
return Response.status(Response.Status.ACCEPTED).entity(responseMessage).build();
|
|
||||||
} catch (ApplicationManagementException e) {
|
|
||||||
String msg = "Error occurred while modifying the application list.";
|
|
||||||
log.error(msg, e);
|
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("license")
|
|
||||||
@Produces("text/html")
|
|
||||||
public Response getLicense() throws AndroidAgentException {
|
|
||||||
License license = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
license =
|
|
||||||
AndroidAPIUtils.getDeviceManagementService().getLicense(
|
|
||||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID,
|
|
||||||
DeviceManagementConstants.LanguageCodes.LANGUAGE_CODE_ENGLISH_US);
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
String msg = "Error occurred while retrieving the license configured for Android device enrolment";
|
|
||||||
log.error(msg, e);
|
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
||||||
}
|
|
||||||
return Response.status(Response.Status.OK).entity((license == null) ? null : license.getText()).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,97 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.services.android.services.enrollment;
|
|
||||||
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
|
||||||
import javax.ws.rs.*;
|
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Android Device Enrollment REST-API implementation.
|
|
||||||
* All end points supports JSON, XMl with content negotiation.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Api(value = "EnrollmentService", description = "Android Device Enrollment REST-API implementation.")
|
|
||||||
@Produces({"application/json", "application/xml"})
|
|
||||||
@Consumes({"application/json", "application/xml"})
|
|
||||||
public interface EnrollmentService {
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Registering an Android Device",
|
|
||||||
notes = "When carrying out device registration via an Android device, you need to initially install" +
|
|
||||||
" an Android Agent on the device, before being able to register the device with WSO2 EMM. Instead," +
|
|
||||||
" you can use this REST API to register an Android device with WSO2 EMM, without having to install" +
|
|
||||||
" an Android Agent on the respective device"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Device enrollment succeeded"),
|
|
||||||
@ApiResponse(code = 500, message = "Device enrollment failed"),
|
|
||||||
})
|
|
||||||
Response enrollDevice(@ApiParam(name = "device", value = "Device Information to be enroll")
|
|
||||||
org.wso2.carbon.device.mgt.common.Device device) throws AndroidAgentException;
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("{deviceId}")
|
|
||||||
@ApiOperation(
|
|
||||||
httpMethod = "GET",
|
|
||||||
value = "Getting the Registration Status of an Android Device",
|
|
||||||
notes = "Use this REST API to retrieve the registration status of an Android device"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 202, message = "Device has already enrolled"),
|
|
||||||
@ApiResponse(code = 404, message = "Device not found")
|
|
||||||
})
|
|
||||||
Response isEnrolled(@ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId") String id)
|
|
||||||
throws AndroidAgentException;
|
|
||||||
|
|
||||||
@PUT
|
|
||||||
@Path("{deviceId}")
|
|
||||||
@ApiOperation(
|
|
||||||
httpMethod = "PUT",
|
|
||||||
value = "Updating the Registration Details of an Android Device",
|
|
||||||
notes = "Use this REST API to update the registration details of an Android device"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 202, message = "Device enrollment has updated successfully"),
|
|
||||||
@ApiResponse(code = 404, message = "Device not found for enrollment")
|
|
||||||
})
|
|
||||||
Response modifyEnrollment(@ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId") String id,
|
|
||||||
@ApiParam(name = "device", value = "Device information to be modify")
|
|
||||||
org.wso2.carbon.device.mgt.common.Device device)
|
|
||||||
throws AndroidAgentException;
|
|
||||||
|
|
||||||
@DELETE
|
|
||||||
@ApiOperation(
|
|
||||||
httpMethod = "DELETE",
|
|
||||||
value = "Un-registering an Android Device",
|
|
||||||
notes = "Use this REST API to unregister a specific Android device"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 202, message = "Device has removed successfully"),
|
|
||||||
@ApiResponse(code = 404, message = "Device not found")
|
|
||||||
})
|
|
||||||
@Path("{deviceId}")
|
|
||||||
Response disEnrollDevice(@ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId") String id)
|
|
||||||
throws AndroidAgentException;
|
|
||||||
}
|
|
||||||
@ -1,151 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.services.android.services.enrollment.impl;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
||||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
|
||||||
import org.wso2.carbon.mdm.services.android.services.enrollment.EnrollmentService;
|
|
||||||
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
|
||||||
import org.wso2.carbon.mdm.services.android.util.Message;
|
|
||||||
import javax.ws.rs.*;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Android Device Enrollment REST-API implementation.
|
|
||||||
* All end points supports JSON, XMl with content negotiation.
|
|
||||||
*/
|
|
||||||
@Produces({"application/json", "application/xml"})
|
|
||||||
@Consumes({"application/json", "application/xml"})
|
|
||||||
public class EnrollmentServiceImpl implements EnrollmentService {
|
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(EnrollmentService.class);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
public Response enrollDevice(org.wso2.carbon.device.mgt.common.Device device)
|
|
||||||
throws AndroidAgentException {
|
|
||||||
|
|
||||||
Message responseMsg = new Message();
|
|
||||||
String msg;
|
|
||||||
try {
|
|
||||||
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
||||||
device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser());
|
|
||||||
boolean status = AndroidAPIUtils.getDeviceManagementService().enrollDevice(device);
|
|
||||||
if (status) {
|
|
||||||
Response.status(Response.Status.CREATED);
|
|
||||||
responseMsg.setResponseMessage("Device enrollment succeeded.");
|
|
||||||
return Response.status(Response.Status.CREATED).entity(responseMsg).build();
|
|
||||||
} else {
|
|
||||||
Response.status(Response.Status.INTERNAL_SERVER_ERROR);
|
|
||||||
responseMsg.setResponseMessage("Device enrollment failed.");
|
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(responseMsg).build();
|
|
||||||
}
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
msg = "Error occurred while enrolling the device";
|
|
||||||
log.error(msg, e);
|
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("{deviceId}")
|
|
||||||
public Response isEnrolled(@PathParam("deviceId") String id) throws AndroidAgentException {
|
|
||||||
String msg;
|
|
||||||
boolean result;
|
|
||||||
Message responseMsg = new Message();
|
|
||||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
|
||||||
|
|
||||||
try {
|
|
||||||
result = AndroidAPIUtils.getDeviceManagementService().isEnrolled(deviceIdentifier);
|
|
||||||
if (result) {
|
|
||||||
responseMsg.setResponseMessage("Device has already enrolled");
|
|
||||||
responseMsg.setResponseCode(Response.Status.ACCEPTED.toString());
|
|
||||||
return Response.status(Response.Status.ACCEPTED).entity(responseMsg).build();
|
|
||||||
} else {
|
|
||||||
responseMsg.setResponseMessage("Device not found");
|
|
||||||
responseMsg.setResponseCode(Response.Status.NOT_FOUND.toString());
|
|
||||||
return Response.status(Response.Status.NOT_FOUND).entity(responseMsg).build();
|
|
||||||
}
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
msg = "Error occurred while checking enrollment status of the device.";
|
|
||||||
responseMsg.setResponseMessage(msg);
|
|
||||||
responseMsg.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR.toString());
|
|
||||||
Response.status(Response.Status.INTERNAL_SERVER_ERROR);
|
|
||||||
log.error(msg, e);
|
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@PUT
|
|
||||||
@Path("{deviceId}")
|
|
||||||
public Response modifyEnrollment(@PathParam("deviceId") String id,
|
|
||||||
org.wso2.carbon.device.mgt.common.Device device)
|
|
||||||
throws AndroidAgentException {
|
|
||||||
String msg;
|
|
||||||
boolean result;
|
|
||||||
Message responseMsg = new Message();
|
|
||||||
try {
|
|
||||||
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
||||||
result = AndroidAPIUtils.getDeviceManagementService().modifyEnrollment(device);
|
|
||||||
if (result) {
|
|
||||||
responseMsg.setResponseMessage("Device enrollment has updated successfully");
|
|
||||||
responseMsg.setResponseCode(Response.Status.ACCEPTED.toString());
|
|
||||||
return Response.status(Response.Status.ACCEPTED).entity(responseMsg).build();
|
|
||||||
} else {
|
|
||||||
responseMsg.setResponseMessage("Device not found for enrollment");
|
|
||||||
responseMsg.setResponseCode(Response.Status.NOT_MODIFIED.toString());
|
|
||||||
return Response.status(Response.Status.NOT_MODIFIED).entity(responseMsg).build();
|
|
||||||
}
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
msg = "Error occurred while modifying enrollment of the device";
|
|
||||||
log.error(msg, e);
|
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@DELETE
|
|
||||||
@Path("{deviceId}")
|
|
||||||
public Response disEnrollDevice(@PathParam("deviceId") String id) throws AndroidAgentException {
|
|
||||||
Message responseMsg = new Message();
|
|
||||||
boolean result;
|
|
||||||
String msg;
|
|
||||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
|
||||||
|
|
||||||
try {
|
|
||||||
result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier);
|
|
||||||
if (result) {
|
|
||||||
responseMsg.setResponseMessage("Device has removed successfully");
|
|
||||||
responseMsg.setResponseCode(Response.Status.ACCEPTED.toString());
|
|
||||||
return Response.status(Response.Status.ACCEPTED).entity(responseMsg).build();
|
|
||||||
} else {
|
|
||||||
responseMsg.setResponseMessage("Device not found");
|
|
||||||
responseMsg.setResponseCode(Response.Status.NOT_FOUND.toString());
|
|
||||||
return Response.status(Response.Status.NOT_FOUND).entity(responseMsg).build();
|
|
||||||
}
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
msg = "Error occurred while dis enrolling the device";
|
|
||||||
log.error(msg, e);
|
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,822 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.mdm.services.android.services.impl;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
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.core.operation.mgt.CommandOperation;
|
||||||
|
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.*;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.wrapper.*;
|
||||||
|
import org.wso2.carbon.mdm.services.android.exception.BadRequestException;
|
||||||
|
import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException;
|
||||||
|
import org.wso2.carbon.mdm.services.android.services.DeviceManagementAdminService;
|
||||||
|
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
||||||
|
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Path("/admin/devices")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminService {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(DeviceManagementAdminServiceImpl.class);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/lock-devices")
|
||||||
|
@Override
|
||||||
|
public Response configureDeviceLock(DeviceLockBeanWrapper deviceLockBeanWrapper) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking Android device lock operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (deviceLockBeanWrapper == null || deviceLockBeanWrapper.getOperation() == null) {
|
||||||
|
String errorMessage = "Lock bean is empty.";
|
||||||
|
log.error(errorMessage);
|
||||||
|
throw new BadRequestException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
DeviceLock lock = deviceLockBeanWrapper.getOperation();
|
||||||
|
ProfileOperation operation = new ProfileOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCK);
|
||||||
|
operation.setType(Operation.Type.PROFILE);
|
||||||
|
operation.setEnabled(true);
|
||||||
|
operation.setPayLoad(lock.toJSON());
|
||||||
|
return AndroidAPIUtils.getOperationResponse(deviceLockBeanWrapper.getDeviceIDs(), operation);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/unlock-devices")
|
||||||
|
@Override
|
||||||
|
public Response configureDeviceUnlock(List<String> deviceIDs) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking Android device unlock operation.");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
CommandOperation operation = new CommandOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.DEVICE_UNLOCK);
|
||||||
|
operation.setType(Operation.Type.COMMAND);
|
||||||
|
operation.setEnabled(true);
|
||||||
|
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/location")
|
||||||
|
@Override
|
||||||
|
public Response getDeviceLocation(List<String> deviceIDs) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking Android device location operation.");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
CommandOperation operation = new CommandOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCATION);
|
||||||
|
operation.setType(Operation.Type.COMMAND);
|
||||||
|
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/clear-password")
|
||||||
|
@Override
|
||||||
|
public Response removePassword(List<String> deviceIDs) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking Android clear password operation.");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
CommandOperation operation = new CommandOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.CLEAR_PASSWORD);
|
||||||
|
operation.setType(Operation.Type.COMMAND);
|
||||||
|
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance.";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/control-camera")
|
||||||
|
@Override
|
||||||
|
public Response configureCamera(CameraBeanWrapper cameraBeanWrapper) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking Android Camera operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (cameraBeanWrapper == null || cameraBeanWrapper.getOperation() == null) {
|
||||||
|
String errorMessage = "The payload of the configure camera operation is incorrect.";
|
||||||
|
log.error(errorMessage);
|
||||||
|
throw new BadRequestException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
Camera camera = cameraBeanWrapper.getOperation();
|
||||||
|
CommandOperation operation = new CommandOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.CAMERA);
|
||||||
|
operation.setType(Operation.Type.COMMAND);
|
||||||
|
operation.setEnabled(camera.isEnabled());
|
||||||
|
return AndroidAPIUtils.getOperationResponse(cameraBeanWrapper.getDeviceIDs(), operation);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/info")
|
||||||
|
@Override
|
||||||
|
public Response getDeviceInformation(List<String> deviceIDs) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking get Android device information operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
CommandOperation operation = new CommandOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.DEVICE_INFO);
|
||||||
|
operation.setType(Operation.Type.COMMAND);
|
||||||
|
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/enterprise-wipe")
|
||||||
|
@Override
|
||||||
|
public Response wipeDevice(List<String> deviceIDs) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking enterprise-wipe device operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
CommandOperation operation = new CommandOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.ENTERPRISE_WIPE);
|
||||||
|
operation.setType(Operation.Type.COMMAND);
|
||||||
|
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/wipe")
|
||||||
|
@Override
|
||||||
|
public Response wipeData(WipeDataBeanWrapper wipeDataBeanWrapper) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking Android wipe-data device operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (wipeDataBeanWrapper == null || wipeDataBeanWrapper.getOperation() == null) {
|
||||||
|
String errorMessage = "WipeData bean is empty.";
|
||||||
|
log.error(errorMessage);
|
||||||
|
throw new BadRequestException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
WipeData wipeData = wipeDataBeanWrapper.getOperation();
|
||||||
|
ProfileOperation operation = new ProfileOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.WIPE_DATA);
|
||||||
|
operation.setType(Operation.Type.PROFILE);
|
||||||
|
operation.setPayLoad(wipeData.toJSON());
|
||||||
|
return AndroidAPIUtils.getOperationResponse(wipeDataBeanWrapper.getDeviceIDs(), operation);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/applications")
|
||||||
|
@Override
|
||||||
|
public Response getApplications(List<String> deviceIDs) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking Android getApplicationList device operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
CommandOperation operation = new CommandOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.APPLICATION_LIST);
|
||||||
|
operation.setType(Operation.Type.COMMAND);
|
||||||
|
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/ring")
|
||||||
|
@Override
|
||||||
|
public Response ringDevice(List<String> deviceIDs) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking Android ring-device device operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
CommandOperation operation = new CommandOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.DEVICE_RING);
|
||||||
|
operation.setType(Operation.Type.COMMAND);
|
||||||
|
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/reboot")
|
||||||
|
@Override
|
||||||
|
public Response rebootDevice(List<String> deviceIDs) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking Android reboot-device device operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
CommandOperation operation = new CommandOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.DEVICE_REBOOT);
|
||||||
|
operation.setType(Operation.Type.COMMAND);
|
||||||
|
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/mute")
|
||||||
|
@Override
|
||||||
|
public Response muteDevice(List<String> deviceIDs) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking mute device operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
CommandOperation operation = new CommandOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.DEVICE_MUTE);
|
||||||
|
operation.setType(Operation.Type.COMMAND);
|
||||||
|
operation.setEnabled(true);
|
||||||
|
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/install-application")
|
||||||
|
@Override
|
||||||
|
public Response installApplication(ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking 'InstallApplication' operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (applicationInstallationBeanWrapper == null || applicationInstallationBeanWrapper.getOperation() ==
|
||||||
|
null) {
|
||||||
|
String errorMessage = "The payload of the application installing operation is incorrect";
|
||||||
|
log.error(errorMessage);
|
||||||
|
throw new BadRequestException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
ApplicationInstallation applicationInstallation = applicationInstallationBeanWrapper.getOperation();
|
||||||
|
ProfileOperation operation = new ProfileOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.INSTALL_APPLICATION);
|
||||||
|
operation.setType(Operation.Type.PROFILE);
|
||||||
|
operation.setPayLoad(applicationInstallation.toJSON());
|
||||||
|
return AndroidAPIUtils.getOperationResponse(applicationInstallationBeanWrapper.getDeviceIDs(),
|
||||||
|
operation);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/update-application")
|
||||||
|
@Override
|
||||||
|
public Response updateApplication(ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking 'UpdateApplication' operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (applicationUpdateBeanWrapper == null || applicationUpdateBeanWrapper.getOperation() == null) {
|
||||||
|
String errorMessage = "The payload of the application update operation is incorrect";
|
||||||
|
log.error(errorMessage);
|
||||||
|
throw new BadRequestException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
ApplicationUpdate applicationUpdate = applicationUpdateBeanWrapper.getOperation();
|
||||||
|
ProfileOperation operation = new ProfileOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.UPDATE_APPLICATION);
|
||||||
|
operation.setType(Operation.Type.PROFILE);
|
||||||
|
operation.setPayLoad(applicationUpdate.toJSON());
|
||||||
|
|
||||||
|
return AndroidAPIUtils.getOperationResponse(applicationUpdateBeanWrapper.getDeviceIDs(),
|
||||||
|
operation);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/uninstall-application")
|
||||||
|
@Override
|
||||||
|
public Response uninstallApplication(ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking 'UninstallApplication' operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (applicationUninstallationBeanWrapper == null ||
|
||||||
|
applicationUninstallationBeanWrapper.getOperation() == null) {
|
||||||
|
String errorMessage = "The payload of the application uninstalling operation is incorrect";
|
||||||
|
log.error(errorMessage);
|
||||||
|
throw new BadRequestException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
ApplicationUninstallation applicationUninstallation = applicationUninstallationBeanWrapper.getOperation();
|
||||||
|
ProfileOperation operation = new ProfileOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.UNINSTALL_APPLICATION);
|
||||||
|
operation.setType(Operation.Type.PROFILE);
|
||||||
|
operation.setPayLoad(applicationUninstallation.toJSON());
|
||||||
|
|
||||||
|
return AndroidAPIUtils.getOperationResponse(applicationUninstallationBeanWrapper.getDeviceIDs(),
|
||||||
|
operation);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/blacklist-applications")
|
||||||
|
@Override
|
||||||
|
public Response blacklistApplications(BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking 'Blacklist-Applications' operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (blacklistApplicationsBeanWrapper == null || blacklistApplicationsBeanWrapper.getOperation() == null) {
|
||||||
|
String errorMessage = "The payload of the blacklisting apps operation is incorrect";
|
||||||
|
log.error(errorMessage);
|
||||||
|
throw new BadRequestException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
BlacklistApplications blacklistApplications = blacklistApplicationsBeanWrapper.getOperation();
|
||||||
|
ProfileOperation operation = new ProfileOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.BLACKLIST_APPLICATIONS);
|
||||||
|
operation.setType(Operation.Type.PROFILE);
|
||||||
|
operation.setPayLoad(blacklistApplications.toJSON());
|
||||||
|
return AndroidAPIUtils.getOperationResponse(blacklistApplicationsBeanWrapper.getDeviceIDs(),
|
||||||
|
operation);
|
||||||
|
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/upgrade-firmware")
|
||||||
|
@Override
|
||||||
|
public Response upgradeFirmware(UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking Android upgrade-firmware device operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (upgradeFirmwareBeanWrapper == null || upgradeFirmwareBeanWrapper.getOperation() == null) {
|
||||||
|
String errorMessage = "The payload of the upgrade firmware operation is incorrect";
|
||||||
|
log.error(errorMessage);
|
||||||
|
throw new BadRequestException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
UpgradeFirmware upgradeFirmware = upgradeFirmwareBeanWrapper.getOperation();
|
||||||
|
ProfileOperation operation = new ProfileOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.UPGRADE_FIRMWARE);
|
||||||
|
operation.setType(Operation.Type.PROFILE);
|
||||||
|
operation.setPayLoad(upgradeFirmware.toJSON());
|
||||||
|
return AndroidAPIUtils.getOperationResponse(upgradeFirmwareBeanWrapper.getDeviceIDs(), operation);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/configure-vpn")
|
||||||
|
@Override
|
||||||
|
public Response configureVPN(VpnBeanWrapper vpnBeanWrapper) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking Android VPN device operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (vpnBeanWrapper == null || vpnBeanWrapper.getOperation() == null) {
|
||||||
|
String errorMessage = "The payload of the VPN operation is incorrect";
|
||||||
|
log.error(errorMessage);
|
||||||
|
throw new BadRequestException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
Vpn vpn = vpnBeanWrapper.getOperation();
|
||||||
|
ProfileOperation operation = new ProfileOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.VPN);
|
||||||
|
operation.setType(Operation.Type.PROFILE);
|
||||||
|
operation.setPayLoad(vpn.toJSON());
|
||||||
|
return AndroidAPIUtils.getOperationResponse(vpnBeanWrapper.getDeviceIDs(),
|
||||||
|
operation);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/send-notification")
|
||||||
|
@Override
|
||||||
|
public Response sendNotification(NotificationBeanWrapper notificationBeanWrapper) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking 'notification' operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (notificationBeanWrapper == null || notificationBeanWrapper.getOperation() == null) {
|
||||||
|
String errorMessage = "The payload of the notification operation is incorrect";
|
||||||
|
log.error(errorMessage);
|
||||||
|
throw new BadRequestException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
Notification notification = notificationBeanWrapper.getOperation();
|
||||||
|
ProfileOperation operation = new ProfileOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.NOTIFICATION);
|
||||||
|
operation.setType(Operation.Type.PROFILE);
|
||||||
|
operation.setPayLoad(notification.toJSON());
|
||||||
|
return AndroidAPIUtils.getOperationResponse(notificationBeanWrapper.getDeviceIDs(),
|
||||||
|
operation);
|
||||||
|
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/configure-wifi")
|
||||||
|
@Override
|
||||||
|
public Response configureWifi(WifiBeanWrapper wifiBeanWrapper) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking 'configure wifi' operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (wifiBeanWrapper == null || wifiBeanWrapper.getOperation() == null) {
|
||||||
|
String errorMessage = "The payload of the wifi operation is incorrect";
|
||||||
|
log.error(errorMessage);
|
||||||
|
throw new BadRequestException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
Wifi wifi = wifiBeanWrapper.getOperation();
|
||||||
|
ProfileOperation operation = new ProfileOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.WIFI);
|
||||||
|
operation.setType(Operation.Type.PROFILE);
|
||||||
|
operation.setPayLoad(wifi.toJSON());
|
||||||
|
|
||||||
|
return AndroidAPIUtils.getOperationResponse(wifiBeanWrapper.getDeviceIDs(),
|
||||||
|
operation);
|
||||||
|
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/encrypt-storage")
|
||||||
|
@Override
|
||||||
|
public Response encryptStorage(EncryptionBeanWrapper encryptionBeanWrapper) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking 'encrypt' operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (encryptionBeanWrapper == null || encryptionBeanWrapper.getOperation() == null) {
|
||||||
|
String errorMessage = "The payload of the device encryption operation is incorrect";
|
||||||
|
log.error(errorMessage);
|
||||||
|
throw new BadRequestException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
DeviceEncryption deviceEncryption = encryptionBeanWrapper.getOperation();
|
||||||
|
CommandOperation operation = new CommandOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.ENCRYPT_STORAGE);
|
||||||
|
operation.setType(Operation.Type.COMMAND);
|
||||||
|
operation.setEnabled(deviceEncryption.isEncrypted());
|
||||||
|
return AndroidAPIUtils.getOperationResponse(encryptionBeanWrapper.getDeviceIDs(),
|
||||||
|
operation);
|
||||||
|
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/change-lock-code")
|
||||||
|
@Override
|
||||||
|
public Response changeLockCode(LockCodeBeanWrapper lockCodeBeanWrapper) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking 'change lock code' operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (lockCodeBeanWrapper == null || lockCodeBeanWrapper.getOperation() == null) {
|
||||||
|
String errorMessage = "The payload of the change lock code operation is incorrect";
|
||||||
|
log.error(errorMessage);
|
||||||
|
throw new BadRequestException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
LockCode lockCode = lockCodeBeanWrapper.getOperation();
|
||||||
|
ProfileOperation operation = new ProfileOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.CHANGE_LOCK_CODE);
|
||||||
|
operation.setType(Operation.Type.PROFILE);
|
||||||
|
operation.setPayLoad(lockCode.toJSON());
|
||||||
|
return AndroidAPIUtils.getOperationResponse(lockCodeBeanWrapper.getDeviceIDs(),
|
||||||
|
operation);
|
||||||
|
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/set-password-policy")
|
||||||
|
@Override
|
||||||
|
public Response setPasswordPolicy(PasswordPolicyBeanWrapper passwordPolicyBeanWrapper) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking 'password policy' operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (passwordPolicyBeanWrapper == null || passwordPolicyBeanWrapper.getOperation() == null) {
|
||||||
|
String errorMessage = "The payload of the change password policy operation is incorrect";
|
||||||
|
log.error(errorMessage);
|
||||||
|
throw new BadRequestException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
PasscodePolicy passcodePolicy = passwordPolicyBeanWrapper.getOperation();
|
||||||
|
ProfileOperation operation = new ProfileOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.PASSCODE_POLICY);
|
||||||
|
operation.setType(Operation.Type.PROFILE);
|
||||||
|
operation.setPayLoad(passcodePolicy.toJSON());
|
||||||
|
|
||||||
|
return AndroidAPIUtils.getOperationResponse(passwordPolicyBeanWrapper.getDeviceIDs(),
|
||||||
|
operation);
|
||||||
|
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("set-webclip")
|
||||||
|
@Override
|
||||||
|
public Response setWebClip(WebClipBeanWrapper webClipBeanWrapper) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking 'webclip' operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
if (webClipBeanWrapper == null || webClipBeanWrapper.getOperation() == null) {
|
||||||
|
String errorMessage = "The payload of the add webclip operation is incorrect";
|
||||||
|
log.error(errorMessage);
|
||||||
|
throw new BadRequestException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
WebClip webClip = webClipBeanWrapper.getOperation();
|
||||||
|
ProfileOperation operation = new ProfileOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.WEBCLIP);
|
||||||
|
operation.setType(Operation.Type.PROFILE);
|
||||||
|
operation.setPayLoad(webClip.toJSON());
|
||||||
|
return AndroidAPIUtils.getOperationResponse(webClipBeanWrapper.getDeviceIDs(), operation);
|
||||||
|
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String errorMessage = "Issue in retrieving device management service instance";
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,269 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.mdm.services.android.services.impl;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
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.notification.mgt.NotificationManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
||||||
|
import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException;
|
||||||
|
import org.wso2.carbon.mdm.services.android.services.DeviceManagementService;
|
||||||
|
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
||||||
|
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
|
||||||
|
import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils;
|
||||||
|
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
|
||||||
|
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||||
|
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Path("/devices")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||||
|
|
||||||
|
private static final String OPERATION_ERROR_STATUS = "ERROR";
|
||||||
|
private static final Log log = LogFactory.getLog(DeviceManagementServiceImpl.class);
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("/{id}/applications")
|
||||||
|
@Override
|
||||||
|
public Response updateApplicationList(@PathParam("id") String id, List<Application> applications) {
|
||||||
|
Message responseMessage = new Message();
|
||||||
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||||
|
deviceIdentifier.setId(id);
|
||||||
|
deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
|
try {
|
||||||
|
AndroidAPIUtils.getApplicationManagerService().
|
||||||
|
updateApplicationListInstalledInDevice(deviceIdentifier, applications);
|
||||||
|
responseMessage.setResponseMessage("Device information has modified successfully.");
|
||||||
|
return Response.status(Response.Status.ACCEPTED).entity(responseMessage).build();
|
||||||
|
} catch (ApplicationManagementException e) {
|
||||||
|
String msg = "Error occurred while modifying the application list.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("/{id}/pending-operations")
|
||||||
|
@Override
|
||||||
|
public Response getPendingOperations(@PathParam("id") String id,
|
||||||
|
@HeaderParam("If-Modified-Since") String ifModifiedSince,
|
||||||
|
List<? extends Operation> resultOperations) {
|
||||||
|
if (id == null || id.isEmpty()) {
|
||||||
|
String msg = "Device identifier is null or empty, hence returning device not found";
|
||||||
|
log.error(msg);
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
||||||
|
}
|
||||||
|
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
||||||
|
try {
|
||||||
|
if (!AndroidDeviceUtils.isValidDeviceIdentifier(deviceIdentifier)) {
|
||||||
|
String msg = "Device not found for identifier '" + id + "'";
|
||||||
|
log.error(msg);
|
||||||
|
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
|
||||||
|
}
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking Android pending operations:" + id);
|
||||||
|
}
|
||||||
|
if (resultOperations != null && !resultOperations.isEmpty()) {
|
||||||
|
updateOperations(id, resultOperations);
|
||||||
|
}
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String msg = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
|
} catch (PolicyComplianceException e) {
|
||||||
|
String msg = "Issue in updating Monitoring operation";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String msg = "Issue in retrieving device management service instance";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
|
} catch (ApplicationManagementException e) {
|
||||||
|
String msg = "Issue in retrieving application management service instance";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
|
} catch (NotificationManagementException e) {
|
||||||
|
String msg = "Issue in retrieving Notification management service instance";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<? extends Operation> pendingOperations;
|
||||||
|
try {
|
||||||
|
pendingOperations = AndroidAPIUtils.getPendingOperations(deviceIdentifier);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String msg = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
|
}
|
||||||
|
return Response.status(Response.Status.CREATED).entity(pendingOperations).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateOperations(String deviceId, List<? extends Operation> operations)
|
||||||
|
throws OperationManagementException, PolicyComplianceException,
|
||||||
|
ApplicationManagementException, NotificationManagementException, DeviceManagementException {
|
||||||
|
for (org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation : operations) {
|
||||||
|
AndroidAPIUtils.updateOperation(deviceId, operation);
|
||||||
|
if (OPERATION_ERROR_STATUS.equals(operation.getStatus().toString())) {
|
||||||
|
org.wso2.carbon.device.mgt.common.notification.mgt.Notification notification = new
|
||||||
|
org.wso2.carbon.device.mgt.common.notification.mgt.Notification();
|
||||||
|
DeviceIdentifier id = new DeviceIdentifier();
|
||||||
|
id.setId(deviceId);
|
||||||
|
id.setType(AndroidConstants.DEVICE_TYPE_ANDROID);
|
||||||
|
String deviceName = AndroidAPIUtils.getDeviceManagementService().getDevice(id).getName();
|
||||||
|
notification.setOperationId(operation.getId());
|
||||||
|
notification.setStatus(org.wso2.carbon.device.mgt.common.notification.mgt.Notification.
|
||||||
|
Status.NEW.toString());
|
||||||
|
notification.setDescription("Operation " + operation.getCode() + " failed to execute on device " +
|
||||||
|
deviceName + ". Device ID : " + deviceId);
|
||||||
|
AndroidAPIUtils.getNotificationManagementService().addNotification(id, notification);
|
||||||
|
}
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Updating operation '" + operation.toString() + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Override
|
||||||
|
public Response enrollDevice(Device device) {
|
||||||
|
try {
|
||||||
|
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
|
device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser());
|
||||||
|
boolean status = AndroidAPIUtils.getDeviceManagementService().enrollDevice(device);
|
||||||
|
|
||||||
|
PolicyManagerService policyManagerService = AndroidAPIUtils.getPolicyManagerService();
|
||||||
|
policyManagerService.getEffectivePolicy(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
||||||
|
if (status) {
|
||||||
|
return Response.status(Response.Status.OK).entity("Android device, which carries the id '" +
|
||||||
|
device.getDeviceIdentifier() + "' has successfully been enrolled").build();
|
||||||
|
} else {
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Failed to enroll '" +
|
||||||
|
device.getType() + "' device, which carries the id '" +
|
||||||
|
device.getDeviceIdentifier() + "'").build();
|
||||||
|
}
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String msg = "Error occurred while enrolling the '" + device.getType() + "', which carries the id '" +
|
||||||
|
device.getDeviceIdentifier() + "'";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
|
} catch (PolicyManagementException e) {
|
||||||
|
String msg = "Error occurred while enforcing default enrollment policy upon '" + device.getType() +
|
||||||
|
"', which carries the id '" +
|
||||||
|
device.getDeviceIdentifier() + "'";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/{id}/status")
|
||||||
|
@Override
|
||||||
|
public Response isEnrolled(@PathParam("id") String id, @HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
||||||
|
boolean result;
|
||||||
|
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
||||||
|
try {
|
||||||
|
result = AndroidAPIUtils.getDeviceManagementService().isEnrolled(deviceIdentifier);
|
||||||
|
if (result) {
|
||||||
|
return Response.status(Response.Status.OK).entity("Android device that carries the id '" +
|
||||||
|
id + "' is enrolled").build();
|
||||||
|
} else {
|
||||||
|
return Response.status(Response.Status.NOT_FOUND).entity("No Android device is found upon the id '" +
|
||||||
|
id + "'").build();
|
||||||
|
}
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String msg = "Error occurred while checking enrollment status of the device.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("/{id}")
|
||||||
|
@Override
|
||||||
|
public Response modifyEnrollment(@PathParam("id") String id, Device device) {
|
||||||
|
boolean result;
|
||||||
|
try {
|
||||||
|
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
|
result = AndroidAPIUtils.getDeviceManagementService().modifyEnrollment(device);
|
||||||
|
if (result) {
|
||||||
|
return Response.status(Response.Status.ACCEPTED).entity("Enrollment of Android device that " +
|
||||||
|
"carries the id '" + id + "' has successfully updated").build();
|
||||||
|
} else {
|
||||||
|
return Response.status(Response.Status.NOT_MODIFIED).entity("Enrollment of Android device that " +
|
||||||
|
"carries the id '" + id + "' has not been updated").build();
|
||||||
|
}
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String msg = "Error occurred while modifying enrollment of the Android device that carries the id '" +
|
||||||
|
id + "'";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@DELETE
|
||||||
|
@Path("/{id}")
|
||||||
|
@Override
|
||||||
|
public Response disEnrollDevice(@PathParam("id") String id) {
|
||||||
|
boolean result;
|
||||||
|
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
||||||
|
try {
|
||||||
|
result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier);
|
||||||
|
if (result) {
|
||||||
|
return Response.status(Response.Status.OK).entity("Android device that carries id '" + id +
|
||||||
|
"' has successfully dis-enrolled").build();
|
||||||
|
} else {
|
||||||
|
return Response.status(Response.Status.NOT_FOUND).entity("Android device that carries id '" + id +
|
||||||
|
"' has not been dis-enrolled").build();
|
||||||
|
}
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String msg = "Error occurred while dis-enrolling the Android device that carries the id '" + id + "'";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,22 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* 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.
|
||||||
*
|
*
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
|
package org.wso2.carbon.mdm.services.android.services.impl;
|
||||||
package org.wso2.carbon.mdm.services.android.services.configuration.impl;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@ -25,69 +25,32 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|||||||
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.license.mgt.License;
|
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
||||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
||||||
import org.wso2.carbon.mdm.services.android.services.configuration.ConfigurationMgtService;
|
import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException;
|
||||||
|
import org.wso2.carbon.mdm.services.android.services.DeviceTypeConfigurationService;
|
||||||
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
||||||
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
|
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
|
||||||
import org.wso2.carbon.mdm.services.android.util.Message;
|
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||||
|
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
@Path("/configuration")
|
||||||
* Android Platform Configuration REST-API implementation.
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
* All end points supports JSON, XMl with content negotiation.
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
*/
|
public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurationService {
|
||||||
@Produces({"application/json", "application/xml"})
|
|
||||||
@Consumes({"application/json", "application/xml"})
|
|
||||||
public class ConfigurationMgtServiceImpl implements ConfigurationMgtService {
|
|
||||||
private static Log log = LogFactory.getLog(ConfigurationMgtServiceImpl.class);
|
|
||||||
|
|
||||||
@POST
|
private static final Log log = LogFactory.getLog(DeviceTypeConfigurationServiceImpl.class);
|
||||||
public Response configureSettings(PlatformConfiguration configuration)
|
|
||||||
throws AndroidAgentException {
|
|
||||||
|
|
||||||
Message responseMsg = new Message();
|
|
||||||
String msg;
|
|
||||||
ConfigurationEntry licenseEntry = null;
|
|
||||||
try {
|
|
||||||
configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
||||||
List<ConfigurationEntry> configs = configuration.getConfiguration();
|
|
||||||
for (ConfigurationEntry entry : configs) {
|
|
||||||
if (AndroidConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())) {
|
|
||||||
License license = new License();
|
|
||||||
license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
||||||
license.setLanguage(AndroidConstants.TenantConfigProperties.LANGUAGE_US);
|
|
||||||
license.setVersion("1.0.0");
|
|
||||||
license.setText(entry.getValue().toString());
|
|
||||||
AndroidAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants.
|
|
||||||
MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, license);
|
|
||||||
licenseEntry = entry;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (licenseEntry != null) {
|
|
||||||
configs.remove(licenseEntry);
|
|
||||||
}
|
|
||||||
configuration.setConfiguration(configs);
|
|
||||||
AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
|
|
||||||
Response.status(Response.Status.CREATED);
|
|
||||||
responseMsg.setResponseMessage("Android platform configuration saved successfully.");
|
|
||||||
responseMsg.setResponseCode(Response.Status.CREATED.toString());
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
msg = "Error occurred while configuring the android platform";
|
|
||||||
log.error(msg, e);
|
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
||||||
}
|
|
||||||
return Response.status(Response.Status.CREATED).entity(responseMsg).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
public Response getConfiguration() throws AndroidAgentException {
|
@Override
|
||||||
|
public Response getConfiguration(
|
||||||
|
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
||||||
String msg;
|
String msg;
|
||||||
PlatformConfiguration PlatformConfiguration = null;
|
PlatformConfiguration PlatformConfiguration;
|
||||||
List<ConfigurationEntry> configs;
|
List<ConfigurationEntry> configs;
|
||||||
try {
|
try {
|
||||||
PlatformConfiguration = AndroidAPIUtils.getDeviceManagementService().
|
PlatformConfiguration = AndroidAPIUtils.getDeviceManagementService().
|
||||||
@ -98,11 +61,10 @@ public class ConfigurationMgtServiceImpl implements ConfigurationMgtService {
|
|||||||
PlatformConfiguration = new PlatformConfiguration();
|
PlatformConfiguration = new PlatformConfiguration();
|
||||||
configs = new ArrayList<>();
|
configs = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationEntry entry = new ConfigurationEntry();
|
ConfigurationEntry entry = new ConfigurationEntry();
|
||||||
License license = AndroidAPIUtils.getDeviceManagementService().getLicense(
|
License license = AndroidAPIUtils.getDeviceManagementService().getLicense(
|
||||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, AndroidConstants.
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, AndroidConstants.
|
||||||
TenantConfigProperties.LANGUAGE_US);
|
TenantConfigProperties.LANGUAGE_US);
|
||||||
|
|
||||||
if (license != null && configs != null) {
|
if (license != null && configs != null) {
|
||||||
entry.setContentType(AndroidConstants.TenantConfigProperties.CONTENT_TYPE_TEXT);
|
entry.setContentType(AndroidConstants.TenantConfigProperties.CONTENT_TYPE_TEXT);
|
||||||
@ -114,13 +76,15 @@ public class ConfigurationMgtServiceImpl implements ConfigurationMgtService {
|
|||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
msg = "Error occurred while retrieving the Android tenant configuration";
|
msg = "Error occurred while retrieving the Android tenant configuration";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity(PlatformConfiguration).build();
|
return Response.status(Response.Status.OK).entity(PlatformConfiguration).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
public Response updateConfiguration(PlatformConfiguration configuration) throws AndroidAgentException {
|
@Override
|
||||||
|
public Response updateConfiguration(PlatformConfiguration configuration) {
|
||||||
String msg;
|
String msg;
|
||||||
Message responseMsg = new Message();
|
Message responseMsg = new Message();
|
||||||
ConfigurationEntry licenseEntry = null;
|
ConfigurationEntry licenseEntry = null;
|
||||||
@ -147,14 +111,36 @@ public class ConfigurationMgtServiceImpl implements ConfigurationMgtService {
|
|||||||
AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
|
AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
|
||||||
//AndroidAPIUtils.getGCMService().resetTenantConfigCache();
|
//AndroidAPIUtils.getGCMService().resetTenantConfigCache();
|
||||||
Response.status(Response.Status.ACCEPTED);
|
Response.status(Response.Status.ACCEPTED);
|
||||||
responseMsg.setResponseMessage("Android platform configuration has updated successfully.");
|
responseMsg.setResponseMessage("Android platform configuration has been updated successfully.");
|
||||||
responseMsg.setResponseCode(Response.Status.ACCEPTED.toString());
|
responseMsg.setResponseCode(Response.Status.ACCEPTED.toString());
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
msg = "Error occurred while modifying configuration settings of Android platform";
|
msg = "Error occurred while modifying configuration settings of Android platform";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.CREATED).entity(responseMsg).build();
|
return Response.status(Response.Status.CREATED).entity(responseMsg).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/license")
|
||||||
|
@Produces(MediaType.TEXT_PLAIN)
|
||||||
|
public Response getLicense(
|
||||||
|
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
||||||
|
License license;
|
||||||
|
try {
|
||||||
|
license =
|
||||||
|
AndroidAPIUtils.getDeviceManagementService().getLicense(
|
||||||
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID,
|
||||||
|
DeviceManagementConstants.LanguageCodes.LANGUAGE_CODE_ENGLISH_US);
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String msg = "Error occurred while retrieving the license configured for Android device enrolment";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
|
}
|
||||||
|
return Response.status(Response.Status.OK).entity((license == null) ? null : license.getText()).build();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -0,0 +1,170 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.mdm.services.android.services.impl;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
|
||||||
|
import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.DeviceState;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper;
|
||||||
|
import org.wso2.carbon.mdm.services.android.exception.BadRequestException;
|
||||||
|
import org.wso2.carbon.mdm.services.android.exception.NotFoundException;
|
||||||
|
import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException;
|
||||||
|
import org.wso2.carbon.mdm.services.android.services.EventReceiverService;
|
||||||
|
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
||||||
|
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||||
|
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Path("/events")
|
||||||
|
public class EventReceiverServiceImpl implements EventReceiverService {
|
||||||
|
|
||||||
|
private static final String EVENT_STREAM_DEFINITION = "android_agent";
|
||||||
|
private static final Log log = LogFactory.getLog(EventReceiverServiceImpl.class);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/publish")
|
||||||
|
@Override
|
||||||
|
public Response publishEvents(EventBeanWrapper eventBeanWrapper) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Invoking Android device even logging.");
|
||||||
|
}
|
||||||
|
Message message = new Message();
|
||||||
|
|
||||||
|
Object payload[] = {eventBeanWrapper.getDeviceIdentifier(), eventBeanWrapper.getPayload(),
|
||||||
|
eventBeanWrapper.getType()};
|
||||||
|
try {
|
||||||
|
if (AndroidAPIUtils.getEventPublisherService().publishEvent(
|
||||||
|
EVENT_STREAM_DEFINITION, "1.0.0", new Object[0], new Object[0], payload)) {
|
||||||
|
message.setResponseCode("Event is published successfully.");
|
||||||
|
return Response.status(Response.Status.CREATED).entity(message).build();
|
||||||
|
} else {
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage("Error occurred while " +
|
||||||
|
"publishing the event.").build());
|
||||||
|
}
|
||||||
|
} catch (DataPublisherConfigurationException e) {
|
||||||
|
String msg = "Error occurred while getting the Data publisher Service instance.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Override
|
||||||
|
public Response retrieveAlerts(@QueryParam("id") String deviceId, @QueryParam("from") long from,
|
||||||
|
@QueryParam("to") long to, @QueryParam("type") String type,
|
||||||
|
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
||||||
|
|
||||||
|
if (from != 0l && to != 0l && deviceId != null) {
|
||||||
|
return retrieveAlertFromDate(deviceId, from, to);
|
||||||
|
} else if (deviceId != null && type != null) {
|
||||||
|
return retrieveAlertByType(deviceId, type);
|
||||||
|
} else if (deviceId != null) {
|
||||||
|
return retrieveAlert(deviceId);
|
||||||
|
} else {
|
||||||
|
throw new BadRequestException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request must contain " +
|
||||||
|
"the device identifier. Optionally, both from and to value should be present to get " +
|
||||||
|
"alerts between times.").build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Response retrieveAlert(String deviceId) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Retrieving events for given device Identifier.");
|
||||||
|
}
|
||||||
|
String query = "deviceIdentifier:" + deviceId;
|
||||||
|
List<DeviceState> deviceStates;
|
||||||
|
try {
|
||||||
|
deviceStates = AndroidAPIUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query);
|
||||||
|
if (deviceStates == null) {
|
||||||
|
throw new NotFoundException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No any alerts are " +
|
||||||
|
"published for Device: " + deviceId + ".").build());
|
||||||
|
} else {
|
||||||
|
return Response.status(Response.Status.OK).entity(deviceStates).build();
|
||||||
|
}
|
||||||
|
} catch (AnalyticsException e) {
|
||||||
|
String msg = "Error occurred while getting published events for specific device: " + deviceId + ".";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Response retrieveAlertFromDate(String deviceId, long from, long to) {
|
||||||
|
String fromDate = String.valueOf(from);
|
||||||
|
String toDate = String.valueOf(to);
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Retrieving events for given device Identifier and time period.");
|
||||||
|
}
|
||||||
|
|
||||||
|
String query = "deviceIdentifier:" + deviceId + " AND _timestamp: [" + fromDate + " TO " + toDate + "]";
|
||||||
|
List<DeviceState> deviceStates;
|
||||||
|
try {
|
||||||
|
deviceStates = AndroidAPIUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query);
|
||||||
|
if (deviceStates == null) {
|
||||||
|
throw new NotFoundException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No any alerts are " +
|
||||||
|
"published on given date for given Device: " + deviceId + ".").build());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return Response.status(Response.Status.OK).entity(deviceStates).build();
|
||||||
|
}
|
||||||
|
} catch (AnalyticsException e) {
|
||||||
|
String msg = "Error occurred while getting published events for specific " +
|
||||||
|
"Device: " + deviceId + " on given Date.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Response retrieveAlertByType(String deviceId, String type) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Retrieving events for given device identifier and type.");
|
||||||
|
}
|
||||||
|
String query = "deviceIdentifier:" + deviceId + " AND type:" + type;
|
||||||
|
List<DeviceState> deviceStates;
|
||||||
|
try {
|
||||||
|
deviceStates = AndroidAPIUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query);
|
||||||
|
if (deviceStates == null) {
|
||||||
|
throw new NotFoundException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No any alerts are " +
|
||||||
|
"published for given Device: '" + deviceId + "' and given specific Type.").build());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return Response.status(Response.Status.OK).entity(deviceStates).build();
|
||||||
|
}
|
||||||
|
} catch (AnalyticsException e) {
|
||||||
|
String msg = "Error occurred while getting published events for specific " +
|
||||||
|
"Device: " + deviceId + "and given specific Type.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,506 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.services.android.services.operationmgt;
|
|
||||||
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
|
||||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.*;
|
|
||||||
|
|
||||||
import javax.ws.rs.*;
|
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Android Device Operation REST-API implementation.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Api(value = "OperationMgtService", description = "Android Device Operation REST-API implementation.")
|
|
||||||
public interface OperationMgtService {
|
|
||||||
String ACCEPT = "Accept";
|
|
||||||
|
|
||||||
@PUT
|
|
||||||
@Path("{id}")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "PUT",
|
|
||||||
value = "Getting Pending Android Device Operations",
|
|
||||||
responseContainer = "List",
|
|
||||||
notes = "The Android agent communicates with the server to get the operations that are queued up " +
|
|
||||||
"at the server end for a given device using this REST API",
|
|
||||||
response = Operation.class)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 200, message = "List of pending operations"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving operation management service instance")
|
|
||||||
})
|
|
||||||
Response getPendingOperations(
|
|
||||||
@ApiParam(name = "acceptHeader", value = "Accept Header") @HeaderParam(ACCEPT) String acceptHeader,
|
|
||||||
@ApiParam(name = "id", value = "DeviceIdentifier") @PathParam("id") String id,
|
|
||||||
@ApiParam(name = "resultOperations", value = "Device Operation Status")
|
|
||||||
List<? extends Operation> resultOperations);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("lock")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Adding a Device Lock on Android Devices",
|
|
||||||
notes = "Using this API you have the option of hard locking an Android device, where the Administrator " +
|
|
||||||
"permanently locks the device or screen locking an Android device"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response configureDeviceLock(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "cameraBeanWrapper",
|
|
||||||
value = "Device lock configurations with device IDs") DeviceLockBeanWrapper deviceLockBeanWrapper);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("unlock")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Adding a Device Unlock on Android Devices",
|
|
||||||
responseContainer = "List",
|
|
||||||
notes = "Using this API you have the option of unlocking an Android device, where the Administrator " +
|
|
||||||
"unlocks the device",
|
|
||||||
response = String.class)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response configureDeviceUnlock(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs", value =
|
|
||||||
"DeviceIds to be enable device unlock operation")
|
|
||||||
List<String> deviceIDs);
|
|
||||||
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("location")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Requesting Location Coordinates of Android Devices",
|
|
||||||
responseContainer = "List",
|
|
||||||
notes = "Request location coordinates of Android devices",
|
|
||||||
response = String.class)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 200, message = "Requested Device Coordinates"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")})
|
|
||||||
Response getDeviceLocation(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs",
|
|
||||||
value = "DeviceIDs to be requested to get device location")
|
|
||||||
List<String> deviceIDs);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("clear-password")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Clearing the Password on Android Devices",
|
|
||||||
notes = "Clear the password on Android devices"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response removePassword(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs",
|
|
||||||
value = "DeviceIds to be requested to remove password")
|
|
||||||
List<String> deviceIDs);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("camera")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Enabling or Disabling the Camera on Android Devices",
|
|
||||||
notes = "Enable or disable the camera on Android devices"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in creating a new camera instance")
|
|
||||||
})
|
|
||||||
Response configureCamera(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "cameraBeanWrapper",
|
|
||||||
value = "Camera enable/disable configurations with device IDs") CameraBeanWrapper cameraBeanWrapper);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("device-info")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Requesting Information from Android Devices",
|
|
||||||
notes = "Using this REST API you are able to request for Android device details. Once this REST API is" +
|
|
||||||
" executed it will be in the Android operation queue until the device calls the server to retrieve " +
|
|
||||||
"the list of operations that needs to be executed on the device"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 200, message = "Device Information"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response getDeviceInformation(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIds",
|
|
||||||
value = "Device IDs to be requested to get device information")
|
|
||||||
List<String> deviceIDs);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("enterprise-wipe")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Enterprise Wiping Android Devices",
|
|
||||||
notes = "Enterprise wipe is the process of deleting enterprise related data on a device while keeping the " +
|
|
||||||
"personal data intact. You are able to enterprise wipe Android devices using this REST API"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance"
|
|
||||||
)})
|
|
||||||
Response wipeDevice(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs",
|
|
||||||
value = "Device IDs to be requested to done enterprise-wipe")
|
|
||||||
List<String> deviceIDs);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("wipe-data")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Factory Resetting an Android Device",
|
|
||||||
notes = "Factory rest or erases all the data stored in the Android devices " +
|
|
||||||
"to restore them back to the original system"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")})
|
|
||||||
Response wipeData(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "wipeDataBeanWrapper",
|
|
||||||
value = "Configurations and DeviceIds to be need to done wipe-data")
|
|
||||||
WipeDataBeanWrapper wipeDataBeanWrapper);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("application-list")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Requesting the List of Installed Applications on Android Devices",
|
|
||||||
notes = "Using this REST API the server requests for the list of applications that are installed on" +
|
|
||||||
" the Android devices. Once this REST API is executed it will be in the Android operation queue " +
|
|
||||||
"until the device calls the server to retrieve the list of operations that needs to be executed " +
|
|
||||||
"on the device"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 200, message = "List of applications for specific deviceIdentifier"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response getApplications(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs",
|
|
||||||
value = "Device Ids to be need to get applications which already installed")
|
|
||||||
List<String> deviceIDs);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("ring-device")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Ringing Android Devices",
|
|
||||||
notes = "Ring Android devices"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response ringDevice(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs",
|
|
||||||
value = "Device Ids needs to be ring") List<String> deviceIDs);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("reboot-device")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Rebooting Android Devices",
|
|
||||||
notes = "Reboot Android devices"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response rebootDevice(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs",
|
|
||||||
value = "Device Ids needs to be rebooted") List<String> deviceIDs);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Muting Android Devices",
|
|
||||||
notes = "Mute Android devices"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
@Path("mute")
|
|
||||||
Response muteDevice(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader,
|
|
||||||
@ApiParam(name = "deviceIDs", value = "DeviceIDs need to be muted") List<String> deviceIDs);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("install-application")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Installing an Application on Android Devices",
|
|
||||||
notes = "Install an application on an Android device. If the device you are installing the application" +
|
|
||||||
" on has the WSO2 system service installed, the application installation will happen in silent " +
|
|
||||||
"mode, else the device user's consent will be required"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response installApplication(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader,
|
|
||||||
@ApiParam(name = "applicationInstallationBeanWrapper",
|
|
||||||
value = "Properties of installed apps and device IDs")
|
|
||||||
ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("update-application")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Updating an Application on Android Devices",
|
|
||||||
notes = "Update an application on an Android device. If the device you are updating the application" +
|
|
||||||
" has the WSO2 system service installed, the application update will happen in silent " +
|
|
||||||
"mode, else the device user's consent will be required"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response updateApplication(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader,
|
|
||||||
@ApiParam(name = "applicationUpdateBeanWrapper",
|
|
||||||
value = "Properties of updated apps and device IDs")
|
|
||||||
ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("uninstall-application")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Uninstalling an Application from Android Devices",
|
|
||||||
notes = "Uninstall an application from Android devices"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response uninstallApplication(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader,
|
|
||||||
@ApiParam(name = "applicationUninstallationBeanWrapper",
|
|
||||||
value = "applicationUninstallationConfigs and Device Ids")
|
|
||||||
ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("blacklist-applications")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Get BlackListed Applications",
|
|
||||||
notes = "Getting BlackListed Applications"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response blacklistApplications(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader,
|
|
||||||
@ApiParam(name = "blacklistApplicationsBeanWrapper",
|
|
||||||
value = "BlacklistApplications Configuration and DeviceIds")
|
|
||||||
BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("upgrade-firmware")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Upgrading device firmware",
|
|
||||||
notes = "Device firmware upgrade"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response upgradeFirmware(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader,
|
|
||||||
@ApiParam(name = "upgradeFirmwareBeanWrapper",
|
|
||||||
value = "Firmware upgrade configuration and DeviceIds")
|
|
||||||
UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("vpn")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Configuring VPN on Android devices",
|
|
||||||
notes = "Configure VPN on Android devices"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response configureVPN(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader,
|
|
||||||
@ApiParam(name = "vpnBeanWrapper",
|
|
||||||
value = "VPN configuration and DeviceIds")
|
|
||||||
VpnBeanWrapper vpnBeanWrapper);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("notification")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Sending a Notification to Android Devices",
|
|
||||||
notes = "Send a notification to Android devices"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response sendNotification(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader,
|
|
||||||
@ApiParam(name = "notificationBeanWrapper",
|
|
||||||
value = "Notification Configurations and device Ids")
|
|
||||||
NotificationBeanWrapper notificationBeanWrapper);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("wifi")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Configuring Wi-Fi on Android Devices",
|
|
||||||
notes = "Configure Wi-Fi on Android devices"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response configureWifi(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "wifiBeanWrapper",
|
|
||||||
value = "WifiConfigurations and Device Ids") WifiBeanWrapper wifiBeanWrapper);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("encrypt")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Encrypting Storage on Android Devices",
|
|
||||||
notes = "Encrypt the data stored on Android devices"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response encryptStorage(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "encryptionBeanWrapper",
|
|
||||||
value = "Configurations and deviceIds need to be done data encryption")
|
|
||||||
EncryptionBeanWrapper encryptionBeanWrapper);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("change-lock-code")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Changing the Lock Code on Android Devices",
|
|
||||||
notes = "Change the lock code on Android devices"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response changeLockCode(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "lockCodeBeanWrapper",
|
|
||||||
value = "Configurations and device Ids need to be done change lock code")
|
|
||||||
LockCodeBeanWrapper lockCodeBeanWrapper);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("password-policy")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Setting a Passcode Policy on Android Devices",
|
|
||||||
notes = "Set a password policy on Android devices"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "created"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response setPasswordPolicy(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "passwordPolicyBeanWrapper",
|
|
||||||
value = "Password Policy Configurations and Device Ids")
|
|
||||||
PasswordPolicyBeanWrapper passwordPolicyBeanWrapper);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("webclip")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Setting a Web Clip on Android Devices",
|
|
||||||
notes = "Set a web clip on Android devices. A web clip is used to add a bookmark to a web application"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Accepted"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response setWebClip(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "webClipBeanWrapper",
|
|
||||||
value = "Configurations to need set web clip on device and device Ids")
|
|
||||||
WebClipBeanWrapper webClipBeanWrapper);
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("disenroll")
|
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Un-Register The Device from the EMM server",
|
|
||||||
notes = "unregister the given device"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Accepted"),
|
|
||||||
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
|
||||||
})
|
|
||||||
Response setDisenrollment(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam(ACCEPT) String acceptHeader,
|
|
||||||
@ApiParam(name = "disenrollmentBeanWrapper", value = "Dis-enrollment configurations")
|
|
||||||
DisenrollmentBeanWrapper disenrollmentBeanWrapper);
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.services.android.services.policymgt;
|
|
||||||
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
|
||||||
import org.wso2.carbon.mdm.services.android.util.Message;
|
|
||||||
import org.wso2.carbon.policy.mgt.common.ProfileFeature;
|
|
||||||
|
|
||||||
import javax.jws.WebService;
|
|
||||||
import javax.ws.rs.*;
|
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Api(value = "PolicyMgtService", description = "Policy management related REST-API implementation.")
|
|
||||||
@WebService
|
|
||||||
@Produces({"application/json", "application/xml"})
|
|
||||||
@Consumes({"application/json", "application/xml"})
|
|
||||||
public interface PolicyMgtService {
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("{deviceId}")
|
|
||||||
@ApiOperation(
|
|
||||||
httpMethod = "GET",
|
|
||||||
value = "Identifying whether a Policy is Enforced on an Android Device",
|
|
||||||
notes = "When a device registers with WSO2 EMM, a policy is enforced on the device based on the policy " +
|
|
||||||
"enforcement criteria. Using this API you are able to identify if a specific device has a policy " +
|
|
||||||
"enforced or if no policy is enforced on the device."
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 200, message = "Effective policy added to operation"),
|
|
||||||
@ApiResponse(code = 204, message = "No effective policy found")
|
|
||||||
})
|
|
||||||
Response getEffectivePolicy(@ApiParam(name = "acceptHeader", value = "Accept Header") @HeaderParam("Accept")
|
|
||||||
String acceptHeader,
|
|
||||||
@ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId")
|
|
||||||
String id) throws AndroidAgentException;
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/features/{deviceId}")
|
|
||||||
@ApiOperation(
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "GET",
|
|
||||||
value = "Get Effective Features",
|
|
||||||
responseContainer = "List",
|
|
||||||
notes = "Get already applied features for given device Identifier",
|
|
||||||
response = ProfileFeature.class)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 200, message = "Effective Feature List"),
|
|
||||||
@ApiResponse(code = 404, message = "Not Found"),
|
|
||||||
@ApiResponse(code = 500, message = "Error occurred while getting the features")
|
|
||||||
})
|
|
||||||
Response getEffectiveFeatures(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
|
||||||
@HeaderParam("Accept") String acceptHeader,
|
|
||||||
@ApiParam(name = "deviceId", value = "DeviceIdentifier")
|
|
||||||
@PathParam("deviceId") String id) throws AndroidAgentException;
|
|
||||||
}
|
|
||||||
@ -1,100 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.services.android.services.policymgt.impl;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
||||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
|
||||||
import org.wso2.carbon.mdm.services.android.services.policymgt.PolicyMgtService;
|
|
||||||
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
|
||||||
import org.wso2.carbon.mdm.services.android.util.Message;
|
|
||||||
import org.wso2.carbon.policy.mgt.common.FeatureManagementException;
|
|
||||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
|
||||||
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
|
||||||
import org.wso2.carbon.policy.mgt.common.ProfileFeature;
|
|
||||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
|
||||||
|
|
||||||
import javax.ws.rs.GET;
|
|
||||||
import javax.ws.rs.HeaderParam;
|
|
||||||
import javax.ws.rs.Path;
|
|
||||||
import javax.ws.rs.PathParam;
|
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class PolicyMgtServiceImpl implements PolicyMgtService {
|
|
||||||
private static Log log = LogFactory.getLog(PolicyMgtService.class);
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("{deviceId}")
|
|
||||||
public Response getEffectivePolicy(@HeaderParam("Accept") String acceptHeader,
|
|
||||||
@PathParam("deviceId") String id) throws AndroidAgentException {
|
|
||||||
|
|
||||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
|
||||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
|
||||||
Message responseMessage = new Message();
|
|
||||||
Policy policy;
|
|
||||||
try {
|
|
||||||
PolicyManagerService policyManagerService = AndroidAPIUtils.getPolicyManagerService();
|
|
||||||
policy = policyManagerService.getEffectivePolicy(deviceIdentifier);
|
|
||||||
if (policy == null) {
|
|
||||||
responseMessage = Message.responseMessage("No effective policy found").
|
|
||||||
responseCode(Response.Status.NO_CONTENT.toString()).build();
|
|
||||||
return Response.status(Response.Status.NO_CONTENT).entity(responseMessage).type(
|
|
||||||
responseMediaType).build();
|
|
||||||
} else {
|
|
||||||
responseMessage = Message.responseMessage("Effective policy added to operation").
|
|
||||||
responseCode(Response.Status.OK.toString()).build();
|
|
||||||
return Response.status(Response.Status.OK).entity(responseMessage).type(
|
|
||||||
responseMediaType).build();
|
|
||||||
}
|
|
||||||
} catch (PolicyManagementException e) {
|
|
||||||
String msg = "Error occurred while getting the policy.";
|
|
||||||
log.error(msg, e);
|
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).type(
|
|
||||||
responseMediaType).build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/features/{deviceId}")
|
|
||||||
public Response getEffectiveFeatures(@HeaderParam("Accept") String acceptHeader,
|
|
||||||
@PathParam("deviceId") String id) throws AndroidAgentException {
|
|
||||||
List<ProfileFeature> profileFeatures;
|
|
||||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
|
||||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
|
||||||
try {
|
|
||||||
PolicyManagerService policyManagerService = AndroidAPIUtils.getPolicyManagerService();
|
|
||||||
profileFeatures = policyManagerService.getEffectiveFeatures(deviceIdentifier);
|
|
||||||
if (profileFeatures == null) {
|
|
||||||
Response.status(Response.Status.NOT_FOUND);
|
|
||||||
return Response.status(Response.Status.NOT_FOUND).type(
|
|
||||||
responseMediaType).build();
|
|
||||||
}
|
|
||||||
} catch (FeatureManagementException e) {
|
|
||||||
String msg = "Error occurred while getting the features.";
|
|
||||||
log.error(msg, e);
|
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).type(
|
|
||||||
responseMediaType).build();
|
|
||||||
}
|
|
||||||
return Response.status(Response.Status.OK).entity(profileFeatures).type(
|
|
||||||
responseMediaType).build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -36,6 +36,7 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
|||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
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.device.details.DeviceInfo;
|
||||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
|
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
|
||||||
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService;
|
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
|
||||||
@ -47,6 +48,8 @@ import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManag
|
|||||||
import org.wso2.carbon.device.mgt.core.search.mgt.impl.Utils;
|
import org.wso2.carbon.device.mgt.core.search.mgt.impl.Utils;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
import org.wso2.carbon.mdm.services.android.bean.DeviceState;
|
import org.wso2.carbon.mdm.services.android.bean.DeviceState;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
||||||
|
import org.wso2.carbon.mdm.services.android.exception.BadRequestException;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
|
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
|
||||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||||
|
|
||||||
@ -114,13 +117,16 @@ public class AndroidAPIUtils {
|
|||||||
return responseMediaType;
|
return responseMediaType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Response getOperationResponse(List<String> deviceIDs, Operation operation,
|
public static Response getOperationResponse(List<String> deviceIDs, Operation operation)
|
||||||
Message message, MediaType responseMediaType)
|
|
||||||
throws DeviceManagementException, OperationManagementException {
|
throws DeviceManagementException, OperationManagementException {
|
||||||
|
if (deviceIDs == null || deviceIDs.size() == 0) {
|
||||||
|
String errorMessage = "Device identifier list is empty";
|
||||||
|
log.error(errorMessage);
|
||||||
|
throw new BadRequestException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||||
|
}
|
||||||
AndroidDeviceUtils deviceUtils = new AndroidDeviceUtils();
|
AndroidDeviceUtils deviceUtils = new AndroidDeviceUtils();
|
||||||
DeviceIDHolder deviceIDHolder = deviceUtils.validateDeviceIdentifiers(deviceIDs,
|
DeviceIDHolder deviceIDHolder = deviceUtils.validateDeviceIdentifiers(deviceIDs);
|
||||||
message, responseMediaType);
|
|
||||||
|
|
||||||
List<DeviceIdentifier> validDeviceIds = deviceIDHolder.getValidDeviceIDList();
|
List<DeviceIdentifier> validDeviceIds = deviceIDHolder.getValidDeviceIDList();
|
||||||
Activity activity = getDeviceManagementService().addOperation(
|
Activity activity = getDeviceManagementService().addOperation(
|
||||||
@ -137,13 +143,11 @@ public class AndroidAPIUtils {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
if (!deviceIDHolder.getErrorDeviceIdList().isEmpty()) {
|
if (!deviceIDHolder.getErrorDeviceIdList().isEmpty()) {
|
||||||
return javax.ws.rs.core.Response.status(AndroidConstants.StatusCodes.
|
throw new BadRequestException(
|
||||||
MULTI_STATUS_HTTP_CODE).type(
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(deviceUtils.
|
||||||
responseMediaType).entity(deviceUtils.
|
convertErrorMapIntoErrorMessage(deviceIDHolder.getErrorDeviceIdList())).build());
|
||||||
convertErrorMapIntoErrorMessage(deviceIDHolder.getErrorDeviceIdList())).build();
|
|
||||||
}
|
}
|
||||||
return javax.ws.rs.core.Response.status(javax.ws.rs.core.Response.Status.CREATED).entity(activity).
|
return Response.status(Response.Status.CREATED).entity(activity).build();
|
||||||
type(responseMediaType).build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -262,33 +266,39 @@ public class AndroidAPIUtils {
|
|||||||
deviceIdentifier.setId(deviceId);
|
deviceIdentifier.setId(deviceId);
|
||||||
deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
|
|
||||||
if (AndroidConstants.OperationCodes.MONITOR.equals(operation.getCode())) {
|
if (!Operation.Status.ERROR.equals(operation.getStatus()) &&
|
||||||
|
AndroidConstants.OperationCodes.MONITOR.equals(operation.getCode())) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.info("Received compliance status from MONITOR operation ID: " + operation.getId());
|
log.info("Received compliance status from MONITOR operation ID: " + operation.getId());
|
||||||
}
|
}
|
||||||
getPolicyManagerService().checkPolicyCompliance(deviceIdentifier, operation.getPayLoad());
|
getPolicyManagerService().checkPolicyCompliance(deviceIdentifier, operation.getPayLoad());
|
||||||
} else if (AndroidConstants.OperationCodes.APPLICATION_LIST.equals(operation.getCode())) {
|
} else if (!Operation.Status.ERROR.equals(operation.getStatus()) && AndroidConstants.
|
||||||
|
OperationCodes.APPLICATION_LIST.equals(operation.getCode())) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.info("Received applications list from device '" + deviceId + "'");
|
log.info("Received applications list from device '" + deviceId + "'");
|
||||||
}
|
}
|
||||||
updateApplicationList(operation, deviceIdentifier);
|
updateApplicationList(operation, deviceIdentifier);
|
||||||
|
|
||||||
} else if (AndroidConstants.OperationCodes.DEVICE_INFO.equals(operation.getCode())) {
|
} else if (!Operation.Status.ERROR.equals(operation.getStatus()) && AndroidConstants.
|
||||||
|
OperationCodes.DEVICE_INFO.equals(operation.getCode())) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Device device = new Gson().fromJson(operation.getOperationResponse(), Device.class);
|
Device device = new Gson().fromJson(operation.getOperationResponse(), Device.class);
|
||||||
org.wso2.carbon.device.mgt.common.device.details.DeviceInfo deviceInfo = convertDeviceToInfo(device);
|
org.wso2.carbon.device.mgt.common.device.details.DeviceInfo deviceInfo = convertDeviceToInfo(device);
|
||||||
deviceInfo.setDeviceIdentifier(deviceIdentifier);
|
updateDeviceInfo(deviceIdentifier, deviceInfo);
|
||||||
updateDeviceInfo(deviceInfo);
|
|
||||||
} catch (DeviceDetailsMgtException e) {
|
} catch (DeviceDetailsMgtException e) {
|
||||||
throw new OperationManagementException("Error occurred while updating the device information.", e);
|
throw new OperationManagementException("Error occurred while updating the device information.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else if (AndroidConstants.OperationCodes.DEVICE_LOCATION.equals(operation.getCode())) {
|
} else if (!Operation.Status.ERROR.equals(operation.getStatus()) &&
|
||||||
|
AndroidConstants.OperationCodes.DEVICE_LOCATION.equals(operation.getCode())) {
|
||||||
try {
|
try {
|
||||||
DeviceLocation location = new Gson().fromJson(operation.getOperationResponse(), DeviceLocation.class);
|
DeviceLocation location = new Gson().fromJson(operation.getOperationResponse(), DeviceLocation.class);
|
||||||
if (location != null) {
|
// reason for checking "location.getLatitude() != null" because when device fails to provide
|
||||||
|
// device location and send status instead, above Gson converter create new location object
|
||||||
|
// with null attributes
|
||||||
|
if (location != null && location.getLatitude() != null) {
|
||||||
location.setDeviceIdentifier(deviceIdentifier);
|
location.setDeviceIdentifier(deviceIdentifier);
|
||||||
updateDeviceLocation(location);
|
updateDeviceLocation(location);
|
||||||
}
|
}
|
||||||
@ -296,7 +306,6 @@ public class AndroidAPIUtils {
|
|||||||
throw new OperationManagementException("Error occurred while updating the device location.", e);
|
throw new OperationManagementException("Error occurred while updating the device location.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getDeviceManagementService().updateOperation(deviceIdentifier, operation);
|
getDeviceManagementService().updateOperation(deviceIdentifier, operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,31 +320,35 @@ public class AndroidAPIUtils {
|
|||||||
private static void updateApplicationList(Operation operation, DeviceIdentifier deviceIdentifier)
|
private static void updateApplicationList(Operation operation, DeviceIdentifier deviceIdentifier)
|
||||||
throws ApplicationManagementException {
|
throws ApplicationManagementException {
|
||||||
// Parsing json string to get applications list.
|
// Parsing json string to get applications list.
|
||||||
JsonElement jsonElement = new JsonParser().parse(operation.getOperationResponse());
|
if (operation.getOperationResponse() != null) {
|
||||||
JsonArray jsonArray = jsonElement.getAsJsonArray();
|
JsonElement jsonElement = new JsonParser().parse(operation.getOperationResponse());
|
||||||
Application app;
|
JsonArray jsonArray = jsonElement.getAsJsonArray();
|
||||||
List<Application> applications = new ArrayList<Application>(jsonArray.size());
|
Application app;
|
||||||
for (JsonElement element : jsonArray) {
|
List<Application> applications = new ArrayList<Application>(jsonArray.size());
|
||||||
app = new Application();
|
for (JsonElement element : jsonArray) {
|
||||||
app.setName(element.getAsJsonObject().
|
app = new Application();
|
||||||
get(AndroidConstants.ApplicationProperties.NAME).getAsString());
|
app.setName(element.getAsJsonObject().
|
||||||
app.setApplicationIdentifier(element.getAsJsonObject().
|
get(AndroidConstants.ApplicationProperties.NAME).getAsString());
|
||||||
get(AndroidConstants.ApplicationProperties.IDENTIFIER).getAsString());
|
app.setApplicationIdentifier(element.getAsJsonObject().
|
||||||
app.setPlatform(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
get(AndroidConstants.ApplicationProperties.IDENTIFIER).getAsString());
|
||||||
if (element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.USS) != null) {
|
app.setPlatform(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
app.setMemoryUsage(element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.USS).getAsInt());
|
if (element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.USS) != null) {
|
||||||
|
app.setMemoryUsage(element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.USS).getAsInt());
|
||||||
|
}
|
||||||
|
if (element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.VERSION) != null) {
|
||||||
|
app.setVersion(element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.VERSION).getAsString());
|
||||||
|
}
|
||||||
|
applications.add(app);
|
||||||
}
|
}
|
||||||
if (element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.VERSION) != null) {
|
getApplicationManagerService().updateApplicationListInstalledInDevice(deviceIdentifier, applications);
|
||||||
app.setVersion(element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.VERSION).getAsString());
|
} else {
|
||||||
}
|
log.error("Operation Response is null.");
|
||||||
applications.add(app);
|
|
||||||
}
|
}
|
||||||
getApplicationManagerService().updateApplicationListInstalledInDevice(deviceIdentifier, applications);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void updateDeviceLocation(DeviceLocation deviceLocation) throws DeviceDetailsMgtException {
|
private static void updateDeviceLocation(DeviceLocation deviceLocation) throws DeviceDetailsMgtException {
|
||||||
|
|
||||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
DeviceInformationManager informationManager =
|
DeviceInformationManager informationManager =
|
||||||
(DeviceInformationManager) ctx.getOSGiService(DeviceInformationManager.class, null);
|
(DeviceInformationManager) ctx.getOSGiService(DeviceInformationManager.class, null);
|
||||||
@ -344,14 +357,14 @@ public class AndroidAPIUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void updateDeviceInfo(org.wso2.carbon.device.mgt.common.device.details.DeviceInfo deviceInfo)
|
private static void updateDeviceInfo(DeviceIdentifier deviceId, DeviceInfo deviceInfo)
|
||||||
throws DeviceDetailsMgtException {
|
throws DeviceDetailsMgtException {
|
||||||
|
|
||||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
DeviceInformationManager informationManager =
|
DeviceInformationManager informationManager =
|
||||||
(DeviceInformationManager) ctx.getOSGiService(DeviceInformationManager.class, null);
|
(DeviceInformationManager) ctx.getOSGiService(DeviceInformationManager.class, null);
|
||||||
|
|
||||||
informationManager.addDeviceInfo(deviceInfo);
|
informationManager.addDeviceInfo(deviceId, deviceInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -23,101 +23,111 @@ package org.wso2.carbon.mdm.services.android.util;
|
|||||||
*/
|
*/
|
||||||
public final class AndroidConstants {
|
public final class AndroidConstants {
|
||||||
|
|
||||||
public final class DeviceProperties{
|
public static final String DEVICE_TYPE_ANDROID = "android";
|
||||||
private DeviceProperties() {
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
public static final String PROPERTY_USER_KEY = "username";
|
|
||||||
public static final String PROPERTY_DEVICE_KEY = "device";
|
|
||||||
}
|
|
||||||
|
|
||||||
public final class DeviceFeatures{
|
public final class DeviceProperties {
|
||||||
private DeviceFeatures() {
|
private DeviceProperties() {
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final class DeviceConstants{
|
|
||||||
private DeviceConstants() {
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
public static final String DEVICE_MAC_KEY = "mac";
|
|
||||||
public static final String DEVICE_DESCRIPTION_KEY = "description";
|
|
||||||
public static final String DEVICE_OWNERSHIP_KEY = "ownership";
|
|
||||||
public static final String DEVICE_PROPERTIES_KEY = "properties";
|
|
||||||
public static final String DEVICE_FEATURES_KEY = "features";
|
|
||||||
public static final String DEVICE_DATA = "data";
|
|
||||||
public static final String DEVICE_ID_NOT_FOUND = "Device Id not found for device found at %s";
|
|
||||||
public static final String DEVICE_ID_SERVICE_NOT_FOUND =
|
|
||||||
"Issue in retrieving device management service instance for device found at %s";
|
|
||||||
}
|
|
||||||
|
|
||||||
public final class Messages{
|
|
||||||
private Messages(){
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
public static final String DEVICE_MANAGER_SERVICE_NOT_AVAILABLE =
|
|
||||||
"Device Manager service not available";
|
|
||||||
}
|
|
||||||
|
|
||||||
public final class OperationCodes{
|
|
||||||
private OperationCodes(){
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
public static final String DEVICE_LOCK = "DEVICE_LOCK";
|
|
||||||
public static final String DEVICE_UNLOCK = "DEVICE_UNLOCK";
|
|
||||||
public static final String DEVICE_LOCATION = "DEVICE_LOCATION";
|
|
||||||
public static final String WIFI = "WIFI";
|
|
||||||
public static final String CAMERA = "CAMERA";
|
|
||||||
public static final String DEVICE_MUTE = "DEVICE_MUTE";
|
|
||||||
public static final String PASSCODE_POLICY = "PASSCODE_POLICY";
|
|
||||||
public static final String DEVICE_INFO = "DEVICE_INFO";
|
|
||||||
public static final String ENTERPRISE_WIPE = "ENTERPRISE_WIPE";
|
|
||||||
public static final String CLEAR_PASSWORD = "CLEAR_PASSWORD";
|
|
||||||
public static final String WIPE_DATA = "WIPE_DATA";
|
|
||||||
public static final String APPLICATION_LIST = "APPLICATION_LIST";
|
|
||||||
public static final String CHANGE_LOCK_CODE = "CHANGE_LOCK_CODE";
|
|
||||||
public static final String INSTALL_APPLICATION = "INSTALL_APPLICATION";
|
|
||||||
public static final String UPDATE_APPLICATION = "UPDATE_APPLICATION";
|
|
||||||
public static final String UNINSTALL_APPLICATION = "UNINSTALL_APPLICATION";
|
|
||||||
public static final String BLACKLIST_APPLICATIONS = "BLACKLIST_APPLICATIONS";
|
|
||||||
public static final String ENCRYPT_STORAGE = "ENCRYPT_STORAGE";
|
|
||||||
public static final String DEVICE_RING = "DEVICE_RING";
|
|
||||||
public static final String DEVICE_REBOOT = "REBOOT";
|
|
||||||
public static final String UPGRADE_FIRMWARE = "UPGRADE_FIRMWARE";
|
|
||||||
public static final String NOTIFICATION = "NOTIFICATION";
|
|
||||||
public static final String WEBCLIP = "WEBCLIP";
|
|
||||||
public static final String DISENROLL = "DISENROLL";
|
|
||||||
public static final String MONITOR = "MONITOR";
|
|
||||||
public static final String VPN = "VPN";
|
|
||||||
public static final String APP_RESTRICTION = "APP-RESTRICTION";
|
|
||||||
public static final String WORK_PROFILE = "WORK_PROFILE";
|
|
||||||
}
|
|
||||||
|
|
||||||
public final class StatusCodes{
|
|
||||||
private StatusCodes(){
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
public static final int MULTI_STATUS_HTTP_CODE = 207;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final class TenantConfigProperties{
|
|
||||||
private TenantConfigProperties(){
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
public static final String LICENSE_KEY = "androidEula";
|
|
||||||
public static final String LANGUAGE_US = "en_US";
|
|
||||||
public static final String CONTENT_TYPE_TEXT = "text";
|
|
||||||
}
|
|
||||||
|
|
||||||
public final class ApplicationProperties {
|
|
||||||
private ApplicationProperties(){
|
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final String PROPERTY_USER_KEY = "username";
|
||||||
|
public static final String PROPERTY_DEVICE_KEY = "device";
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class DeviceFeatures {
|
||||||
|
private DeviceFeatures() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class DeviceConstants {
|
||||||
|
private DeviceConstants() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String DEVICE_MAC_KEY = "mac";
|
||||||
|
public static final String DEVICE_DESCRIPTION_KEY = "description";
|
||||||
|
public static final String DEVICE_OWNERSHIP_KEY = "ownership";
|
||||||
|
public static final String DEVICE_PROPERTIES_KEY = "properties";
|
||||||
|
public static final String DEVICE_FEATURES_KEY = "features";
|
||||||
|
public static final String DEVICE_DATA = "data";
|
||||||
|
public static final String DEVICE_ID_NOT_FOUND = "Device not found for device id: %s";
|
||||||
|
public static final String DEVICE_ID_SERVICE_NOT_FOUND =
|
||||||
|
"Issue in retrieving device management service instance for device found at %s";
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class Messages {
|
||||||
|
private Messages() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String DEVICE_MANAGER_SERVICE_NOT_AVAILABLE =
|
||||||
|
"Device Manager service not available";
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class OperationCodes {
|
||||||
|
private OperationCodes() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String DEVICE_LOCK = "DEVICE_LOCK";
|
||||||
|
public static final String DEVICE_UNLOCK = "DEVICE_UNLOCK";
|
||||||
|
public static final String DEVICE_LOCATION = "DEVICE_LOCATION";
|
||||||
|
public static final String WIFI = "WIFI";
|
||||||
|
public static final String CAMERA = "CAMERA";
|
||||||
|
public static final String DEVICE_MUTE = "DEVICE_MUTE";
|
||||||
|
public static final String PASSCODE_POLICY = "PASSCODE_POLICY";
|
||||||
|
public static final String DEVICE_INFO = "DEVICE_INFO";
|
||||||
|
public static final String ENTERPRISE_WIPE = "ENTERPRISE_WIPE";
|
||||||
|
public static final String CLEAR_PASSWORD = "CLEAR_PASSWORD";
|
||||||
|
public static final String WIPE_DATA = "WIPE_DATA";
|
||||||
|
public static final String APPLICATION_LIST = "APPLICATION_LIST";
|
||||||
|
public static final String CHANGE_LOCK_CODE = "CHANGE_LOCK_CODE";
|
||||||
|
public static final String INSTALL_APPLICATION = "INSTALL_APPLICATION";
|
||||||
|
public static final String UPDATE_APPLICATION = "UPDATE_APPLICATION";
|
||||||
|
public static final String UNINSTALL_APPLICATION = "UNINSTALL_APPLICATION";
|
||||||
|
public static final String BLACKLIST_APPLICATIONS = "BLACKLIST_APPLICATIONS";
|
||||||
|
public static final String ENCRYPT_STORAGE = "ENCRYPT_STORAGE";
|
||||||
|
public static final String DEVICE_RING = "DEVICE_RING";
|
||||||
|
public static final String DEVICE_REBOOT = "REBOOT";
|
||||||
|
public static final String UPGRADE_FIRMWARE = "UPGRADE_FIRMWARE";
|
||||||
|
public static final String NOTIFICATION = "NOTIFICATION";
|
||||||
|
public static final String WEBCLIP = "WEBCLIP";
|
||||||
|
public static final String DISENROLL = "DISENROLL";
|
||||||
|
public static final String MONITOR = "MONITOR";
|
||||||
|
public static final String VPN = "VPN";
|
||||||
|
public static final String APP_RESTRICTION = "APP-RESTRICTION";
|
||||||
|
public static final String WORK_PROFILE = "WORK_PROFILE";
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class StatusCodes {
|
||||||
|
private StatusCodes() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final int MULTI_STATUS_HTTP_CODE = 207;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class TenantConfigProperties {
|
||||||
|
private TenantConfigProperties() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String LICENSE_KEY = "androidEula";
|
||||||
|
public static final String LANGUAGE_US = "en_US";
|
||||||
|
public static final String CONTENT_TYPE_TEXT = "text";
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class ApplicationProperties {
|
||||||
|
private ApplicationProperties() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
public static final String NAME = "name";
|
public static final String NAME = "name";
|
||||||
public static final String IDENTIFIER = "package";
|
public static final String IDENTIFIER = "package";
|
||||||
public static final String USS = "USS";
|
public static final String USS = "USS";
|
||||||
public static final String VERSION = "version";
|
public static final String VERSION = "version";
|
||||||
public static final String ICON = "icon";
|
public static final String ICON = "icon";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,9 +20,6 @@ package org.wso2.carbon.mdm.services.android.util;
|
|||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.wso2.carbon.device.mgt.common.*;
|
import org.wso2.carbon.device.mgt.common.*;
|
||||||
import org.wso2.carbon.mdm.services.android.exception.BadRequestException;
|
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -33,13 +30,7 @@ public class AndroidDeviceUtils {
|
|||||||
|
|
||||||
private static final String COMMA_SEPARATION_PATTERN = ", ";
|
private static final String COMMA_SEPARATION_PATTERN = ", ";
|
||||||
|
|
||||||
public DeviceIDHolder validateDeviceIdentifiers(List<String> deviceIDs,
|
public DeviceIDHolder validateDeviceIdentifiers(List<String> deviceIDs) {
|
||||||
Message message, MediaType responseMediaType) {
|
|
||||||
|
|
||||||
if (deviceIDs == null || deviceIDs.isEmpty()) {
|
|
||||||
message.setResponseMessage("Device identifier list is empty");
|
|
||||||
throw new BadRequestException(message, responseMediaType);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> errorDeviceIdList = new ArrayList<String>();
|
List<String> errorDeviceIdList = new ArrayList<String>();
|
||||||
List<DeviceIdentifier> validDeviceIDList = new ArrayList<DeviceIdentifier>();
|
List<DeviceIdentifier> validDeviceIDList = new ArrayList<DeviceIdentifier>();
|
||||||
@ -64,8 +55,8 @@ public class AndroidDeviceUtils {
|
|||||||
if (isValidDeviceIdentifier(deviceIdentifier)) {
|
if (isValidDeviceIdentifier(deviceIdentifier)) {
|
||||||
validDeviceIDList.add(deviceIdentifier);
|
validDeviceIDList.add(deviceIdentifier);
|
||||||
} else {
|
} else {
|
||||||
errorDeviceIdList.add(String.format(AndroidConstants.DeviceConstants.DEVICE_ID_NOT_FOUND,
|
errorDeviceIdList.add(String.format(AndroidConstants.DeviceConstants.
|
||||||
deviceIDCounter));
|
DEVICE_ID_NOT_FOUND, deviceID));
|
||||||
}
|
}
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
errorDeviceIdList.add(String.format(AndroidConstants.DeviceConstants.DEVICE_ID_SERVICE_NOT_FOUND,
|
errorDeviceIdList.add(String.format(AndroidConstants.DeviceConstants.DEVICE_ID_SERVICE_NOT_FOUND,
|
||||||
|
|||||||
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.mdm.services.android.util;
|
||||||
|
|
||||||
|
import javax.servlet.*;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ApiOriginFilter implements Filter {
|
||||||
|
|
||||||
|
public void doFilter(ServletRequest request, ServletResponse response,
|
||||||
|
FilterChain chain) throws IOException, ServletException {
|
||||||
|
HttpServletResponse res = (HttpServletResponse) response;
|
||||||
|
res.addHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
|
||||||
|
res.addHeader("Access-Control-Allow-Headers", "Content-Type");
|
||||||
|
chain.doFilter(request, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroy() {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(FilterConfig filterConfig) throws ServletException {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -30,121 +30,116 @@
|
|||||||
<PermissionConfiguration>
|
<PermissionConfiguration>
|
||||||
<APIVersion></APIVersion>
|
<APIVersion></APIVersion>
|
||||||
<!-- Operations management related permissions for admin -->
|
<!-- Operations management related permissions for admin -->
|
||||||
<Permission>
|
|
||||||
<name>Get Pending Operation</name>
|
|
||||||
<path>/device-mgt/android/operations/poll</path>
|
|
||||||
<url>/operation/*</url>
|
|
||||||
<method>PUT</method>
|
|
||||||
<scope>emm_android_agent</scope>
|
|
||||||
</Permission>
|
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Lock</name>
|
<name>Lock</name>
|
||||||
<path>/device-mgt/android/operations/lock</path>
|
<path>/device-mgt/admin/operations/android/lock</path>
|
||||||
<url>/operation/lock</url>
|
<url>/admin/devices/lock-devices</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin,emm_user</scope>
|
<scope>emm_admin,emm_user</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Unlock</name>
|
<name>Unlock</name>
|
||||||
<path>/device-mgt/android/operations/unlock</path>
|
<path>/device-mgt/admin/operations/android/unlock</path>
|
||||||
<url>/operation/unlock</url>
|
<url>/admin/devices/unlock-devices</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin,emm_user</scope>
|
<scope>emm_admin,emm_user</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Mute</name>
|
<name>Mute</name>
|
||||||
<path>/device-mgt/android/operations/mute</path>
|
<path>/device-mgt/admin/operations/android/mute</path>
|
||||||
<url>/operation/mute</url>
|
<url>/admin/devices/mute</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin,emm_user</scope>
|
<scope>emm_admin,emm_user</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Location</name>
|
<name>Location</name>
|
||||||
<path>/device-mgt/android/operations/location</path>
|
<path>/device-mgt/admin/operations/android/location</path>
|
||||||
<url>/operation/location</url>
|
<url>/admin/devices/location</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin,emm_user</scope>
|
<scope>emm_admin,emm_user</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Clear Passcode</name>
|
<name>Clear Passcode</name>
|
||||||
<url>/operation/clear-password/</url>
|
<path>/device-mgt/admin/operations/android/clear-password</path>
|
||||||
|
<url>/admin/devices/clear-password</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin</scope>
|
<scope>emm_admin</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Camera</name>
|
<name>Camera</name>
|
||||||
<path>/device-mgt/android/operations/camera</path>
|
<path>/device-mgt/admin/operations/android/camera</path>
|
||||||
<url>/operation/camera</url>
|
<url>/admin/devices/control-camera</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin,emm_user</scope>
|
<scope>emm_admin,emm_user</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Device Info</name>
|
<name>Device Info</name>
|
||||||
<path>/device-mgt/android/operations/device-info</path>
|
<path>/device-mgt/admin/operations/android/device-info</path>
|
||||||
<url>/operation/device-info</url>
|
<url>/admin/devices/info</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin,emm_user</scope>
|
<scope>emm_admin,emm_user</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Enterprise Wipe</name>
|
<name>Enterprise Wipe</name>
|
||||||
<path>/device-mgt/android/operations/enterprise-wipe</path>
|
<path>/device-mgt/admin/operations/android/enterprise-wipe</path>
|
||||||
<url>/operation/enterprise-wipe</url>
|
<url>/admin/devices/enterprise-wipe</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin</scope>
|
<scope>emm_admin</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Wipe Data</name>
|
<name>Wipe Data</name>
|
||||||
<path>/device-mgt/android/operations/wipe-data</path>
|
<path>/device-mgt/admin/operations/android/wipe-data</path>
|
||||||
<url>/operation/wipe-data</url>
|
<url>/admin/devices/wipe</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin</scope>
|
<scope>emm_admin</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Application List</name>
|
<name>Application List</name>
|
||||||
<path>/device-mgt/android/operations/application-list</path>
|
<path>/device-mgt/admin/operations/android/application-list</path>
|
||||||
<url>/operation/application-list</url>
|
<url>/admin/devices/applications</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin,emm_user</scope>
|
<scope>emm_admin,emm_user</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Ring</name>
|
<name>Ring</name>
|
||||||
<path>/device-mgt/android/operations/ring-device</path>
|
<path>/device-mgt/admin/operations/android/ring-device</path>
|
||||||
<url>/operation/ring-device</url>
|
<url>/admin/devices/ring</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin,emm_user</scope>
|
<scope>emm_admin,emm_user</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Reboot</name>
|
<name>Reboot</name>
|
||||||
<path>/device-mgt/android/operations/reboot-device</path>
|
<path>/device-mgt/admin/operations/android/reboot-device</path>
|
||||||
<url>/operation/reboot-device</url>
|
<url>/admin/devices/reboot</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin,emm_user</scope>
|
<scope>emm_admin,emm_user</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Upgrade Firmware</name>
|
<name>Upgrade Firmware</name>
|
||||||
<path>/device-mgt/android/operations/upgrade-firmware</path>
|
<path>/device-mgt/admin/operations/android/upgrade-firmware</path>
|
||||||
<url>/operation/upgrade-firmware</url>
|
<url>/admin/devices/upgrade-firmware</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin,emm_user</scope>
|
<scope>emm_admin</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Configure VPN</name>
|
<name>Configure VPN</name>
|
||||||
<path>/device-mgt/android/operations/vpn</path>
|
<path>/device-mgt/admin/operations/android/vpn</path>
|
||||||
<url>/operation/vpn</url>
|
<url>/admin/devices/configure-vpn</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin,emm_user</scope>
|
<scope>emm_admin,emm_user</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
@ -152,86 +147,86 @@
|
|||||||
<Permission>
|
<Permission>
|
||||||
<name>Install Application</name>
|
<name>Install Application</name>
|
||||||
<path>/device-mgt/android/operations/install-application</path>
|
<path>/device-mgt/android/operations/install-application</path>
|
||||||
<url>/operation/install-application</url>
|
<url>/admin/devices/install-application</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin,emm_user</scope>
|
<scope>emm_admin,emm_user</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Update Application</name>
|
<name>Update Application</name>
|
||||||
<path>/device-mgt/android/operations/update-application</path>
|
<path>/device-mgt/admin/operations/android/install-application</path>
|
||||||
<url>/operation/update-application</url>
|
<url>/admin/devices/update-application</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin,emm_user</scope>
|
<scope>emm_admin,emm_user</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Uninstall Application</name>
|
<name>Uninstall Application</name>
|
||||||
<path>/device-mgt/android/operations/uninstall-application</path>
|
<path>/device-mgt/admin/operations/android/uninstall-application</path>
|
||||||
<url>/operation/uninstall-application</url>
|
<url>/admin/devices/uninstall-application</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin,emm_user</scope>
|
<scope>emm_admin,emm_user</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Blacklist Applications</name>
|
<name>Blacklist Applications</name>
|
||||||
<path>/device-mgt/android/operations/blacklist-applications</path>
|
<path>/device-mgt/admin/operations/android/blacklist-applications</path>
|
||||||
<url>/operation/blacklist-applications</url>
|
<url>/admin/devices/blacklist-applications</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin</scope>
|
<scope>emm_admin</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Notification</name>
|
<name>Notification</name>
|
||||||
<path>/device-mgt/android/operations/notification</path>
|
<path>/device-mgt/admin/operations/android/notification</path>
|
||||||
<url>/operation/notification</url>
|
<url>/admin/devices/send-notification</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin,emm_user</scope>
|
<scope>emm_admin,emm_user</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Wifi</name>
|
<name>Wifi</name>
|
||||||
<path>/device-mgt/android/operations/wifi</path>
|
<path>/device-mgt/admin/operations/android/wifi</path>
|
||||||
<url>/operation/wifi</url>
|
<url>/admin/devices/configure-wifi</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin</scope>
|
<scope>emm_admin</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Encryption</name>
|
<name>Encryption</name>
|
||||||
<path>/device-mgt/android/operations/encrypt</path>
|
<path>/device-mgt/admin/operations/android/encrypt</path>
|
||||||
<url>/operation/encrypt</url>
|
<url>/admin/devices/encrypt-storage</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin</scope>
|
<scope>emm_admin</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Change lock code</name>
|
<name>Change lock code</name>
|
||||||
<path>/device-mgt/android/operations/change-lock-code</path>
|
<path>/device-mgt/admin/operations/android/change-lock-code</path>
|
||||||
<url>/operation/change-lock-code</url>
|
<url>/admin/devices/change-lock-code</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin</scope>
|
<scope>emm_admin</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Password Policy</name>
|
<name>Password Policy</name>
|
||||||
<path>/device-mgt/android/operations/password-policy</path>
|
<path>/device-mgt/admin/operations/android/password-policy</path>
|
||||||
<url>/operation/password-policy</url>
|
<url>/admin/devices/set-password-policy</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin</scope>
|
<scope>emm_admin</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Webclip</name>
|
<name>Webclip</name>
|
||||||
<path>/device-mgt/android/operations/webclip</path>
|
<path>/device-mgt/admin/operations/android/webclip</path>
|
||||||
<url>/operation/webclip</url>
|
<url>/admin/devices/set-webclip</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin</scope>
|
<scope>emm_admin</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Disenroll</name>
|
<name>Disenroll</name>
|
||||||
<path>/device-mgt/android/operations/disenroll</path>
|
<path>/device-mgt/admin/operations/android/disenroll</path>
|
||||||
<url>/operation/disenroll</url>
|
<url>/operation/disenroll</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_android_agent</scope>
|
<scope>emm_android_agent</scope>
|
||||||
@ -240,7 +235,7 @@
|
|||||||
<!-- Device management related permissions -->
|
<!-- Device management related permissions -->
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>View devices</name>
|
<name>View devices</name>
|
||||||
<path>/device-mgt/android/devices/list</path>
|
<path>/device-mgt/admin/devices/view</path>
|
||||||
<url>/device</url>
|
<url>/device</url>
|
||||||
<method>GET</method>
|
<method>GET</method>
|
||||||
<scope>emm_admin</scope>
|
<scope>emm_admin</scope>
|
||||||
@ -248,7 +243,7 @@
|
|||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>View device</name>
|
<name>View device</name>
|
||||||
<path>/device-mgt/android/devices/view</path>
|
<path>/device-mgt/admin/devices/view</path>
|
||||||
<url>/device/*</url>
|
<url>/device/*</url>
|
||||||
<method>GET</method>
|
<method>GET</method>
|
||||||
<scope>emm_admin,emm_user</scope>
|
<scope>emm_admin,emm_user</scope>
|
||||||
@ -256,7 +251,7 @@
|
|||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Update device</name>
|
<name>Update device</name>
|
||||||
<path>/device-mgt/android/devices/update</path>
|
<path>/device-mgt/admin/devices/update</path>
|
||||||
<url>/device/*</url>
|
<url>/device/*</url>
|
||||||
<method>PUT</method>
|
<method>PUT</method>
|
||||||
<scope>emm_admin,emm_user</scope>
|
<scope>emm_admin,emm_user</scope>
|
||||||
@ -264,7 +259,7 @@
|
|||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Update application list</name>
|
<name>Update application list</name>
|
||||||
<path>/device-mgt/android/devices/update-app</path>
|
<path>/device-mgt/admin/operations/android/update-applist</path>
|
||||||
<url>/device/appList/*</url>
|
<url>/device/appList/*</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin</scope>
|
<scope>emm_admin</scope>
|
||||||
@ -272,8 +267,8 @@
|
|||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>View license</name>
|
<name>View license</name>
|
||||||
<path>/device-mgt/android/license/view</path>
|
<path>/device-mgt/user/enroll/android</path>
|
||||||
<url>/device/license</url>
|
<url>/configuration/license</url>
|
||||||
<method>GET</method>
|
<method>GET</method>
|
||||||
<scope>emm_android_agent</scope>
|
<scope>emm_android_agent</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
@ -281,20 +276,52 @@
|
|||||||
<!-- Enrollment related permissions -->
|
<!-- Enrollment related permissions -->
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Enroll device</name>
|
<name>Enroll device</name>
|
||||||
<path>/device-mgt/android/devices/enroll</path>
|
<path>/device-mgt/user/enroll/android</path>
|
||||||
<url>/enrollment</url>
|
<url>/devices</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_android_agent</scope>
|
<scope>emm_android_agent</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Get Enrollment Status</name>
|
<name>Devices related Operations</name>
|
||||||
<path>/device-mgt/android/devices/enroll</path>
|
<path>/device-mgt/user/enroll/android</path>
|
||||||
<url>/enrollment/*</url>
|
<url>/devices/*</url>
|
||||||
<method>GET</method>
|
<method>GET</method>
|
||||||
<scope>emm_android_agent</scope>
|
<scope>emm_android_agent</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
|
<Permission>
|
||||||
|
<name>Device is enrolled</name>
|
||||||
|
<path>/device-mgt/user/enroll/android</path>
|
||||||
|
<url>/devices/*/status</url>
|
||||||
|
<method>GET</method>
|
||||||
|
<scope>emm_android_agent</scope>
|
||||||
|
</Permission>
|
||||||
|
|
||||||
|
<Permission>
|
||||||
|
<name>Devices related Operations</name>
|
||||||
|
<path>/device-mgt/user/enroll/android</path>
|
||||||
|
<url>/devices/*/pending-operations</url>
|
||||||
|
<method>PUT</method>
|
||||||
|
<scope>emm_android_agent</scope>
|
||||||
|
</Permission>
|
||||||
|
|
||||||
|
<Permission>
|
||||||
|
<name>Modify devices</name>
|
||||||
|
<path>/device-mgt/user/enroll/android</path>
|
||||||
|
<url>/devices/*</url>
|
||||||
|
<method>PUT</method>
|
||||||
|
<scope>emm_android_agent</scope>
|
||||||
|
</Permission>
|
||||||
|
|
||||||
|
<Permission>
|
||||||
|
<name>Delete devices</name>
|
||||||
|
<path>/device-mgt/user/enroll/android</path>
|
||||||
|
<url>/devices/*</url>
|
||||||
|
<method>DELETE</method>
|
||||||
|
<scope>emm_android_agent</scope>
|
||||||
|
</Permission>
|
||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Update Enrollment</name>
|
<name>Update Enrollment</name>
|
||||||
<path>/device-mgt/android/devices/enroll</path>
|
<path>/device-mgt/android/devices/enroll</path>
|
||||||
@ -314,7 +341,7 @@
|
|||||||
<!-- Policy related permissions -->
|
<!-- Policy related permissions -->
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>View Policies</name>
|
<name>View Policies</name>
|
||||||
<path>/device-mgt/android/policies/view</path>
|
<path>/device-mgt/user/enroll/android</path>
|
||||||
<url>/policy/*</url>
|
<url>/policy/*</url>
|
||||||
<method>GET</method>
|
<method>GET</method>
|
||||||
<scope>emm_admin</scope>
|
<scope>emm_admin</scope>
|
||||||
@ -322,7 +349,7 @@
|
|||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>View Policy Features</name>
|
<name>View Policy Features</name>
|
||||||
<path>/device-mgt/android/policies/view</path>
|
<path>/device-mgt/user/enroll/android</path>
|
||||||
<url>/policy/features/*</url>
|
<url>/policy/features/*</url>
|
||||||
<method>GET</method>
|
<method>GET</method>
|
||||||
<scope>emm_admin</scope>
|
<scope>emm_admin</scope>
|
||||||
@ -331,7 +358,7 @@
|
|||||||
<!-- Configuration related permissions -->
|
<!-- Configuration related permissions -->
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>View Tenant configuration</name>
|
<name>View Tenant configuration</name>
|
||||||
<path>/device-mgt/android/tenant/configuration</path>
|
<path>/device-mgt/admin/platform-configs/view</path>
|
||||||
<url>/configuration</url>
|
<url>/configuration</url>
|
||||||
<method>GET</method>
|
<method>GET</method>
|
||||||
<scope>emm_admin</scope>
|
<scope>emm_admin</scope>
|
||||||
@ -339,7 +366,7 @@
|
|||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Add Tenant configuration</name>
|
<name>Add Tenant configuration</name>
|
||||||
<path>/device-mgt/android/tenant/configuration</path>
|
<path>/device-mgt/admin/platform-configs/add</path>
|
||||||
<url>/configuration</url>
|
<url>/configuration</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_admin</scope>
|
<scope>emm_admin</scope>
|
||||||
@ -347,7 +374,7 @@
|
|||||||
|
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Update Tenant configuration</name>
|
<name>Update Tenant configuration</name>
|
||||||
<path>/device-mgt/android/tenant/configuration</path>
|
<path>/device-mgt/admin/platform-configs/modify</path>
|
||||||
<url>/configuration</url>
|
<url>/configuration</url>
|
||||||
<method>PUT</method>
|
<method>PUT</method>
|
||||||
<scope>emm_admin</scope>
|
<scope>emm_admin</scope>
|
||||||
@ -355,28 +382,14 @@
|
|||||||
<Permission>
|
<Permission>
|
||||||
<name>Event Addition</name>
|
<name>Event Addition</name>
|
||||||
<path>/device-mgt/android/events/add</path>
|
<path>/device-mgt/android/events/add</path>
|
||||||
<url>/events</url>
|
<url>/events/publish</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
<scope>emm_user,emm_admin</scope>
|
<scope>emm_user,emm_admin</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Event Retrieve</name>
|
<name>Event Retrieve</name>
|
||||||
<path>/device-mgt/android/events/view</path>
|
<path>/device-mgt/android/events/view</path>
|
||||||
<url>/events/*</url>
|
<url>/events</url>
|
||||||
<method>GET</method>
|
|
||||||
<scope>emm_admin</scope>
|
|
||||||
</Permission>
|
|
||||||
<Permission>
|
|
||||||
<name>Event Retrieve</name>
|
|
||||||
<path>/device-mgt/android/events/date</path>
|
|
||||||
<url>/events/*/date</url>
|
|
||||||
<method>GET</method>
|
|
||||||
<scope>emm_admin</scope>
|
|
||||||
</Permission>
|
|
||||||
<Permission>
|
|
||||||
<name>Event Retrieve</name>
|
|
||||||
<path>/device-mgt/android/events/type</path>
|
|
||||||
<url>/events/*/type/*</url>
|
|
||||||
<method>GET</method>
|
<method>GET</method>
|
||||||
<scope>emm_admin</scope>
|
<scope>emm_admin</scope>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|||||||
@ -23,67 +23,41 @@
|
|||||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||||
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
|
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
|
||||||
|
|
||||||
<jaxrs:server id="operationService" address="/operation">
|
<jaxrs:server id="services" address="/">
|
||||||
<jaxrs:serviceBeans>
|
<jaxrs:serviceBeans>
|
||||||
<ref bean="operationServiceBean"/>
|
<ref bean="deviceManagementService"/>
|
||||||
</jaxrs:serviceBeans>
|
<ref bean="deviceManagementAdminService"/>
|
||||||
<jaxrs:providers>
|
<ref bean="eventReceiverService"/>
|
||||||
<ref bean="jsonProvider"/>
|
<ref bean="deviceTypeConfigurationService"/>
|
||||||
<ref bean="errorHandler"/>
|
<ref bean="swaggerResource"/>
|
||||||
</jaxrs:providers>
|
|
||||||
</jaxrs:server>
|
|
||||||
<jaxrs:server id="deviceManagementService" address="/device">
|
|
||||||
<jaxrs:serviceBeans>
|
|
||||||
<ref bean="deviceMgtServiceBean"/>
|
|
||||||
</jaxrs:serviceBeans>
|
|
||||||
<jaxrs:providers>
|
|
||||||
<ref bean="jsonProvider"/>
|
|
||||||
<ref bean="errorHandler"/>
|
|
||||||
</jaxrs:providers>
|
|
||||||
</jaxrs:server>
|
|
||||||
<jaxrs:server id="enrollmentService" address="/enrollment">
|
|
||||||
<jaxrs:serviceBeans>
|
|
||||||
<ref bean="enrollmentServiceBean"/>
|
|
||||||
</jaxrs:serviceBeans>
|
|
||||||
<jaxrs:providers>
|
|
||||||
<ref bean="jsonProvider"/>
|
|
||||||
<ref bean="errorHandler"/>
|
|
||||||
</jaxrs:providers>
|
|
||||||
</jaxrs:server>
|
|
||||||
<jaxrs:server id="policyService" address="/policy">
|
|
||||||
<jaxrs:serviceBeans>
|
|
||||||
<ref bean="policyServiceBean"/>
|
|
||||||
</jaxrs:serviceBeans>
|
|
||||||
<jaxrs:providers>
|
|
||||||
<ref bean="jsonProvider"/>
|
|
||||||
<ref bean="errorHandler"/>
|
|
||||||
</jaxrs:providers>
|
|
||||||
</jaxrs:server>
|
|
||||||
<jaxrs:server id="configurationService" address="/configuration">
|
|
||||||
<jaxrs:serviceBeans>
|
|
||||||
<ref bean="configurationServiceBean"/>
|
|
||||||
</jaxrs:serviceBeans>
|
|
||||||
<jaxrs:providers>
|
|
||||||
<ref bean="jsonProvider"/>
|
|
||||||
<ref bean="errorHandler"/>
|
|
||||||
</jaxrs:providers>
|
|
||||||
</jaxrs:server>
|
|
||||||
<jaxrs:server id="eventService" address="/events">
|
|
||||||
<jaxrs:serviceBeans>
|
|
||||||
<ref bean="eventServiceBean"/>
|
|
||||||
</jaxrs:serviceBeans>
|
</jaxrs:serviceBeans>
|
||||||
<jaxrs:providers>
|
<jaxrs:providers>
|
||||||
<ref bean="jsonProvider"/>
|
<ref bean="jsonProvider"/>
|
||||||
<ref bean="errorHandler"/>
|
<ref bean="errorHandler"/>
|
||||||
|
<ref bean="swaggerWriter"/>
|
||||||
</jaxrs:providers>
|
</jaxrs:providers>
|
||||||
</jaxrs:server>
|
</jaxrs:server>
|
||||||
|
|
||||||
<bean id="deviceMgtServiceBean" class="org.wso2.carbon.mdm.services.android.services.devicemgt.impl.DeviceManagementServiceImpl"/>
|
<bean id="swaggerWriter" class="io.swagger.jaxrs.listing.SwaggerSerializers" />
|
||||||
<bean id="enrollmentServiceBean" class="org.wso2.carbon.mdm.services.android.services.enrollment.impl.EnrollmentServiceImpl"/>
|
<bean id="swaggerResource" class="io.swagger.jaxrs.listing.ApiListingResource" />
|
||||||
<bean id="operationServiceBean" class="org.wso2.carbon.mdm.services.android.services.operationmgt.impl.OperationMgtServiceImpl"/>
|
|
||||||
<bean id="policyServiceBean" class="org.wso2.carbon.mdm.services.android.services.policymgt.impl.PolicyMgtServiceImpl"/>
|
<bean id="swaggerConfig" class="io.swagger.jaxrs.config.BeanConfig">
|
||||||
<bean id="configurationServiceBean" class="org.wso2.carbon.mdm.services.android.services.configuration.impl.ConfigurationMgtServiceImpl"/>
|
<property name="resourcePackage" value="org.wso2.carbon.mdm.services.android.services"/>
|
||||||
<bean id="eventServiceBean" class="org.wso2.carbon.mdm.services.android.services.event.impl.EventServiceImpl"/>
|
<property name="version" value="1.0"/>
|
||||||
|
<property name="host" value="localhost:9443"/>
|
||||||
|
<property name="schemes" value="https" />
|
||||||
|
<property name="basePath" value="/api/device-mgt/android/v1.0"/>
|
||||||
|
<property name="title" value="Android Device Management API Definitions"/>
|
||||||
|
<property name="contact" value="dev@wso2.org"/>
|
||||||
|
<property name="license" value="Apache 2.0"/>
|
||||||
|
<property name="licenseUrl" value="http://www.apache.org/licenses/LICENSE-2.0.html"/>
|
||||||
|
<property name="scan" value="true"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="deviceManagementService" class="org.wso2.carbon.mdm.services.android.services.impl.DeviceManagementServiceImpl"/>
|
||||||
|
<bean id="deviceManagementAdminService" class="org.wso2.carbon.mdm.services.android.services.impl.DeviceManagementAdminServiceImpl"/>
|
||||||
|
<bean id="eventReceiverService" class="org.wso2.carbon.mdm.services.android.services.impl.EventReceiverServiceImpl"/>
|
||||||
|
<bean id="deviceTypeConfigurationService" class="org.wso2.carbon.mdm.services.android.services.impl.DeviceTypeConfigurationServiceImpl"/>
|
||||||
<bean id="jsonProvider" class="org.wso2.carbon.mdm.services.android.common.GsonMessageBodyHandler"/>
|
<bean id="jsonProvider" class="org.wso2.carbon.mdm.services.android.common.GsonMessageBodyHandler"/>
|
||||||
<bean id="errorHandler" class="org.wso2.carbon.mdm.services.android.common.ErrorHandler"/>
|
<bean id="errorHandler" class="org.wso2.carbon.mdm.services.android.common.ErrorHandler"/>
|
||||||
</beans>
|
</beans>
|
||||||
|
|||||||
@ -28,6 +28,11 @@
|
|||||||
<servlet-class>
|
<servlet-class>
|
||||||
org.apache.cxf.transport.servlet.CXFServlet
|
org.apache.cxf.transport.servlet.CXFServlet
|
||||||
</servlet-class>
|
</servlet-class>
|
||||||
|
<!-- configure a security filter -->
|
||||||
|
<init-param>
|
||||||
|
<param-name>swagger.security.filter</param-name>
|
||||||
|
<param-value>ApiAuthorizationFilterImpl</param-value>
|
||||||
|
</init-param>
|
||||||
<load-on-startup>1</load-on-startup>
|
<load-on-startup>1</load-on-startup>
|
||||||
</servlet>
|
</servlet>
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
@ -74,4 +79,13 @@
|
|||||||
</user-data-constraint>
|
</user-data-constraint>
|
||||||
</security-constraint-->
|
</security-constraint-->
|
||||||
|
|
||||||
|
<filter>
|
||||||
|
<filter-name>ApiOriginFilter</filter-name>
|
||||||
|
<filter-class>org.wso2.carbon.mdm.services.android.util.ApiOriginFilter</filter-class>
|
||||||
|
</filter>
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>ApiOriginFilter</filter-name>
|
||||||
|
<url-pattern>/*</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
|
||||||
</web-app>
|
</web-app>
|
||||||
|
|||||||
@ -87,10 +87,9 @@ public class OperationUtils {
|
|||||||
Notification lockResetNotification = new Notification();
|
Notification lockResetNotification = new Notification();
|
||||||
lockResetNotification.setOperationId(status.getCommandReference());
|
lockResetNotification.setOperationId(status.getCommandReference());
|
||||||
lockResetNotification.setStatus(String.valueOf(Notification.Status.NEW));
|
lockResetNotification.setStatus(String.valueOf(Notification.Status.NEW));
|
||||||
lockResetNotification.setDeviceIdentifier(deviceIdentifier);
|
|
||||||
lockResetNotification.setDescription(
|
lockResetNotification.setDescription(
|
||||||
Constants.SyncMLResponseCodes.LOCKRESET_NOTIFICATION);
|
Constants.SyncMLResponseCodes.LOCKRESET_NOTIFICATION);
|
||||||
nmService.addNotification(lockResetNotification);
|
nmService.addNotification(deviceIdentifier, lockResetNotification);
|
||||||
} catch (NotificationManagementException e) {
|
} catch (NotificationManagementException e) {
|
||||||
throw new WindowsOperationException("Failure occurred in getting notification service", e);
|
throw new WindowsOperationException("Failure occurred in getting notification service", e);
|
||||||
}
|
}
|
||||||
@ -156,10 +155,9 @@ public class OperationUtils {
|
|||||||
Notification lockResetNotification = new Notification();
|
Notification lockResetNotification = new Notification();
|
||||||
lockResetNotification.setOperationId(status.getCommandReference());
|
lockResetNotification.setOperationId(status.getCommandReference());
|
||||||
lockResetNotification.setStatus(String.valueOf(Notification.Status.NEW));
|
lockResetNotification.setStatus(String.valueOf(Notification.Status.NEW));
|
||||||
lockResetNotification.setDeviceIdentifier(deviceIdentifier);
|
|
||||||
lockResetNotification.setDescription(Constants.SyncMLResponseCodes.LOCKRESET_NOTIFICATION);
|
lockResetNotification.setDescription(Constants.SyncMLResponseCodes.LOCKRESET_NOTIFICATION);
|
||||||
|
|
||||||
nmService.addNotification(lockResetNotification);
|
nmService.addNotification(deviceIdentifier, lockResetNotification);
|
||||||
} catch (NotificationManagementException e) {
|
} catch (NotificationManagementException e) {
|
||||||
String msg = "Failure occurred in getting notification service";
|
String msg = "Failure occurred in getting notification service";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
@ -404,10 +402,9 @@ public class OperationUtils {
|
|||||||
Notification notification = new Notification();
|
Notification notification = new Notification();
|
||||||
notification.setDescription("Auto generated DevicePin : " + pinValue);
|
notification.setDescription("Auto generated DevicePin : " + pinValue);
|
||||||
notification.setOperationId(result.getCommandReference());
|
notification.setOperationId(result.getCommandReference());
|
||||||
notification.setDeviceIdentifier(deviceIdentifier);
|
|
||||||
notification.setStatus(String.valueOf(Notification.Status.NEW));
|
notification.setStatus(String.valueOf(Notification.Status.NEW));
|
||||||
try {
|
try {
|
||||||
nmService.addNotification(notification);
|
nmService.addNotification(deviceIdentifier, notification);
|
||||||
} catch (NotificationManagementException e) {
|
} catch (NotificationManagementException e) {
|
||||||
String msg = "Failure Occurred in getting notification service.";
|
String msg = "Failure Occurred in getting notification service.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
|
|||||||
@ -118,7 +118,7 @@
|
|||||||
<overWrite>true</overWrite>
|
<overWrite>true</overWrite>
|
||||||
<outputDirectory>${project.build.directory}/maven-shared-archive-resources/webapps/
|
<outputDirectory>${project.build.directory}/maven-shared-archive-resources/webapps/
|
||||||
</outputDirectory>
|
</outputDirectory>
|
||||||
<destFileName>mdm-android-agent.war</destFileName>
|
<destFileName>api#device-mgt#android#v1.0.war</destFileName>
|
||||||
</artifactItem>
|
</artifactItem>
|
||||||
</artifactItems>
|
</artifactItems>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
instructions.configure = \
|
instructions.configure = \
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/webapps/mdm-android-agent.war,target:${installFolder}/../../deployment/server/webapps/mdm-android-agent.war,overwrite:true);\
|
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/webapps/api#device-mgt#android#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#device-mgt#android#v1.0.war,overwrite:true);\
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\
|
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/conf/mobile-config.xml,target:${installFolder}/../../conf/mobile-config.xml,overwrite:true);\
|
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/conf/mobile-config.xml,target:${installFolder}/../../conf/mobile-config.xml,overwrite:true);\
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/dbscripts/plugins/,target:${installFolder}/../../../dbscripts/cdm/plugins/android,overwrite:true);\
|
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/dbscripts/plugins/,target:${installFolder}/../../../dbscripts/cdm/plugins/android,overwrite:true);\
|
||||||
|
|||||||
24
pom.xml
24
pom.xml
@ -49,6 +49,28 @@
|
|||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
<version>${swagger.version}</version>
|
<version>${swagger.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-core</artifactId>
|
||||||
|
<version>${swagger.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-jaxrs</artifactId>
|
||||||
|
<version>${swagger.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>servlet-api</artifactId>
|
||||||
|
<version>${servlet-api.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!--Carbon Kernel Dependencies-->
|
<!--Carbon Kernel Dependencies-->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -1180,6 +1202,8 @@
|
|||||||
|
|
||||||
<!-- Release plugin ID for github-->
|
<!-- Release plugin ID for github-->
|
||||||
<project.scm.id>github-scm</project.scm.id>
|
<project.scm.id>github-scm</project.scm.id>
|
||||||
|
|
||||||
|
<servlet-api.version>2.5</servlet-api.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user