mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Implemented policy compliance checking function for Android plugin
This commit is contained in:
parent
95ea4ab5f4
commit
4790de94ef
@ -76,7 +76,8 @@
|
|||||||
org.wso2.carbon.registry.core.service,
|
org.wso2.carbon.registry.core.service,
|
||||||
org.wso2.carbon.registry.core.session,
|
org.wso2.carbon.registry.core.session,
|
||||||
org.wso2.carbon.registry.api,
|
org.wso2.carbon.registry.api,
|
||||||
org.wso2.carbon.device.mgt.extensions.license.mgt.registry
|
org.wso2.carbon.device.mgt.extensions.license.mgt.registry,
|
||||||
|
com.google.gson.*
|
||||||
</Import-Package>
|
</Import-Package>
|
||||||
<Export-Package>
|
<Export-Package>
|
||||||
!org.wso2.carbon.device.mgt.mobile.internal,
|
!org.wso2.carbon.device.mgt.mobile.internal,
|
||||||
@ -165,5 +166,9 @@
|
|||||||
<artifactId>h2-database-engine</artifactId>
|
<artifactId>h2-database-engine</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.mobile.impl.android;
|
package org.wso2.carbon.device.mgt.mobile.impl.android;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
@ -43,15 +47,28 @@ public class AndroidPolicyMonitoringService implements PolicyMonitoringService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object o) throws PolicyComplianceException {
|
public ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object o)
|
||||||
ComplianceData complianceData = new ComplianceData();
|
throws PolicyComplianceException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Checking policy compliance status of device '" + deviceIdentifier.getId() + "'");
|
log.debug("Checking policy compliance status of device '" + deviceIdentifier.getId() + "'");
|
||||||
}
|
}
|
||||||
if (o == null || policy == null) {
|
if (o == null || policy == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<ComplianceFeature> complianceFeatures = (List<ComplianceFeature>) o;
|
ComplianceData complianceData = new ComplianceData();
|
||||||
|
List<ComplianceFeature> complianceFeatures = new ArrayList<ComplianceFeature>();
|
||||||
|
|
||||||
|
// Parsing json string to get compliance features.
|
||||||
|
JsonElement jsonElement = new JsonParser().parse((String) o);
|
||||||
|
JsonArray jsonArray = jsonElement.getAsJsonArray();
|
||||||
|
Gson gson = new Gson();
|
||||||
|
ComplianceFeature complianceFeature;
|
||||||
|
|
||||||
|
for (int i = 0; i < jsonArray.size(); i++) {
|
||||||
|
complianceFeature = gson.fromJson(jsonArray.get(i), ComplianceFeature.class);
|
||||||
|
complianceFeatures.add(complianceFeature);
|
||||||
|
}
|
||||||
|
|
||||||
complianceData.setComplianceFeatures(complianceFeatures);
|
complianceData.setComplianceFeatures(complianceFeatures);
|
||||||
|
|
||||||
for (ComplianceFeature cf : complianceFeatures) {
|
for (ComplianceFeature cf : complianceFeatures) {
|
||||||
|
|||||||
@ -58,6 +58,10 @@
|
|||||||
<artifactId>org.wso2.carbon.device.mgt.extensions.feature</artifactId>
|
<artifactId>org.wso2.carbon.device.mgt.extensions.feature</artifactId>
|
||||||
<type>zip</type>
|
<type>zip</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
6
pom.xml
6
pom.xml
@ -511,6 +511,11 @@
|
|||||||
<artifactId>axis2</artifactId>
|
<artifactId>axis2</artifactId>
|
||||||
<version>${axis2.orbit.version}</version>
|
<version>${axis2.orbit.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>${google.gson.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
@ -577,6 +582,7 @@
|
|||||||
<bouncycastle.version>1.49</bouncycastle.version>
|
<bouncycastle.version>1.49</bouncycastle.version>
|
||||||
<apache.wss4j.version>2.0.0</apache.wss4j.version>
|
<apache.wss4j.version>2.0.0</apache.wss4j.version>
|
||||||
<codehaus.plexus.version>3.0.21</codehaus.plexus.version>
|
<codehaus.plexus.version>3.0.21</codehaus.plexus.version>
|
||||||
|
<google.gson.version>2.2.4</google.gson.version>
|
||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user