forked from community/device-mgt-plugins
Merge pull request #857 from lasanthaDLPDS/vf-dev-api
Adding New API version (v0.9) for Android device managementrevert-dabc3590
commit
2c38b2e939
@ -0,0 +1,360 @@
|
||||
<!--
|
||||
~ /*
|
||||
~ * Copyright (c) ${date}, 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.
|
||||
~ */
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<artifactId>android-plugin</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<version>4.0.102-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.device.mgt.mobile.android.v09.api</artifactId>
|
||||
<name>WSO2 Carbon - Android JAX-RS v09 API</name>
|
||||
<description>Android JAX-RS v09 API</description>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
<version>2.3.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<configuration>
|
||||
<packagingExcludes>WEB-INF/lib/*cxf*.jar</packagingExcludes>
|
||||
<warName>api#device-mgt#android#v0.9</warName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>jacoco-initialize</id>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>jacoco-site</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
|
||||
<outputDirectory>${basedir}/target/coverage-reports/site</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<log4j.configuration>file:src/test/resources/log4j.properties</log4j.configuration>
|
||||
</systemPropertyVariables>
|
||||
<suiteXmlFiles>
|
||||
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
|
||||
</suiteXmlFiles>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>deploy</id>
|
||||
<build>
|
||||
<defaultGoal>compile</defaultGoal>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<copy todir="${basedir}/../../../repository/deployment/server/webapps" overwrite="true">
|
||||
<fileset dir="${basedir}/target">
|
||||
<include name="api#device-mgt#android#v0.9.war" />
|
||||
</fileset>
|
||||
</copy>
|
||||
</tasks>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>jacoco-initialize</id>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>jacoco-site</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
|
||||
<outputDirectory>${basedir}/target/coverage-reports/site</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>client</id>
|
||||
<build>
|
||||
<defaultGoal>test</defaultGoal>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>java</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<dependencies>
|
||||
<!--project dependancies-->
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-transports-http</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!--CDM Dependencies-->
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.mobile.android</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient.wso2</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.analytics</groupId>
|
||||
<artifactId>org.wso2.carbon.analytics.api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</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>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>javax.ws.rs-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-module-testng</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-mockito</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database.wso2</groupId>
|
||||
<artifactId>h2-database-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.queuing</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.ndatasource.core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-dbcp.wso2</groupId>
|
||||
<artifactId>commons-dbcp</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-pool.wso2</groupId>
|
||||
<artifactId>commons-pool</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>javax.cache.wso2</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javassist</groupId>
|
||||
<artifactId>javassist</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-core-asl</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.google.gson.Gson;
|
||||
/*
|
||||
* This abstract class is used for extending generic functions with regard to operation.
|
||||
*/
|
||||
public abstract class AndroidOperation {
|
||||
|
||||
/*
|
||||
* This method is used to convert operation object to a json format.
|
||||
*
|
||||
* @return json formatted String.
|
||||
*/
|
||||
public String toJSON() {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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 io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(
|
||||
name = "PlatformConfiguration"
|
||||
)
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@ApiModel(
|
||||
value = "PlatformConfiguration",
|
||||
description = "This class carries all the information related to Android platform configurations."
|
||||
)
|
||||
public class AndroidPlatformConfiguration implements Serializable {
|
||||
public static final int INVALID_NOTIFIER_FREQUENCY = -1;
|
||||
@XmlElement(
|
||||
name = "type"
|
||||
)
|
||||
@ApiModelProperty(
|
||||
name = "type",
|
||||
value = "type of device",
|
||||
required = true
|
||||
)
|
||||
@Size(min = 2, max = 10)
|
||||
private String type;
|
||||
@ApiModelProperty(
|
||||
name = "configuration",
|
||||
value = "List of Configuration Entries",
|
||||
required = true
|
||||
)
|
||||
@XmlElement(
|
||||
name = "configuration"
|
||||
)
|
||||
private List<ConfigurationEntry> configuration;
|
||||
|
||||
public AndroidPlatformConfiguration() {
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public List<ConfigurationEntry> getConfiguration() {
|
||||
return this.configuration;
|
||||
}
|
||||
|
||||
public void setConfiguration(List<ConfigurationEntry> configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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 io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class represents information of configuring App Restriction ex: White list and Black list
|
||||
*/
|
||||
@ApiModel(value = "AppRestriction",
|
||||
description = "This class carries all information related to application restriction.")
|
||||
public class AppRestriction extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "restrictionType", value = "Restriction type of the application.", required = true)
|
||||
private String restrictionType;
|
||||
@ApiModelProperty(name = "restrictedList", value = "Device id list of the operation to be executed.", required = true)
|
||||
private List<String> restrictedList;
|
||||
|
||||
public String getRestrictionType() {
|
||||
return restrictionType;
|
||||
}
|
||||
|
||||
public void setRestrictionType(String restrictionType) {
|
||||
this.restrictionType = restrictionType;
|
||||
}
|
||||
|
||||
public List<String> getRestrictedList() {
|
||||
return restrictedList;
|
||||
}
|
||||
|
||||
public void setRestrictedList(List<String> restrictedList) {
|
||||
this.restrictedList = restrictedList;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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 io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of install application operation.
|
||||
*/
|
||||
@ApiModel(value = "ApplicationInstallation",
|
||||
description = "This class carries all information related to install application")
|
||||
public class ApplicationInstallation extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "appIdentifier", value = "Application Identifier", required = true)
|
||||
@Size(min = 2, max = 45)
|
||||
@Pattern(regexp = "^[A-Za-z0-9]*$")
|
||||
private String appIdentifier;
|
||||
|
||||
@ApiModelProperty(name = "type", value = "Application type(Enterprise/Web/public)", required = true)
|
||||
@Size(min = 2, max = 12)
|
||||
@Pattern(regexp = "^[A-Za-z]*$")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(name = "url", value = "Application URL", required = true)
|
||||
private String url;
|
||||
|
||||
@ApiModelProperty(name = "schedule", value = "Schedule of the App installation.")
|
||||
private String schedule;
|
||||
|
||||
public String getAppIdentifier() {
|
||||
return appIdentifier;
|
||||
}
|
||||
|
||||
public void setAppIdentifier(String appIdentifier) {
|
||||
this.appIdentifier = appIdentifier;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String getSchedule() {
|
||||
return schedule;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void setSchedule(String schedule) {
|
||||
this.schedule = schedule;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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 io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of uninstall application operation.
|
||||
*/
|
||||
@ApiModel(value = "ApplicationUninstallation",
|
||||
description = "This class carries all information related to application uninstallation.")
|
||||
public class ApplicationUninstallation extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "appIdentifier", value = "The package name of the application to be uninstalled.", required = true)
|
||||
@Size(min = 2, max = 45)
|
||||
@Pattern(regexp = "^[A-Za-z0-9]*$")
|
||||
private String appIdentifier;
|
||||
|
||||
@ApiModelProperty(name = "type", value = "The type of the application. The following types of applications " +
|
||||
"are supported: enterprise, public and webapp.", required = true)
|
||||
@Size(min = 2, max = 12)
|
||||
@Pattern(regexp = "^[A-Za-z]*$")
|
||||
private String type;
|
||||
|
||||
public String getAppIdentifier() {
|
||||
return appIdentifier;
|
||||
}
|
||||
|
||||
public void setAppIdentifier(String appIdentifier) {
|
||||
this.appIdentifier = appIdentifier;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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 io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of Update application operation.
|
||||
*/
|
||||
@ApiModel(value = "ApplicationUpdate",
|
||||
description = "This class carries all information related to application update.")
|
||||
public class ApplicationUpdate extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "appIdentifier", value = "The package name of the application " +
|
||||
"to be update.", required = true)
|
||||
@Size(min = 2, max = 45)
|
||||
@Pattern(regexp = "^[A-Za-z0-9]*$")
|
||||
private String appIdentifier;
|
||||
@ApiModelProperty(name = "type", value = "The type of the application. The following types of applications " +
|
||||
"are supported: enterprise, public and webapp.", required = true)
|
||||
@Size(min = 2, max = 12)
|
||||
@Pattern(regexp = "^[A-Za-z]*$")
|
||||
private String type;
|
||||
@ApiModelProperty(name = "url", value = "The URL of the application.", required = true)
|
||||
private String url;
|
||||
@ApiModelProperty(name = "schedule", value = "Application update schedule.", required = false)
|
||||
private String schedule;
|
||||
|
||||
public String getAppIdentifier() {
|
||||
return appIdentifier;
|
||||
}
|
||||
|
||||
public void setAppIdentifier(String appIdentifier) {
|
||||
this.appIdentifier = appIdentifier;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getSchedule() {
|
||||
return schedule;
|
||||
}
|
||||
|
||||
public void setSchedule(String schedule) {
|
||||
this.schedule = schedule;
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class represents the blacklist applications information.
|
||||
*/
|
||||
@ApiModel(value = "BlacklistApplications",
|
||||
description = "This class represents the blacklist applications information.")
|
||||
public class BlacklistApplications extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "appIdentifiers", value = "A list of application package names to be blacklisted.",
|
||||
required = true)
|
||||
@Size(min = 1, max = 45)
|
||||
private List<String> appIdentifiers;
|
||||
|
||||
public List<String> getAppIdentifier() {
|
||||
return appIdentifiers;
|
||||
}
|
||||
|
||||
public void setAppIdentifier(List<String> appIdentifiers) {
|
||||
this.appIdentifiers = appIdentifiers;
|
||||
}
|
||||
|
||||
}
|
@ -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.bean;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of camera operation.
|
||||
*/
|
||||
@ApiModel(value = "Camera",
|
||||
description = "This class represents the information of camera operation.")
|
||||
public class Camera extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "enabled", value = "Disable the camera on the device by assigning false as the value or " +
|
||||
"enable the camera on the device to function by defining true as the value.", required = true)
|
||||
private boolean enabled;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
@ -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.bean;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of encrypt operation.
|
||||
*/
|
||||
|
||||
@ApiModel(value = "DeviceEncryption",
|
||||
description = "Details related device encryption.")
|
||||
public class DeviceEncryption extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "encrypted", value = "Whether to enable encryption or not.", required = true)
|
||||
private boolean encrypted;
|
||||
|
||||
public boolean isEncrypted() {
|
||||
return encrypted;
|
||||
}
|
||||
|
||||
public void setEncrypted(boolean encrypted) {
|
||||
this.encrypted = encrypted;
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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 io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ApiModel(value = "DeviceLock",
|
||||
description = "This class carries all information related to device lock operation.")
|
||||
public class DeviceLock extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "message", value = "Pop up message of the lock operation.", required = false)
|
||||
private String message;
|
||||
@ApiModelProperty(name = "isHardLockEnabled", value = "Hard lock enable status of the Device", required = true)
|
||||
private boolean isHardLockEnabled;
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public boolean isHardLockEnabled() {
|
||||
return isHardLockEnabled;
|
||||
}
|
||||
|
||||
public void setHardLockEnabled(boolean hardLockEnabled) {
|
||||
isHardLockEnabled = hardLockEnabled;
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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 io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@XmlRootElement
|
||||
/**
|
||||
* Store Device state event/data for androidDevice.
|
||||
*/
|
||||
@ApiModel(value = "DeviceState",
|
||||
description = "This class carries all information related to device state.")
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class DeviceState {
|
||||
|
||||
@XmlElementWrapper(required = true, name = "values")
|
||||
@ApiModelProperty(name = "values", value = "Device and its statuses.", required = true)
|
||||
private Map<String, Object> values;
|
||||
|
||||
/** The id. */
|
||||
@XmlElement(required = false, name = "id")
|
||||
@ApiModelProperty(name = "id", value = "Identification code.", required = true)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* Gets the values.
|
||||
* @return the values
|
||||
*/
|
||||
public Map<String, Object> getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the values.
|
||||
* @param values the values
|
||||
*/
|
||||
public void setValues(Map<String, Object> values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id.
|
||||
* @param id the new id
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
List<String> valueList = new ArrayList<String>();
|
||||
for (Map.Entry<String, Object> entry : values.entrySet()) {
|
||||
valueList.add(entry.getKey() + ":" + entry.getValue());
|
||||
}
|
||||
return valueList.toString();
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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 io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel(value = "Disenrollment",
|
||||
description = "Details related to disenrolling a device.")
|
||||
public class Disenrollment extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "enabled", value = "Whether to enable disenrollment or not.", required = true)
|
||||
private boolean enabled;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
@ -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,190 @@
|
||||
/*
|
||||
* 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<>();
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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 io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.AndroidOperation;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of file transfer operation payload.
|
||||
*/
|
||||
@ApiModel(value = "FileTransfer",
|
||||
description = "This class carries all information related to file transfer operation.")
|
||||
public class FileTransfer extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "fileURL", value = "File URL", required = true)
|
||||
private String fileURL;
|
||||
|
||||
@ApiModelProperty(name = "userName", value = "User Name", required = true)
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty(name = "ftpPassword", value = "FTP password", required = true)
|
||||
private String ftpPassword;
|
||||
|
||||
@ApiModelProperty(name = "fileLocation", value = "fileLocation", required = true)
|
||||
private String fileLocation;
|
||||
|
||||
public String getFileURL() {
|
||||
return fileURL;
|
||||
}
|
||||
|
||||
public void setFileURL(String fileURL) {
|
||||
this.fileURL = fileURL;
|
||||
}
|
||||
|
||||
public String getFtpPassword() {
|
||||
return ftpPassword;
|
||||
}
|
||||
|
||||
public void setFtpPassword(String ftpPassword) {
|
||||
this.ftpPassword = ftpPassword;
|
||||
}
|
||||
|
||||
public String getFileLocation() {
|
||||
return fileLocation;
|
||||
}
|
||||
|
||||
public void setFileLocation(String fileLocation) {
|
||||
this.fileLocation = fileLocation;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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 io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of changing lock code operation.
|
||||
*/
|
||||
@ApiModel(value = "LockCode",
|
||||
description = "Details related to lock code sent on device.")
|
||||
public class LockCode extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "lockCode", value = "The lock code to be sent to the device.", required = true)
|
||||
private String lockCode;
|
||||
|
||||
public String getLockCode() {
|
||||
return lockCode;
|
||||
}
|
||||
|
||||
public void setLockCode(String lockCode) {
|
||||
this.lockCode = lockCode;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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 io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of sending notification operation.
|
||||
*/
|
||||
@ApiModel(value = "Notification",
|
||||
description = "Details related to notifications passed to device.")
|
||||
public class Notification extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "messageText", value = "The message text to be sent to the device.", required = true)
|
||||
private String messageText;
|
||||
|
||||
@ApiModelProperty(name = "messageTitle", value = "The message title to be sent to the device.", required = true)
|
||||
private String messageTitle;
|
||||
|
||||
public String getMessageText() {
|
||||
return messageText;
|
||||
}
|
||||
|
||||
public void setMessageText(String messageText) {
|
||||
this.messageText = messageText;
|
||||
}
|
||||
|
||||
public String getMessageTitle() {
|
||||
return messageTitle;
|
||||
}
|
||||
|
||||
public void setMessageTitle(String messageTitle) {
|
||||
this.messageTitle = messageTitle;
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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 io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of setting up password policy.
|
||||
*/
|
||||
@ApiModel(value = "PasscodePolicy", description = "This class represents the information of setting up "
|
||||
+ "password policy")
|
||||
public class PasscodePolicy extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "maxFailedAttempts", value = "The maximum number of times the end-user can enter"
|
||||
+ " his/her device passcode incorrectly. EMM will take different courses of action based on the"
|
||||
+ " OS when the failed attempts exceed the maximum failed attempts. Android devices will be "
|
||||
+ "automatically reset to the original factory settings", required = true)
|
||||
|
||||
@Max(10)
|
||||
private int maxFailedAttempts;
|
||||
@ApiModelProperty(name = "minLength", value = "The minimum number of alphanumerical values that the "
|
||||
+ "end-user can enter as his/her passcode", required = true)
|
||||
@Max(15)
|
||||
private int minLength;
|
||||
@ApiModelProperty(name = "pinHistory", value = "The end-user will not be allowed to reuse a passcode that"
|
||||
+ " he/she previously entered until he/she exceeds the set pin history length", required = true)
|
||||
@Max(50)
|
||||
private int pinHistory;
|
||||
@ApiModelProperty(name = "minComplexChars", value = "The minimum number of special characters that the "
|
||||
+ "end-user will have to enter in his/her passcode", required = true)
|
||||
@Max(5)
|
||||
private int minComplexChars;
|
||||
@ApiModelProperty(name = "maxPINAgeInDays", value = "The number of days after which the device owner has"
|
||||
+ " to change his/her passcode", required = true)
|
||||
@Max(730)
|
||||
private int maxPINAgeInDays;
|
||||
@ApiModelProperty(name = "requireAlphanumeric", value = "Whether or not it is mandatory for the end-user"
|
||||
+ " to have a mix of digits and characters in his/her passcode", required = true)
|
||||
private boolean requireAlphanumeric;
|
||||
@ApiModelProperty(name = "allowSimple", value = "If this field is set to 'true', the device owner will be"
|
||||
+ " able to have a simple passcode and the following criteria in the passcode policy will not be"
|
||||
+ " applicable:\n"
|
||||
+ "Minimum length\n" + "Minimum complex characters", required = true)
|
||||
private boolean allowSimple;
|
||||
|
||||
public int getMaxFailedAttempts() {
|
||||
return maxFailedAttempts;
|
||||
}
|
||||
|
||||
public void setMaxFailedAttempts(int maxFailedAttempts) {
|
||||
this.maxFailedAttempts = maxFailedAttempts;
|
||||
}
|
||||
|
||||
public int getMinLength() {
|
||||
return minLength;
|
||||
}
|
||||
|
||||
public void setMinLength(int minLength) {
|
||||
this.minLength = minLength;
|
||||
}
|
||||
|
||||
public int getPinHistory() {
|
||||
return pinHistory;
|
||||
}
|
||||
|
||||
public void setPinHistory(int pinHistory) {
|
||||
this.pinHistory = pinHistory;
|
||||
}
|
||||
|
||||
public int getMinComplexChars() {
|
||||
return minComplexChars;
|
||||
}
|
||||
|
||||
public void setMinComplexChars(int minComplexChars) {
|
||||
this.minComplexChars = minComplexChars;
|
||||
}
|
||||
|
||||
public int getMaxPINAgeInDays() {
|
||||
return maxPINAgeInDays;
|
||||
}
|
||||
|
||||
public void setMaxPINAgeInDays(int maxPINAgeInDays) {
|
||||
this.maxPINAgeInDays = maxPINAgeInDays;
|
||||
}
|
||||
|
||||
public boolean isRequireAlphanumeric() {
|
||||
return requireAlphanumeric;
|
||||
}
|
||||
|
||||
public void setRequireAlphanumeric(boolean requireAlphanumeric) {
|
||||
this.requireAlphanumeric = requireAlphanumeric;
|
||||
}
|
||||
|
||||
public boolean isAllowSimple() {
|
||||
return allowSimple;
|
||||
}
|
||||
|
||||
public void setAllowSimple(boolean allowSimple) {
|
||||
this.allowSimple = allowSimple;
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.bean;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of sending Upgrade Firmware operation.
|
||||
*/
|
||||
@ApiModel(value = "UpgradeFirmware",
|
||||
description = "This class carries all information related to UpgradeFirmware.")
|
||||
public class UpgradeFirmware extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "schedule", value = "Schedule of the UpgradeFirmware.")
|
||||
private String schedule;
|
||||
|
||||
@ApiModelProperty(name = "server", value = "Firmware package server.")
|
||||
private String server;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String getSchedule() {
|
||||
return schedule;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void setSchedule(String schedule) {
|
||||
this.schedule = schedule;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void setServer(String server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* you may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.bean;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of configuring VPN operation.
|
||||
*/
|
||||
@ApiModel(value = "Vpn",
|
||||
description = "This class carries all information related to VPN.")
|
||||
public class Vpn extends AndroidOperation implements Serializable {
|
||||
@ApiModelProperty(name = "serverAddress", value = "Server Address.", required = true)
|
||||
private String serverAddress;
|
||||
@ApiModelProperty(name = "serverPort", value = "Server Port.", required = true)
|
||||
private String serverPort;
|
||||
@ApiModelProperty(name = "sharedSecret", value = "Shared secret.", required = true)
|
||||
private String sharedSecret;
|
||||
@ApiModelProperty(name = "dnsServer", value = "DNS server.", required = true)
|
||||
private String dnsServer;
|
||||
|
||||
public String getServerAddress() {
|
||||
return serverAddress;
|
||||
}
|
||||
|
||||
public void setServerAddress(String serverAddress) {
|
||||
this.serverAddress = serverAddress;
|
||||
}
|
||||
|
||||
public String getServerPort() {
|
||||
return serverPort;
|
||||
}
|
||||
|
||||
public void setServerPort(String serverPort) {
|
||||
this.serverPort = serverPort;
|
||||
}
|
||||
|
||||
public String getSharedSecret() {
|
||||
return sharedSecret;
|
||||
}
|
||||
|
||||
public void setSharedSecret(String sharedSecret) {
|
||||
this.sharedSecret = sharedSecret;
|
||||
}
|
||||
|
||||
public String getDnsServer() {
|
||||
return dnsServer;
|
||||
}
|
||||
|
||||
public void setDnsServer(String dnsServer) {
|
||||
this.dnsServer = dnsServer;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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 io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of setting up webclip.
|
||||
*/
|
||||
@ApiModel(value = "WebClip", description = "This class represents the information of setting up webclip")
|
||||
public class WebClip extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "identity", value = "The URL of the application", required = true)
|
||||
private String identity;
|
||||
@ApiModelProperty(name = "title", value = "The name of the web application", required = true)
|
||||
private String title;
|
||||
@ApiModelProperty(name = "type", value = "The type of the operation. Following are the possible operation"
|
||||
+ " types: install and uninstall. If the operation type is install, the web clip is added, and "
|
||||
+ "if the operation type is uninstall, the existing web clip is removed", required = true)
|
||||
private String type;
|
||||
|
||||
public String getIdentity() {
|
||||
return identity;
|
||||
}
|
||||
|
||||
public void setIdentity(String identity) {
|
||||
this.identity = identity;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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 io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of configuring wifi operation.
|
||||
*/
|
||||
@ApiModel(value = "Wifi", description = "This class represents the information of configuring wifi operation")
|
||||
public class Wifi extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "ssid", value = "The name of the Wifi network that you wish to configure",
|
||||
required = true)
|
||||
private String ssid;
|
||||
@ApiModelProperty(name = "password", value = "The password to connect to the specified Wifi network",
|
||||
required = true)
|
||||
private String password;
|
||||
|
||||
public String getSsid() {
|
||||
return ssid;
|
||||
}
|
||||
|
||||
public void setSsid(String ssid) {
|
||||
this.ssid = ssid;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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 io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of wipedata operation.
|
||||
*/
|
||||
@ApiModel(value = "WipeData", description = "This class represents the information of wipedata operation")
|
||||
public class WipeData extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "pin", value = "PIN number to proceed with the data wipe", required = true)
|
||||
private String pin;
|
||||
|
||||
public String getPin() {
|
||||
return pin;
|
||||
}
|
||||
|
||||
public void setPin(String pin) {
|
||||
this.pin = pin;
|
||||
}
|
||||
}
|
@ -0,0 +1,206 @@
|
||||
package org.wso2.carbon.mdm.services.android.bean.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
@ApiModel(
|
||||
value = "Application",
|
||||
description = "This class carries all information related application"
|
||||
)
|
||||
public class AndroidApplication implements Serializable{
|
||||
private static final long serialVersionUID = 1998101711L;
|
||||
@ApiModelProperty(
|
||||
name = "id",
|
||||
value = "The ID given to the application when it is stored in the EMM database",
|
||||
required = true
|
||||
)
|
||||
private int id;
|
||||
@ApiModelProperty(
|
||||
name = "platform",
|
||||
value = "The mobile device platform. It can be android, ios or windows",
|
||||
required = true
|
||||
)
|
||||
private String platform;
|
||||
@ApiModelProperty(
|
||||
name = "category",
|
||||
value = "The application category",
|
||||
required = true
|
||||
)
|
||||
private String category;
|
||||
@ApiModelProperty(
|
||||
name = "name",
|
||||
value = "The application\'s name",
|
||||
required = true
|
||||
)
|
||||
private String name;
|
||||
private String locationUrl;
|
||||
@ApiModelProperty(
|
||||
name = "imageUrl",
|
||||
value = "The icon url of the application",
|
||||
required = true
|
||||
)
|
||||
private String imageUrl;
|
||||
@ApiModelProperty(
|
||||
name = "version",
|
||||
value = "The application\'s version",
|
||||
required = true
|
||||
)
|
||||
private String version;
|
||||
@ApiModelProperty(
|
||||
name = "type",
|
||||
value = "The application type",
|
||||
required = true
|
||||
)
|
||||
private String type;
|
||||
@ApiModelProperty(
|
||||
name = "appProperties",
|
||||
value = "The properties of the application",
|
||||
required = true
|
||||
)
|
||||
private Properties appProperties;
|
||||
@ApiModelProperty(
|
||||
name = "applicationIdentifier",
|
||||
value = "The application identifier",
|
||||
required = true
|
||||
)
|
||||
private String applicationIdentifier;
|
||||
@ApiModelProperty(
|
||||
name = "memoryUsage",
|
||||
value = "Amount of memory used by the application",
|
||||
required = true
|
||||
)
|
||||
private int memoryUsage;
|
||||
@ApiModelProperty(
|
||||
name = "isActive",
|
||||
value = "Is the application actively running",
|
||||
required = true
|
||||
)
|
||||
private boolean isActive;
|
||||
|
||||
public AndroidApplication() {
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLocationUrl() {
|
||||
return this.locationUrl;
|
||||
}
|
||||
|
||||
public void setLocationUrl(String locationUrl) {
|
||||
this.locationUrl = locationUrl;
|
||||
}
|
||||
|
||||
public String getImageUrl() {
|
||||
return this.imageUrl;
|
||||
}
|
||||
|
||||
public void setImageUrl(String imageUrl) {
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getPlatform() {
|
||||
return this.platform;
|
||||
}
|
||||
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return this.category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public String getApplicationIdentifier() {
|
||||
return this.applicationIdentifier;
|
||||
}
|
||||
|
||||
public void setApplicationIdentifier(String applicationIdentifier) {
|
||||
this.applicationIdentifier = applicationIdentifier;
|
||||
}
|
||||
|
||||
public int getMemoryUsage() {
|
||||
return this.memoryUsage;
|
||||
}
|
||||
|
||||
public void setMemoryUsage(int memoryUsage) {
|
||||
this.memoryUsage = memoryUsage;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) {
|
||||
return true;
|
||||
} else if(o != null && this.getClass() == o.getClass()) {
|
||||
AndroidApplication that = (AndroidApplication)o;
|
||||
if(this.applicationIdentifier != null) {
|
||||
if(!this.applicationIdentifier.equals(that.applicationIdentifier)) {
|
||||
return false;
|
||||
}
|
||||
} else if(that.applicationIdentifier != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result = this.id;
|
||||
result = 31 * result + (this.applicationIdentifier != null?this.applicationIdentifier.hashCode():0);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Properties getAppProperties() {
|
||||
return this.appProperties;
|
||||
}
|
||||
|
||||
public void setAppProperties(Properties appProperties) {
|
||||
this.appProperties = appProperties;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return this.isActive;
|
||||
}
|
||||
|
||||
public void setActive(boolean active) {
|
||||
this.isActive = active;
|
||||
}
|
||||
}
|
@ -0,0 +1,201 @@
|
||||
/*
|
||||
* 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||
import org.wso2.carbon.device.mgt.common.Feature;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class AndroidDevice implements Serializable {
|
||||
private static final long serialVersionUID = 1998101711L;
|
||||
|
||||
@ApiModelProperty(
|
||||
name = "name",
|
||||
value = "The device name that can be set on the device by the device user.",
|
||||
required = true
|
||||
)
|
||||
@Size(min = 2, max = 45)
|
||||
private String name;
|
||||
@ApiModelProperty(
|
||||
name = "description",
|
||||
value = "Additional information on the device.",
|
||||
required = true
|
||||
)
|
||||
private String description;
|
||||
@ApiModelProperty(
|
||||
name = "deviceIdentifier",
|
||||
value = "This is a 64-bit number (as a hex string) that is randomly generated when the user first sets up the device and should remain constant for the lifetime of the user\'s device. The value may change if a factory reset is performed on the device.",
|
||||
required = true
|
||||
)
|
||||
@NotNull
|
||||
@Size(min = 2, max = 45)
|
||||
private String deviceIdentifier;
|
||||
@ApiModelProperty(
|
||||
name = "enrolmentInfo",
|
||||
value = "This defines the device registration related information. It is mandatory to define this information.",
|
||||
required = true
|
||||
)
|
||||
private EnrolmentInfo enrolmentInfo;
|
||||
@ApiModelProperty(
|
||||
name = "features",
|
||||
value = "List of features.",
|
||||
required = true
|
||||
)
|
||||
private List<Feature> features;
|
||||
private List<Device.Property> properties;
|
||||
@ApiModelProperty(
|
||||
name = "advanceInfo",
|
||||
value = "This defines the device registration related information. It is mandatory to define this information.",
|
||||
required = false
|
||||
)
|
||||
private DeviceInfo deviceInfo;
|
||||
@ApiModelProperty(
|
||||
name = "applications",
|
||||
value = "This represents the application list installed into the device",
|
||||
required = false
|
||||
)
|
||||
private List<Application> applications;
|
||||
|
||||
public AndroidDevice() {
|
||||
}
|
||||
|
||||
public AndroidDevice(String name, String description, String deviceId, EnrolmentInfo enrolmentInfo, List<Feature> features, List<Device.Property> properties) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.deviceIdentifier = deviceId;
|
||||
this.enrolmentInfo = enrolmentInfo;
|
||||
this.features = features;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getDeviceIdentifier() {
|
||||
return this.deviceIdentifier;
|
||||
}
|
||||
|
||||
public void setDeviceIdentifier(String deviceIdentifier) {
|
||||
this.deviceIdentifier = deviceIdentifier;
|
||||
}
|
||||
|
||||
public EnrolmentInfo getEnrolmentInfo() {
|
||||
return this.enrolmentInfo;
|
||||
}
|
||||
|
||||
public void setEnrolmentInfo(EnrolmentInfo enrolmentInfo) {
|
||||
this.enrolmentInfo = enrolmentInfo;
|
||||
}
|
||||
|
||||
public List<Feature> getFeatures() {
|
||||
return this.features;
|
||||
}
|
||||
|
||||
public void setFeatures(List<Feature> features) {
|
||||
this.features = features;
|
||||
}
|
||||
|
||||
public List<Device.Property> getProperties() {
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
public void setProperties(List<Device.Property> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public DeviceInfo getDeviceInfo() {
|
||||
return this.deviceInfo;
|
||||
}
|
||||
|
||||
public void setDeviceInfo(DeviceInfo deviceInfo) {
|
||||
this.deviceInfo = deviceInfo;
|
||||
}
|
||||
|
||||
public List<Application> getApplications() {
|
||||
return this.applications;
|
||||
}
|
||||
|
||||
public void setApplications(List<Application> applications) {
|
||||
this.applications = applications;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "device [name=" + this.name + ";" + ";" + "description=" + this.description + ";" + "identifier=" + this.deviceIdentifier + ";" + "]";
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
} else if (!(o instanceof AndroidDevice)) {
|
||||
return false;
|
||||
} else {
|
||||
AndroidDevice device = (AndroidDevice) o;
|
||||
return this.getDeviceIdentifier().equals(device.getDeviceIdentifier());
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.getDeviceIdentifier().hashCode();
|
||||
}
|
||||
|
||||
public static class Property {
|
||||
private String name;
|
||||
private String value;
|
||||
|
||||
public Property() {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,321 @@
|
||||
package org.wso2.carbon.mdm.services.android.bean.wrapper;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ApiModel(
|
||||
value = "DeviceInfo",
|
||||
description = "This class carries all information related to the device information provided by a device."
|
||||
)
|
||||
public class AndroidDeviceInfo extends DeviceInfo implements Serializable {
|
||||
private static final long serialVersionUID = 1998101733L;
|
||||
@ApiModelProperty(
|
||||
name = "IMEI",
|
||||
value = "IMEI number of the device.",
|
||||
required = true
|
||||
)
|
||||
private String IMEI;
|
||||
@ApiModelProperty(
|
||||
name = "IMSI",
|
||||
value = "IMSI number of the device.",
|
||||
required = true
|
||||
)
|
||||
private String IMSI;
|
||||
@ApiModelProperty(
|
||||
name = "deviceModel",
|
||||
value = "Model of the device.",
|
||||
required = true
|
||||
)
|
||||
private String deviceModel;
|
||||
@ApiModelProperty(
|
||||
name = "vendor",
|
||||
value = "Vendor of the device.",
|
||||
required = true
|
||||
)
|
||||
private String vendor;
|
||||
@ApiModelProperty(
|
||||
name = "osVersion",
|
||||
value = "Operating system version.",
|
||||
required = true
|
||||
)
|
||||
private String osVersion;
|
||||
@ApiModelProperty(
|
||||
name = "batteryLevel",
|
||||
value = "Battery level of the device.",
|
||||
required = true
|
||||
)
|
||||
private Double batteryLevel;
|
||||
@ApiModelProperty(
|
||||
name = "internalTotalMemory",
|
||||
value = "Total internal memory of the device.",
|
||||
required = true
|
||||
)
|
||||
private Double internalTotalMemory;
|
||||
@ApiModelProperty(
|
||||
name = "internalAvailableMemory",
|
||||
value = "Total available memory of the device.",
|
||||
required = true
|
||||
)
|
||||
private Double internalAvailableMemory;
|
||||
@ApiModelProperty(
|
||||
name = "externalTotalMemory",
|
||||
value = "Total external memory of the device.",
|
||||
required = true
|
||||
)
|
||||
private Double externalTotalMemory;
|
||||
@ApiModelProperty(
|
||||
name = "externalAvailableMemory",
|
||||
value = "Total external memory avilable of the device.",
|
||||
required = true
|
||||
)
|
||||
private Double externalAvailableMemory;
|
||||
@ApiModelProperty(
|
||||
name = "operator",
|
||||
value = "Mobile operator of the device.",
|
||||
required = true
|
||||
)
|
||||
private String operator;
|
||||
@ApiModelProperty(
|
||||
name = "connectionType",
|
||||
value = "How the device is connected to the network.",
|
||||
required = true
|
||||
)
|
||||
private String connectionType;
|
||||
@ApiModelProperty(
|
||||
name = "mobileSignalStrength",
|
||||
value = "Current mobile signal strength.",
|
||||
required = true
|
||||
)
|
||||
private Double mobileSignalStrength;
|
||||
@ApiModelProperty(
|
||||
name = "ssid",
|
||||
value = "ssid of the connected WiFi.",
|
||||
required = true
|
||||
)
|
||||
private String ssid;
|
||||
@ApiModelProperty(
|
||||
name = "cpuUsage",
|
||||
value = "Current total cpu usage.",
|
||||
required = true
|
||||
)
|
||||
private Double cpuUsage;
|
||||
@ApiModelProperty(
|
||||
name = "totalRAMMemory",
|
||||
value = "Total Ram memory size.",
|
||||
required = true
|
||||
)
|
||||
private Double totalRAMMemory;
|
||||
@ApiModelProperty(
|
||||
name = "availableRAMMemory",
|
||||
value = "Available total memory of RAM.",
|
||||
required = true
|
||||
)
|
||||
private Double availableRAMMemory;
|
||||
@ApiModelProperty(
|
||||
name = "pluggedIn",
|
||||
value = "Whether the device is plugged into power or not.",
|
||||
required = true
|
||||
)
|
||||
private boolean pluggedIn;
|
||||
@ApiModelProperty(
|
||||
name = "updatedTime",
|
||||
value = "Device updated time.",
|
||||
required = true
|
||||
)
|
||||
private Date updatedTime;
|
||||
@ApiModelProperty(
|
||||
name = "location",
|
||||
value = "Last updated location of the device",
|
||||
required = false
|
||||
)
|
||||
private DeviceLocation location;
|
||||
@ApiModelProperty(
|
||||
name = "deviceDetailsMap",
|
||||
value = ".",
|
||||
required = true
|
||||
)
|
||||
private Map<String, String> deviceDetailsMap = new HashMap();
|
||||
|
||||
public AndroidDeviceInfo() {
|
||||
}
|
||||
|
||||
public DeviceLocation getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
public void setLocation(DeviceLocation location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getIMEI() {
|
||||
return this.IMEI != null?this.IMEI:"";
|
||||
}
|
||||
|
||||
public void setIMEI(String IMEI) {
|
||||
this.IMEI = IMEI;
|
||||
}
|
||||
|
||||
public String getIMSI() {
|
||||
return this.IMSI != null?this.IMSI:"";
|
||||
}
|
||||
|
||||
public void setIMSI(String IMSI) {
|
||||
this.IMSI = IMSI;
|
||||
}
|
||||
|
||||
public String getDeviceModel() {
|
||||
return this.deviceModel != null?this.deviceModel:"";
|
||||
}
|
||||
|
||||
public void setDeviceModel(String deviceModel) {
|
||||
this.deviceModel = deviceModel;
|
||||
}
|
||||
|
||||
public String getVendor() {
|
||||
return this.vendor != null?this.vendor:"";
|
||||
}
|
||||
|
||||
public void setVendor(String vendor) {
|
||||
this.vendor = vendor;
|
||||
}
|
||||
|
||||
public String getOsVersion() {
|
||||
return this.osVersion != null?this.osVersion:"";
|
||||
}
|
||||
|
||||
public void setOsVersion(String osVersion) {
|
||||
this.osVersion = osVersion;
|
||||
}
|
||||
|
||||
public Double getBatteryLevel() {
|
||||
return this.batteryLevel != null?this.batteryLevel:Double.valueOf(0.0D);
|
||||
}
|
||||
|
||||
public void setBatteryLevel(Double batteryLevel) {
|
||||
this.batteryLevel = batteryLevel;
|
||||
}
|
||||
|
||||
public Double getInternalTotalMemory() {
|
||||
return this.internalTotalMemory != null?this.internalTotalMemory:Double.valueOf(0.0D);
|
||||
}
|
||||
|
||||
public void setInternalTotalMemory(Double internalTotalMemory) {
|
||||
this.internalTotalMemory = internalTotalMemory;
|
||||
}
|
||||
|
||||
public Double getInternalAvailableMemory() {
|
||||
return this.internalAvailableMemory != null?this.internalAvailableMemory:Double.valueOf(0.0D);
|
||||
}
|
||||
|
||||
public void setInternalAvailableMemory(Double internalAvailableMemory) {
|
||||
this.internalAvailableMemory = internalAvailableMemory;
|
||||
}
|
||||
|
||||
public Double getExternalTotalMemory() {
|
||||
return this.externalTotalMemory != null?this.externalTotalMemory:Double.valueOf(0.0D);
|
||||
}
|
||||
|
||||
public void setExternalTotalMemory(Double externalTotalMemory) {
|
||||
this.externalTotalMemory = externalTotalMemory;
|
||||
}
|
||||
|
||||
public Double getExternalAvailableMemory() {
|
||||
return this.externalAvailableMemory != null?this.externalAvailableMemory:Double.valueOf(0.0D);
|
||||
}
|
||||
|
||||
public void setExternalAvailableMemory(Double externalAvailableMemory) {
|
||||
this.externalAvailableMemory = externalAvailableMemory;
|
||||
}
|
||||
|
||||
public String getOperator() {
|
||||
return this.operator != null?this.operator:"";
|
||||
}
|
||||
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public String getConnectionType() {
|
||||
return this.connectionType != null?this.connectionType:"";
|
||||
}
|
||||
|
||||
public void setConnectionType(String connectionType) {
|
||||
this.connectionType = connectionType;
|
||||
}
|
||||
|
||||
public Double getMobileSignalStrength() {
|
||||
return this.mobileSignalStrength != null?this.mobileSignalStrength:Double.valueOf(0.0D);
|
||||
}
|
||||
|
||||
public void setMobileSignalStrength(Double mobileSignalStrength) {
|
||||
this.mobileSignalStrength = mobileSignalStrength;
|
||||
}
|
||||
|
||||
public String getSsid() {
|
||||
return this.ssid != null?this.ssid:"";
|
||||
}
|
||||
|
||||
public void setSsid(String ssid) {
|
||||
this.ssid = ssid;
|
||||
}
|
||||
|
||||
public Double getCpuUsage() {
|
||||
return this.cpuUsage != null?this.cpuUsage:Double.valueOf(0.0D);
|
||||
}
|
||||
|
||||
public void setCpuUsage(Double cpuUsage) {
|
||||
this.cpuUsage = cpuUsage;
|
||||
}
|
||||
|
||||
public Double getTotalRAMMemory() {
|
||||
return this.totalRAMMemory != null?this.totalRAMMemory:Double.valueOf(0.0D);
|
||||
}
|
||||
|
||||
public void setTotalRAMMemory(Double totalRAMMemory) {
|
||||
this.totalRAMMemory = totalRAMMemory;
|
||||
}
|
||||
|
||||
public Double getAvailableRAMMemory() {
|
||||
return this.availableRAMMemory != null?this.availableRAMMemory:Double.valueOf(0.0D);
|
||||
}
|
||||
|
||||
public void setAvailableRAMMemory(Double availableRAMMemory) {
|
||||
this.availableRAMMemory = availableRAMMemory;
|
||||
}
|
||||
|
||||
public boolean isPluggedIn() {
|
||||
return this.pluggedIn;
|
||||
}
|
||||
|
||||
public void setPluggedIn(boolean pluggedIn) {
|
||||
this.pluggedIn = pluggedIn;
|
||||
}
|
||||
|
||||
public Date getUpdatedTime() {
|
||||
if(this.updatedTime == null) {
|
||||
this.updatedTime = new Date();
|
||||
}
|
||||
|
||||
return this.updatedTime;
|
||||
}
|
||||
|
||||
public void setUpdatedTime(Date updatedTime) {
|
||||
this.updatedTime = updatedTime;
|
||||
}
|
||||
|
||||
public void setDeviceDetailsMap(Map<String, String> deviceDetailsMap) {
|
||||
this.deviceDetailsMap = deviceDetailsMap;
|
||||
}
|
||||
|
||||
public Map<String, String> getDeviceDetailsMap() {
|
||||
return this.deviceDetailsMap;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.AppRestriction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap AppRestriction bean with devices
|
||||
*/
|
||||
@ApiModel(value = "AppRestrictionBeanWrapper",
|
||||
description = "Application Restriction related information.")
|
||||
public class AppRestrictionBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "operation", value = "AppRestriction related information.", required = true)
|
||||
private AppRestriction operation;
|
||||
@ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true)
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public AppRestriction getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(AppRestriction operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.ApplicationInstallation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the InstallApplication bean with devices.
|
||||
*/
|
||||
|
||||
@ApiModel(value = "ApplicationInstallationBeanWrapper",
|
||||
description = "This class carries all information related to a InstallApplication")
|
||||
public class ApplicationInstallationBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "deviceIDs", value = "List of Devices", required = true)
|
||||
private List<String> deviceIDs;
|
||||
@ApiModelProperty(name = "operation", value = "App Installation property", required = true)
|
||||
private ApplicationInstallation operation;
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
|
||||
public ApplicationInstallation getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(ApplicationInstallation operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.ApplicationUninstallation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the UninstallApplication bean with devices.
|
||||
*/
|
||||
@ApiModel(value = "ApplicationUninstallationBeanWrapper",
|
||||
description = "This class carries all information related to Uninstall Application")
|
||||
public class ApplicationUninstallationBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true)
|
||||
private List<String> deviceIDs;
|
||||
|
||||
@ApiModelProperty(name = "operation", value = "Name of the device", required = true)
|
||||
private ApplicationUninstallation operation;
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
|
||||
public ApplicationUninstallation getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(ApplicationUninstallation operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.ApplicationUpdate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the UpdateApplication bean with devices.
|
||||
*/
|
||||
@ApiModel(value = "ApplicationUpdateBeanWrapper",
|
||||
description = "Application Update related Info.")
|
||||
public class ApplicationUpdateBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true)
|
||||
private List<String> deviceIDs;
|
||||
@ApiModelProperty(name = "operation", value = "Application Update related information.", required = true)
|
||||
private ApplicationUpdate operation;
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
|
||||
public ApplicationUpdate getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(ApplicationUpdate operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.BlacklistApplications;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the BlacklistApplications bean with devices.
|
||||
*/
|
||||
@ApiModel(value = "BlacklistApplicationsBeanWrapper",
|
||||
description = "Mapping between blacklist application and the device ids.")
|
||||
public class BlacklistApplicationsBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "operation", value = "Blacklist applications information", required = true)
|
||||
private @Valid BlacklistApplications operation;
|
||||
@ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true)
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public @Valid BlacklistApplications getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(@Valid BlacklistApplications operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.Camera;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the Camera bean with devices.
|
||||
*/
|
||||
|
||||
@ApiModel(value = "CameraBeanWrapper",
|
||||
description = "Mapping between camera operation and device list to be applied.")
|
||||
public class CameraBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "operation", value = "Information of camera operation", required = true)
|
||||
private Camera operation;
|
||||
@ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true)
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public Camera getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(Camera operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel(value = "EnrolmentInfo", description = "This class carries all information related to a devices enrollment" +
|
||||
" status.")
|
||||
public class DeviceEnrollmentInfo extends EnrolmentInfo implements Serializable {
|
||||
private static final long serialVersionUID = 1998101712L;
|
||||
|
||||
@ApiModelProperty(name = "device", value = "Enrolled device.", required = true)
|
||||
private Device device;
|
||||
@ApiModelProperty(name = "dateOfEnrolment", value = "Date of the device enrollment.", required = true)
|
||||
private Long dateOfEnrolment;
|
||||
@ApiModelProperty(name = "dateOfLastUpdate", value = "Date of the device's last update.", required = true)
|
||||
private Long dateOfLastUpdate;
|
||||
@ApiModelProperty(name = "ownership", value = "Defines the ownership details. The ownership type can be any of the" +
|
||||
" following values.\n" +
|
||||
"BYOD - Bring your own device (BYOD).\n" +
|
||||
"COPE - Corporate owned personally enabled (COPE).", required = true)
|
||||
private OwnerShip ownership;
|
||||
@ApiModelProperty(name = "status", value = "Current status of the device, such as whether the device " +
|
||||
"is active, removed etc.", required = true)
|
||||
private Status status;
|
||||
@ApiModelProperty(name = "owner", value = "The device owner's name.", required = true)
|
||||
private String owner;
|
||||
|
||||
public DeviceEnrollmentInfo() {
|
||||
}
|
||||
|
||||
public DeviceEnrollmentInfo(Device device, String owner, OwnerShip ownership, Status status) {
|
||||
this.device = device;
|
||||
this.owner = owner;
|
||||
this.ownership = ownership;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Long getDateOfEnrolment() {
|
||||
return dateOfEnrolment;
|
||||
}
|
||||
|
||||
public void setDateOfEnrolment(Long dateOfEnrolment) {
|
||||
this.dateOfEnrolment = dateOfEnrolment;
|
||||
}
|
||||
|
||||
public Long getDateOfLastUpdate() {
|
||||
return dateOfLastUpdate;
|
||||
}
|
||||
|
||||
public void setDateOfLastUpdate(Long dateOfLastUpdate) {
|
||||
this.dateOfLastUpdate = dateOfLastUpdate;
|
||||
}
|
||||
|
||||
public OwnerShip getOwnership() {
|
||||
return ownership;
|
||||
}
|
||||
|
||||
public void setOwnership(OwnerShip ownership) {
|
||||
this.ownership = ownership;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public Device getDevice() {
|
||||
return device;
|
||||
}
|
||||
|
||||
public void setDevice(Device device) {
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof DeviceEnrollmentInfo) {
|
||||
DeviceEnrollmentInfo tempInfo = (DeviceEnrollmentInfo) obj;
|
||||
if (this.owner != null && this.ownership != null) {
|
||||
if (this.owner.equals(tempInfo.getOwner()) && this.ownership.equals(tempInfo.getOwnership())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return owner.hashCode() ^ ownership.hashCode();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.DeviceLock;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the Notification bean with devices.
|
||||
*/
|
||||
@ApiModel(value = "DeviceLockBeanWrapper",
|
||||
description = "DeviceLock related Information.")
|
||||
public class DeviceLockBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true)
|
||||
private List<String> deviceIDs;
|
||||
@ApiModelProperty(name = "operation", value = "Information of the Device lock operation.", required = true)
|
||||
private DeviceLock operation;
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
|
||||
public DeviceLock getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(DeviceLock operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.Disenrollment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel(value = "DisenrollmentBeanWrapper", description = "Disenrollment details are mapped to devices list.")
|
||||
public class DisenrollmentBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "operation", value = "Disenrollment operation.", required = true)
|
||||
private Disenrollment operation;
|
||||
@ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true)
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public Disenrollment getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(Disenrollment operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.DeviceEncryption;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the Encrypt bean with devices.
|
||||
*/
|
||||
@ApiModel(value = "EncryptionBeanWrapper",
|
||||
description = "Mapping between encryption operation and device list to be applied.")
|
||||
public class EncryptionBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "operation", value = "The information of encrypt operation", required = true)
|
||||
private DeviceEncryption operation;
|
||||
@ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true)
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public DeviceEncryption getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(DeviceEncryption operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the events which receive from the agent application.
|
||||
*/
|
||||
@ApiModel(value = "EventBeanWrapper",
|
||||
description = "Android agent's event related Information.")
|
||||
public class EventBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "deviceIdentifier", value = "DeviceIdentifier to be need to retrieve/publish Event.", required = true)
|
||||
@Size(min = 2, max = 45)
|
||||
private String deviceIdentifier;
|
||||
@ApiModelProperty(name = "payload", value = "Event payload.", required = true)
|
||||
private String payload;
|
||||
@ApiModelProperty(name = "type", value = "Type of the event.", required = true)
|
||||
@Size(min = 2, max = 20)
|
||||
private String type;
|
||||
|
||||
public String getPayload() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
public void setPayload(String payload) {
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
public String getDeviceIdentifier() {
|
||||
return deviceIdentifier;
|
||||
}
|
||||
|
||||
public void setDeviceIdentifier(String deviceIdentifier) {
|
||||
this.deviceIdentifier = deviceIdentifier;
|
||||
}
|
||||
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.FileTransfer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the File Transfer bean with devices.
|
||||
*/
|
||||
@ApiModel(value = "FileTransferBeanWrapper",
|
||||
description = "FileTransfer related Information.")
|
||||
public class FileTransferBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true)
|
||||
private List<String> deviceIDs;
|
||||
|
||||
@ApiModelProperty(name = "upload", value = "Upload / Download w.r.t device.",
|
||||
notes = "upload = true , If file is to be uploaded to the device.", required = true)
|
||||
private boolean upload;
|
||||
|
||||
@ApiModelProperty(name = "operation", value = "Information of the File Transfer Operation.", required = true)
|
||||
private FileTransfer operation;
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
|
||||
public FileTransfer getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(FileTransfer operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public boolean isUpload() {
|
||||
return upload;
|
||||
}
|
||||
|
||||
public void setUpload(boolean upload) {
|
||||
this.upload = upload;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.LockCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the LockCode bean with devices.
|
||||
*/
|
||||
|
||||
@ApiModel(value = "LockCodeBeanWrapper",
|
||||
description = "Mapping between lock operation and device list to be applied.")
|
||||
public class LockCodeBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "operation", value = "The information of device lock operation", required = true)
|
||||
private LockCode operation;
|
||||
@ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true)
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public LockCode getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(LockCode operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.Notification;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the Notification bean with devices.
|
||||
*/
|
||||
|
||||
@ApiModel(value = "NotificationBeanWrapper",
|
||||
description = "Mapping between notification operation and device list to be applied.")
|
||||
public class NotificationBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true)
|
||||
private List<String> deviceIDs;
|
||||
@ApiModelProperty(name = "operation", value = "The information of notification operation", required = true)
|
||||
private Notification operation;
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
|
||||
public Notification getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(Notification operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.PasscodePolicy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the PasswordPolicy bean with devices.
|
||||
*/
|
||||
|
||||
@ApiModel(value = "PasswordPolicyBeanWrapper",
|
||||
description = "Mapping between passcode policy and device list to be applied.")
|
||||
public class PasswordPolicyBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "operation", value = "The information of setting up password policy", required = true)
|
||||
private PasscodePolicy operation;
|
||||
@ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true)
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public PasscodePolicy getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(PasscodePolicy operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.wso2.carbon.mdm.services.android.bean.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.UpgradeFirmware;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the UpgradeFirmware bean with devices.
|
||||
*/
|
||||
@ApiModel(value = "UpgradeFirmwareBeanWrapper",
|
||||
description = "Information related to UpgradeFirmware.")
|
||||
public class UpgradeFirmwareBeanWrapper {
|
||||
@ApiModelProperty(name = "deviceIDs",
|
||||
value = "List of device Ids to be need to execute UpgradeFirmware operation.", required = true)
|
||||
private List<String> deviceIDs;
|
||||
@ApiModelProperty(name = "operation", value = "Information related to UpgradeFirmware operation.", required = true)
|
||||
private UpgradeFirmware operation;
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
|
||||
public UpgradeFirmware getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(UpgradeFirmware operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.wso2.carbon.mdm.services.android.bean.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.Vpn;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the Vpn bean with devices.
|
||||
*/
|
||||
@ApiModel(value = "VpnBeanWrapper",
|
||||
description = "Information related to VPN Configuration.")
|
||||
public class VpnBeanWrapper {
|
||||
@ApiModelProperty(name = "operation",
|
||||
value = "List of device Ids to be need to execute VPN operation.", required = true)
|
||||
private Vpn operation;
|
||||
@ApiModelProperty(name = "deviceIDs",
|
||||
value = "List of device Ids to be need to execute VPN operation.", required = true)
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public Vpn getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(Vpn operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.WebClip;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the WebClip bean with devices.
|
||||
*/
|
||||
|
||||
@ApiModel(value = "WebClipBeanWrapper",
|
||||
description = "Mapping between web clip operation and device list to be applied.")
|
||||
public class WebClipBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "operation", value = "the information of setting up webclip.", required = true)
|
||||
private WebClip operation;
|
||||
@ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true)
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public WebClip getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(WebClip operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.Wifi;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the Wifi bean with devices.
|
||||
*/
|
||||
@ApiModel(value = "WifiBeanWrapper",
|
||||
description = "Mapping between wifi operation and device list to be applied.")
|
||||
public class WifiBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "operation", value = "Information of configuring wifi operation", required = true)
|
||||
private Wifi operation;
|
||||
@ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true)
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public Wifi getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(Wifi operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.WipeData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the WipeData bean with devices.
|
||||
*/
|
||||
@ApiModel(value = "WipeDataBeanWrapper",
|
||||
description = "Mapping between wipe operation and device list to be applied.")
|
||||
public class WipeDataBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "operation", value = "The information of wipedata operation", required = true)
|
||||
private WipeData operation;
|
||||
@ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true)
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public WipeData getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(WipeData operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -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.common;
|
||||
|
||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
||||
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.ext.ExceptionMapper;
|
||||
|
||||
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
public class ErrorHandler implements ExceptionMapper<AndroidAgentException> {
|
||||
|
||||
public Response toResponse(AndroidAgentException exception) {
|
||||
ErrorMessage errorMessage = new ErrorMessage();
|
||||
errorMessage.setErrorMessage(exception.getErrorMessage());
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.common;
|
||||
|
||||
|
||||
public class ErrorMessage {
|
||||
|
||||
private String errorMessage;
|
||||
private String errorCode;
|
||||
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
public void setErrorMessage(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public void setErrorCode(String errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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.common;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.ext.MessageBodyReader;
|
||||
import javax.ws.rs.ext.MessageBodyWriter;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||
|
||||
@Provider
|
||||
@Produces(APPLICATION_JSON)
|
||||
@Consumes(APPLICATION_JSON)
|
||||
public class GsonMessageBodyHandler implements MessageBodyWriter<Object>, MessageBodyReader<Object> {
|
||||
|
||||
private Gson gson;
|
||||
private static final String UTF_8 = "UTF-8";
|
||||
|
||||
public boolean isReadable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private Gson getGson() {
|
||||
if (gson == null) {
|
||||
final GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
gson = gsonBuilder.create();
|
||||
}
|
||||
return gson;
|
||||
}
|
||||
|
||||
public Object readFrom(Class<Object> objectClass, Type type, Annotation[] annotations, MediaType mediaType,
|
||||
MultivaluedMap<String, String> stringStringMultivaluedMap, InputStream entityStream)
|
||||
throws IOException, WebApplicationException {
|
||||
|
||||
InputStreamReader reader = new InputStreamReader(entityStream, "UTF-8");
|
||||
|
||||
try {
|
||||
return getGson().fromJson(reader, type);
|
||||
} finally {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isWriteable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public long getSize(Object o, Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void writeTo(Object object, Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType,
|
||||
MultivaluedMap<String, Object> stringObjectMultivaluedMap, OutputStream entityStream)
|
||||
throws IOException, WebApplicationException {
|
||||
|
||||
OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8);
|
||||
try {
|
||||
getGson().toJson(object, type, writer);
|
||||
} finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 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.common;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.cxf.interceptor.Fault;
|
||||
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
|
||||
import org.apache.cxf.jaxrs.model.ClassResourceInfo;
|
||||
import org.apache.cxf.jaxrs.model.OperationResourceInfo;
|
||||
import org.apache.cxf.message.Message;
|
||||
import org.apache.cxf.message.MessageContentsList;
|
||||
import org.apache.cxf.phase.AbstractPhaseInterceptor;
|
||||
import org.apache.cxf.phase.Phase;
|
||||
|
||||
import javax.validation.*;
|
||||
import javax.validation.executable.ExecutableValidator;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ValidationInterceptor extends AbstractPhaseInterceptor<Message> {
|
||||
|
||||
private Log log = LogFactory.getLog(getClass());
|
||||
private Validator validator = null; //validator interface is thread-safe
|
||||
|
||||
public ValidationInterceptor() {
|
||||
super(Phase.PRE_INVOKE);
|
||||
ValidatorFactory defaultFactory = Validation.buildDefaultValidatorFactory();
|
||||
validator = defaultFactory.getValidator();
|
||||
if (validator == null) {
|
||||
log.warn("Bean Validation provider could not be found, no validation will be performed");
|
||||
} else {
|
||||
log.debug("Validation In-Interceptor initialized successfully");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void handleMessage(Message message) throws Fault {
|
||||
final OperationResourceInfo operationResource = message.getExchange().get(OperationResourceInfo.class);
|
||||
if (operationResource == null) {
|
||||
log.info("OperationResourceInfo is not available, skipping validation");
|
||||
return;
|
||||
}
|
||||
|
||||
final ClassResourceInfo classResource = operationResource.getClassResourceInfo();
|
||||
if (classResource == null) {
|
||||
log.info("ClassResourceInfo is not available, skipping validation");
|
||||
return;
|
||||
}
|
||||
|
||||
final ResourceProvider resourceProvider = classResource.getResourceProvider();
|
||||
if (resourceProvider == null) {
|
||||
log.info("ResourceProvider is not available, skipping validation");
|
||||
return;
|
||||
}
|
||||
|
||||
final List<Object> arguments = MessageContentsList.getContentsList(message);
|
||||
final Method method = operationResource.getAnnotatedMethod();
|
||||
final Object instance = resourceProvider.getInstance(message);
|
||||
if (method != null && arguments != null) {
|
||||
//validate the parameters(arguments) over the invoked method
|
||||
validate(method, arguments.toArray(), instance);
|
||||
|
||||
//validate the fields of each argument
|
||||
for (Object arg : arguments) {
|
||||
if (arg != null)
|
||||
validate(arg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public <T> void validate(final Method method, final Object[] arguments, final T instance) {
|
||||
if (validator == null) {
|
||||
log.warn("Bean Validation provider could not be found, no validation will be performed");
|
||||
return;
|
||||
}
|
||||
|
||||
ExecutableValidator methodValidator = validator.forExecutables();
|
||||
Set<ConstraintViolation<T>> violations = methodValidator.validateParameters(instance,
|
||||
method, arguments);
|
||||
|
||||
if (!violations.isEmpty()) {
|
||||
throw new ConstraintViolationException(violations);
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void validate(final T object) {
|
||||
if (validator == null) {
|
||||
log.warn("Bean Validation provider could be found, no validation will be performed");
|
||||
return;
|
||||
}
|
||||
|
||||
Set<ConstraintViolation<T>> violations = validator.validate(object);
|
||||
|
||||
if (!violations.isEmpty()) {
|
||||
throw new ConstraintViolationException(violations);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleFault(Message messageParam) {
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* Custom exception class for Android API related exceptions.
|
||||
*
|
||||
*/
|
||||
public class AndroidAgentException extends Exception{
|
||||
|
||||
private static final long serialVersionUID = 7950151650447893900L;
|
||||
private String errorMessage;
|
||||
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
public void setErrorMessage(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
public AndroidAgentException(String msg, Exception nestedEx) {
|
||||
super(msg, nestedEx);
|
||||
setErrorMessage(msg);
|
||||
}
|
||||
|
||||
public AndroidAgentException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
setErrorMessage(message);
|
||||
}
|
||||
|
||||
public AndroidAgentException(String msg) {
|
||||
super(msg);
|
||||
setErrorMessage(msg);
|
||||
}
|
||||
|
||||
public AndroidAgentException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public AndroidAgentException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.util.Message;
|
||||
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
* Custom exception class for wrapping Android Operation related exceptions.
|
||||
*/
|
||||
public class AndroidOperationException extends WebApplicationException {
|
||||
|
||||
public AndroidOperationException(Message message, MediaType mediaType) {
|
||||
super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).
|
||||
type(mediaType).build());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Custom exception class for wrapping BadRequest related exceptions.
|
||||
*/
|
||||
public class BadRequestException extends WebApplicationException {
|
||||
|
||||
public BadRequestException(ErrorResponse error) {
|
||||
super(Response.status(Response.Status.BAD_REQUEST).entity(error).build());
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ErrorDTO {
|
||||
|
||||
private Long code = null;
|
||||
private String message = null;
|
||||
private String description = null;
|
||||
|
||||
public void setMoreInfo(String moreInfo) {
|
||||
this.moreInfo = moreInfo;
|
||||
}
|
||||
|
||||
public void setCode(Long code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setError(List<ErrorDTO> error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
private String moreInfo = null;
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public Long getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getMoreInfo() {
|
||||
return moreInfo;
|
||||
}
|
||||
|
||||
public List<ErrorDTO> getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("class ErrorDTO {\n");
|
||||
stringBuilder.append(" code: ").append(code).append("\n");
|
||||
stringBuilder.append(" message: ").append(message).append("\n");
|
||||
stringBuilder.append(" description: ").append(description).append("\n");
|
||||
stringBuilder.append(" moreInfo: ").append(moreInfo).append("\n");
|
||||
stringBuilder.append(" error: ").append(error).append("\n");
|
||||
stringBuilder.append("}\n");
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
private List<ErrorDTO> error = new ArrayList<>();
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.util.AndroidConstants;
|
||||
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
* Exception class that is corresponding to 401 Forbidden response
|
||||
*/
|
||||
|
||||
public class ForbiddenException extends WebApplicationException {
|
||||
|
||||
private String message;
|
||||
|
||||
public ForbiddenException() {
|
||||
super(Response.status(Response.Status.FORBIDDEN)
|
||||
.build());
|
||||
}
|
||||
|
||||
public ForbiddenException(ErrorDTO errorDTO) {
|
||||
super(Response.status(Response.Status.FORBIDDEN)
|
||||
.entity(errorDTO)
|
||||
.header(AndroidConstants.HEADER_CONTENT_TYPE, AndroidConstants.APPLICATION_JSON)
|
||||
.build());
|
||||
message = errorDTO.getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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 com.google.gson.JsonParseException;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils;
|
||||
|
||||
import javax.naming.AuthenticationException;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import javax.ws.rs.ClientErrorException;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.ext.ExceptionMapper;
|
||||
|
||||
/**
|
||||
* Handle the cxf level exceptions.
|
||||
*/
|
||||
public class GlobalThrowableMapper implements ExceptionMapper {
|
||||
private static final Log log = LogFactory.getLog(GlobalThrowableMapper.class);
|
||||
|
||||
private ErrorDTO e500 = new ErrorDTO();
|
||||
|
||||
GlobalThrowableMapper() {
|
||||
e500.setCode((long) 500);
|
||||
e500.setMessage("Internal server error.");
|
||||
e500.setMoreInfo("");
|
||||
e500.setDescription("The server encountered an internal error. Please contact administrator.");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response toResponse(Throwable e) {
|
||||
|
||||
if (e instanceof JsonParseException) {
|
||||
String errorMessage = "Malformed request body.";
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(errorMessage, e);
|
||||
}
|
||||
return AndroidDeviceUtils.buildBadRequestException(errorMessage).getResponse();
|
||||
}
|
||||
if (e instanceof NotFoundException) {
|
||||
return ((NotFoundException) e).getResponse();
|
||||
}
|
||||
if (e instanceof BadRequestException) {
|
||||
return ((BadRequestException) e).getResponse();
|
||||
}
|
||||
if (e instanceof UnexpectedServerErrorException) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Unexpected server error", e);
|
||||
}
|
||||
return ((UnexpectedServerErrorException) e).getResponse();
|
||||
}
|
||||
if (e instanceof ConstraintViolationException) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Constraint violation issue.", e);
|
||||
return ((ParameterValidationException) e).getResponse();
|
||||
}
|
||||
}
|
||||
if (e instanceof IllegalArgumentException) {
|
||||
ErrorDTO errorDetail = new ErrorDTO();
|
||||
errorDetail.setCode((long) 400);
|
||||
errorDetail.setMoreInfo("");
|
||||
errorDetail.setMessage("");
|
||||
errorDetail.setDescription(e.getMessage());
|
||||
return Response
|
||||
.status(Response.Status.BAD_REQUEST)
|
||||
.entity(errorDetail)
|
||||
.build();
|
||||
}
|
||||
if (e instanceof ClientErrorException) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Client error", e);
|
||||
}
|
||||
return ((ClientErrorException) e).getResponse();
|
||||
}
|
||||
if (e instanceof AuthenticationException) {
|
||||
ErrorDTO errorDetail = new ErrorDTO();
|
||||
errorDetail.setCode((long) 401);
|
||||
errorDetail.setMoreInfo("");
|
||||
errorDetail.setMessage("");
|
||||
errorDetail.setDescription(e.getMessage());
|
||||
return Response
|
||||
.status(Response.Status.UNAUTHORIZED)
|
||||
.entity(errorDetail)
|
||||
.build();
|
||||
}
|
||||
if (e instanceof ForbiddenException) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Resource forbidden", e);
|
||||
}
|
||||
return ((ForbiddenException) e).getResponse();
|
||||
}
|
||||
//unknown exception log and return
|
||||
log.error("An Unknown exception has been captured by global exception mapper.", e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).header("Content-Type", "application/json")
|
||||
.entity(e500).build();
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 org.wso2.carbon.mdm.services.android.util.AndroidConstants;
|
||||
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
public class NotFoundException extends WebApplicationException {
|
||||
private String message;
|
||||
private static final long serialVersionUID = 147943572342342340L;
|
||||
|
||||
public NotFoundException(ErrorResponse error) {
|
||||
super(Response.status(Response.Status.NOT_FOUND).entity(error).build());
|
||||
}
|
||||
public NotFoundException(ErrorDTO errorDTO) {
|
||||
super(Response.status(Response.Status.NOT_FOUND)
|
||||
.entity(errorDTO)
|
||||
.header(AndroidConstants.HEADER_CONTENT_TYPE, AndroidConstants.APPLICATION_JSON)
|
||||
.build());
|
||||
message = errorDTO.getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* Custom exception class for operation configuration related exceptions.
|
||||
*
|
||||
*/
|
||||
public class OperationConfigurationException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 7435543643747623629L;
|
||||
|
||||
public OperationConfigurationException(String errorMessage) {
|
||||
super(errorMessage);
|
||||
}
|
||||
|
||||
public OperationConfigurationException(String errorMessage, Throwable throwable) {
|
||||
super(errorMessage, throwable);
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.util.AndroidConstants;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.Set;
|
||||
|
||||
public class ParameterValidationException extends WebApplicationException {
|
||||
|
||||
private String message;
|
||||
public <T> ParameterValidationException(Set<ConstraintViolation<T>> violations) {
|
||||
super(Response.status(Response.Status.BAD_REQUEST)
|
||||
.entity(AndroidDeviceUtils.getConstraintViolationErrorDTO(violations))
|
||||
.header(AndroidConstants.HEADER_CONTENT_TYPE, AndroidConstants.APPLICATION_JSON)
|
||||
.build());
|
||||
|
||||
//Set the error message
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (ConstraintViolation violation : violations) {
|
||||
stringBuilder.append(violation.getRootBeanClass().getSimpleName());
|
||||
stringBuilder.append(".");
|
||||
stringBuilder.append(violation.getPropertyPath());
|
||||
stringBuilder.append(": ");
|
||||
stringBuilder.append(violation.getMessage());
|
||||
stringBuilder.append(", ");
|
||||
}
|
||||
message = stringBuilder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 org.wso2.carbon.mdm.services.android.util.AndroidConstants;
|
||||
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
public class UnexpectedServerErrorException extends WebApplicationException {
|
||||
private String message;
|
||||
private static final long serialVersionUID = 147943579458906890L;
|
||||
|
||||
public UnexpectedServerErrorException(ErrorResponse error) {
|
||||
super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build());
|
||||
}
|
||||
public UnexpectedServerErrorException(ErrorDTO errorDTO) {
|
||||
super(Response.status(Response.Status.INTERNAL_SERVER_ERROR)
|
||||
.entity(errorDTO)
|
||||
.header(AndroidConstants.HEADER_CONTENT_TYPE, AndroidConstants.APPLICATION_JSON)
|
||||
.build());
|
||||
message = errorDTO.getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,412 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) ${date}, 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.apimgt.annotations.api.Scope;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scopes;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidApplication;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.HeaderParam;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.List;
|
||||
|
||||
@SwaggerDefinition(
|
||||
info = @Info(
|
||||
version = "0.9.0",
|
||||
title = "",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = "name", value = "Android Device Management"),
|
||||
@ExtensionProperty(name = "context", value = "/api/device-mgt/android/v0.9/devices"),
|
||||
})
|
||||
}
|
||||
),
|
||||
tags = {
|
||||
@Tag(name = "android,device_management", description = "")
|
||||
}
|
||||
)
|
||||
@Api(value = "Android Device Management",
|
||||
description = "This carries all the resources related to the Android device management functionalities.")
|
||||
@Path("/devices")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Scopes(
|
||||
scopes = {
|
||||
@Scope(
|
||||
name = "Enroll Device",
|
||||
description = "Register an Android device",
|
||||
key = "perm:android:enroll",
|
||||
permissions = {"/device-mgt/devices/enroll/android"}
|
||||
),
|
||||
@Scope(
|
||||
name = "Un-enroll Device",
|
||||
description = "Unregister an Android device",
|
||||
key = "perm:android:disenroll",
|
||||
permissions = {"/device-mgt/devices/disenroll/android"}
|
||||
)
|
||||
}
|
||||
)
|
||||
public interface DeviceManagementService {
|
||||
|
||||
@PUT
|
||||
@Path("/{id}/applications")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
consumes = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "PUT",
|
||||
value = "Updating the Application Details on Android Devices",
|
||||
notes = "Update the details of the applications that are installed on Android devices.",
|
||||
tags = "Android Device Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully updated the application details.",
|
||||
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 was last modified.\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 The specified resource does not exist."),
|
||||
@ApiResponse(
|
||||
code = 415,
|
||||
message = "Unsupported media type. \n The format of the requested entity was not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n " +
|
||||
"Server error occurred while updating the application list.")
|
||||
})
|
||||
Response updateApplicationList(
|
||||
@ApiParam(
|
||||
name = "id",
|
||||
value = "The unique device identifier.")
|
||||
@NotNull
|
||||
@Size(min = 2 , max = 45)
|
||||
@Pattern(regexp = "^[A-Za-z0-9]*$")
|
||||
@PathParam("id") String id,
|
||||
@ApiParam(
|
||||
name = "applications",
|
||||
value = "The properties to update application details. Multiple applications can be updated using comma separated values.")
|
||||
List<AndroidApplication> androidApplications);
|
||||
|
||||
@PUT
|
||||
@Path("/{id}/pending-operations")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "PUT",
|
||||
value = "Getting the Pending Operation List",
|
||||
responseContainer = "List",
|
||||
notes = "The Android agent communicates with the server to get the operations that are queued up " +
|
||||
"at the server end via this REST API." +
|
||||
" While getting the pending operations the details of the operations executed at the device end is shared with the server. " +
|
||||
"The server then updates the status of the operations that were carried out on the device.",
|
||||
response = Operation.class,
|
||||
tags = "Android Device Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully fetched the pending operations 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 was last modified.\n" +
|
||||
"Used by caches, or in conditional requests.")
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. \n Empty body because the client already has 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 list of pending operations.")
|
||||
})
|
||||
Response getPendingOperations(
|
||||
@ApiParam(
|
||||
name = "id",
|
||||
value = "The unique device identifier.",
|
||||
required = true)
|
||||
@PathParam("id") String id,
|
||||
@ApiParam(
|
||||
name = "If-Modified-Since",
|
||||
value = "Checks if the requested variant was modified, since the specified date-time.\n" +
|
||||
"Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" +
|
||||
"Example: Mon, 05 Jan 2014 15:10:00 +0200.",
|
||||
required = false)
|
||||
@HeaderParam("If-Modified-Since") String ifModifiedSince,
|
||||
@ApiParam(
|
||||
name = "resultOperations",
|
||||
value = "Properties to update the device operations and their status.")
|
||||
List<? extends Operation> resultOperations);
|
||||
|
||||
@POST
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
consumes = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "POST",
|
||||
value = "Registering an Android Device",
|
||||
notes = "When registering an Android device, you need to install" +
|
||||
" the 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. This API can be mainly used to test the device enrollment process.",
|
||||
tags = "Android Device Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(
|
||||
code = 201,
|
||||
message = "Created. \n Successfully created an instance of the device.",
|
||||
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 was last modified.\n" +
|
||||
"Used by caches, or in conditional requests.")}),
|
||||
@ApiResponse(
|
||||
code = 303,
|
||||
message = "See Other. \n The source can be retrieved from the URL specified in 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 format of the requested entity was not supported.\n"),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n " +
|
||||
"Server error occurred while adding a new device.")
|
||||
})
|
||||
Response enrollDevice(@ApiParam(
|
||||
name = "device",
|
||||
value = "The properties required to enroll a device.")
|
||||
@Valid AndroidDevice 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",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll")
|
||||
})
|
||||
}
|
||||
)
|
||||
@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 was last modified.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. \n Empty body because the client already has 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 = "The unique device identifier")
|
||||
@PathParam("id") String id,
|
||||
@ApiParam(
|
||||
name = "If-Modified-Since",
|
||||
value = "Checks if the requested variant was modified, since the specified date-time.\n" +
|
||||
"Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" +
|
||||
"Example: Mon, 05 Jan 2014 15:10:00 +0200",
|
||||
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",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully updated the device enrollment details.",
|
||||
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 was last modified.\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 The specified resource does not exist."),
|
||||
@ApiResponse(
|
||||
code = 415,
|
||||
message = "Unsupported media type. \n The format of the requested entity was not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n " +
|
||||
"Server error occurred while updating the device enrollment.")
|
||||
})
|
||||
Response modifyEnrollment(
|
||||
@ApiParam(
|
||||
name = "id",
|
||||
value = "The unique device identifier.")
|
||||
@PathParam("id") String id,
|
||||
@ApiParam(
|
||||
name = "device",
|
||||
value = "The properties of required to update device enrollment details.") @Valid AndroidDevice androidDevice);
|
||||
|
||||
@DELETE
|
||||
@Path("/{id}")
|
||||
@ApiOperation(
|
||||
httpMethod = "DELETE",
|
||||
value = "Unregistering an Android Device",
|
||||
notes = "Use this REST API to unregister an Android device.",
|
||||
tags = "Android Device Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:disenroll")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully disenrolled the device."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "Not Found. \n The specified resource 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 = "The unique device identifier.")
|
||||
@PathParam("id") String id);
|
||||
|
||||
}
|
@ -0,0 +1,253 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) ${date}, 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.SwaggerDefinition;
|
||||
import io.swagger.annotations.Info;
|
||||
import io.swagger.annotations.ExtensionProperty;
|
||||
import io.swagger.annotations.Extension;
|
||||
import io.swagger.annotations.Tag;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.ResponseHeader;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scopes;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
||||
import org.wso2.carbon.mdm.services.android.bean.AndroidPlatformConfiguration;
|
||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
@SwaggerDefinition(
|
||||
info = @Info(
|
||||
version = "0.9.0",
|
||||
title = "",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = "name",
|
||||
value = "Android Configuration Management"),
|
||||
@ExtensionProperty(name = "context",
|
||||
value = "/api/device-mgt/android/v0.9/configuration"),
|
||||
})
|
||||
}
|
||||
),
|
||||
tags = {
|
||||
@Tag(name = "android,device_management", description = "")
|
||||
}
|
||||
)
|
||||
@Api(value = "Android Configuration Management", description = "This API carries all the resource used to mange the Android platform configurations.")
|
||||
@Path("/configuration")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Scopes(
|
||||
scopes = {
|
||||
@Scope(
|
||||
name = "Enroll Device",
|
||||
description = "Register an Android device",
|
||||
key = "perm:android:enroll",
|
||||
permissions = {"/device-mgt/devices/enroll/android"}
|
||||
),
|
||||
@Scope(
|
||||
name = "View Configurations",
|
||||
description = "Getting Android Platform Configurations",
|
||||
key = "perm:android:view-configuration",
|
||||
permissions = {"/device-mgt/devices/enroll/android"}
|
||||
),
|
||||
@Scope(
|
||||
name = "Manage Configurations",
|
||||
description = "Updating Android Platform Configurations",
|
||||
key = "perm:android:manage-configuration",
|
||||
permissions = {"/device-mgt/platform-configurations/manage"}
|
||||
)
|
||||
}
|
||||
)
|
||||
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",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:view-configuration")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully fetched the Android platform configurations.",
|
||||
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 was last modified.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "Not Found. \n The specified resource 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 the Android platform configuration.")
|
||||
})
|
||||
Response getConfiguration(
|
||||
@ApiParam(
|
||||
name = "If-Modified-Since",
|
||||
value = "Checks if the requested variant was modified, since the specified date-time.\n" +
|
||||
"Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" +
|
||||
"Example: Mon, 05 Jan 2014 15:10:00 +0200",
|
||||
required = false)
|
||||
@HeaderParam("If-Modified-Since") String ifModifiedSince);
|
||||
|
||||
@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.",
|
||||
tags = "Android Configuration Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:manage-configuration")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully updated the Android platform configurations.",
|
||||
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 was last modified.\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 The specified resource does not exist."),
|
||||
@ApiResponse(
|
||||
code = 415,
|
||||
message = "Unsupported media type. \n The format of the requested entity was not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n " +
|
||||
"Server error occurred while modifying the Android platform configuration.")
|
||||
})
|
||||
Response updateConfiguration(
|
||||
@ApiParam(name = "configuration",
|
||||
value = "The properties to update the Android platform configurations.")
|
||||
@Valid AndroidPlatformConfiguration androidPlatformConfiguration);
|
||||
|
||||
@GET
|
||||
@Path("license")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
@ApiOperation(
|
||||
produces = MediaType.TEXT_PLAIN,
|
||||
httpMethod = "GET",
|
||||
value = "Getting the License Agreement for the 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",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully fetched Android license configuration.",
|
||||
response = String.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 was last modified.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "Not Found. \n The specified resource 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 the Android license configuration.")
|
||||
})
|
||||
Response getLicense(
|
||||
@ApiParam(
|
||||
name = "If-Modified-Since",
|
||||
value = "Checks if the requested variant was modified, since the specified date-time.\n" +
|
||||
"Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" +
|
||||
"Example: Mon, 05 Jan 2014 15:10:00 +0200.",
|
||||
required = false)
|
||||
@HeaderParam("If-Modified-Since") String ifModifiedSince) throws AndroidAgentException;
|
||||
|
||||
}
|
@ -0,0 +1,215 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) ${date}, 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.SwaggerDefinition;
|
||||
import io.swagger.annotations.Info;
|
||||
import io.swagger.annotations.ExtensionProperty;
|
||||
import io.swagger.annotations.Extension;
|
||||
import io.swagger.annotations.Tag;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.ResponseHeader;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scopes;
|
||||
import org.wso2.carbon.mdm.services.android.bean.DeviceState;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.Size;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
@SwaggerDefinition(
|
||||
info = @Info(
|
||||
version = "0.9.0",
|
||||
title = "",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = "name", value = "Android Event Receiver"),
|
||||
@ExtensionProperty(name = "context", value = "/api/device-mgt/android/v0.9/events"),
|
||||
})
|
||||
}
|
||||
),
|
||||
tags = {
|
||||
@Tag(name = "android,device_management", description = "")
|
||||
}
|
||||
)
|
||||
@Api(value = "Event Receiver", description = "Event publishing/retrieving related APIs. To enable event publishing/retrieving you need to" +
|
||||
" configure WSO2 EMM as explained in https://docs.wso2.com/display/EMM220/Managing+Event+Publishing+with+WSO2+Data+Analytics+Server, " +
|
||||
"https://docs.wso2.com/display/EMM220/Creating+a+New+Event+Stream+and+Receiver")
|
||||
@Path("/events")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Scopes(
|
||||
scopes = {
|
||||
@Scope(
|
||||
name = "Enroll Device",
|
||||
description = "Register an Android device",
|
||||
key = "perm:android:enroll",
|
||||
permissions = {"/device-mgt/devices/enroll/android"}
|
||||
)
|
||||
}
|
||||
)
|
||||
public interface EventReceiverService {
|
||||
|
||||
@POST
|
||||
@Path("/publish")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
consumes = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "POST",
|
||||
value = "Publishing Events",
|
||||
notes = "Publish events received by the WSO2 EMM Android client to the WSO2 Data Analytics Server (DAS) using this API.",
|
||||
tags = "Event Receiver",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(code = 201, message = "Created. \n Successfully published the event. 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 was last modified.\n" +
|
||||
"Used by caches, or in conditional requests.")
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 303,
|
||||
message = "See Other. \n The source can be retrieved from the URL specified in 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 format of the requested entity was not supported."),
|
||||
@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.")
|
||||
@Valid
|
||||
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. The request must contain " +
|
||||
"the device identifier. Optionally, both date from and date to value should be present to get " +
|
||||
"alerts between a specified time. Filtering can also be done based on the device type and the device identifier." +
|
||||
"(This cannot be combined with the to and from parameters).",
|
||||
response = DeviceState.class,
|
||||
responseContainer = "List",
|
||||
tags = "Event Receiver",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully fetched the event details of the specified device for a given time duration.",
|
||||
response = DeviceState.class, responseContainer = "List"),
|
||||
@ApiResponse(
|
||||
code = 303,
|
||||
message = "See Other. \n The source can be retrieved from the URL specified in 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 device type" +
|
||||
" OR the from and to date."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "Not Found. \n The specified resource does not exist."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Error occurred while getting the published events for the specified device.")
|
||||
})
|
||||
Response retrieveAlerts(
|
||||
@ApiParam(
|
||||
name = "id",
|
||||
value = "The unique device identifier.",
|
||||
required = true)
|
||||
@Size(min = 2, max = 45)
|
||||
@QueryParam("id") String deviceId,
|
||||
@ApiParam(
|
||||
name = "from",
|
||||
value = "Specify the time and date from when you want to get the data." +
|
||||
"Provide the time and date format in the unix/epoch format as the value for {unixTimestamp}. Use a Epoch convertor, to convert the time and date to this format.")
|
||||
@QueryParam("from") long from,
|
||||
@ApiParam(
|
||||
name = "to",
|
||||
value = "Specify the time and date up to when you require the data." +
|
||||
"Provide the time and date format in the unix/epoch format as the value for {unixTimestamp}. Use a Epoch convertor, to convert the time and date to this format.")
|
||||
@QueryParam("to") long to,
|
||||
@ApiParam(
|
||||
name = "type",
|
||||
value = "The alert type to retrieve the events." +
|
||||
"Provide APPLICATION_STATE or RUNTIME_STATE as the value.")
|
||||
@Size(min = 2, max = 45)
|
||||
@QueryParam("type") String type,
|
||||
@ApiParam(
|
||||
name = "If-Modified-Since",
|
||||
value = "Checks if the requested variant was modified, since the specified date-time.\n" +
|
||||
"Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" +
|
||||
"Example: Mon, 05 Jan 2014 15:10:00 +0200",
|
||||
required = false)
|
||||
@HeaderParam("If-Modified-Since") String ifModifiedSince);
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,481 @@
|
||||
/*
|
||||
* 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.InvalidDeviceException;
|
||||
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.device.details.DeviceLocation;
|
||||
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.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
|
||||
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException;
|
||||
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
|
||||
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidApplication;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice;
|
||||
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.core.PolicyManagerService;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.HeaderParam;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.ArrayList;
|
||||
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")
|
||||
@NotNull
|
||||
@Size(min = 2, max = 45)
|
||||
@Pattern(regexp = "^[A-Za-z0-9]*$")
|
||||
String id, List<AndroidApplication> androidApplications) {
|
||||
Application application;
|
||||
List<Application> applications = new ArrayList<>();
|
||||
for (AndroidApplication androidApplication : androidApplications) {
|
||||
application = new Application();
|
||||
application.setPlatform(androidApplication.getPlatform());
|
||||
application.setCategory(androidApplication.getCategory());
|
||||
application.setName(androidApplication.getName());
|
||||
application.setLocationUrl(androidApplication.getLocationUrl());
|
||||
application.setImageUrl(androidApplication.getImageUrl());
|
||||
application.setVersion(androidApplication.getVersion());
|
||||
application.setType(androidApplication.getType());
|
||||
application.setAppProperties(androidApplication.getAppProperties());
|
||||
application.setApplicationIdentifier(androidApplication.getApplicationIdentifier());
|
||||
application.setMemoryUsage(androidApplication.getMemoryUsage());
|
||||
applications.add(application);
|
||||
}
|
||||
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 = AndroidDeviceUtils.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 = AndroidDeviceUtils.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) {
|
||||
AndroidDeviceUtils.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, false).getName();
|
||||
notification.setOperationId(operation.getId());
|
||||
notification.setStatus(org.wso2.carbon.device.mgt.common.notification.mgt.Notification.
|
||||
Status.NEW.toString());
|
||||
notification.setDescription(operation.getCode() + " operation failed to execute on device " +
|
||||
deviceName + " (ID: " + deviceId + ")");
|
||||
AndroidAPIUtils.getNotificationManagementService().addNotification(id, notification);
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Updating operation '" + operation.toString() + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Override
|
||||
public Response enrollDevice(@Valid AndroidDevice androidDevice) {
|
||||
if (androidDevice == null) {
|
||||
String errorMessage = "The payload of the android device enrollment is incorrect.";
|
||||
log.error(errorMessage);
|
||||
throw new org.wso2.carbon.mdm.services.android.exception.BadRequestException(
|
||||
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||
}
|
||||
try {
|
||||
Device device = new Device();
|
||||
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
device.setEnrolmentInfo(androidDevice.getEnrolmentInfo());
|
||||
device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser());
|
||||
device.setDeviceInfo(androidDevice.getDeviceInfo());
|
||||
device.setDeviceIdentifier(androidDevice.getDeviceIdentifier());
|
||||
device.setDescription(androidDevice.getDescription());
|
||||
device.setName(androidDevice.getName());
|
||||
device.setFeatures(androidDevice.getFeatures());
|
||||
device.setProperties(androidDevice.getProperties());
|
||||
|
||||
boolean status = AndroidAPIUtils.getDeviceManagementService().enrollDevice(device);
|
||||
if (status) {
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(androidDevice.getDeviceIdentifier(),
|
||||
device.getType());
|
||||
|
||||
//Immediately update location information from initial payload
|
||||
DeviceLocation deviceLocation = extractLocation(deviceIdentifier, androidDevice.getProperties());
|
||||
if (deviceLocation != null) {
|
||||
try {
|
||||
DeviceInformationManager informationManager = AndroidAPIUtils
|
||||
.getDeviceInformationManagerService();
|
||||
informationManager.addDeviceLocation(deviceLocation);
|
||||
} catch (DeviceDetailsMgtException e) {
|
||||
String msg = "Error occurred while updating the device location upon android " +
|
||||
"', which carries the id '" + androidDevice.getDeviceIdentifier() + "'";
|
||||
log.error(msg, e);
|
||||
throw new UnexpectedServerErrorException(
|
||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||
}
|
||||
}
|
||||
|
||||
//Adding Tasks to get device information
|
||||
List<DeviceIdentifier> deviceIdentifiers = new ArrayList<>();
|
||||
deviceIdentifiers.add(deviceIdentifier);
|
||||
|
||||
List<String> taskOperaions = new ArrayList<>();
|
||||
taskOperaions.add(AndroidConstants.OperationCodes.APPLICATION_LIST);
|
||||
taskOperaions.add(AndroidConstants.OperationCodes.DEVICE_INFO);
|
||||
taskOperaions.add(AndroidConstants.OperationCodes.DEVICE_LOCATION);
|
||||
|
||||
for (String str : taskOperaions) {
|
||||
CommandOperation operation = new CommandOperation();
|
||||
operation.setEnabled(true);
|
||||
operation.setType(Operation.Type.COMMAND);
|
||||
operation.setCode(str);
|
||||
AndroidAPIUtils.getDeviceManagementService().
|
||||
addOperation(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID,
|
||||
operation, deviceIdentifiers);
|
||||
}
|
||||
PolicyManagerService policyManagerService = AndroidAPIUtils.getPolicyManagerService();
|
||||
policyManagerService.getEffectivePolicy(new DeviceIdentifier(androidDevice.getDeviceIdentifier(), device.getType()));
|
||||
|
||||
Message responseMessage = new Message();
|
||||
responseMessage.setResponseCode(Response.Status.OK.toString());
|
||||
responseMessage.setResponseMessage("Android device, which carries the id '" +
|
||||
androidDevice.getDeviceIdentifier() + "' has successfully been enrolled");
|
||||
return Response.status(Response.Status.OK).entity(responseMessage).build();
|
||||
} else {
|
||||
Message responseMessage = new Message();
|
||||
responseMessage.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR.toString());
|
||||
responseMessage.setResponseMessage("Failed to enroll '" +
|
||||
device.getType() + "' device, which carries the id '" +
|
||||
androidDevice.getDeviceIdentifier() + "'");
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(responseMessage).build();
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
String msg = "Error occurred while enrolling the android, which carries the id '" +
|
||||
androidDevice.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 android " +
|
||||
"', which carries the id '" +
|
||||
androidDevice.getDeviceIdentifier() + "'";
|
||||
log.error(msg, e);
|
||||
throw new UnexpectedServerErrorException(
|
||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||
} catch (OperationManagementException e) {
|
||||
String msg = "Error occurred while enforcing default enrollment policy upon android " +
|
||||
"', which carries the id '" +
|
||||
androidDevice.getDeviceIdentifier() + "'";
|
||||
log.error(msg, e);
|
||||
throw new UnexpectedServerErrorException(
|
||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||
} catch (InvalidDeviceException e) {
|
||||
String msg = "Error occurred while enforcing default enrollment policy upon android " +
|
||||
"', which carries the id '" +
|
||||
androidDevice.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) {
|
||||
DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id);
|
||||
try {
|
||||
Device device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
|
||||
if (device != null) {
|
||||
String status = String.valueOf(device.getEnrolmentInfo().getStatus());
|
||||
Message responseMessage = new Message();
|
||||
responseMessage.setResponseCode(Response.Status.OK.toString());
|
||||
responseMessage
|
||||
.setResponseMessage("Status of android device that carries the id '" + id + "' is " + status);
|
||||
return Response.status(Response.Status.OK).entity(responseMessage).build();
|
||||
} else {
|
||||
Message responseMessage = new Message();
|
||||
responseMessage.setResponseCode(Response.Status.NOT_FOUND.toString());
|
||||
responseMessage.setResponseMessage("No Android device is found upon the id '" + id + "'");
|
||||
return Response.status(Response.Status.NOT_FOUND).entity(responseMessage).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, @Valid AndroidDevice androidDevice) {
|
||||
Device device;
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(id);
|
||||
deviceIdentifier.setType(AndroidConstants.DEVICE_TYPE_ANDROID);
|
||||
try {
|
||||
device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
|
||||
} catch (DeviceManagementException e) {
|
||||
String msg = "Error occurred while getting enrollment details of the Android device that carries the id '" +
|
||||
id + "'";
|
||||
log.error(msg, e);
|
||||
throw new UnexpectedServerErrorException(
|
||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||
}
|
||||
|
||||
if (androidDevice == null) {
|
||||
String errorMessage = "The payload of the android device enrollment is incorrect.";
|
||||
log.error(errorMessage);
|
||||
throw new org.wso2.carbon.mdm.services.android.exception.BadRequestException(
|
||||
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||
}
|
||||
if (device == null) {
|
||||
String errorMessage = "The device to be modified doesn't exist.";
|
||||
log.error(errorMessage);
|
||||
throw new org.wso2.carbon.mdm.services.android.exception.NotFoundException(
|
||||
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage(errorMessage).build());
|
||||
}
|
||||
if(androidDevice.getEnrolmentInfo() != null){
|
||||
device.setEnrolmentInfo(device.getEnrolmentInfo());
|
||||
}
|
||||
device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser());
|
||||
if(androidDevice.getDeviceInfo() != null) {
|
||||
device.setDeviceInfo(androidDevice.getDeviceInfo());
|
||||
}
|
||||
device.setDeviceIdentifier(androidDevice.getDeviceIdentifier());
|
||||
if(androidDevice.getDescription() != null) {
|
||||
device.setDescription(androidDevice.getDescription());
|
||||
}
|
||||
if(androidDevice.getName() != null) {
|
||||
device.setName(androidDevice.getName());
|
||||
}
|
||||
if(androidDevice.getFeatures() != null) {
|
||||
device.setFeatures(androidDevice.getFeatures());
|
||||
}
|
||||
if(androidDevice.getProperties() != null) {
|
||||
device.setProperties(androidDevice.getProperties());
|
||||
}
|
||||
boolean result;
|
||||
try {
|
||||
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
result = AndroidAPIUtils.getDeviceManagementService().modifyEnrollment(device);
|
||||
if (result) {
|
||||
Message responseMessage = new Message();
|
||||
responseMessage.setResponseCode(Response.Status.ACCEPTED.toString());
|
||||
responseMessage.setResponseMessage("Enrollment of Android device that " +
|
||||
"carries the id '" + id + "' has successfully updated");
|
||||
return Response.status(Response.Status.ACCEPTED).entity(responseMessage).build();
|
||||
} else {
|
||||
Message responseMessage = new Message();
|
||||
responseMessage.setResponseCode(Response.Status.NOT_MODIFIED.toString());
|
||||
responseMessage.setResponseMessage("Enrollment of Android device that " +
|
||||
"carries the id '" + id + "' has not been updated");
|
||||
return Response.status(Response.Status.NOT_MODIFIED).entity(responseMessage).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 = AndroidDeviceUtils.convertToDeviceIdentifierObject(id);
|
||||
try {
|
||||
result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier);
|
||||
if (result) {
|
||||
Message responseMessage = new Message();
|
||||
responseMessage.setResponseCode(Response.Status.OK.toString());
|
||||
responseMessage.setResponseMessage("Android device that carries id '" + id +
|
||||
"' has successfully dis-enrolled");
|
||||
return Response.status(Response.Status.OK).entity(responseMessage).build();
|
||||
} else {
|
||||
Message responseMessage = new Message();
|
||||
responseMessage.setResponseCode(Response.Status.NOT_FOUND.toString());
|
||||
responseMessage.setResponseMessage("Android device that carries id '" + id +
|
||||
"' has not been dis-enrolled");
|
||||
return Response.status(Response.Status.NOT_FOUND).entity(responseMessage).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());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the device location
|
||||
*
|
||||
* @param deviceIdentifier
|
||||
* @param properties
|
||||
* @return returns null when location not found
|
||||
*/
|
||||
private DeviceLocation extractLocation(DeviceIdentifier deviceIdentifier, List<Device.Property> properties)
|
||||
throws DeviceManagementException {
|
||||
|
||||
DeviceLocation location = null;
|
||||
String latitude = "", longitude = "";
|
||||
|
||||
if (properties == null) return null;
|
||||
|
||||
for (Device.Property property : properties) {
|
||||
String propertyName = property.getName();
|
||||
if (propertyName == null) continue;
|
||||
if (propertyName.equals("LATITUDE")) {
|
||||
latitude = property.getValue();
|
||||
if (!longitude.isEmpty()) break;
|
||||
} else if (propertyName.equals("LONGITUDE")) {
|
||||
longitude = property.getValue();
|
||||
if (!latitude.isEmpty()) break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!latitude.isEmpty() && !longitude.isEmpty()) {
|
||||
location = new DeviceLocation();
|
||||
location.setLatitude(Double.valueOf(latitude));
|
||||
location.setLongitude(Double.valueOf(longitude));
|
||||
location.setDeviceIdentifier(deviceIdentifier);
|
||||
Device savedDevice = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier, false);
|
||||
location.setDeviceId(savedDevice.getId());
|
||||
}
|
||||
return location;
|
||||
}
|
||||
}
|
@ -0,0 +1,156 @@
|
||||
/*
|
||||
* 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.DeviceManagementConstants;
|
||||
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.PlatformConfiguration;
|
||||
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
||||
import org.wso2.carbon.mdm.services.android.bean.AndroidPlatformConfiguration;
|
||||
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.DeviceTypeConfigurationService;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.HeaderParam;
|
||||
import javax.ws.rs.PUT;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Path("/configuration")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurationService {
|
||||
|
||||
private static final Log log = LogFactory.getLog(DeviceTypeConfigurationServiceImpl.class);
|
||||
|
||||
@GET
|
||||
@Override
|
||||
public Response getConfiguration(
|
||||
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
||||
String msg;
|
||||
PlatformConfiguration platformConfiguration;
|
||||
List<ConfigurationEntry> configs;
|
||||
try {
|
||||
platformConfiguration = AndroidAPIUtils.getDeviceManagementService().
|
||||
getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
if (platformConfiguration != null) {
|
||||
configs = platformConfiguration.getConfiguration();
|
||||
} else {
|
||||
platformConfiguration = new PlatformConfiguration();
|
||||
configs = new ArrayList<>();
|
||||
}
|
||||
ConfigurationEntry entry = new ConfigurationEntry();
|
||||
License license = AndroidAPIUtils.getDeviceManagementService().getLicense(
|
||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, AndroidConstants.
|
||||
TenantConfigProperties.LANGUAGE_US);
|
||||
|
||||
if (license != null && configs != null) {
|
||||
entry.setContentType(AndroidConstants.TenantConfigProperties.CONTENT_TYPE_TEXT);
|
||||
entry.setName(AndroidConstants.TenantConfigProperties.LICENSE_KEY);
|
||||
entry.setValue(license.getText());
|
||||
configs.add(entry);
|
||||
platformConfiguration.setConfiguration(configs);
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while retrieving the Android tenant configuration";
|
||||
log.error(msg, e);
|
||||
throw new UnexpectedServerErrorException(
|
||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||
}
|
||||
return Response.status(Response.Status.OK).entity(platformConfiguration).build();
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Override
|
||||
public Response updateConfiguration(@Valid AndroidPlatformConfiguration androidPlatformConfiguration) {
|
||||
String msg;
|
||||
ConfigurationEntry licenseEntry = null;
|
||||
PlatformConfiguration configuration = new PlatformConfiguration();
|
||||
if (androidPlatformConfiguration == null) {
|
||||
String errorMessage = "The payload of the android platform configuration is incorrect.";
|
||||
log.error(errorMessage);
|
||||
throw new org.wso2.carbon.mdm.services.android.exception.BadRequestException(
|
||||
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||
}
|
||||
configuration.setConfiguration(androidPlatformConfiguration.getConfiguration());
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (licenseEntry != null) {
|
||||
configs.remove(licenseEntry);
|
||||
}
|
||||
configuration.setConfiguration(configs);
|
||||
AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
|
||||
//AndroidAPIUtils.getGCMService().resetTenantConfigCache();
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while modifying configuration settings of Android platform";
|
||||
log.error(msg, e);
|
||||
throw new UnexpectedServerErrorException(
|
||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||
}
|
||||
return Response.status(Response.Status.OK).entity("Android platform configuration has been updated successfully.").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,222 @@
|
||||
/*
|
||||
* 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 com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
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.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
|
||||
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.AndroidConstants;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils;
|
||||
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.Size;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.HeaderParam;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.List;
|
||||
|
||||
@Path("/events")
|
||||
public class EventReceiverServiceImpl implements EventReceiverService {
|
||||
private static final String EVENT_STREAM_DEFINITION = "org.wso2.iot.LocationStream";
|
||||
private static final Log log = LogFactory.getLog(EventReceiverServiceImpl.class);
|
||||
private Gson gson = new Gson();
|
||||
|
||||
private static final String LONGITUDE = "longitude";
|
||||
private static final String LATITUDE = "latitude";
|
||||
private static final String TIME_STAMP = "timeStamp";
|
||||
private static final String LOCATION_EVENT_TYPE = "location";
|
||||
|
||||
@POST
|
||||
@Path("/publish")
|
||||
@Override
|
||||
public Response publishEvents(@Valid EventBeanWrapper eventBeanWrapper) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking Android device event logging.");
|
||||
}
|
||||
try {
|
||||
if (!DeviceManagerUtil.isOperationAnalyticsEnabled()) {
|
||||
return Response.status(Response.Status.ACCEPTED).entity("Event is publishing has not enabled.").build();
|
||||
}
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(eventBeanWrapper.getDeviceIdentifier(),
|
||||
AndroidConstants.DEVICE_TYPE_ANDROID);
|
||||
Device device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
|
||||
if (device != null && EnrolmentInfo.Status.ACTIVE != device.getEnrolmentInfo().getStatus()){
|
||||
return Response.status(Response.Status.ACCEPTED).entity("Device is not in Active state.").build();
|
||||
} else if (device == null){
|
||||
return Response.status(Response.Status.ACCEPTED).entity("Device is not enrolled yet.").build();
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
log.error("Error occurred while checking Operation Analytics is Enabled.", e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
|
||||
}
|
||||
String eventType = eventBeanWrapper.getType();
|
||||
if (!LOCATION_EVENT_TYPE.equals(eventType)) {
|
||||
String msg = "Dropping Android " + eventType + " Event.Only Location Event Type is supported.";
|
||||
log.warn(msg);
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
||||
}
|
||||
Message message = new Message();
|
||||
Object[] metaData = {eventBeanWrapper.getDeviceIdentifier(), AndroidConstants.DEVICE_TYPE_ANDROID};
|
||||
String eventPayload = eventBeanWrapper.getPayload();
|
||||
JsonObject jsonObject = gson.fromJson(eventPayload, JsonObject.class);
|
||||
Object[] payload = {
|
||||
jsonObject.get(TIME_STAMP).getAsLong(),
|
||||
jsonObject.get(LATITUDE).getAsDouble(),
|
||||
jsonObject.get(LONGITUDE).getAsDouble()
|
||||
};
|
||||
try {
|
||||
if (AndroidAPIUtils.getEventPublisherService().publishEvent(
|
||||
EVENT_STREAM_DEFINITION, "1.0.0", metaData, 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")
|
||||
@Size(min = 2, max = 45)
|
||||
String deviceId,
|
||||
@QueryParam("from") long from,
|
||||
@QueryParam("to") long to,
|
||||
@Size(min = 2, max = 45)
|
||||
@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 = AndroidDeviceUtils.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 = AndroidDeviceUtils.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 = AndroidDeviceUtils.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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.util;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.analytics.api.AnalyticsDataAPI;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
|
||||
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService;
|
||||
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
|
||||
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||
|
||||
/**
|
||||
* AndroidAPIUtil class provides utility functions used by Android REST-API classes.
|
||||
*/
|
||||
public class AndroidAPIUtils {
|
||||
|
||||
private static Log log = LogFactory.getLog(AndroidAPIUtils.class);
|
||||
|
||||
private AndroidAPIUtils(){
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static String getAuthenticatedUser() {
|
||||
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
String username = threadLocalCarbonContext.getUsername();
|
||||
String tenantDomain = threadLocalCarbonContext.getTenantDomain();
|
||||
if (username != null && username.endsWith(tenantDomain)) {
|
||||
return username.substring(0, username.lastIndexOf("@"));
|
||||
}
|
||||
return username;
|
||||
}
|
||||
|
||||
public static DeviceManagementProviderService getDeviceManagementService() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
DeviceManagementProviderService deviceManagementProviderService =
|
||||
(DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null);
|
||||
if (deviceManagementProviderService == null) {
|
||||
String msg = "Device Management service has not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return deviceManagementProviderService;
|
||||
}
|
||||
|
||||
public static DeviceInformationManager getDeviceInformationManagerService() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
DeviceInformationManager informationManager =
|
||||
(DeviceInformationManager) ctx.getOSGiService(DeviceInformationManager.class, null);
|
||||
if (informationManager == null) {
|
||||
String msg = "Information Manager service not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return informationManager;
|
||||
}
|
||||
|
||||
public static PolicyManagerService getPolicyManagerService() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
PolicyManagerService policyManagerService = (PolicyManagerService) ctx.getOSGiService(
|
||||
PolicyManagerService.class, null);
|
||||
if (policyManagerService == null) {
|
||||
String msg = "Policy Manager service has not initialized";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return policyManagerService;
|
||||
}
|
||||
|
||||
public static ApplicationManagementProviderService getApplicationManagerService() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
ApplicationManagementProviderService applicationManagementProviderService =
|
||||
(ApplicationManagementProviderService) ctx.getOSGiService(ApplicationManagementProviderService.class, null);
|
||||
if (applicationManagementProviderService == null) {
|
||||
String msg = "Application Management provider service has not initialized";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return applicationManagementProviderService;
|
||||
}
|
||||
|
||||
public static NotificationManagementService getNotificationManagementService() {
|
||||
NotificationManagementService notificationManagementService;
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
notificationManagementService = (NotificationManagementService) ctx.getOSGiService(
|
||||
NotificationManagementService.class, null);
|
||||
if (notificationManagementService == null) {
|
||||
String msg = "Notification Management service not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return notificationManagementService;
|
||||
}
|
||||
|
||||
public static EventsPublisherService getEventPublisherService() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
EventsPublisherService eventsPublisherService =
|
||||
(EventsPublisherService) ctx.getOSGiService(EventsPublisherService.class, null);
|
||||
if (eventsPublisherService == null) {
|
||||
String msg = "Event Publisher service has not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return eventsPublisherService;
|
||||
}
|
||||
|
||||
public static AnalyticsDataAPI getAnalyticsDataAPI() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
AnalyticsDataAPI analyticsDataAPI =
|
||||
(AnalyticsDataAPI) ctx.getOSGiService(AnalyticsDataAPI.class, null);
|
||||
if (analyticsDataAPI == null) {
|
||||
String msg = "Analytics api service has not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return analyticsDataAPI;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.util;
|
||||
|
||||
/**
|
||||
* Defines constants used in Android-REST API bundle.
|
||||
*/
|
||||
public final class AndroidConstants {
|
||||
|
||||
public static final String DEVICE_TYPE_ANDROID = "android";
|
||||
public static final String HEADER_CONTENT_TYPE = "Content-Type";
|
||||
public static final String APPLICATION_JSON = "application/json";
|
||||
public static final String SCOPE = "scope";
|
||||
|
||||
public final class DeviceProperties {
|
||||
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 {
|
||||
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 FILE_DOWNLOAD = "FILE_UPLOAD_TO_THE_DEVICE";
|
||||
public static final String FILE_UPLOAD = "FILE_DOWNLOAD_FROM_THE_DEVICE";
|
||||
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 LOGCAT = "LOGCAT";
|
||||
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 IDENTIFIER = "package";
|
||||
public static final String USS = "USS";
|
||||
public static final String VERSION = "version";
|
||||
public static final String ICON = "icon";
|
||||
public static final String IS_ACTIVE = "isActive";
|
||||
}
|
||||
|
||||
public final class ErrorMessages {
|
||||
private ErrorMessages () { throw new AssertionError(); }
|
||||
|
||||
public static final String STATUS_BAD_REQUEST_MESSAGE_DEFAULT = "Bad Request";
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,463 @@
|
||||
/*
|
||||
* 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 com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonNull;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.analytics.api.AnalyticsDataAPI;
|
||||
import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil;
|
||||
import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse;
|
||||
import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry;
|
||||
import org.wso2.carbon.analytics.datasource.commons.Record;
|
||||
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
|
||||
import org.wso2.carbon.context.CarbonContext;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
|
||||
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.device.details.DeviceInfo;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
|
||||
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException;
|
||||
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
|
||||
import org.wso2.carbon.device.mgt.core.search.mgt.impl.Utils;
|
||||
import org.wso2.carbon.mdm.services.android.bean.DeviceState;
|
||||
import org.wso2.carbon.mdm.services.android.bean.ErrorListItem;
|
||||
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
||||
import org.wso2.carbon.mdm.services.android.exception.BadRequestException;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Util class for holding Android device related util methods.
|
||||
*/
|
||||
public class AndroidDeviceUtils {
|
||||
|
||||
private static Log log = LogFactory.getLog(AndroidDeviceUtils.class);
|
||||
|
||||
private AndroidDeviceUtils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static boolean isValidDeviceIdentifier(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
|
||||
Device device = AndroidAPIUtils.getDeviceManagementService().
|
||||
getDevice(deviceIdentifier, false);
|
||||
return !(device == null || device.getDeviceIdentifier() == null ||
|
||||
device.getDeviceIdentifier().isEmpty() ||
|
||||
device.getEnrolmentInfo() == null ||
|
||||
EnrolmentInfo.Status.REMOVED.equals(device.getEnrolmentInfo().getStatus()));
|
||||
}
|
||||
|
||||
public static DeviceIdentifier convertToDeviceIdentifierObject(String deviceId) {
|
||||
DeviceIdentifier identifier = new DeviceIdentifier();
|
||||
identifier.setId(deviceId);
|
||||
identifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public static Activity getOperationResponse(List<String> deviceIDs, Operation operation)
|
||||
throws OperationManagementException, InvalidDeviceException {
|
||||
if (deviceIDs == null || deviceIDs.isEmpty()) {
|
||||
String errorMessage = "Device identifier list is empty";
|
||||
log.error(errorMessage);
|
||||
throw new BadRequestException(
|
||||
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||
}
|
||||
DeviceIdentifier deviceIdentifier;
|
||||
List<DeviceIdentifier> deviceIdentifiers = new ArrayList<>();
|
||||
for (String deviceId : deviceIDs) {
|
||||
deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(deviceId);
|
||||
deviceIdentifier.setType(AndroidConstants.DEVICE_TYPE_ANDROID);
|
||||
deviceIdentifiers.add(deviceIdentifier);
|
||||
}
|
||||
return AndroidAPIUtils.getDeviceManagementService().addOperation(
|
||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, operation, deviceIdentifiers);
|
||||
}
|
||||
|
||||
public static List<DeviceState> getAllEventsForDevice(String tableName, String query) throws AnalyticsException {
|
||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
AnalyticsDataAPI analyticsDataAPI = AndroidAPIUtils.getAnalyticsDataAPI();
|
||||
int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query);
|
||||
if (eventCount == 0) {
|
||||
return null;
|
||||
}
|
||||
List<SearchResultEntry> resultEntries = analyticsDataAPI.search(tenantId, tableName, query, 0, eventCount);
|
||||
List<String> recordIds = getRecordIds(resultEntries);
|
||||
AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
|
||||
Map<String, DeviceState> deviceStateses = createDeviceStatusData(AnalyticsDataAPIUtil.listRecords(
|
||||
analyticsDataAPI, response));
|
||||
return getSortedDeviceStateData(deviceStateses, resultEntries);
|
||||
}
|
||||
|
||||
private static List<String> getRecordIds(List<SearchResultEntry> searchResults) {
|
||||
List<String> ids = new ArrayList<>();
|
||||
for (SearchResultEntry searchResult : searchResults) {
|
||||
ids.add(searchResult.getId());
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
public static Map<String, DeviceState> createDeviceStatusData(List<Record> records) {
|
||||
Map<String, DeviceState> deviceStatuses = new HashMap<>();
|
||||
for (Record record : records) {
|
||||
DeviceState deviceState = createDeviceStatusData(record);
|
||||
deviceStatuses.put(deviceState.getId(), deviceState);
|
||||
}
|
||||
return deviceStatuses;
|
||||
}
|
||||
|
||||
private static DeviceState createDeviceStatusData(Record record) {
|
||||
DeviceState deviceState = new DeviceState();
|
||||
deviceState.setId(record.getId());
|
||||
deviceState.setValues(record.getValues());
|
||||
return deviceState;
|
||||
}
|
||||
|
||||
public static List<DeviceState> getSortedDeviceStateData(Map<String, DeviceState> sensorDatas,
|
||||
List<SearchResultEntry> searchResults) {
|
||||
List<DeviceState> sortedRecords = new ArrayList<>();
|
||||
for (SearchResultEntry searchResultEntry : searchResults) {
|
||||
sortedRecords.add(sensorDatas.get(searchResultEntry.getId()));
|
||||
}
|
||||
return sortedRecords;
|
||||
}
|
||||
|
||||
public static void updateOperation(String deviceId, Operation operation)
|
||||
throws OperationManagementException, PolicyComplianceException, ApplicationManagementException {
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(deviceId);
|
||||
deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
|
||||
if (!Operation.Status.ERROR.equals(operation.getStatus()) &&
|
||||
AndroidConstants.OperationCodes.MONITOR.equals(operation.getCode())) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Received compliance status from MONITOR operation ID: " + operation.getId());
|
||||
}
|
||||
AndroidAPIUtils.getPolicyManagerService().checkPolicyCompliance(deviceIdentifier,
|
||||
getComplianceFeatures(operation.getPayLoad()));
|
||||
} else if (!Operation.Status.ERROR.equals(operation.getStatus()) && AndroidConstants.
|
||||
OperationCodes.APPLICATION_LIST.equals(operation.getCode())) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Received applications list from device '" + deviceId + "'");
|
||||
}
|
||||
updateApplicationList(operation, deviceIdentifier);
|
||||
|
||||
} else if (!Operation.Status.ERROR.equals(operation.getStatus()) && AndroidConstants.
|
||||
OperationCodes.DEVICE_INFO.equals(operation.getCode())) {
|
||||
|
||||
try {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Operation response: " + operation.getOperationResponse());
|
||||
}
|
||||
Device device = new Gson().fromJson(operation.getOperationResponse(), Device.class);
|
||||
org.wso2.carbon.device.mgt.common.device.details.DeviceInfo deviceInfo = convertDeviceToInfo(device);
|
||||
updateDeviceInfo(deviceIdentifier, deviceInfo);
|
||||
} catch (DeviceDetailsMgtException e) {
|
||||
throw new OperationManagementException("Error occurred while updating the device information.", e);
|
||||
}
|
||||
|
||||
} else if (!Operation.Status.ERROR.equals(operation.getStatus()) &&
|
||||
AndroidConstants.OperationCodes.DEVICE_LOCATION.equals(operation.getCode())) {
|
||||
try {
|
||||
DeviceLocation location = new Gson().fromJson(operation.getOperationResponse(), DeviceLocation.class);
|
||||
// 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);
|
||||
updateDeviceLocation(location);
|
||||
}
|
||||
} catch (DeviceDetailsMgtException e) {
|
||||
throw new OperationManagementException("Error occurred while updating the device location.", e);
|
||||
}
|
||||
}
|
||||
AndroidAPIUtils.getDeviceManagementService().updateOperation(deviceIdentifier, operation);
|
||||
}
|
||||
|
||||
public static List<? extends Operation> getPendingOperations
|
||||
(DeviceIdentifier deviceIdentifier) throws OperationManagementException {
|
||||
|
||||
List<? extends Operation> operations;
|
||||
operations = AndroidAPIUtils.getDeviceManagementService().getPendingOperations(deviceIdentifier);
|
||||
return operations;
|
||||
}
|
||||
|
||||
private static void updateApplicationList(Operation operation, DeviceIdentifier deviceIdentifier)
|
||||
throws ApplicationManagementException {
|
||||
// Parsing json string to get applications list.
|
||||
if (operation.getOperationResponse() != null) {
|
||||
JsonElement jsonElement = new JsonParser().parse(operation.getOperationResponse());
|
||||
JsonArray jsonArray = jsonElement.getAsJsonArray();
|
||||
Application app;
|
||||
List<Application> applications = new ArrayList<>(jsonArray.size());
|
||||
for (JsonElement element : jsonArray) {
|
||||
app = new Application();
|
||||
app.setName(element.getAsJsonObject().
|
||||
get(AndroidConstants.ApplicationProperties.NAME).getAsString());
|
||||
app.setApplicationIdentifier(element.getAsJsonObject().
|
||||
get(AndroidConstants.ApplicationProperties.IDENTIFIER).getAsString());
|
||||
app.setPlatform(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
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());
|
||||
}
|
||||
if (element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.IS_ACTIVE) != null) {
|
||||
app.setActive(element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.IS_ACTIVE).getAsBoolean());
|
||||
}
|
||||
applications.add(app);
|
||||
}
|
||||
AndroidAPIUtils.getApplicationManagerService().updateApplicationListInstalledInDevice(deviceIdentifier, applications);
|
||||
} else {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Operation Response is null.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void updateDeviceLocation(DeviceLocation deviceLocation) throws DeviceDetailsMgtException {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
DeviceInformationManager informationManager =
|
||||
(DeviceInformationManager) ctx.getOSGiService(DeviceInformationManager.class, null);
|
||||
|
||||
informationManager.addDeviceLocation(deviceLocation);
|
||||
}
|
||||
|
||||
private static void updateDeviceInfo(DeviceIdentifier deviceId, DeviceInfo deviceInfo)
|
||||
throws DeviceDetailsMgtException {
|
||||
DeviceInformationManager informationManager = AndroidAPIUtils.getDeviceInformationManagerService();
|
||||
informationManager.addDeviceInfo(deviceId, deviceInfo);
|
||||
}
|
||||
|
||||
private static org.wso2.carbon.device.mgt.common.device.details.DeviceInfo convertDeviceToInfo(Device device) {
|
||||
|
||||
org.wso2.carbon.device.mgt.common.device.details.DeviceInfo deviceInfo =
|
||||
new org.wso2.carbon.device.mgt.common.device.details.DeviceInfo();
|
||||
if (deviceInfo.getDeviceDetailsMap() == null) {
|
||||
deviceInfo.setDeviceDetailsMap(new HashMap<>());
|
||||
}
|
||||
List<Device.Property> props = device.getProperties();
|
||||
|
||||
for (Device.Property prop : props) {
|
||||
if (Utils.getDeviceDetailsColumnNames().containsValue(prop.getName())) {
|
||||
extractDefinedProperties(deviceInfo, prop);
|
||||
} else {
|
||||
extractMapProperties(deviceInfo, prop);
|
||||
}
|
||||
}
|
||||
return deviceInfo;
|
||||
}
|
||||
|
||||
private static void extractMapProperties(DeviceInfo deviceInfo, Device.Property prop) {
|
||||
if (prop.getName().equalsIgnoreCase("CPU_INFO")) {
|
||||
deviceInfo.getDeviceDetailsMap().put("cpuUser", getProperty(prop.getValue(), "User"));
|
||||
deviceInfo.getDeviceDetailsMap().put("cpuSystem", getProperty(prop.getValue(), "System"));
|
||||
deviceInfo.getDeviceDetailsMap().put("IOW", getProperty(prop.getValue(), "IOW"));
|
||||
deviceInfo.getDeviceDetailsMap().put("IRQ", getProperty(prop.getValue(), "IRQ"));
|
||||
} else if (prop.getName().equalsIgnoreCase("RAM_INFO")) {
|
||||
deviceInfo.setTotalRAMMemory(Double.parseDouble(getProperty(prop.getValue(), "TOTAL_MEMORY")));
|
||||
deviceInfo.setAvailableRAMMemory(Double.parseDouble(
|
||||
getProperty(prop.getValue(), "AVAILABLE_MEMORY")));
|
||||
deviceInfo.getDeviceDetailsMap().put("ramThreshold", getProperty(prop.getValue(), "THRESHOLD"));
|
||||
deviceInfo.getDeviceDetailsMap().put("ramLowMemory", getProperty(prop.getValue(), "LOW_MEMORY"));
|
||||
} else if (prop.getName().equalsIgnoreCase("BATTERY_INFO")) {
|
||||
deviceInfo.setPluggedIn(Boolean.parseBoolean(getProperty(prop.getValue(), "PLUGGED")));
|
||||
|
||||
deviceInfo.getDeviceDetailsMap().put("batteryLevel", getProperty(prop.getValue(), "BATTERY_LEVEL"));
|
||||
deviceInfo.getDeviceDetailsMap().put("batteryScale", getProperty(prop.getValue(), "SCALE"));
|
||||
deviceInfo.getDeviceDetailsMap().put("batteryVoltage",
|
||||
getProperty(prop.getValue(), "BATTERY_VOLTAGE"));
|
||||
deviceInfo.getDeviceDetailsMap().put("batteryTemperature",
|
||||
getProperty(prop.getValue(), "TEMPERATURE"));
|
||||
deviceInfo.getDeviceDetailsMap().put("batteryCurrentTemperature",
|
||||
getProperty(prop.getValue(), "CURRENT_AVERAGE"));
|
||||
deviceInfo.getDeviceDetailsMap().put("batteryTechnology",
|
||||
getProperty(prop.getValue(), "TECHNOLOGY"));
|
||||
deviceInfo.getDeviceDetailsMap().put("batteryHealth", getProperty(prop.getValue(), "HEALTH"));
|
||||
deviceInfo.getDeviceDetailsMap().put("batteryStatus", getProperty(prop.getValue(), "STATUS"));
|
||||
} else if (prop.getName().equalsIgnoreCase("NETWORK_INFO")) {
|
||||
deviceInfo.setSsid(getProperty(prop.getValue(), "WIFI_SSID"));
|
||||
deviceInfo.setConnectionType(getProperty(prop.getValue(), "CONNECTION_TYPE"));
|
||||
|
||||
deviceInfo.getDeviceDetailsMap().put("mobileSignalStrength",
|
||||
getProperty(prop.getValue(), "MOBILE_SIGNAL_STRENGTH"));
|
||||
deviceInfo.getDeviceDetailsMap().put("wifiSignalStrength",
|
||||
getProperty(prop.getValue(), "WIFI_SIGNAL_STRENGTH"));
|
||||
} else if (prop.getName().equalsIgnoreCase("DEVICE_INFO")) {
|
||||
deviceInfo.setBatteryLevel(Double.parseDouble(
|
||||
getProperty(prop.getValue(), "BATTERY_LEVEL")));
|
||||
deviceInfo.setInternalTotalMemory(Double.parseDouble(
|
||||
getProperty(prop.getValue(), "INTERNAL_TOTAL_MEMORY")));
|
||||
deviceInfo.setInternalAvailableMemory(Double.parseDouble(
|
||||
getProperty(prop.getValue(), "INTERNAL_AVAILABLE_MEMORY")));
|
||||
deviceInfo.setExternalTotalMemory(Double.parseDouble(
|
||||
getProperty(prop.getValue(), "EXTERNAL_TOTAL_MEMORY")));
|
||||
deviceInfo.setExternalAvailableMemory(Double.parseDouble(
|
||||
getProperty(prop.getValue(), "EXTERNAL_AVAILABLE_MEMORY")));
|
||||
|
||||
deviceInfo.getDeviceDetailsMap().put("encryptionEnabled",
|
||||
getProperty(prop.getValue(), "ENCRYPTION_ENABLED"));
|
||||
deviceInfo.getDeviceDetailsMap().put("passcodeEnabled",
|
||||
getProperty(prop.getValue(), "PASSCODE_ENABLED"));
|
||||
deviceInfo.getDeviceDetailsMap().put("operator",
|
||||
getProperty(prop.getValue(), "OPERATOR"));
|
||||
deviceInfo.getDeviceDetailsMap().put("PhoneNumber",
|
||||
getProperty(prop.getValue(), "PHONE_NUMBER"));
|
||||
} else if (prop.getName().equalsIgnoreCase("IMEI")) {
|
||||
deviceInfo.getDeviceDetailsMap().put("IMEI", prop.getValue());
|
||||
} else if (prop.getName().equalsIgnoreCase("IMSI")) {
|
||||
deviceInfo.getDeviceDetailsMap().put("IMSI", prop.getValue());
|
||||
} else if (prop.getName().equalsIgnoreCase("MAC")) {
|
||||
deviceInfo.getDeviceDetailsMap().put("mac", prop.getValue());
|
||||
} else if (prop.getName().equalsIgnoreCase("SERIAL")) {
|
||||
deviceInfo.getDeviceDetailsMap().put("serial", prop.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private static void extractDefinedProperties(DeviceInfo deviceInfo, Device.Property prop) {
|
||||
if (prop.getName().equalsIgnoreCase("DEVICE_MODEL")) {
|
||||
deviceInfo.setDeviceModel(prop.getValue());
|
||||
} else if (prop.getName().equalsIgnoreCase("VENDOR")) {
|
||||
deviceInfo.setVendor(prop.getValue());
|
||||
} else if (prop.getName().equalsIgnoreCase("OS_VERSION")) {
|
||||
deviceInfo.setOsVersion(prop.getValue());
|
||||
} else if (prop.getName().equalsIgnoreCase("OS_BUILD_DATE")) {
|
||||
deviceInfo.setOsBuildDate(prop.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private static String getProperty(String properties, String needed) {
|
||||
// This is not a key value pair. value is the immediate element to its filed name.
|
||||
// Ex:
|
||||
// [{"name":"ENCRYPTION_ENABLED","value":"false"},{"name":"PASSCODE_ENABLED","value":"true"},
|
||||
// {"name":"BATTERY_LEVEL","value":"100"},{"name":"INTERNAL_TOTAL_MEMORY","value":"0.76"}]
|
||||
JsonElement jsonElement = new JsonParser().parse(properties);
|
||||
JsonArray jsonArray = jsonElement.getAsJsonArray();
|
||||
for (JsonElement element : jsonArray) {
|
||||
if (element.isJsonObject()) {
|
||||
JsonObject jsonObject = element.getAsJsonObject();
|
||||
if (jsonObject.has("name")
|
||||
&& jsonObject.get("name").getAsString().equalsIgnoreCase(needed)) {
|
||||
if (jsonObject.has("value") && jsonObject.get("value") != JsonNull.INSTANCE) {
|
||||
return jsonObject.get("value").getAsString().replace("%", "");
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static List<ComplianceFeature> getComplianceFeatures(Object compliancePayload)
|
||||
throws PolicyComplianceException {
|
||||
String compliancePayloadString = new Gson().toJson(compliancePayload);
|
||||
if (compliancePayload == null) {
|
||||
return null;
|
||||
}
|
||||
// Parsing json string to get compliance features.
|
||||
JsonElement jsonElement;
|
||||
if (compliancePayloadString instanceof String) {
|
||||
jsonElement = new JsonParser().parse(compliancePayloadString);
|
||||
} else {
|
||||
throw new PolicyComplianceException("Invalid policy compliance payload");
|
||||
}
|
||||
|
||||
JsonArray jsonArray = jsonElement.getAsJsonArray();
|
||||
Gson gson = new Gson();
|
||||
ComplianceFeature complianceFeature;
|
||||
List<ComplianceFeature> complianceFeatures = new ArrayList<ComplianceFeature>(jsonArray.size());
|
||||
|
||||
for (JsonElement element : jsonArray) {
|
||||
complianceFeature = gson.fromJson(element, ComplianceFeature.class);
|
||||
complianceFeatures.add(complianceFeature);
|
||||
}
|
||||
return complianceFeatures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new BadRequestException
|
||||
*
|
||||
* @param description description of the exception
|
||||
* @return a new BadRequestException with the specified details as a response DTO
|
||||
*/
|
||||
public static BadRequestException buildBadRequestException(String description) {
|
||||
ErrorResponse errorResponse = getErrorResponse(AndroidConstants.
|
||||
ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT, 400l, description);
|
||||
return new BadRequestException(errorResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns generic ErrorResponse.
|
||||
*
|
||||
* @param message specific error message
|
||||
* @param code error code
|
||||
* @param description error description
|
||||
* @return generic Response with error specific details.
|
||||
*/
|
||||
public static ErrorResponse getErrorResponse(String message, Long code, String description) {
|
||||
ErrorResponse errorResponse = new ErrorResponse();
|
||||
errorResponse.setCode(code);
|
||||
errorResponse.setMoreInfo("");
|
||||
errorResponse.setMessage(message);
|
||||
errorResponse.setDescription(description);
|
||||
return errorResponse;
|
||||
}
|
||||
|
||||
public static <T> ErrorResponse getConstraintViolationErrorDTO(Set<ConstraintViolation<T>> violations) {
|
||||
ErrorResponse errorResponse = new ErrorResponse();
|
||||
errorResponse.setDescription("Validation Error");
|
||||
errorResponse.setMessage("Bad Request");
|
||||
errorResponse.setCode(400l);
|
||||
errorResponse.setMoreInfo("");
|
||||
List<ErrorListItem> errorListItems = new ArrayList<>();
|
||||
for (ConstraintViolation violation : violations) {
|
||||
ErrorListItem errorListItemDTO = new ErrorListItem();
|
||||
errorListItemDTO.setCode(400 + "_" + violation.getPropertyPath());
|
||||
errorListItemDTO.setMessage(violation.getPropertyPath() + ": " + violation.getMessage());
|
||||
errorListItems.add(errorListItemDTO);
|
||||
}
|
||||
errorResponse.setErrorItems(errorListItems);
|
||||
return errorResponse;
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Holder class for storing valid & invalid device-ids.
|
||||
*/
|
||||
public class DeviceIDHolder {
|
||||
|
||||
private List<String> errorDeviceIdList;
|
||||
private List<DeviceIdentifier> validDeviceIDList;
|
||||
|
||||
public List<String> getErrorDeviceIdList() {
|
||||
return errorDeviceIdList;
|
||||
}
|
||||
|
||||
public void setErrorDeviceIdList(List<String> errorDeviceIdList) {
|
||||
this.errorDeviceIdList = errorDeviceIdList;
|
||||
}
|
||||
|
||||
public List<DeviceIdentifier> getValidDeviceIDList() {
|
||||
return validDeviceIDList;
|
||||
}
|
||||
|
||||
public void setValidDeviceIDList(List<DeviceIdentifier> validDeviceIDList) {
|
||||
this.validDeviceIDList = validDeviceIDList;
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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.ws.rs.core.MediaType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* This class contains the information of response message.
|
||||
*/
|
||||
@XmlRootElement
|
||||
public class Message {
|
||||
|
||||
private String responseCode;
|
||||
private String responseMessage;
|
||||
|
||||
@XmlElement
|
||||
public String getResponseMessage() {
|
||||
return responseMessage;
|
||||
}
|
||||
|
||||
public void setResponseMessage(String responseMessage) {
|
||||
this.responseMessage = responseMessage;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getResponseCode() {
|
||||
return responseCode;
|
||||
}
|
||||
|
||||
public void setResponseCode(String responseCode) {
|
||||
this.responseCode = responseCode;
|
||||
}
|
||||
|
||||
private Message.MessageBuilder getBuilder() {
|
||||
return new Message.MessageBuilder();
|
||||
}
|
||||
|
||||
public static Message.MessageBuilder responseCode(String responseCode) {
|
||||
Message message = new Message();
|
||||
return message.getBuilder().responseCode(responseCode);
|
||||
}
|
||||
|
||||
public static Message.MessageBuilder responseMessage(String responseMessage) {
|
||||
Message message = new Message();
|
||||
return message.getBuilder().responseMessage(responseMessage);
|
||||
}
|
||||
|
||||
public class MessageBuilder {
|
||||
|
||||
private String responseCode;
|
||||
private String responseMessage;
|
||||
|
||||
public MessageBuilder responseCode(String responseCode) {
|
||||
this.responseCode = responseCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessageBuilder responseMessage(String responseMessage) {
|
||||
this.responseMessage = responseMessage;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Message build() {
|
||||
Message message = new Message();
|
||||
message.setResponseCode(responseCode);
|
||||
message.setResponseMessage(responseMessage);
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,317 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<!-- This file contains the list of permissions that are associated with URL end points
|
||||
of the web app. Each permission should contain the name, permission path, API path
|
||||
(URL) and HTTP method.
|
||||
When defining dynamic paths for APIs, path variables are denoted by '*' notation.
|
||||
For ex:
|
||||
Actual API endpoint: mdm-android-agent/1.0.0/operation/{device-id}
|
||||
URL to be represented here: /operation/*
|
||||
NOTE: All the endpoints of the web app should be available in this file. Otherwise
|
||||
it will result 403 error at the runtime.
|
||||
-->
|
||||
<PermissionConfiguration>
|
||||
<APIVersion></APIVersion>
|
||||
|
||||
<!-- Configuration related permissions -->
|
||||
|
||||
<Permission>
|
||||
<name>View Tenant configuration</name>
|
||||
<path>/device-mgt/admin/platform-configs/view</path>
|
||||
<url>/configuration</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Modify Tenant configuration</name>
|
||||
<path>/device-mgt/admin/platform-configs/add</path>
|
||||
<url>/configuration</url>
|
||||
<method>PUT</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Add Tenant configuration</name>
|
||||
<path>/device-mgt/admin/platform-configs/add</path>
|
||||
<url>/configuration</url>
|
||||
<method>PUT</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Enroll</name>
|
||||
<path>/device-mgt/user/device/enroll/android</path>
|
||||
<url>/configuration/license</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
|
||||
<!-- End of Configuration related permissions -->
|
||||
|
||||
<!-- Device related permissions -->
|
||||
|
||||
<Permission>
|
||||
<name>Enroll</name>
|
||||
<path>/device-mgt/user/device/enroll/android</path>
|
||||
<url>/devices</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Enroll</name>
|
||||
<path>/device-mgt/user/device/enroll/android</path>
|
||||
<url>/devices/*</url>
|
||||
<method>DELETE</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Enroll</name>
|
||||
<path>/device-mgt/user/device/enroll/android</path>
|
||||
<url>/devices/*</url>
|
||||
<method>PUT</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Enroll</name>
|
||||
<path>/device-mgt/user/device/enroll/android</path>
|
||||
<url>/devices/*/applications</url>
|
||||
<method>PUT</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Enroll</name>
|
||||
<path>/device-mgt/user/device/enroll/android</path>
|
||||
<url>/devices/*/pending-operations</url>
|
||||
<method>PUT</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Enroll</name>
|
||||
<path>/device-mgt/user/device/enroll/android</path>
|
||||
<url>/devices/*/status</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
|
||||
<!-- End of device related permissions -->
|
||||
|
||||
<!-- Event related permissions -->
|
||||
|
||||
<Permission>
|
||||
<name>Enroll</name>
|
||||
<path>/device-mgt/user/device/enroll/android</path>
|
||||
<url>/events/publish</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>View Events</name>
|
||||
<path>/device-mgt/admin/events/view</path>
|
||||
<url>/events/publish</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>GET Events</name>
|
||||
<path>/device-mgt/admin/events/get</path>
|
||||
<url>/events</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
|
||||
|
||||
|
||||
<!-- End of event related permissions -->
|
||||
|
||||
<!-- Operations related permissions -->
|
||||
|
||||
<Permission>
|
||||
<name>Get installed applications</name>
|
||||
<path>/device-mgt/admin/device/android/operation/get-installed-applications</path>
|
||||
<url>/admin/devices/applications</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Blacklist applications</name>
|
||||
<path>/device-mgt/admin/device/android/operation/blacklist-applications</path>
|
||||
<url>/admin/devices/blacklist-applications</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Change lock code</name>
|
||||
<path>/device-mgt/admin/device/android/operation/change-lock-code</path>
|
||||
<url>/admin/devices/change-lock-code</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Clear password</name>
|
||||
<path>/device-mgt/admin/device/android/operation/clear-password</path>
|
||||
<url>/admin/devices/clear-password</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Logcat</name>
|
||||
<path>/device-mgt/admin/device/android/operation/logcat</path>
|
||||
<url>/admin/devices/logcat</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Configure VPN</name>
|
||||
<path>/device-mgt/admin/device/android/operation/configure-vpn</path>
|
||||
<url>/admin/devices/configure-vpn</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Configure WiFi</name>
|
||||
<path>/device-mgt/admin/device/android/operation/configure-wifi</path>
|
||||
<url>/admin/devices/configure-wifi</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Control camera</name>
|
||||
<path>/device-mgt/admin/device/android/operation/control-camera</path>
|
||||
<url>/admin/devices/control-camera</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Encrypt storage</name>
|
||||
<path>/device-mgt/admin/device/android/operation/encrypt-storage</path>
|
||||
<url>/admin/devices/encrypt-storage</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Enterprise wipe</name>
|
||||
<path>/device-mgt/admin/device/android/operation/enterprise-wipe</path>
|
||||
<url>/admin/devices/enterprise-wipe</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Get device info</name>
|
||||
<path>/device-mgt/admin/device/android/operation/get-info</path>
|
||||
<url>/admin/devices/info</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Install application</name>
|
||||
<path>/device-mgt/admin/device/android/operation/install-application</path>
|
||||
<url>/admin/devices/install-application</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Get location details</name>
|
||||
<path>/device-mgt/admin/device/android/operation/location</path>
|
||||
<url>/admin/devices/location</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Lock device</name>
|
||||
<path>/device-mgt/admin/device/android/operation/lock-device</path>
|
||||
<url>/admin/devices/lock-devices</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Mute device</name>
|
||||
<path>/device-mgt/admin/device/android/operation/mute</path>
|
||||
<url>/admin/devices/mute</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Reboot device</name>
|
||||
<path>/device-mgt/admin/device/android/operation/reboot</path>
|
||||
<url>/admin/devices/reboot</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Ring device</name>
|
||||
<path>/device-mgt/admin/device/android/operation/ring</path>
|
||||
<url>/admin/devices/ring</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Send notification</name>
|
||||
<path>/device-mgt/admin/device/android/operation/send-notification</path>
|
||||
<url>/admin/devices/send-notification</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Set password policy</name>
|
||||
<path>/device-mgt/admin/device/android/operation/set-password-policy</path>
|
||||
<url>/admin/devices/set-password-policy</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Set web clip</name>
|
||||
<path>/device-mgt/admin/device/android/operation/set-webclip</path>
|
||||
<url>/admin/devices/set-webclip</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Uninstall application</name>
|
||||
<path>/device-mgt/admin/device/android/operation/uninstall-application</path>
|
||||
<url>/admin/devices/uninstall-application</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Unlock device</name>
|
||||
<path>/device-mgt/admin/device/android/operation/unlock-device</path>
|
||||
<url>/admin/devices/unlock-devices</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Update applications</name>
|
||||
<path>/device-mgt/admin/device/android/operation/update-application</path>
|
||||
<url>/admin/devices/update-application</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Upgrade firmware</name>
|
||||
<path>/device-mgt/admin/device/android/operation/upgrade-firmware</path>
|
||||
<url>/admin/devices/upgrade-firmware</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Wipe device</name>
|
||||
<path>/device-mgt/admin/device/android/operation/wipe</path>
|
||||
<url>/admin/devices/wipe</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
<!-- End of operation related permissions -->
|
||||
|
||||
</PermissionConfiguration>
|
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<!--
|
||||
This file defines class loading policy of the whole container. But this behaviour can be overridden by individual webapps by putting this file into the META-INF/ directory.
|
||||
-->
|
||||
<Classloading xmlns="http://wso2.org/projects/as/classloading">
|
||||
|
||||
<!-- Parent-first or child-first. Default behaviour is child-first.-->
|
||||
<ParentFirst>false</ParentFirst>
|
||||
|
||||
<!--
|
||||
Default environments that contains provides to all the webapps. This can be overridden by individual webapps by specifing required environments
|
||||
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
|
||||
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
|
||||
-->
|
||||
<Environments>CXF,Carbon</Environments>
|
||||
</Classloading>
|
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ /*
|
||||
~ * Copyright (c) ${date}, 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.
|
||||
~ */
|
||||
-->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="http://cxf.apache.org/core"
|
||||
xsi:schemaLocation="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/core http://cxf.apache.org/schemas/core.xsd">
|
||||
<jaxrs:server id="services" address="/">
|
||||
<jaxrs:serviceBeans>
|
||||
<ref bean="deviceManagementService"/>
|
||||
<ref bean="deviceManagementAdminService"/>
|
||||
<ref bean="eventReceiverService"/>
|
||||
<ref bean="deviceTypeConfigurationService"/>
|
||||
<ref bean="swaggerResource"/>
|
||||
</jaxrs:serviceBeans>
|
||||
<jaxrs:providers>
|
||||
<ref bean="jsonProvider"/>
|
||||
<ref bean="errorHandler"/>
|
||||
<ref bean="swaggerWriter"/>
|
||||
<ref bean="GlobalExceptionMapper"/>
|
||||
</jaxrs:providers>
|
||||
<jaxrs:properties>
|
||||
<!-- This is added to catch interceptor level exceptions in GlobalThrowableMapper. -->
|
||||
<entry key="map.cxf.interceptor.fault" value="true" />
|
||||
</jaxrs:properties>
|
||||
</jaxrs:server>
|
||||
|
||||
<bean id="swaggerWriter" class="io.swagger.jaxrs.listing.SwaggerSerializers" />
|
||||
<bean id="swaggerResource" class="io.swagger.jaxrs.listing.ApiListingResource" />
|
||||
<bean id="GlobalExceptionMapper" class="org.wso2.carbon.mdm.services.android.exception.GlobalThrowableMapper"/>
|
||||
<bean id="ValidationInterceptor" class="org.wso2.carbon.mdm.services.android.common.ValidationInterceptor"/>
|
||||
|
||||
<bean id="swaggerConfig" class="io.swagger.jaxrs.config.BeanConfig">
|
||||
<property name="resourcePackage" value="org.wso2.carbon.mdm.services.android.services"/>
|
||||
<property name="version" value="0.9"/>
|
||||
<property name="host" value="localhost:9443"/>
|
||||
<property name="schemes" value="https" />
|
||||
<property name="basePath" value="/api/device-mgt/android/v0.9"/>
|
||||
<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="errorHandler" class="org.wso2.carbon.mdm.services.android.common.ErrorHandler"/>
|
||||
<cxf:bus>
|
||||
<cxf:inInterceptors>
|
||||
<ref bean="ValidationInterceptor"/>
|
||||
</cxf:inInterceptors>
|
||||
</cxf:bus>
|
||||
</beans>
|
||||
|
@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
version="2.5">
|
||||
<display-name>Android-Agent-Webapp</display-name>
|
||||
<servlet>
|
||||
<description>JAX-WS/JAX-RS MDM Android Endpoint</description>
|
||||
<display-name>JAX-WS/JAX-RS Servlet</display-name>
|
||||
<servlet-name>CXFServlet</servlet-name>
|
||||
<servlet-class>
|
||||
org.apache.cxf.transport.servlet.CXFServlet
|
||||
</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>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>CXFServlet</servlet-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
<session-config>
|
||||
<session-timeout>60</session-timeout>
|
||||
</session-config>
|
||||
<context-param>
|
||||
<param-name>managed-api-enabled</param-name>
|
||||
<param-value>true</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>doAuthentication</param-name>
|
||||
<param-value>true</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>isSharedWithAllTenants</param-name>
|
||||
<param-value>true</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>isDefault</param-name>
|
||||
<param-value>false</param-value>
|
||||
</context-param>
|
||||
<!--<context-param>-->
|
||||
<!--<param-name>managed-api-version</param-name>-->
|
||||
<!--<param-value>1.0.0</param-value>-->
|
||||
<!--</context-param>-->
|
||||
<!--<context-param>-->
|
||||
<!--<param-name>managed-api-isSecured</param-name>-->
|
||||
<!--<param-value>true</param-value>-->
|
||||
<!--</context-param>-->
|
||||
|
||||
<!-- Below configuration is used to redirect http requests to https -->
|
||||
<!--security-constraint>
|
||||
<web-resource-collection>
|
||||
<web-resource-name>MDM-Admin</web-resource-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</web-resource-collection>
|
||||
<user-data-constraint>
|
||||
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
|
||||
</user-data-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>
|
@ -0,0 +1,135 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@CHARSET "ISO-8859-1";
|
||||
|
||||
/* http://meyerweb.com/eric/tools/css/reset/
|
||||
v2.0 | 20110126
|
||||
License: none (public domain)
|
||||
*/
|
||||
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, img, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||
article, aside, canvas, details, embed,
|
||||
figure, figcaption, footer, header, hgroup,
|
||||
menu, nav, output, ruby, section, summary,
|
||||
time, mark, audio, video {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
/* HTML5 display-role reset for older browsers */
|
||||
article, aside, details, figcaption, figure,
|
||||
footer, header, hgroup, menu, nav, section {
|
||||
display: block;
|
||||
}
|
||||
|
||||
html {
|
||||
background: #efefef;
|
||||
}
|
||||
|
||||
body {
|
||||
line-height: 1;
|
||||
width:960px;
|
||||
margin:auto;
|
||||
background:white;
|
||||
padding:10px;
|
||||
box-shadow:0px 0px 5px #CCC;
|
||||
font-family:"Lucida Grande","Lucida Sans","Microsoft Sans Serif", "Lucida Sans Unicode","Verdana","Sans-serif","trebuchet ms" !important;
|
||||
|
||||
}
|
||||
ol, ul {
|
||||
list-style: none;
|
||||
}
|
||||
blockquote, q {
|
||||
quotes: none;
|
||||
}
|
||||
blockquote:before, blockquote:after,
|
||||
q:before, q:after {
|
||||
content: '';
|
||||
content: none;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
width:960px;
|
||||
border:solid 1px #ccc;
|
||||
}
|
||||
|
||||
table a {
|
||||
font-size:12px;
|
||||
color:#1e90ff;
|
||||
padding:7px;
|
||||
float:left;
|
||||
;
|
||||
}
|
||||
|
||||
.heading {
|
||||
font-size: 18px;
|
||||
margin-top: 20px;
|
||||
float:left;
|
||||
color:#0067B1;
|
||||
margin-bottom:20px;
|
||||
padding-top:20px;
|
||||
}
|
||||
|
||||
.field {
|
||||
font-weight: normal;
|
||||
width:120px;
|
||||
font-size:12px;
|
||||
float:left;
|
||||
padding:7px;
|
||||
clear:left;
|
||||
}
|
||||
.value {
|
||||
font-weight: bold;
|
||||
font-size:12px;
|
||||
float:left;
|
||||
padding:7px;
|
||||
clear:right;
|
||||
}
|
||||
.porttypename {
|
||||
font-weight: bold;
|
||||
font-size:14px;
|
||||
}
|
||||
UL {
|
||||
margin-top: 0;
|
||||
}
|
||||
LI {
|
||||
font-weight: normal;
|
||||
font-size:12px;
|
||||
margin-top:10px;
|
||||
}
|
||||
|
||||
TD {
|
||||
border:1px solid #ccc;
|
||||
vertical-align: text-top;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,303 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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;
|
||||
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.testng.PowerMockObjectFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.IObjectFactory;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.ObjectFactory;
|
||||
import org.testng.annotations.Test;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||
import org.wso2.carbon.mdm.services.android.mocks.DeviceManagementProviderServiceMock;
|
||||
import org.wso2.carbon.mdm.services.android.services.impl.DeviceManagementAdminServiceImpl;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
||||
import org.wso2.carbon.mdm.services.android.utils.TestUtils;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"})
|
||||
@PrepareForTest(AndroidAPIUtils.class)
|
||||
public class DeviceManagementAdminServiceTests {
|
||||
|
||||
private DeviceManagementAdminServiceImpl deviceManagementAdminService;
|
||||
|
||||
@ObjectFactory
|
||||
public IObjectFactory getObjectFactory() {
|
||||
return new PowerMockObjectFactory();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public void init() throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
deviceManagementAdminService = new DeviceManagementAdminServiceImpl();
|
||||
}
|
||||
|
||||
private void mockDeviceManagementService()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getDeviceManagementService"))
|
||||
.toReturn(new DeviceManagementProviderServiceMock());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigureDeviceLock()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.configureDeviceLock(TestUtils.getDeviceLockBeanWrapper());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigureDeviceUnlock()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.configureDeviceUnlock(TestUtils.getDeviceIds());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDeviceLocation()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.getDeviceLocation(TestUtils.getDeviceIds());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemovePassword()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.removePassword(TestUtils.getDeviceIds());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigureCamera()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.configureCamera(TestUtils.getCamerabeanWrapper());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDeviceInformation()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.getDeviceInformation(TestUtils.getDeviceIds());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDeviceLogcat()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.getDeviceLogcat(TestUtils.getDeviceIds());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWipeDevice()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.wipeDevice(TestUtils.getDeviceIds());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWipeData()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.wipeData(TestUtils.getWipeDataBeanWrapper());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetApplications()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.getApplications(TestUtils.getDeviceIds());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRingDevice()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.ringDevice(TestUtils.getDeviceIds());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRebootDevice()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.rebootDevice(TestUtils.getDeviceIds());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMuteDevice()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.muteDevice(TestUtils.getDeviceIds());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInstallApplication()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService
|
||||
.installApplication(TestUtils.getApplicationInstallationBeanWrapper());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateApplication()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.updateApplication(TestUtils.getApplicationUpdateBeanWrapper());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUninstallApplicationPublic()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService
|
||||
.uninstallApplication(TestUtils.getApplicationUninstallationBeanWrapperPublic());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUninstallApplicationWebApp()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService
|
||||
.uninstallApplication(TestUtils.getApplicationUninstallationBeanWrapperWebApp());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBlacklistApplications()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService
|
||||
.blacklistApplications(TestUtils.getBlacklistApplicationsBeanWrapper());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpgradeFirmware()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.upgradeFirmware(TestUtils.getUpgradeFirmwareBeanWrapper());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigureVPN()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.configureVPN(TestUtils.getVpnBeanWrapper());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendNotification()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.sendNotification(TestUtils.getNotificationBeanWrapper());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigureWifi()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.configureWifi(TestUtils.getWifiBeanWrapper());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEncryptStorage()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.encryptStorage(TestUtils.getEncryptionBeanWrapper());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeLockCode()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.changeLockCode(TestUtils.getLockCodeBeanWrapper());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetPasswordPolicy()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.setPasswordPolicy(TestUtils.getPasswordPolicyBeanWrapper());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetWebClip()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementAdminService.setWebClip(TestUtils.getWebClipBeanWrapper());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,318 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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;
|
||||
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.testng.PowerMockObjectFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.IObjectFactory;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.ObjectFactory;
|
||||
import org.testng.annotations.Test;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice;
|
||||
import org.wso2.carbon.mdm.services.android.mocks.ApplicationManagementProviderServiceMock;
|
||||
import org.wso2.carbon.mdm.services.android.mocks.DeviceInformationManagerServiceMock;
|
||||
import org.wso2.carbon.mdm.services.android.mocks.DeviceManagementProviderServiceMock;
|
||||
import org.wso2.carbon.mdm.services.android.mocks.NotificationManagementServiceMock;
|
||||
import org.wso2.carbon.mdm.services.android.mocks.PolicyManagerServiceMock;
|
||||
import org.wso2.carbon.mdm.services.android.services.impl.DeviceManagementServiceImpl;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
||||
import org.wso2.carbon.mdm.services.android.utils.TestUtils;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"})
|
||||
@PrepareForTest(AndroidAPIUtils.class)
|
||||
public class DeviceManagementServiceTests {
|
||||
|
||||
private DeviceManagementServiceImpl deviceManagementService;
|
||||
|
||||
@ObjectFactory
|
||||
public IObjectFactory getObjectFactory() {
|
||||
return new PowerMockObjectFactory();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public void init() throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
deviceManagementService = new DeviceManagementServiceImpl();
|
||||
}
|
||||
|
||||
private void mockDeviceManagementService()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getDeviceManagementService"))
|
||||
.toReturn(new DeviceManagementProviderServiceMock());
|
||||
}
|
||||
|
||||
private void mockApplicationManagerService()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getApplicationManagerService"))
|
||||
.toReturn(new ApplicationManagementProviderServiceMock());
|
||||
}
|
||||
|
||||
private void mockPolicyManagerService()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getPolicyManagerService"))
|
||||
.toReturn(new PolicyManagerServiceMock());
|
||||
}
|
||||
|
||||
private void mockDeviceInformationManagerService()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getDeviceInformationManagerService"))
|
||||
.toReturn(new DeviceInformationManagerServiceMock());
|
||||
}
|
||||
|
||||
private void mockNotificationManagementService()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getNotificationManagementService"))
|
||||
.toReturn(new NotificationManagementServiceMock());
|
||||
}
|
||||
|
||||
private void mockUser()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getAuthenticatedUser"))
|
||||
.toReturn("admin");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateApplicationList()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockApplicationManagerService();
|
||||
Response response = deviceManagementService
|
||||
.updateApplicationList(TestUtils.getDeviceId(), TestUtils.getAndroidApplications());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPendingOperationsForNullDevice()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
Response response = deviceManagementService
|
||||
.getPendingOperations(null, null, null);
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPendingOperationsInvalidDevice()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementService
|
||||
.getPendingOperations("1234", null, null);
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPendingOperationsNullResponse()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementService
|
||||
.getPendingOperations(TestUtils.getDeviceId(), null, null);
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPendingOperationsWithMonitorResponse()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
mockPolicyManagerService();
|
||||
Response response = deviceManagementService
|
||||
.getPendingOperations(TestUtils.getDeviceId(), null,
|
||||
TestUtils.getSuccessMonitorOperationResponse());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPendingOperationsWithApplicationResponse()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
mockApplicationManagerService();
|
||||
Response response = deviceManagementService
|
||||
.getPendingOperations(TestUtils.getDeviceId(), null,
|
||||
TestUtils.getSuccessApplicationOperationResponse());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPendingOperationsWithDeviceInfoResponse()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
mockDeviceInformationManagerService();
|
||||
Response response = deviceManagementService
|
||||
.getPendingOperations(TestUtils.getDeviceId(), null,
|
||||
TestUtils.getSuccessInfoOperationResponse());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPendingOperationsWithInProgressResponse()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementService
|
||||
.getPendingOperations(TestUtils.getDeviceId(), null,
|
||||
TestUtils.getInProgressOperationResponse());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPendingOperationsWithErrorResponse()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
mockNotificationManagementService();
|
||||
Response response = deviceManagementService
|
||||
.getPendingOperations(TestUtils.getDeviceId(), null,
|
||||
TestUtils.getErrorOperationResponse());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnrollDeviceWithoutLocationSuccess()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
mockPolicyManagerService();
|
||||
mockUser();
|
||||
Response response = deviceManagementService.enrollDevice(TestUtils.getBasicAndroidDevice());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnrollDeviceWithLocationSuccess()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
mockDeviceInformationManagerService();
|
||||
mockPolicyManagerService();
|
||||
mockUser();
|
||||
AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice();
|
||||
|
||||
List<Device.Property> properties = new ArrayList<>();
|
||||
Device.Property property = new Device.Property();
|
||||
property.setName("LATITUDE");
|
||||
property.setValue("79.5");
|
||||
properties.add(property);
|
||||
property = new Device.Property();
|
||||
property.setName("LONGITUDE");
|
||||
property.setValue("6.9");
|
||||
properties.add(property);
|
||||
androidDevice.setProperties(properties);
|
||||
|
||||
Response response = deviceManagementService.enrollDevice(androidDevice);
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnrollDeviceUnSuccess()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
mockUser();
|
||||
AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice();
|
||||
androidDevice.setDeviceIdentifier("1234");
|
||||
Response response = deviceManagementService.enrollDevice(androidDevice);
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEnrolledExists()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementService.isEnrolled(TestUtils.getDeviceId(), null);
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEnrolledNonExist()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementService.isEnrolled("1234", null);
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEnrolledNull()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementService.isEnrolled(null, null);
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifyEnrollmentSuccess()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
mockUser();
|
||||
Response response = deviceManagementService
|
||||
.modifyEnrollment(TestUtils.getDeviceId(), TestUtils.getBasicAndroidDevice());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifyEnrollmentUnSuccess()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
mockUser();
|
||||
AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice();
|
||||
androidDevice.setDeviceIdentifier("1234");
|
||||
Response response = deviceManagementService
|
||||
.modifyEnrollment(TestUtils.getDeviceId(), androidDevice);
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.NOT_MODIFIED.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisEnrollDeviceSuccess()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementService.disEnrollDevice(TestUtils.getDeviceId());
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisenrollUnSuccess()
|
||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
mockDeviceManagementService();
|
||||
Response response = deviceManagementService.disEnrollDevice("1234");
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.mocks;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
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.operation.mgt.Activity;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ApplicationManagementProviderServiceMock implements ApplicationManagementProviderService {
|
||||
@Override
|
||||
public void updateApplicationListInstalledInDevice(DeviceIdentifier deviceIdentifier, List<Application> list)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Application> getApplicationListForDevice(DeviceIdentifier deviceIdentifier)
|
||||
throws ApplicationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Application[] getApplications(String s, int i, int i1) throws ApplicationManagementException {
|
||||
return new Application[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateApplicationStatus(DeviceIdentifier deviceIdentifier, Application application, String s)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getApplicationStatus(DeviceIdentifier deviceIdentifier, Application application)
|
||||
throws ApplicationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Activity installApplicationForDevices(Operation operation, List<DeviceIdentifier> list)
|
||||
throws ApplicationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Activity installApplicationForUsers(Operation operation, List<String> list)
|
||||
throws ApplicationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Activity installApplicationForUserRoles(Operation operation, List<String> list)
|
||||
throws ApplicationManagementException {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package org.wso2.carbon.mdm.services.android.mocks;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
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.core.device.details.mgt.DeviceDetailsMgtException;
|
||||
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DeviceInformationManagerServiceMock implements DeviceInformationManager {
|
||||
@Override
|
||||
public void addDeviceInfo(DeviceIdentifier deviceIdentifier, DeviceInfo deviceInfo)
|
||||
throws DeviceDetailsMgtException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceInfo getDeviceInfo(DeviceIdentifier deviceIdentifier) throws DeviceDetailsMgtException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceInfo> getDevicesInfo(List<DeviceIdentifier> list) throws DeviceDetailsMgtException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDeviceLocation(DeviceLocation deviceLocation) throws DeviceDetailsMgtException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceLocation getDeviceLocation(DeviceIdentifier deviceIdentifier) throws DeviceDetailsMgtException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceLocation> getDeviceLocations(List<DeviceIdentifier> list) throws DeviceDetailsMgtException {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,516 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.mocks;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||
import org.wso2.carbon.device.mgt.common.FeatureManager;
|
||||
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
|
||||
import org.wso2.carbon.device.mgt.common.MonitoringOperation;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException;
|
||||
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.operation.mgt.Activity;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
|
||||
import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationExecutionFailedException;
|
||||
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||
import org.wso2.carbon.device.mgt.core.geo.GeoCluster;
|
||||
import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
import org.wso2.carbon.device.mgt.core.service.EmailMetaInfo;
|
||||
import org.wso2.carbon.mdm.services.android.utils.TestUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class DeviceManagementProviderServiceMock implements DeviceManagementProviderService {
|
||||
@Override
|
||||
public List<Device> getAllDevices(String s) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getAllDevices(String s, boolean b) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getAllDevices() throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getAllDevices(boolean b) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getDevices(Date date) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getDevices(Date date, boolean b) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getDevicesByType(PaginationRequest paginationRequest) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getDevicesByType(PaginationRequest paginationRequest, boolean b)
|
||||
throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getAllDevices(PaginationRequest paginationRequest) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getAllDevices(PaginationRequest paginationRequest, boolean b)
|
||||
throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device getDevice(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
|
||||
if (TestUtils.getDeviceId().equals(deviceIdentifier.getId())) {
|
||||
return TestUtils.getDevice();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device getDeviceWithTypeProperties(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device getDevice(DeviceIdentifier deviceIdentifier, boolean b) throws DeviceManagementException {
|
||||
if (TestUtils.getDeviceId().equals(deviceIdentifier.getId())) {
|
||||
return TestUtils.getDevice();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device getDevice(DeviceIdentifier deviceIdentifier, String s, boolean b) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device getDevice(DeviceIdentifier deviceIdentifier, Date date) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device getDevice(DeviceIdentifier deviceIdentifier, Date date, boolean b) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device getDevice(DeviceIdentifier deviceIdentifier, String s, Date date, boolean b)
|
||||
throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device getDevice(DeviceIdentifier deviceIdentifier, EnrolmentInfo.Status status)
|
||||
throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device getDevice(DeviceIdentifier deviceIdentifier, EnrolmentInfo.Status status, boolean b)
|
||||
throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getDevicesOfUser(PaginationRequest paginationRequest) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getDevicesOfUser(PaginationRequest paginationRequest, boolean b)
|
||||
throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getDevicesByOwnership(PaginationRequest paginationRequest)
|
||||
throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getDevicesByOwnership(PaginationRequest paginationRequest, boolean b)
|
||||
throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getDevicesOfUser(String s) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getDevicesOfUser(String s, boolean b) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getDevicesOfUser(String s, String s1) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getDevicesOfUser(String s, String s1, boolean b) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getAllDevicesOfRole(String s) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getAllDevicesOfRole(String s, boolean b) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getDevicesByStatus(PaginationRequest paginationRequest) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getDevicesByStatus(PaginationRequest paginationRequest, boolean b)
|
||||
throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getDevicesByNameAndType(PaginationRequest paginationRequest, boolean b)
|
||||
throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getDevicesByName(PaginationRequest paginationRequest) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getDevicesByName(PaginationRequest paginationRequest, boolean b)
|
||||
throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getDevicesByStatus(EnrolmentInfo.Status status) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getDevicesByStatus(EnrolmentInfo.Status status, boolean b) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDeviceCount(String s) throws DeviceManagementException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDeviceCount() throws DeviceManagementException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Integer, Device> getTenantedDevice(DeviceIdentifier deviceIdentifier)
|
||||
throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEnrolmentInvitation(String s, EmailMetaInfo emailMetaInfo)
|
||||
throws DeviceManagementException, ConfigurationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRegistrationEmail(EmailMetaInfo emailMetaInfo)
|
||||
throws DeviceManagementException, ConfigurationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureManager getFeatureManager(String s) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformConfiguration getConfiguration(String s) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnrolled(DeviceIdentifier deviceIdentifier, String s) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotificationStrategy getNotificationStrategyByDeviceType(String s) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public License getLicense(String s, String s1) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLicense(String s, License license) throws DeviceManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
||||
return TestUtils.getDeviceId().equals(device.getDeviceIdentifier());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
||||
return TestUtils.getDeviceId().equals(device.getDeviceIdentifier());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveConfiguration(PlatformConfiguration platformConfiguration) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disenrollDevice(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
|
||||
return TestUtils.getDeviceId().equals(deviceIdentifier.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnrolled(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setActive(DeviceIdentifier deviceIdentifier, boolean b) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAvailableDeviceTypes() throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setOwnership(DeviceIdentifier deviceIdentifier, String s) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setStatus(DeviceIdentifier deviceIdentifier, String s, EnrolmentInfo.Status status)
|
||||
throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setStatus(String s, EnrolmentInfo.Status status) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyOperationToDevices(Operation operation, List<DeviceIdentifier> list)
|
||||
throws DeviceManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Activity addOperation(String s, Operation operation, List<DeviceIdentifier> list)
|
||||
throws OperationManagementException, InvalidDeviceException {
|
||||
return TestUtils.getActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Operation> getOperations(DeviceIdentifier deviceIdentifier)
|
||||
throws OperationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getOperations(DeviceIdentifier deviceIdentifier, PaginationRequest paginationRequest)
|
||||
throws OperationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Operation> getPendingOperations(DeviceIdentifier deviceIdentifier)
|
||||
throws OperationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation getNextPendingOperation(DeviceIdentifier deviceIdentifier) throws OperationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOperation(DeviceIdentifier deviceIdentifier, Operation operation)
|
||||
throws OperationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateProperties(DeviceIdentifier deviceIdentifier, List<Device.Property> list) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceIdentifier, int i)
|
||||
throws OperationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Operation> getOperationsByDeviceAndStatus(DeviceIdentifier deviceIdentifier,
|
||||
Operation.Status status)
|
||||
throws OperationManagementException, DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation getOperation(String s, int i) throws OperationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Activity getOperationByActivityId(String s) throws OperationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Activity getOperationByActivityIdAndDevice(String s, DeviceIdentifier deviceIdentifier)
|
||||
throws OperationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Activity> getActivitiesUpdatedAfter(long l, int i, int i1) throws OperationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActivityCountUpdatedAfter(long l) throws OperationManagementException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MonitoringOperation> getMonitoringOperationList(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDeviceMonitoringFrequency(String s) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeviceMonitoringEnabled(String s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PolicyMonitoringManager getPolicyMonitoringManager(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean changeDeviceStatus(DeviceIdentifier deviceIdentifier, EnrolmentInfo.Status status)
|
||||
throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerDeviceType(DeviceManagementService deviceManagementService) throws DeviceManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceType getDeviceType(String s) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getDeviceTypes() throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyPullNotificationSubscriber(DeviceIdentifier deviceIdentifier, Operation operation)
|
||||
throws PullNotificationExecutionFailedException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getDeviceEnrolledTenants() throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GeoCluster> findGeoClusters(GeoCoordinate geoCoordinate, GeoCoordinate geoCoordinate1, int i) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.mocks;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
||||
import org.wso2.carbon.device.mgt.common.notification.mgt.Notification;
|
||||
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NotificationManagementServiceMock implements NotificationManagementService {
|
||||
@Override
|
||||
public boolean addNotification(DeviceIdentifier deviceIdentifier, Notification notification)
|
||||
throws NotificationManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateNotification(Notification notification) throws NotificationManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateNotificationStatus(int i, Notification.Status status) throws NotificationManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Notification> getAllNotifications() throws NotificationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Notification getNotification(int i) throws NotificationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getAllNotifications(PaginationRequest paginationRequest)
|
||||
throws NotificationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Notification> getNotificationsByStatus(Notification.Status status)
|
||||
throws NotificationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getNotificationsByStatus(Notification.Status status, PaginationRequest paginationRequest)
|
||||
throws NotificationManagementException {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.mocks;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.Feature;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.Profile;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
|
||||
import org.wso2.carbon.policy.mgt.common.FeatureManagementException;
|
||||
import org.wso2.carbon.policy.mgt.common.PolicyAdministratorPoint;
|
||||
import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint;
|
||||
import org.wso2.carbon.policy.mgt.common.PolicyInformationPoint;
|
||||
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||
import org.wso2.carbon.policy.mgt.common.PolicyMonitoringTaskException;
|
||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||
import org.wso2.carbon.policy.mgt.core.task.TaskScheduleService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PolicyManagerServiceMock implements PolicyManagerService {
|
||||
|
||||
@Override
|
||||
public Profile addProfile(Profile profile) throws PolicyManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile updateProfile(Profile profile) throws PolicyManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy addPolicy(Policy policy) throws PolicyManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy updatePolicy(Policy policy) throws PolicyManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePolicy(Policy policy) throws PolicyManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePolicy(int i) throws PolicyManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy getEffectivePolicy(DeviceIdentifier deviceIdentifier) throws PolicyManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProfileFeature> getEffectiveFeatures(DeviceIdentifier deviceIdentifier)
|
||||
throws FeatureManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Policy> getPolicies(String s) throws PolicyManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Feature> getFeatures() throws FeatureManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PolicyAdministratorPoint getPAP() throws PolicyManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PolicyInformationPoint getPIP() throws PolicyManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PolicyEvaluationPoint getPEP() throws PolicyManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskScheduleService getTaskScheduleService() throws PolicyMonitoringTaskException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPolicyCount() throws PolicyManagementException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy getAppliedPolicyToDevice(DeviceIdentifier deviceIdentifier) throws PolicyManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ComplianceFeature> checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Object o)
|
||||
throws PolicyComplianceException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkCompliance(DeviceIdentifier deviceIdentifier, Object o) throws PolicyComplianceException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonComplianceData getDeviceCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompliant(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,425 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.utils;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
||||
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.operation.mgt.Activity;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.mdm.services.android.bean.ApplicationInstallation;
|
||||
import org.wso2.carbon.mdm.services.android.bean.ApplicationUninstallation;
|
||||
import org.wso2.carbon.mdm.services.android.bean.ApplicationUpdate;
|
||||
import org.wso2.carbon.mdm.services.android.bean.BlacklistApplications;
|
||||
import org.wso2.carbon.mdm.services.android.bean.Camera;
|
||||
import org.wso2.carbon.mdm.services.android.bean.DeviceEncryption;
|
||||
import org.wso2.carbon.mdm.services.android.bean.DeviceLock;
|
||||
import org.wso2.carbon.mdm.services.android.bean.LockCode;
|
||||
import org.wso2.carbon.mdm.services.android.bean.Notification;
|
||||
import org.wso2.carbon.mdm.services.android.bean.PasscodePolicy;
|
||||
import org.wso2.carbon.mdm.services.android.bean.UpgradeFirmware;
|
||||
import org.wso2.carbon.mdm.services.android.bean.Vpn;
|
||||
import org.wso2.carbon.mdm.services.android.bean.WebClip;
|
||||
import org.wso2.carbon.mdm.services.android.bean.Wifi;
|
||||
import org.wso2.carbon.mdm.services.android.bean.WipeData;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidApplication;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationInstallationBeanWrapper;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationUninstallationBeanWrapper;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationUpdateBeanWrapper;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.BlacklistApplicationsBeanWrapper;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.CameraBeanWrapper;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.DeviceLockBeanWrapper;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.EncryptionBeanWrapper;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.LockCodeBeanWrapper;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.NotificationBeanWrapper;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.PasswordPolicyBeanWrapper;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.UpgradeFirmwareBeanWrapper;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.VpnBeanWrapper;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.WebClipBeanWrapper;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.WifiBeanWrapper;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.WipeDataBeanWrapper;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TestUtils {
|
||||
|
||||
public static Activity getActivity() {
|
||||
Activity activity = new Activity();
|
||||
activity.setActivityId("ACTIVITY_1");
|
||||
activity.setCode("CODE");
|
||||
return activity;
|
||||
}
|
||||
|
||||
public static String getDeviceId() {
|
||||
return "1a2b3c4d5e";
|
||||
}
|
||||
|
||||
public static List<String> getDeviceIds() {
|
||||
List<String> deviceIds = new ArrayList<>();
|
||||
deviceIds.add(getDeviceId());
|
||||
return deviceIds;
|
||||
}
|
||||
|
||||
public static Device getDevice() {
|
||||
Device device = new Device();
|
||||
device.setId(1);
|
||||
device.setName("Test");
|
||||
device.setDeviceIdentifier(getDeviceId());
|
||||
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
EnrolmentInfo enrolmentInfo = new EnrolmentInfo();
|
||||
enrolmentInfo.setId(1);
|
||||
enrolmentInfo.setOwner("admin");
|
||||
enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD);
|
||||
enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE);
|
||||
device.setEnrolmentInfo(enrolmentInfo);
|
||||
return device;
|
||||
}
|
||||
|
||||
public static DeviceLockBeanWrapper getDeviceLockBeanWrapper() {
|
||||
DeviceLockBeanWrapper deviceLockBeanWrapper = new DeviceLockBeanWrapper();
|
||||
deviceLockBeanWrapper.setDeviceIDs(getDeviceIds());
|
||||
DeviceLock deviceLockOperation = new DeviceLock();
|
||||
deviceLockOperation.setHardLockEnabled(true);
|
||||
deviceLockOperation.setMessage("Test Operation");
|
||||
deviceLockBeanWrapper.setOperation(deviceLockOperation);
|
||||
return deviceLockBeanWrapper;
|
||||
}
|
||||
|
||||
public static CameraBeanWrapper getCamerabeanWrapper() {
|
||||
CameraBeanWrapper cameraBeanWrapper = new CameraBeanWrapper();
|
||||
cameraBeanWrapper.setDeviceIDs(getDeviceIds());
|
||||
Camera camera = new Camera();
|
||||
camera.setEnabled(false);
|
||||
cameraBeanWrapper.setOperation(camera);
|
||||
return cameraBeanWrapper;
|
||||
}
|
||||
|
||||
public static WipeDataBeanWrapper getWipeDataBeanWrapper() {
|
||||
WipeDataBeanWrapper wipeDataBeanWrapper = new WipeDataBeanWrapper();
|
||||
wipeDataBeanWrapper.setDeviceIDs(getDeviceIds());
|
||||
WipeData wipeData = new WipeData();
|
||||
wipeData.setPin("1234");
|
||||
wipeDataBeanWrapper.setOperation(wipeData);
|
||||
return wipeDataBeanWrapper;
|
||||
}
|
||||
|
||||
public static ApplicationInstallationBeanWrapper getApplicationInstallationBeanWrapper() {
|
||||
ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper = new ApplicationInstallationBeanWrapper();
|
||||
applicationInstallationBeanWrapper.setDeviceIDs(getDeviceIds());
|
||||
ApplicationInstallation applicationInstallation = new ApplicationInstallation();
|
||||
applicationInstallation.setAppIdentifier("org.wso2.iot.agent");
|
||||
applicationInstallation.setUrl("https://github.com/wso2/cdmf-agent-android/releases/download/v3.1.21/client-standalone.apk");
|
||||
applicationInstallation.setType("enterprise");
|
||||
applicationInstallation.setSchedule("2017-10-11T18:46:19-0530");
|
||||
applicationInstallationBeanWrapper.setOperation(applicationInstallation);
|
||||
return applicationInstallationBeanWrapper;
|
||||
}
|
||||
|
||||
public static ApplicationUpdateBeanWrapper getApplicationUpdateBeanWrapper() {
|
||||
ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper = new ApplicationUpdateBeanWrapper();
|
||||
applicationUpdateBeanWrapper.setDeviceIDs(getDeviceIds());
|
||||
ApplicationUpdate applicationUpdate = new ApplicationUpdate();
|
||||
applicationUpdate.setAppIdentifier("org.wso2.iot.agent");
|
||||
applicationUpdate.setUrl("https://github.com/wso2/cdmf-agent-android/releases/download/v3.1.21/client-standalone.apk");
|
||||
applicationUpdate.setType("enterprise");
|
||||
applicationUpdate.setSchedule("2017-10-11T18:46:19-0530");
|
||||
applicationUpdateBeanWrapper.setOperation(applicationUpdate);
|
||||
return applicationUpdateBeanWrapper;
|
||||
}
|
||||
|
||||
public static ApplicationUninstallationBeanWrapper getApplicationUninstallationBeanWrapperPublic() {
|
||||
ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper = new ApplicationUninstallationBeanWrapper();
|
||||
applicationUninstallationBeanWrapper.setDeviceIDs(getDeviceIds());
|
||||
ApplicationUninstallation applicationUninstallation = new ApplicationUninstallation();
|
||||
applicationUninstallation.setAppIdentifier("org.wso2.iot.agent");
|
||||
applicationUninstallation.setType("public");
|
||||
applicationUninstallationBeanWrapper.setOperation(applicationUninstallation);
|
||||
return applicationUninstallationBeanWrapper;
|
||||
}
|
||||
|
||||
public static ApplicationUninstallationBeanWrapper getApplicationUninstallationBeanWrapperWebApp() {
|
||||
ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper = new ApplicationUninstallationBeanWrapper();
|
||||
applicationUninstallationBeanWrapper.setDeviceIDs(getDeviceIds());
|
||||
ApplicationUninstallation applicationUninstallation = new ApplicationUninstallation();
|
||||
applicationUninstallation.setAppIdentifier("org.wso2.iot.agent");
|
||||
applicationUninstallation.setType("webapp");
|
||||
applicationUninstallationBeanWrapper.setOperation(applicationUninstallation);
|
||||
return applicationUninstallationBeanWrapper;
|
||||
}
|
||||
|
||||
public static BlacklistApplicationsBeanWrapper getBlacklistApplicationsBeanWrapper() {
|
||||
BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper = new BlacklistApplicationsBeanWrapper();
|
||||
blacklistApplicationsBeanWrapper.setDeviceIDs(getDeviceIds());
|
||||
BlacklistApplications blacklistApplications = new BlacklistApplications();
|
||||
List<String> appIds = new ArrayList<>();
|
||||
appIds.add("org.wso2.iot.agent");
|
||||
blacklistApplications.setAppIdentifier(appIds);
|
||||
blacklistApplicationsBeanWrapper.setOperation(blacklistApplications);
|
||||
return blacklistApplicationsBeanWrapper;
|
||||
}
|
||||
|
||||
public static UpgradeFirmwareBeanWrapper getUpgradeFirmwareBeanWrapper() {
|
||||
UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper = new UpgradeFirmwareBeanWrapper();
|
||||
upgradeFirmwareBeanWrapper.setDeviceIDs(getDeviceIds());
|
||||
UpgradeFirmware upgradeFirmware = new UpgradeFirmware();
|
||||
upgradeFirmware.setServer("https://github.com/wso2/cdmf-agent-android/releases/download/");
|
||||
upgradeFirmware.setSchedule("2017-10-11T18:46:19-0530");
|
||||
upgradeFirmwareBeanWrapper.setOperation(upgradeFirmware);
|
||||
return upgradeFirmwareBeanWrapper;
|
||||
}
|
||||
|
||||
public static VpnBeanWrapper getVpnBeanWrapper() {
|
||||
VpnBeanWrapper vpnBeanWrapper = new VpnBeanWrapper();
|
||||
vpnBeanWrapper.setDeviceIDs(getDeviceIds());
|
||||
Vpn vpn = new Vpn();
|
||||
vpnBeanWrapper.setOperation(vpn);
|
||||
return vpnBeanWrapper;
|
||||
}
|
||||
|
||||
public static NotificationBeanWrapper getNotificationBeanWrapper() {
|
||||
NotificationBeanWrapper notificationBeanWrapper = new NotificationBeanWrapper();
|
||||
notificationBeanWrapper.setDeviceIDs(getDeviceIds());
|
||||
Notification notification = new Notification();
|
||||
notification.setMessageText("Message");
|
||||
notification.setMessageTitle("Title");
|
||||
notificationBeanWrapper.setOperation(notification);
|
||||
return notificationBeanWrapper;
|
||||
}
|
||||
|
||||
public static WifiBeanWrapper getWifiBeanWrapper() {
|
||||
WifiBeanWrapper wifiBeanWrapper = new WifiBeanWrapper();
|
||||
wifiBeanWrapper.setDeviceIDs(getDeviceIds());
|
||||
Wifi wifi = new Wifi();
|
||||
wifiBeanWrapper.setOperation(wifi);
|
||||
return wifiBeanWrapper;
|
||||
}
|
||||
|
||||
public static EncryptionBeanWrapper getEncryptionBeanWrapper() {
|
||||
EncryptionBeanWrapper encryptionBeanWrapper = new EncryptionBeanWrapper();
|
||||
encryptionBeanWrapper.setDeviceIDs(getDeviceIds());
|
||||
DeviceEncryption deviceEncryption = new DeviceEncryption();
|
||||
deviceEncryption.setEncrypted(true);
|
||||
encryptionBeanWrapper.setOperation(deviceEncryption);
|
||||
return encryptionBeanWrapper;
|
||||
}
|
||||
|
||||
public static LockCodeBeanWrapper getLockCodeBeanWrapper() {
|
||||
LockCodeBeanWrapper lockCodeBeanWrapper = new LockCodeBeanWrapper();
|
||||
lockCodeBeanWrapper.setDeviceIDs(getDeviceIds());
|
||||
LockCode lockCode = new LockCode();
|
||||
lockCode.setLockCode("1234");
|
||||
lockCodeBeanWrapper.setOperation(lockCode);
|
||||
return lockCodeBeanWrapper;
|
||||
}
|
||||
|
||||
public static PasswordPolicyBeanWrapper getPasswordPolicyBeanWrapper() {
|
||||
PasswordPolicyBeanWrapper passwordPolicyBeanWrapper = new PasswordPolicyBeanWrapper();
|
||||
passwordPolicyBeanWrapper.setDeviceIDs(getDeviceIds());
|
||||
PasscodePolicy passcodePolicy = new PasscodePolicy();
|
||||
passwordPolicyBeanWrapper.setOperation(passcodePolicy);
|
||||
return passwordPolicyBeanWrapper;
|
||||
}
|
||||
|
||||
public static WebClipBeanWrapper getWebClipBeanWrapper() {
|
||||
WebClipBeanWrapper webClipBeanWrapper = new WebClipBeanWrapper();
|
||||
webClipBeanWrapper.setDeviceIDs(getDeviceIds());
|
||||
WebClip webClip = new WebClip();
|
||||
webClipBeanWrapper.setOperation(webClip);
|
||||
return webClipBeanWrapper;
|
||||
}
|
||||
|
||||
public static List<AndroidApplication> getAndroidApplications() {
|
||||
List<AndroidApplication> androidApplications = new ArrayList<>();
|
||||
AndroidApplication androidApplication = new AndroidApplication();
|
||||
androidApplications.add(androidApplication);
|
||||
return androidApplications;
|
||||
}
|
||||
|
||||
public static List<Operation> getSuccessMonitorOperationResponse() {
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
Operation operation = new Operation();
|
||||
operation.setActivityId(getActivity().getActivityId());
|
||||
operation.setCode(AndroidConstants.OperationCodes.MONITOR);
|
||||
operation.setId(1);
|
||||
operation.setOperationResponse("Operation success.");
|
||||
operation.setStatus(Operation.Status.COMPLETED);
|
||||
operations.add(operation);
|
||||
return operations;
|
||||
}
|
||||
|
||||
public static List<Operation> getSuccessApplicationOperationResponse() {
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
Operation operation = new Operation();
|
||||
operation.setActivityId(getActivity().getActivityId());
|
||||
operation.setCode(AndroidConstants.OperationCodes.APPLICATION_LIST);
|
||||
operation.setId(1);
|
||||
operation.setOperationResponse("[{\"name\":\"Widget%20Preview\",\"package\":\"com.android.widgetpreview\"," +
|
||||
"\"version\":\"7.1.1\",\"isSystemApp\":false,\"isActive\":false}," +
|
||||
"{\"name\":\"com.android.gesture.builder\"," +
|
||||
"\"package\":\"com.android.gesture.builder\",\"version\":\"7.1.1\"," +
|
||||
"\"isSystemApp\":false,\"isActive\":false},{\"name\":\"API%20Demos\"," +
|
||||
"\"package\":\"com.example.android.apis\",\"version\":\"7.1.1\"," +
|
||||
"\"isSystemApp\":false,\"isActive\":false}," +
|
||||
"{\"name\":\"WSO2%20Device%20Management%20Agent\"," +
|
||||
"\"package\":\"org.wso2.iot.agent\",\"version\":\"3.1.21\"," +
|
||||
"\"isSystemApp\":false,\"isActive\":true}," +
|
||||
"{\"name\":\"com.android.smoketest.tests\"," +
|
||||
"\"package\":\"com.android.smoketest.tests\",\"version\":\"7.1.1\"," +
|
||||
"\"isSystemApp\":false,\"isActive\":false}," +
|
||||
"{\"name\":\"Sample%20Soft%20Keyboard\"," +
|
||||
"\"package\":\"com.example.android.softkeyboard\",\"version\":\"7.1.1\"," +
|
||||
"\"isSystemApp\":false,\"isActive\":false},{\"name\":\"Example%20Wallpapers\"," +
|
||||
"\"package\":\"com.example.android.livecubes\",\"version\":\"7.1.1\"," +
|
||||
"\"isSystemApp\":false,\"isActive\":false},{\"name\":\"com.android.smoketest\"," +
|
||||
"\"package\":\"com.android.smoketest\",\"version\":\"7.1.1\"," +
|
||||
"\"isSystemApp\":false,\"isActive\":false}]");
|
||||
operation.setStatus(Operation.Status.COMPLETED);
|
||||
operations.add(operation);
|
||||
return operations;
|
||||
}
|
||||
|
||||
public static List<Operation> getSuccessInfoOperationResponse() {
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
Operation operation = new Operation();
|
||||
operation.setActivityId(getActivity().getActivityId());
|
||||
operation.setCode(AndroidConstants.OperationCodes.DEVICE_INFO);
|
||||
operation.setId(1);
|
||||
operation.setOperationResponse("{\"description\":\"generic_x86\",\"deviceIdentifier\":\"1d9612def9d205f9\"," +
|
||||
"\"enrolmentInfo\":null,\"name\":\"generic_x86\",\"properties\":[" +
|
||||
"{\"name\":\"SERIAL\",\"value\":\"unknown\"}," +
|
||||
"{\"name\":\"IMEI\",\"value\":null}," +
|
||||
"{\"name\":\"IMSI\",\"value\":\"310260000000000\"}," +
|
||||
"{\"name\":\"MAC\",\"value\":\"02:00:00:00:00:00\"}," +
|
||||
"{\"name\":\"DEVICE_MODEL\",\"value\":\"Android SDK built for x86\"}," +
|
||||
"{\"name\":\"VENDOR\",\"value\":\"unknown\"}," +
|
||||
"{\"name\":\"OS_VERSION\",\"value\":\"7.1.1\"}," +
|
||||
"{\"name\":\"OS_BUILD_DATE\",\"value\":\"1487782847000\"}," +
|
||||
"{\"name\":\"DEVICE_NAME\",\"value\":\"generic_x86\"}," +
|
||||
"{\"name\":\"LATITUDE\",\"value\":\"6.90988\"}," +
|
||||
"{\"name\":\"LONGITUDE\",\"value\":\"79.85249999999999\"}," +
|
||||
"{\"name\":\"NETWORK_INFO\",\"value\":\"[" +
|
||||
"{\\\"name\\\":\\\"CONNECTION_TYPE\\\",\\\"value\\\":\\\"MOBILE\\\"}," +
|
||||
"{\\\"name\\\":\\\"MOBILE_CONNECTION_TYPE\\\",\\\"value\\\":\\\"LTE\\\"}," +
|
||||
"{\\\"name\\\":\\\"MOBILE_SIGNAL_STRENGTH\\\",\\\"value\\\":\\\"-89\\\"}]\"}," +
|
||||
"{\"name\":\"CPU_INFO\",\"value\":\"[]\"},{\"name\":\"RAM_INFO\",\"value\":\"[" +
|
||||
"{\\\"name\\\":\\\"TOTAL_MEMORY\\\",\\\"value\\\":\\\"1055113216\\\"}," +
|
||||
"{\\\"name\\\":\\\"AVAILABLE_MEMORY\\\",\\\"value\\\":\\\"708997120\\\"}," +
|
||||
"{\\\"name\\\":\\\"THRESHOLD\\\",\\\"value\\\":\\\"150994944\\\"}," +
|
||||
"{\\\"name\\\":\\\"LOW_MEMORY\\\",\\\"value\\\":\\\"false\\\"}]\"}," +
|
||||
"{\"name\":\"BATTERY_INFO\",\"value\":\"[" +
|
||||
"{\\\"name\\\":\\\"BATTERY_LEVEL\\\",\\\"value\\\":\\\"100\\\"}," +
|
||||
"{\\\"name\\\":\\\"SCALE\\\",\\\"value\\\":\\\"100\\\"}," +
|
||||
"{\\\"BATTERY_VOLTAGE\\\":\\\"0\\\"}," +
|
||||
"{\\\"name\\\":\\\"HEALTH\\\",\\\"value\\\":\\\"GOOD_CONDITION\\\"}," +
|
||||
"{\\\"name\\\":\\\"STATUS\\\"}," +
|
||||
"{\\\"name\\\":\\\"PLUGGED\\\",\\\"value\\\":\\\"AC\\\"}]\"}," +
|
||||
"{\"name\":\"DEVICE_INFO\",\"value\":\"[" +
|
||||
"{\\\"name\\\":\\\"ENCRYPTION_ENABLED\\\",\\\"value\\\":\\\"false\\\"}," +
|
||||
"{\\\"name\\\":\\\"PASSCODE_ENABLED\\\",\\\"value\\\":\\\"true\\\"}," +
|
||||
"{\\\"name\\\":\\\"BATTERY_LEVEL\\\",\\\"value\\\":\\\"100\\\"}," +
|
||||
"{\\\"name\\\":\\\"INTERNAL_TOTAL_MEMORY\\\",\\\"value\\\":\\\"0.76\\\"}," +
|
||||
"{\\\"name\\\":\\\"INTERNAL_AVAILABLE_MEMORY\\\",\\\"value\\\":\\\"0.67\\\"}," +
|
||||
"{\\\"name\\\":\\\"EXTERNAL_TOTAL_MEMORY\\\",\\\"value\\\":\\\"0.1\\\"}," +
|
||||
"{\\\"name\\\":\\\"EXTERNAL_AVAILABLE_MEMORY\\\",\\\"value\\\":\\\"0.1\\\"}," +
|
||||
"{\\\"name\\\":\\\"OPERATOR\\\",\\\"value\\\":\\\"Android\\\"}," +
|
||||
"{\\\"name\\\":\\\"PHONE_NUMBER\\\",\\\"value\\\":\\\"15555215554\\\"}]\"}]}");
|
||||
operation.setStatus(Operation.Status.COMPLETED);
|
||||
operations.add(operation);
|
||||
return operations;
|
||||
}
|
||||
|
||||
public static List<Operation> getInProgressOperationResponse() {
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
Operation operation = new Operation();
|
||||
operation.setActivityId(getActivity().getActivityId());
|
||||
operation.setCode(AndroidConstants.OperationCodes.NOTIFICATION);
|
||||
operation.setId(1);
|
||||
operation.setOperationResponse("Operation in progress.");
|
||||
operation.setStatus(Operation.Status.IN_PROGRESS);
|
||||
operations.add(operation);
|
||||
return operations;
|
||||
}
|
||||
|
||||
public static List<Operation> getErrorOperationResponse() {
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
Operation operation = new Operation();
|
||||
operation.setActivityId(getActivity().getActivityId());
|
||||
operation.setCode(AndroidConstants.OperationCodes.DEVICE_INFO);
|
||||
operation.setId(1);
|
||||
operation.setOperationResponse("Operation failure.");
|
||||
operation.setStatus(Operation.Status.ERROR);
|
||||
operations.add(operation);
|
||||
return operations;
|
||||
}
|
||||
|
||||
public static DeviceLocation getDeviceLocation() {
|
||||
DeviceLocation location = new DeviceLocation();
|
||||
location.setCity("Colombo");
|
||||
location.setCountry("Sri Lanka");
|
||||
location.setLatitude(6.9);
|
||||
location.setLongitude(79.5);
|
||||
location.setDeviceIdentifier(AndroidDeviceUtils.convertToDeviceIdentifierObject(getDeviceId()));
|
||||
return location;
|
||||
}
|
||||
|
||||
public static DeviceInfo getDeviceInfo() {
|
||||
DeviceInfo deviceInfo = new DeviceInfo();
|
||||
deviceInfo.setDeviceModel("nexus");
|
||||
deviceInfo.setAvailableRAMMemory(2.0);
|
||||
deviceInfo.setBatteryLevel(100.0);
|
||||
deviceInfo.setConnectionType("4G");
|
||||
deviceInfo.setCpuUsage(1.0);
|
||||
deviceInfo.setExternalAvailableMemory(2.3);
|
||||
deviceInfo.setExternalTotalMemory(4.0);
|
||||
deviceInfo.setInternalAvailableMemory(1.0);
|
||||
deviceInfo.setInternalTotalMemory(4.0);
|
||||
deviceInfo.setLocation(getDeviceLocation());
|
||||
return deviceInfo;
|
||||
}
|
||||
|
||||
public static List<Application> getApplications() {
|
||||
List<Application> applications = new ArrayList<>();
|
||||
Application app = new Application();
|
||||
app.setName("WSO2 IoT Agent");
|
||||
app.setApplicationIdentifier("org.wos2.iot.agent");
|
||||
app.setVersion("1.0.0");
|
||||
app.setPlatform("Android");
|
||||
applications.add(app);
|
||||
return applications;
|
||||
}
|
||||
|
||||
public static AndroidDevice getBasicAndroidDevice() {
|
||||
AndroidDevice androidDevice = new AndroidDevice();
|
||||
androidDevice.setName(getDevice().getName());
|
||||
androidDevice.setDescription(getDevice().getDescription());
|
||||
androidDevice.setDeviceIdentifier(getDeviceId());
|
||||
androidDevice.setDeviceInfo(getDeviceInfo());
|
||||
androidDevice.setApplications(getApplications());
|
||||
androidDevice.setEnrolmentInfo(getDevice().getEnrolmentInfo());
|
||||
return androidDevice;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
#
|
||||
# Copyright (c) 2017, 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.
|
||||
#
|
||||
|
||||
#
|
||||
# This is the log4j configuration file used by WSO2 Carbon
|
||||
#
|
||||
# IMPORTANT : Please do not remove or change the names of any
|
||||
# of the Appender defined here. The layout pattern & log file
|
||||
# can be changed using the WSO2 Carbon Management Console, and those
|
||||
# settings will override the settings in this file.
|
||||
#
|
||||
|
||||
log4j.rootLogger=DEBUG, STD_OUT
|
||||
|
||||
# Redirect log messages to console
|
||||
log4j.appender.STD_OUT=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.STD_OUT.Target=System.out
|
||||
log4j.appender.STD_OUT.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.STD_OUT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
|
@ -0,0 +1,30 @@
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2017, 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.
|
||||
-->
|
||||
|
||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
||||
|
||||
<suite name="AndroidDeviceManagementAPIs">
|
||||
|
||||
<test name="API Tests" preserve-order="true">
|
||||
<classes>
|
||||
<class name="org.wso2.carbon.mdm.services.android.DeviceManagementAdminServiceTests" />
|
||||
<class name="org.wso2.carbon.mdm.services.android.DeviceManagementServiceTests" />
|
||||
</classes>
|
||||
</test>
|
||||
</suite>
|
Loading…
Reference in new issue