revert-70aa11f8
kamidu 8 years ago
commit 225268bd78

@ -22,13 +22,13 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Annotations</name>
<description>WSO2 Carbon - API Management Custom Annotation Module</description>
@ -78,6 +78,7 @@
org.apache.commons.logging,
javax.servlet,
javax.xml.*,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
org.apache.commons.lang,
</Import-Package>
<Embed-Dependency>
@ -89,4 +90,4 @@
</plugins>
</build>
</project>
</project>

@ -21,12 +21,12 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<artifactId>org.wso2.carbon.apimgt.application.extension.api</artifactId>
<packaging>war</packaging>
<name>WSO2 Carbon - API Application Management API</name>

@ -22,12 +22,12 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<artifactId>org.wso2.carbon.apimgt.application.extension</artifactId>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Application Management</name>

@ -159,14 +159,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
}
}
String[] allowedDomains = new String[1];
if (isAllowedAllDomains) {
allowedDomains[0] = ApiApplicationConstants.ALLOWED_DOMAINS;
} else {
allowedDomains[0] = APIManagerUtil.getTenantDomain();
}
apiConsumer.mapExistingOAuthClient(jsonString, username, clientId, applicationName,
ApiApplicationConstants.DEFAULT_TOKEN_TYPE, allowedDomains);
ApiApplicationConstants.DEFAULT_TOKEN_TYPE);
if (tags != null && tags.length > 0) {
createApplicationAndSubscribeToAPIs(applicationName, tags, username);
}
@ -327,11 +321,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
if (consumer != null) {
synchronized (consumer) {
if (consumer.getSubscriber(subscriberName) == null) {
Subscriber subscriber = new Subscriber(subscriberName);
subscriber.setSubscribedDate(new Date());
subscriber.setEmail(subscriberEmail);
subscriber.setTenantId(tenantId);
consumer.addSubscriber(subscriber, groupId);
consumer.addSubscriber(subscriberName, groupId);
if (log.isDebugEnabled()) {
log.debug("Successfully created subscriber with name : " + subscriberName +
" with groupID : " + groupId);
@ -365,7 +355,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
Subscriber subscriber = apiConsumer.getSubscriber(username);
Set<API> userVisibleAPIs = null;
for (String tag : tags) {
Set<API> tagAPIs = apiConsumer.getAPIsWithTag(tag);
Set<API> tagAPIs = apiConsumer.getAPIsWithTag(tag, APIManagerUtil.getTenantDomain());
if (userVisibleAPIs == null) {
userVisibleAPIs = tagAPIs;
} else {

@ -22,13 +22,13 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Webapp Publisher</name>
<description>WSO2 Carbon - API Management Webapp Publisher</description>
@ -143,6 +143,7 @@
org.apache.commons.logging,
javax.servlet,
javax.xml.*,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
com.google.gson.*,
org.apache.catalina,
org.apache.catalina.core,
@ -168,4 +169,4 @@
</plugins>
</build>
</project>
</project>

@ -56,6 +56,7 @@ public class APIConfig {
private String contextTemplate;
private String endpoint;
private String version;
private String policy;
private String transports;
private APIProvider provider;
private boolean isSecured;
@ -73,6 +74,16 @@ public class APIConfig {
}
}
@XmlElement(name = "Policy", required = true)
public String getPolicy() {
return policy;
}
@SuppressWarnings("unused")
public void setPolicy(String policy) {
this.policy = policy;
}
@XmlElement(name = "ContextTemplate", required = true)
public String getContextTemplate() {
return contextTemplate;

@ -47,6 +47,7 @@ public class APIPublisherUtil {
private static final String PARAM_MANAGED_API_ENDPOINT = "managed-api-endpoint";
private static final String PARAM_MANAGED_API_OWNER = "managed-api-owner";
private static final String PARAM_MANAGED_API_TRANSPORTS = "managed-api-transports";
private static final String PARAM_MANAGED_API_POLICY = "managed-api-policy";
private static final String PARAM_MANAGED_API_IS_SECURED = "managed-api-isSecured";
private static final String PARAM_SHARED_WITH_ALL_TENANTS = "isSharedWithAllTenants";
private static final String PARAM_PROVIDER_TENANT_DOMAIN = "providerTenantDomain";
@ -80,6 +81,7 @@ public class APIPublisherUtil {
api.setEndpointSecured(true);
api.setStatus(APIStatus.CREATED);
api.setTransports(config.getTransports());
api.setApiLevelPolicy(config.getPolicy());
api.setContextTemplate(config.getContextTemplate());
Set<String> environments = new HashSet<>();
environments.add(API_PUBLISH_ENVIRONMENT);
@ -309,6 +311,16 @@ public class APIPublisherUtil {
}
apiConfig.setUriTemplates(uriTemplates);
String policy = servletContext.getInitParameter(PARAM_MANAGED_API_POLICY);
if (policy == null || policy.isEmpty()) {
if (log.isDebugEnabled()) {
log.debug("'managed-api-policy' attribute is not configured. Therefore using the default, " +
"which is 'null'");
}
policy = null;
}
apiConfig.setPolicy(policy);
return apiConfig;
}

@ -22,13 +22,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apimgt-extensions</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - API Management Extensions Component</name>
<url>http://wso2.org</url>

@ -22,7 +22,7 @@
<parent>
<artifactId>certificate-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -161,6 +161,10 @@
<groupId>io.swagger</groupId>
<artifactId>swagger-core</artifactId>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
@ -170,6 +174,16 @@
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jaxrs</artifactId>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>

@ -22,7 +22,7 @@
<parent>
<artifactId>certificate-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -166,6 +166,12 @@
<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>

@ -21,13 +21,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Certificate Management Core</name>
<description>WSO2 Carbon - Certificate Management Core</description>
@ -57,13 +57,14 @@
org.apache.commons.logging,
javax.security.auth.x500,
javax.xml.*,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
org.apache.commons.codec.binary,
org.bouncycastle.asn1,
org.bouncycastle.asn1.x500,
org.bouncycastle.asn1.x509,
org.bouncycastle.asn1.pkcs,
org.bouncycastle.cert,
org.bouncycastle.cert.jcajce,
org.bouncycastle.cert; version="${bcprov.wso2.version.range}",
org.bouncycastle.cert.jcajce; version="${bcprov.wso2.version.range}",
org.bouncycastle.cms,
org.bouncycastle.jce.provider,
org.bouncycastle.operator,
@ -89,6 +90,7 @@
org.wso2.carbon.device.mgt.common.*,
io.swagger.annotations.*;resolution:=optional,
org.wso2.carbon.device.mgt.core.*,
org.wso2.carbon.registry.indexing.*,
<!--org.bouncycastle.pkcs.jcajce-->
</Import-Package>
<Export-Package>
@ -134,19 +136,15 @@
<artifactId>org.wso2.carbon.logging</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle.wso2</groupId>
<groupId>org.wso2.orbit.org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle.wso2</groupId>
<groupId>org.wso2.orbit.org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle.wso2</groupId>
<artifactId>bcmail-jdk15on</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.jscep.wso2</groupId>
<groupId>org.wso2.orbit.com.google.code.jscep</groupId>
<artifactId>jscep</artifactId>
</dependency>
<dependency>
@ -179,7 +177,15 @@
<artifactId>org.wso2.carbon.user.core</artifactId>
<version>4.4.3</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.registry</groupId>
<artifactId>org.wso2.carbon.registry.indexing</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

@ -27,6 +27,8 @@ import org.wso2.carbon.certificate.mgt.core.config.CertificateManagementConfig;
import org.wso2.carbon.certificate.mgt.core.config.datasource.DataSourceConfig;
import org.wso2.carbon.certificate.mgt.core.dao.CertificateManagementDAOFactory;
import org.wso2.carbon.certificate.mgt.core.exception.CertificateManagementException;
import org.wso2.carbon.certificate.mgt.core.scep.SCEPManager;
import org.wso2.carbon.certificate.mgt.core.scep.SCEPManagerImpl;
import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService;
import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementServiceImpl;
import org.wso2.carbon.certificate.mgt.core.util.CertificateManagementConstants;
@ -72,6 +74,9 @@ public class CertificateManagementServiceComponent {
bundleContext.registerService(CertificateManagementService.class.getName(),
CertificateManagementServiceImpl.getInstance(), null);
bundleContext.registerService(SCEPManager.class.getName(),
new SCEPManagerImpl(), null);
if (log.isDebugEnabled()) {
log.debug("Certificate management core bundle has been successfully initialized");
}

@ -1,60 +0,0 @@
package org.wso2.carbon.certificate.mgt.core.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.certificate.mgt.core.scep.SCEPManager;
import org.wso2.carbon.certificate.mgt.core.scep.SCEPManagerImpl;
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
/**
* @scr.component name="org.wso2.carbon.certificate.mgt.core.scep" immediate="true"
* @scr.reference name="app.mgt.service"
* interface="org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService"
* cardinality="1..1"
* policy="dynamic"
* bind="setApplicationManagementProviderService"
* unbind="unsetApplicationManagementProviderService"
*/
public class SCEPManagerServiceComponent {
private static final Log log = LogFactory.getLog(SCEPManagerServiceComponent.class);
protected void activate(ComponentContext componentContext) {
try {
if (log.isDebugEnabled()) {
log.debug("Initializing SCEP core bundle");
}
BundleContext bundleContext = componentContext.getBundleContext();
bundleContext.registerService(SCEPManager.class.getName(),
new SCEPManagerImpl(), null);
if (log.isDebugEnabled()) {
log.debug("SCEP core bundle has been successfully initialized");
}
} catch (Throwable e) {
String msg = "Error occurred while initializing SCEP core bundle";
log.error(msg, e);
}
}
protected void deactivate(ComponentContext ctx) {
if (log.isDebugEnabled()) {
log.debug("Deactivating SCEP core bundle");
}
}
protected void unsetApplicationManagementProviderService(ApplicationManagementProviderService
applicationManagementProviderService) {
//do nothing
}
protected void setApplicationManagementProviderService(ApplicationManagementProviderService
applicationManagementProviderService) {
//do nothing
}
}

@ -19,12 +19,12 @@ package org.wso2.carbon.certificate.mgt.core.scep;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.certificate.mgt.core.internal.CertificateManagementDataHolder;
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.core.dao.DeviceDAO;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
@ -33,19 +33,18 @@ import java.sql.SQLException;
import java.util.HashMap;
public class SCEPManagerImpl implements SCEPManager {
private DeviceDAO deviceDAO;
private static final Log log = LogFactory.getLog(SCEPManagerImpl.class);
DeviceManagementProviderService dms;
public SCEPManagerImpl() {
deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
this.dms = CertificateManagementDataHolder.getInstance().getDeviceManagementService();
}
@Override
public TenantedDeviceWrapper getValidatedDevice(DeviceIdentifier deviceIdentifier) throws SCEPException {
TenantedDeviceWrapper tenantedDeviceWrapper = new TenantedDeviceWrapper();
try {
DeviceManagementDAOFactory.openConnection();
HashMap<Integer, Device> deviceHashMap = deviceDAO.getDevice(deviceIdentifier);
HashMap<Integer, Device> deviceHashMap = dms.getTenantedDevice(deviceIdentifier);
Object[] keySet = deviceHashMap.keySet().toArray();
if (keySet == null || keySet.length == 0) {
@ -71,15 +70,12 @@ public class SCEPManagerImpl implements SCEPManager {
String tenantDomain = realmService.getTenantManager().getDomain(tenantId);
tenantedDeviceWrapper.setTenantDomain(tenantDomain);
} catch (SQLException e) {
throw new SCEPException("Error occurred while getting the datasource connection.", e);
} catch (DeviceManagementDAOException e) {
throw new SCEPException("Error occurred while reading the device dao.", e);
} catch (UserStoreException e) {
throw new SCEPException("Error occurred while getting the tenant domain.", e);
} catch (DeviceManagementException e) {
throw new SCEPException("Error occurred while getting device '" + deviceIdentifier + "'.", e);
} finally {
PrivilegedCarbonContext.endTenantFlow();
DeviceManagementDAOFactory.closeConnection();
}
return tenantedDeviceWrapper;
}

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - Certificate Management Component</name>
<url>http://wso2.org</url>

@ -22,7 +22,7 @@
<parent>
<artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -55,8 +55,8 @@
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>

@ -22,7 +22,7 @@
<parent>
<artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -55,8 +55,8 @@
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
@ -139,6 +139,7 @@
org.wso2.carbon.context,
org.wso2.carbon.device.mgt.common.operation.mgt,
org.wso2.carbon.device.mgt.common.push.notification,
org.wso2.carbon.device.mgt.common,
org.wso2.carbon.device.mgt.core.service,
org.wso2.carbon.event.output.adapter.core,
org.wso2.carbon.event.output.adapter.core.exception,

@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
@ -32,6 +33,7 @@ import org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterExc
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
public class MQTTNotificationStrategy implements NotificationStrategy {
@ -75,7 +77,15 @@ public class MQTTNotificationStrategy implements NotificationStrategy {
@Override
public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException {
Map<String, String> dynamicProperties = new HashMap<>();
dynamicProperties.put("topic", (String) ctx.getOperation().getProperties().get(MQTT_ADAPTER_TOPIC));
Properties properties = ctx.getOperation().getProperties();
if (properties != null && properties.get(MQTT_ADAPTER_TOPIC) != null) {
dynamicProperties.put("topic", (String) properties.get(MQTT_ADAPTER_TOPIC));
} else {
String topic = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true) + "/"
+ ctx.getDeviceId().getType() + "/" + ctx.getDeviceId().getId() + "/" + ctx.getOperation().getType();
dynamicProperties.put("topic", topic);
}
MQTTDataHolder.getInstance().getOutputEventAdapterService().publish(mqttAdapterName, dynamicProperties,
ctx.getOperation().getPayLoad());
}

@ -22,7 +22,7 @@
<parent>
<artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -55,8 +55,8 @@
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>

@ -22,7 +22,7 @@
<parent>
<artifactId>carbon-devicemgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

@ -3,7 +3,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -82,6 +82,10 @@
<groupId>org.wso2.carbon.registry</groupId>
<artifactId>org.wso2.carbon.registry.indexing</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.registry</groupId>
<artifactId>org.wso2.carbon.registry.common</artifactId>
</dependency>
<dependency>
<groupId>org.json.wso2</groupId>
<artifactId>json</artifactId>
@ -122,6 +126,7 @@
org.wso2.carbon.registry.indexing.*; version="${carbon.registry.imp.pkg.version.range}",
org.json;version="${commons-json.version}",
javax.xml.*,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
org.w3c.dom,
org.wso2.carbon.base
</Import-Package>
@ -131,4 +136,4 @@
</plugins>
</build>
</project>
</project>

@ -22,7 +22,7 @@
<parent>
<artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -222,15 +222,37 @@
<groupId>io.swagger</groupId>
<artifactId>swagger-core</artifactId>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jaxrs</artifactId>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
@ -250,7 +272,6 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>

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

@ -21,7 +21,7 @@
<parent>
<artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -49,8 +49,8 @@
</Export-Package>
<Import-Package>
javax.xml.bind.annotation,
com.fasterxml.jackson.annotation,
org.wso2.carbon.apimgt.api.model,
com.fasterxml.jackson.annotation;version="${jackson-annotations.version}",
org.wso2.carbon.apimgt.api.model.*;version="${carbon.api.mgt.version.range}",
io.swagger.annotations.*;resolution:=optional
</Import-Package>
</instructions>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -58,6 +58,7 @@
org.apache.commons.logging,
javax.naming,
javax.xml.*,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
javax.servlet.*,
org.xml.sax,
javax.sql.*,
@ -142,6 +143,12 @@
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.ndatasource.core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.h2database.wso2</groupId>
@ -185,17 +192,17 @@
<artifactId>axis2-transport-mail</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<!--dependency>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom-impl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom</artifactId>
</dependency>
</dependency-->
<dependency>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.api</artifactId>

@ -26,6 +26,7 @@ import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationProvider;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent;
@ -74,7 +75,7 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
}
} catch (DeviceManagementException e) {
throw new DeviceManagementException("Error occurred while adding device management provider '" +
deviceType + "'", e);
deviceType + "'", e);
}
if (isSharedWithAllTenants) {
DeviceTypeIdentifier deviceTypeIdentifier = new DeviceTypeIdentifier(deviceType);
@ -137,10 +138,16 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
deviceTypeIdentifier = new DeviceTypeIdentifier(deviceManagementService.getType(), tenantId);
}
if (pushNoteConfig != null) {
NotificationStrategy notificationStrategy =
DeviceManagementDataHolder.getInstance().getPushNotificationProviderRepository().getProvider(
pushNoteConfig.getType()).getNotificationStrategy(pushNoteConfig);
PushNotificationProvider provider = DeviceManagementDataHolder.getInstance()
.getPushNotificationProviderRepository().getProvider(pushNoteConfig.getType());
if (provider == null) {
throw new DeviceManagementException(
"No registered push notification provider found for the type: '" +
pushNoteConfig.getType() + "'.");
}
NotificationStrategy notificationStrategy = provider.getNotificationStrategy(pushNoteConfig);
operationManagerRepository.addOperationManager(deviceTypeIdentifier, new OperationManagerImpl(
notificationStrategy));
} else {
@ -172,7 +179,8 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
deviceTypeName = provider.getType().toLowerCase();
ProvisioningConfig provisioningConfig = provider.getProvisioningConfig();
int tenantId = DeviceManagerUtil.getTenantId(provisioningConfig.getProviderTenantDomain());
DeviceManagerUtil.registerDeviceType(deviceTypeName, tenantId, provisioningConfig.isSharedWithAllTenants());
DeviceManagerUtil.registerDeviceType(deviceTypeName, tenantId,
provisioningConfig.isSharedWithAllTenants());
registerPushNotificationStrategy(provider);
//TODO:
//This is a temporory fix.
@ -180,12 +188,13 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
//until fix that, use following variable to enable and disable of checking user authorization.
DeviceManagementDataHolder.getInstance().setRequireDeviceAuthorization(provider.getType(),
provider.getDeviceManager().requireDeviceAuthorization());
provider.getDeviceManager()
.requireDeviceAuthorization());
} catch (Throwable e) {
/* Throwable is caught intentionally as failure of one plugin - due to invalid start up parameters,
etc - should not block the initialization of other device management providers */
log.error("Error occurred while initializing device management provider '" +
provider.getType() + "'", e);
provider.getType() + "'", e);
}
}
this.isInited = true;

@ -19,7 +19,6 @@
package org.wso2.carbon.device.mgt.core.app.mgt;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.core.DeviceManagementPluginRepository;
import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
public class ApplicationManagerFactory {

@ -241,11 +241,6 @@ public class DeviceManagementServiceComponent {
= new NotificationManagementServiceImpl();
bundleContext.registerService(NotificationManagementService.class.getName(), notificationManagementService, null);
/* Registering PermissionManager Service */
PermissionManagerService permissionManagerService
= PermissionManagerServiceImpl.getInstance();
bundleContext.registerService(PermissionManagerService.class.getName(), permissionManagerService, null);
/* Registering DeviceAccessAuthorization Service */
DeviceAccessAuthorizationService deviceAccessAuthorizationService = new DeviceAccessAuthorizationServiceImpl();
DeviceManagementDataHolder.getInstance().setDeviceAccessAuthorizationService(deviceAccessAuthorizationService);
@ -262,6 +257,10 @@ public class DeviceManagementServiceComponent {
} catch (ApplicationManagementException e) {
log.error("Application management service not registered.", e);
}
/* Registering PermissionManager Service */
PermissionManagerService permissionManagerService = PermissionManagerServiceImpl.getInstance();
bundleContext.registerService(PermissionManagerService.class.getName(), permissionManagerService, null);
}
private void setupDeviceManagementSchema(DataSourceConfig config) throws DeviceManagementException {

@ -18,12 +18,8 @@
package org.wso2.carbon.device.mgt.core.notification.mgt.dao.impl;
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.core.dao.DeviceManagementDAOException;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationDAO;
import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.notification.mgt.dao.util.NotificationDAOUtil;
@ -80,7 +76,7 @@ public abstract class AbstractNotificationDAOImpl implements NotificationDAO {
conn = NotificationManagementDAOFactory.getConnection();
String sql =
"SELECT NOTIFICATION_ID, OPERATION_ID, DESCRIPTION, STATUS FROM DM_NOTIFICATION WHERE " +
"TENANT_ID = ? AND NOTIFICATION_ID = ?";
"TENANT_ID = ? AND NOTIFICATION_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, tenantId);
stmt.setInt(2, notificationId);
@ -165,7 +161,7 @@ public abstract class AbstractNotificationDAOImpl implements NotificationDAO {
rs = stmt.executeQuery();
notifications = new ArrayList<>();
while (rs.next()) {
notifications.add(NotificationDAOUtil.getNotification(rs));
notifications.add(NotificationDAOUtil.getNotificationWithDeviceInfo(rs));
}
} catch (SQLException e) {
throw new NotificationManagementException(
@ -238,7 +234,7 @@ public abstract class AbstractNotificationDAOImpl implements NotificationDAO {
rs = stmt.executeQuery();
notifications = new ArrayList<>();
while (rs.next()) {
notifications.add(NotificationDAOUtil.getNotification(rs));
notifications.add(NotificationDAOUtil.getNotificationWithDeviceInfo(rs));
}
} catch (SQLException e) {
throw new NotificationManagementException(

@ -126,6 +126,15 @@ public class NotificationDAOUtil {
}
public static Notification getNotification(ResultSet rs) throws SQLException {
Notification notification = new Notification();
notification.setNotificationId(rs.getInt("NOTIFICATION_ID"));
notification.setOperationId(rs.getInt("OPERATION_ID"));
notification.setDescription(rs.getString("DESCRIPTION"));
notification.setStatus(rs.getString("STATUS"));
return notification;
}
public static Notification getNotificationWithDeviceInfo(ResultSet rs) throws SQLException {
Notification notification = new Notification();
notification.setNotificationId(rs.getInt("NOTIFICATION_ID"));
notification.setOperationId(rs.getInt("OPERATION_ID"));

@ -120,8 +120,8 @@ public class OperationManagerImpl implements OperationManager {
boolean isNotRepeated = false;
boolean hasExistingTaskOperation;
int enrolmentId;
if (operationDto.getControl() ==
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Control.NO_REPEAT) {
if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Control.NO_REPEAT == operationDto.
getControl()) {
isNotRepeated = true;
}
@ -357,12 +357,25 @@ public class OperationManagerImpl implements OperationManager {
deviceId.getId() + "'");
}
int enrolmentId = this.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE);
if (enrolmentId < 0) {
//
EnrolmentInfo enrolmentInfo = this.getEnrolmentInfo(deviceId);
if (enrolmentInfo == null) {
throw new OperationManagementException("Device not found for the given device Identifier:" +
deviceId.getId() + " and given type:" +
deviceId.getType());
}
int enrolmentId = enrolmentInfo.getId();
//Changing the enrollment status & attempt count if the device is marked as inactive or unreachable
switch (enrolmentInfo.getStatus()) {
case ACTIVE:
this.resetAttemptCount(enrolmentId);
break;
case INACTIVE:
case UNREACHABLE:
this.resetAttemptCount(enrolmentId);
this.setEnrolmentStatus(deviceId, EnrolmentInfo.Status.ACTIVE);
break;
}
try {
OperationManagementDAOFactory.openConnection();
@ -886,6 +899,65 @@ public class OperationManagerImpl implements OperationManager {
return enrolmentId;
}
private EnrolmentInfo getEnrolmentInfo(DeviceIdentifier deviceId) throws OperationManagementException {
EnrolmentInfo enrolmentInfo;
try {
DeviceManagementDAOFactory.openConnection();
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
String user = this.getUser();
enrolmentInfo = deviceDAO.getEnrolment(deviceId, user, tenantId);
} catch (DeviceManagementDAOException e) {
throw new OperationManagementException("Error occurred while retrieving enrollment data of '" +
deviceId.getType() + "' device carrying the identifier '" +
deviceId.getId() + "'", e);
} catch (SQLException e) {
throw new OperationManagementException(
"Error occurred while opening a connection to the data source", e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
return enrolmentInfo;
}
private boolean setEnrolmentStatus(DeviceIdentifier deviceId, EnrolmentInfo.Status status) throws OperationManagementException {
boolean updateStatus;
try {
DeviceManagementDAOFactory.beginTransaction();
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
String user = this.getUser();
updateStatus = deviceDAO.setEnrolmentStatus(deviceId, user, status, tenantId);
DeviceManagementDAOFactory.commitTransaction();
} catch (DeviceManagementDAOException e) {
DeviceManagementDAOFactory.rollbackTransaction();
throw new OperationManagementException("Error occurred while updating enrollment status of '" +
deviceId.getType() + "' device carrying the identifier '" +
deviceId.getId() + "'", e);
} catch (TransactionManagementException e) {
throw new OperationManagementException("Error occurred while initiating a transaction", e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
return updateStatus;
}
private boolean resetAttemptCount(int enrolmentId) throws OperationManagementException {
boolean resetStatus;
try {
OperationManagementDAOFactory.beginTransaction();
resetStatus = operationDAO.resetAttemptCount(enrolmentId);
OperationManagementDAOFactory.commitTransaction();
} catch (OperationManagementDAOException e) {
OperationManagementDAOFactory.rollbackTransaction();
throw new OperationManagementException("Error occurred while resetting attempt count of device id : '" +
enrolmentId + "'", e);
} catch (TransactionManagementException e) {
throw new OperationManagementException("Error occurred while initiating a transaction", e);
} finally {
OperationManagementDAOFactory.closeConnection();
}
return resetStatus;
}
private boolean isTaskScheduledOperation(Operation operation) {
TaskConfiguration taskConfiguration = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().
getTaskConfiguration();
@ -896,5 +968,4 @@ public class OperationManagerImpl implements OperationManager {
}
return false;
}
}
}

@ -79,4 +79,6 @@ public interface OperationDAO {
int getActivityCountUpdatedAfter(long timestamp) throws OperationManagementDAOException;
boolean resetAttemptCount(int enrolmentId) throws OperationManagementDAOException;
}

@ -37,6 +37,7 @@ import org.wso2.carbon.device.mgt.core.operation.mgt.dao.util.OperationDAOUtil;
import java.io.*;
import java.sql.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@ -1072,4 +1073,29 @@ public class GenericOperationDAOImpl implements OperationDAO {
}
return operations;
}
@Override
public boolean resetAttemptCount(int enrolmentId) throws OperationManagementDAOException {
boolean status = false;
Connection conn;
PreparedStatement stmt = null;
Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try {
conn = OperationManagementDAOFactory.getConnection();
String query = "UPDATE DM_POLICY_COMPLIANCE_STATUS SET ATTEMPTS = 0, LAST_REQUESTED_TIME = ? " +
"WHERE ENROLMENT_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query);
stmt.setTimestamp(1, currentTimestamp);
stmt.setInt(2, enrolmentId);
stmt.setInt(3, tenantId);
stmt.executeUpdate();
status = true;
} catch (SQLException e) {
throw new OperationManagementDAOException("Unable to reset the attempt count in database.", e);
} finally {
OperationManagementDAOUtil.cleanupResources(stmt, null);
}
return status;
}
}

@ -23,8 +23,8 @@ 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.core.dto.DeviceType;
import java.util.HashMap;
import java.util.Date;
import java.util.List;
@ -34,8 +34,23 @@ import java.util.List;
*/
public interface DeviceManagementProviderService {
/**
* Method to retrieve all the devices of a given device type.
*
* @param deviceType Device-type of the required devices
* @return List of devices of given device-type.
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
* devices.
*/
List<Device> getAllDevices(String deviceType) throws DeviceManagementException;
/**
* Method to retrieve all the devices registered in the system.
*
* @return List of registered devices.
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
* devices.
*/
List<Device> getAllDevices() throws DeviceManagementException;
/**
@ -208,6 +223,8 @@ public interface DeviceManagementProviderService {
Device getDevice(DeviceIdentifier deviceId, Date since) throws DeviceManagementException;
HashMap<Integer, Device> getTenantedDevice(DeviceIdentifier deviceIdentifier) throws DeviceManagementException;
Device getDevice(DeviceIdentifier deviceId, EnrolmentInfo.Status status) throws DeviceManagementException;
List<String> getAvailableDeviceTypes() throws DeviceManagementException;

@ -757,6 +757,30 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
}
}
@Override
public HashMap<Integer, Device> getTenantedDevice(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
HashMap<Integer, Device> deviceHashMap;
try {
DeviceManagementDAOFactory.openConnection();
deviceHashMap = deviceDAO.getDevice(deviceIdentifier);
if (deviceHashMap == null) {
if (log.isDebugEnabled()) {
log.debug("No device is found upon the type '" + deviceIdentifier.getType() + "' and id '" +
deviceIdentifier.getId() + "'");
}
return null;
}
} catch (DeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while obtaining the device for id " +
"'" + deviceIdentifier.getId() + "'", e);
} catch (SQLException e) {
throw new DeviceManagementException("Error occurred while opening a connection to the data source", e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
return deviceHashMap;
}
@Override
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
Device device;

@ -84,29 +84,28 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
@Override
public void addOperations() throws DeviceMgtTaskException {
DeviceManagementProviderService deviceManagementProviderService =
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider();
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance().
getDeviceManagementProvider();
try {
List<Device> devices = deviceManagementProviderService.getAllDevices();
List<String> deviceTypes = deviceManagementProviderService.getAvailableDeviceTypes();
List<Device> devices;
List<String> operations = this.getValidOperationNames();
if (!devices.isEmpty()) {
for (String str : operations) {
CommandOperation operation = new CommandOperation();
operation.setEnabled(true);
operation.setType(Operation.Type.COMMAND);
operation.setCode(str);
//TODO: Fix this properly later adding device type to be passed in when the task manage executes "addOperations()"
String type = null;
if (devices.size() > 0) {
type = devices.get(0).getType();
for (String deviceType : deviceTypes) {
devices = deviceManagementProviderService.getAllDevices(deviceType);
if (!devices.isEmpty()) {
for (String str : operations) {
CommandOperation operation = new CommandOperation();
operation.setEnabled(true);
operation.setType(Operation.Type.COMMAND);
operation.setCode(str);
deviceManagementProviderService.addOperation(deviceType, operation,
DeviceManagerUtil.getValidDeviceIdentifiers(devices));
}
} else {
if (log.isDebugEnabled()) {
log.debug("No devices are available to perform the operations.");
}
deviceManagementProviderService.addOperation(type, operation,
DeviceManagerUtil.convertDevices(devices));
}
} else {
if (log.isDebugEnabled()) {
log.debug("No devices are available to perform the operations.");
}
}
} catch (InvalidDeviceException e) {

@ -184,6 +184,27 @@ public final class DeviceManagerUtil {
return deviceIdentifiers;
}
public static List<DeviceIdentifier> getValidDeviceIdentifiers(List<Device> devices) {
List<DeviceIdentifier> deviceIdentifiers = new ArrayList<>();
for (Device device : devices) {
if (device.getEnrolmentInfo() != null) {
switch (device.getEnrolmentInfo().getStatus()) {
case BLOCKED:
case REMOVED:
case SUSPENDED:
break;
default:
DeviceIdentifier identifier = new DeviceIdentifier();
identifier.setId(device.getDeviceIdentifier());
identifier.setType(device.getType());
deviceIdentifiers.add(identifier);
}
}
}
return deviceIdentifiers;
}
public static String getServerBaseHttpsUrl() {
String hostName = "localhost";
try {

@ -22,7 +22,7 @@
<parent>
<artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -55,8 +55,8 @@
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>

@ -22,7 +22,7 @@
<parent>
<artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -48,27 +48,28 @@ if (!user) {
var deviceType = request.getParameter("deviceType"); // need a better solution here
deviceTypeConfig = utility.getDeviceTypeConfig(deviceType);
if (deviceTypeConfig && deviceTypeConfig.deviceType.downloadAgentUri) {
hearders = [{"name": constants["ACCEPT_IDENTIFIER"], "value": constants["APPLICATION_ZIP"]}];
sketchDownloadEndPoint = devicemgtProps["httpsURL"] + "/" + deviceTypeConfig.deviceType.downloadAgentUri;
serviceInvokers.HttpClient.get(sketchDownloadEndPoint + queryString, function (responsePayload, responseHeaders) {
if (responseHeaders) {
for (var i = 0; i < responseHeaders.length; i++) {
var header = responseHeaders[i]
var headerName = String(header.getName());
var headerValue = String(header.getValue());
response.addHeader(headerName, headerValue);
}
var streamObject = new Stream(responsePayload);
print(streamObject);
} else {
return responsePayload;
}
}, function (responsePayload) {
log.error(responsePayload)
var response = {};
response["status"] = "error";
return response;
}
);
if (responseHeaders) {
for (var i = 0; i < responseHeaders.length; i++) {
var header = responseHeaders[i];
var headerName = String(header.getName());
var headerValue = String(header.getValue());
response.addHeader(headerName, headerValue);
}
var streamObject = new Stream(responsePayload);
print(streamObject);
} else {
return responsePayload;
}
}, function (responsePayload) {
log.error(responsePayload);
var response = {};
response["status"] = "error";
return response;
}
, hearders);
} else {
result = 400;
}
@ -143,14 +144,14 @@ if (!user) {
}
serviceInvokers.XMLHttp.get(
targetURL, function (responsePayload) {
response.status = 200;
result = responsePayload;
},
function (responsePayload) {
response.status = responsePayload.status;
result = responsePayload.responseText;
});
targetURL, function (responsePayload) {
response.status = 200;
result = responsePayload;
},
function (responsePayload) {
response.status = responsePayload.status;
result = responsePayload.responseText;
});
} else if (uriMatcher.match("/{context}/api/devices/")) {
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/list")) {
result = deviceModule.listDevices();

@ -1,5 +1,5 @@
{
"appContext": "/emm/",
"appContext": "/devicemgt/",
"webAgentContext" : "/emm-web-agent/",
"apiContext": "api",
"httpsURL" : "%https.ip%",

@ -20,26 +20,14 @@ var deviceModule;
deviceModule = function () {
var log = new Log("/app/modules/business-controllers/device.js");
var utility = require('/app/modules/utility.js').utility;
var utility = require('/app/modules/utility.js')["utility"];
var constants = require('/app/modules/constants.js');
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
// var ArrayList = Packages.java.util.ArrayList;
// var Properties = Packages.java.util.Properties;
// var DeviceIdentifier = Packages.org.wso2.carbon.device.mgt.common.DeviceIdentifier;
// var DeviceManagerUtil = Packages.org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
// var SimpleOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.SimpleOperation;
// var ConfigOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation;
// var CommandOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
var deviceManagementService = utility.getDeviceManagementService();
var publicMethods = {};
var privateMethods = {};
// var deviceCloudService = devicemgtProps["httpsURL"] + "/common/device_manager";
/**
* Only GET method is implemented for now since there are no other type of methods used this method.
* @param url - URL to call the backend without the host
@ -67,170 +55,9 @@ deviceModule = function () {
};
privateMethods.validateAndReturn = function (value) {
return (value == undefined || value == null) ? constants.UNSPECIFIED : value;
return (value == undefined || value == null) ? constants["UNSPECIFIED"] : value;
};
/*
@Deprecated
*/
// publicMethods.listDevices = function () {
// var carbonUser = session.get(constants.USER_SESSION_KEY);
// var utility = require('/app/modules/utility.js').utility;
// if (!carbonUser) {
// log.error("User object was not found in the session");
// throw constants.ERRORS.USER_NOT_FOUND;
// }
// try {
// utility.startTenantFlow(carbonUser);
// var deviceManagementService = utility.getDeviceManagementService();
// var devices = deviceManagementService.getAllDevices();
// var deviceList = [];
// var i, device, propertiesList, deviceObject;
// for (i = 0; i < devices.size(); i++) {
// device = devices.get(i);
// propertiesList = DeviceManagerUtil.convertDevicePropertiesToMap(device.getProperties());
//
// deviceObject = {};
// deviceObject[constants.DEVICE_IDENTIFIER] =
// privateMethods.validateAndReturn(device.getDeviceIdentifier());
// deviceObject[constants.DEVICE_NAME] =
// privateMethods.validateAndReturn(device.getName());
// deviceObject[constants.DEVICE_OWNERSHIP] =
// privateMethods.validateAndReturn(device.getEnrolmentInfo().getOwnership());
// deviceObject[constants.DEVICE_OWNER] =
// privateMethods.validateAndReturn(device.getEnrolmentInfo().getOwner());
// deviceObject[constants.DEVICE_TYPE] =
// privateMethods.validateAndReturn(device.getType());
// deviceObject[constants.DEVICE_PROPERTIES] = {};
// if (device.getType() == constants.PLATFORM_IOS) {
// deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_MODEL] =
// privateMethods.validateAndReturn(propertiesList.get(constants.DEVICE_PRODUCT));
// deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_VENDOR] = constants.VENDOR_APPLE;
// } else {
// deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_MODEL] =
// privateMethods.validateAndReturn(propertiesList.get(constants.DEVICE_MODEL));
// deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_VENDOR] =
// privateMethods.validateAndReturn(propertiesList.get(constants.DEVICE_VENDOR));
// }
// deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_OS_VERSION] =
// privateMethods.validateAndReturn(propertiesList.get(constants.DEVICE_OS_VERSION));
//
// deviceList.push(deviceObject);
// }
// return deviceList;
// } catch (e) {
// throw e;
// } finally {
// utility.endTenantFlow();
// }
// };
/*
@Deprecated
*/
/*
Get the supported features by the device type
*/
// publicMethods.getFeatures = function (deviceType) {
// var carbonUser = session.get(constants.USER_SESSION_KEY);
// var utility = require('/app/modules/utility.js').utility;
// if (!carbonUser) {
// log.error("User object was not found in the session");
// throw constants.ERRORS.USER_NOT_FOUND;
// }
// try {
// utility.startTenantFlow(carbonUser);
// var deviceManagementService = utility.getDeviceManagementService();
// var features = deviceManagementService.getFeatureManager(deviceType).getFeatures();
// var featuresConverted = {};
// if (features) {
// var i, feature, featureObject;
// for (i = 0; i < features.size(); i++) {
// feature = features.get(i);
// featureObject = {};
// featureObject[constants.FEATURE_NAME] = feature.getName();
// featureObject[constants.FEATURE_DESCRIPTION] = feature.getDescription();
// featuresConverted[feature.getName()] = featureObject;
// }
// }
// return featuresConverted;
// } catch (e) {
// throw e;
// } finally {
// utility.endTenantFlow();
// }
// };
/*
@Deprecated
*/
// publicMethods.performOperation = function (devices, operation) {
// var carbonUser = session.get(constants.USER_SESSION_KEY);
// var utility = require('/app/modules/utility.js').utility;
// if (!carbonUser) {
// log.error("User object was not found in the session");
// throw constants.ERRORS.USER_NOT_FOUND;
// }
// try {
// utility.startTenantFlow(carbonUser);
// var deviceManagementService = utility.getDeviceManagementService();
// var operationInstance;
// if (operation.type == "COMMAND") {
// operationInstance = new CommandOperation();
// } else if (operation.type == "CONFIG") {
// operationInstance = new ConfigOperation();
// } else {
// operationInstance = new SimpleOperation();
// }
// operationInstance.setCode(operation.featureName);
// var props = new Properties();
// var i, object;
// for (i = 0; i < operation.properties.length; i++) {
// object = properties[i];
// props.setProperty(object.key, object.value);
// }
// operationInstance.setProperties(props);
// var deviceList = new ArrayList();
// var j, device, deviceIdentifier;
// for (j = 0; j < devices.length; i++) {
// device = devices[j];
// deviceIdentifier = new DeviceIdentifier();
// deviceIdentifier.setId(device.id);
// deviceIdentifier.setType(device.type);
// deviceList.add(deviceIdentifier);
// }
// deviceManagementService.addOperation(operationInstance, deviceList);
// } catch (e) {
// throw e;
// } finally {
// utility.endTenantFlow();
// }
// };
/*
@Deprecated
*/
// privateMethods.getDevice = function (type, deviceId) {
// var carbonUser = session.get(constants.USER_SESSION_KEY);
// var utility = require('/app/modules/utility.js').utility;
// if (!carbonUser) {
// log.error("User object was not found in the session");
// throw constants.ERRORS.USER_NOT_FOUND;
// }
// try {
// utility.startTenantFlow(carbonUser);
// var deviceManagementService = utility.getDeviceManagementService();
// var deviceIdentifier = new DeviceIdentifier();
// deviceIdentifier.setType(type);
// deviceIdentifier.setId(deviceId);
// return deviceManagementService.getDevice(deviceIdentifier);
// } catch (e) {
// throw e;
// } finally {
// utility.endTenantFlow();
// }
// };
/*
@Updated
*/
@ -243,7 +70,6 @@ deviceModule = function () {
var utility = require('/app/modules/utility.js')["utility"];
try {
utility.startTenantFlow(carbonUser);
//var url = mdmProps["httpsURL"] + "/mdm-admin/devices/view?type=" + deviceType + "&id=" + deviceId;
var url = devicemgtProps["httpsURL"] + "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId;
return serviceInvokers.XMLHttp.get(
url,
@ -271,11 +97,18 @@ deviceModule = function () {
properties[constants["DEVICE_VENDOR"]] = constants["VENDOR_APPLE"];
}
deviceObject[constants["DEVICE_PROPERTIES"]] = properties;
if (device["deviceInfo"]) {
deviceObject[constants["DEVICE_INFO"]] = device["deviceInfo"];
}
response["content"] = deviceObject;
return response;
} else if (backendResponse.status == 401) {
response["status"] = "unauthorized";
return response;
} else if (backendResponse.status == 404) {
response["status"] = "notFound";
return response;
} else {
response["status"] = "error";
return response;
@ -298,10 +131,10 @@ deviceModule = function () {
var url;
if (uiPermissions.LIST_DEVICES) {
url = devicemgtProps["httpsURL"] +
devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices?offset=0&limit=1";
devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices?offset=0&limit=1";
} else if (uiPermissions.LIST_OWN_DEVICES) {
url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
"/devices?offset=0&limit=1&user=" + carbonUser.username;
"/devices?offset=0&limit=1&user=" + carbonUser.username;
} else {
log.error("Access denied for user: " + carbonUser.username);
return -1;
@ -330,8 +163,6 @@ deviceModule = function () {
return response;
};
//Old methods
//TODO: make sure these methods are updated
/*
@Updated
*/

@ -34,6 +34,7 @@ var DEVICE_OS_BUILD_DATE = "osBuildDate";
var DEVICE_PROPERTIES = "properties";
var DEVICE_ENROLLMENT_INFO = "enrolmentInfo";
var DEVICE_STATUS = "status";
var DEVICE_INFO = "deviceInfo";
var FEATURE_NAME = "featureName";
var FEATURE_DESCRIPTION = "featureDescription";

@ -66,11 +66,15 @@ var invokers = function () {
* @param endpoint Backend REST API url.
* @param responseCallback a function to be called with response retrieved.
* @param count a counter which hold the number of recursive execution
* @param headers a list of name value pairs for additional http headers
*/
privateMethods["execute"] = function (httpMethod, requestPayload, endpoint, responseCallback, count) {
privateMethods["execute"] = function (httpMethod, requestPayload, endpoint, responseCallback, count, headers) {
var xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.open(httpMethod, endpoint);
for(var i in headers){
xmlHttpRequest.setRequestHeader(headers[i].name, headers[i].value);
}
xmlHttpRequest.setRequestHeader(constants["CONTENT_TYPE_IDENTIFIER"], constants["APPLICATION_JSON"]);
xmlHttpRequest.setRequestHeader(constants["ACCEPT_IDENTIFIER"], constants["APPLICATION_JSON"]);
@ -82,7 +86,7 @@ var invokers = function () {
});
} else {
xmlHttpRequest.setRequestHeader(constants["AUTHORIZATION_HEADER"],
constants["BEARER_PREFIX"] + accessToken);
constants["BEARER_PREFIX"] + accessToken);
}
}
@ -98,9 +102,9 @@ var invokers = function () {
log.debug("Response payload if any : " + xmlHttpRequest.responseText);
if (xmlHttpRequest.status == 401 && (xmlHttpRequest.responseText == TOKEN_EXPIRED ||
xmlHttpRequest.responseText == TOKEN_INVALID ) && count < 5) {
xmlHttpRequest.responseText == TOKEN_INVALID ) && count < 5) {
tokenUtil.refreshTokenPair();
return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, ++count);
return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, ++count, headers);
} else {
return responseCallback(xmlHttpRequest);
}
@ -113,8 +117,8 @@ var invokers = function () {
* @param endpoint Backend REST API url.
* @param responseCallback a function to be called with response retrieved.
*/
privateMethods["initiateXMLHTTPRequest"] = function (httpMethod, requestPayload, endpoint, responseCallback) {
return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, 0);
privateMethods["initiateXMLHTTPRequest"] = function (httpMethod, requestPayload, endpoint, responseCallback, headers) {
return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, 0, headers);
};
/**
@ -122,9 +126,9 @@ var invokers = function () {
* @param endpoint Backend REST API url.
* @param responseCallback a function to be called with response retrieved.
*/
publicXMLHTTPInvokers["get"] = function (endpoint, responseCallback) {
publicXMLHTTPInvokers["get"] = function (endpoint, responseCallback, headers) {
var requestPayload = null;
return privateMethods.initiateXMLHTTPRequest(constants["HTTP_GET"], requestPayload, endpoint, responseCallback);
return privateMethods.initiateXMLHTTPRequest(constants["HTTP_GET"], requestPayload, endpoint, responseCallback, headers);
};
/**
@ -133,8 +137,8 @@ var invokers = function () {
* @param requestPayload payload/data if exists which is needed to be send.
* @param responseCallback a function to be called with response retrieved.
*/
publicXMLHTTPInvokers["post"] = function (endpoint, requestPayload, responseCallback) {
return privateMethods.initiateXMLHTTPRequest(constants["HTTP_POST"], requestPayload, endpoint, responseCallback);
publicXMLHTTPInvokers["post"] = function (endpoint, requestPayload, responseCallback, headers) {
return privateMethods.initiateXMLHTTPRequest(constants["HTTP_POST"], requestPayload, endpoint, responseCallback, headers);
};
/**
@ -143,8 +147,8 @@ var invokers = function () {
* @param requestPayload payload/data if exists which is needed to be send.
* @param responseCallback a function to be called with response retrieved.
*/
publicXMLHTTPInvokers["put"] = function (endpoint, requestPayload, responseCallback) {
return privateMethods.initiateXMLHTTPRequest(constants["HTTP_PUT"], requestPayload, endpoint, responseCallback);
publicXMLHTTPInvokers["put"] = function (endpoint, requestPayload, responseCallback, headers) {
return privateMethods.initiateXMLHTTPRequest(constants["HTTP_PUT"], requestPayload, endpoint, responseCallback, headers);
};
/**
@ -152,9 +156,9 @@ var invokers = function () {
* @param endpoint Backend REST API url.
* @param responseCallback a function to be called with response retrieved.
*/
publicXMLHTTPInvokers["delete"] = function (endpoint, responseCallback) {
publicXMLHTTPInvokers["delete"] = function (endpoint, responseCallback, headers) {
var requestPayload = null;
return privateMethods.initiateXMLHTTPRequest(constants["HTTP_DELETE"], requestPayload, endpoint, responseCallback);
return privateMethods.initiateXMLHTTPRequest(constants["HTTP_DELETE"], requestPayload, endpoint, responseCallback, headers);
};
/**
@ -239,8 +243,9 @@ var invokers = function () {
* @param payload payload/data which need to be send.
* @param successCallback a function to be called if the respond if successful.
* @param errorCallback a function to be called if en error is reserved.
* @param headers a list of name value pairs for additional http headers.
*/
privateMethods["initiateHTTPClientRequest"] = function (method, url, successCallback, errorCallback, payload) {
privateMethods["initiateHTTPClientRequest"] = function (method, url, successCallback, errorCallback, payload, headers) {
//noinspection JSUnresolvedVariable
var HttpClient = Packages.org.apache.commons.httpclient.HttpClient;
var httpMethodObject;
@ -269,8 +274,16 @@ var invokers = function () {
//noinspection JSUnresolvedFunction
throw new IllegalArgumentException("Invalid HTTP request method: " + method);
}
//noinspection JSUnresolvedVariable
var Header = Packages.org.apache.commons.httpclient.Header;
for(var i in headers){
var header = new Header();
header.setName(headers[i].name);
header.setValue(headers[i].value);
httpMethodObject.addRequestHeader(header);
}
var header = new Header();
header.setName(constants["CONTENT_TYPE_IDENTIFIER"]);
header.setValue(constants["APPLICATION_JSON"]);
@ -295,9 +308,12 @@ var invokers = function () {
}
}
//noinspection JSUnresolvedFunction
var stringRequestEntity = new StringRequestEntity(stringify(payload));
//noinspection JSUnresolvedFunction
httpMethodObject.setRequestEntity(stringRequestEntity);
if (payload != null) {
var StringRequestEntity = Packages.org.apache.commons.httpclient.methods.StringRequestEntity;
var stringRequestEntity = new StringRequestEntity(stringify(payload));
//noinspection JSUnresolvedFunction
httpMethodObject.setRequestEntity(stringRequestEntity);
}
var client = new HttpClient();
try {
//noinspection JSUnresolvedFunction
@ -305,17 +321,22 @@ var invokers = function () {
//noinspection JSUnresolvedFunction
var status = httpMethodObject.getStatusCode();
if (status == 200) {
//noinspection JSUnresolvedFunction
return successCallback(httpMethodObject.getResponseBody());
var responseContentDispositionHeader = httpMethodObject.getResponseHeader(constants["CONTENT_DISPOSITION_IDENTIFIER"]);
if (responseContentDispositionHeader) {
return successCallback(httpMethodObject.getResponseBodyAsStream(), httpMethodObject.getResponseHeaders());
} else {
return successCallback(httpMethodObject.getResponseBody());
}
} else {
//noinspection JSUnresolvedFunction
return errorCallback(httpMethodObject.getResponseBody());
}
} catch (e) {
return errorCallback(response);
} finally {
//noinspection JSUnresolvedFunction
method.releaseConnection();
if (method != constants["HTTP_GET"]) {
method.releaseConnection();
}
}
};
@ -324,11 +345,12 @@ var invokers = function () {
* @param url target url.
* @param successCallback a function to be called if the respond if successful.
* @param errorCallback a function to be called if en error is reserved.
* @param headers a list of name value pairs for additional http headers.
*/
publicHTTPClientInvokers["get"] = function (url, successCallback, errorCallback) {
publicHTTPClientInvokers["get"] = function (url, successCallback, errorCallback, headers) {
var requestPayload = null;
return privateMethods.
initiateHTTPClientRequest(constants["HTTP_GET"], url, successCallback, errorCallback, requestPayload);
initiateHTTPClientRequest(constants["HTTP_GET"], url, successCallback, errorCallback, requestPayload, headers);
};
/**
@ -337,10 +359,11 @@ var invokers = function () {
* @param payload payload/data which need to be send.
* @param successCallback a function to be called if the respond if successful.
* @param errorCallback a function to be called if en error is reserved.
* @param headers a list of name value pairs for additional http headers.
*/
publicHTTPClientInvokers["post"] = function (url, payload, successCallback, errorCallback) {
publicHTTPClientInvokers["post"] = function (url, payload, successCallback, errorCallback, headers) {
return privateMethods.
initiateHTTPClientRequest(constants["HTTP_POST"], url, successCallback, errorCallback, payload);
initiateHTTPClientRequest(constants["HTTP_POST"], url, successCallback, errorCallback, payload, headers);
};
/**
@ -349,10 +372,11 @@ var invokers = function () {
* @param payload payload/data which need to be send.
* @param successCallback a function to be called if the respond if successful.
* @param errorCallback a function to be called if en error is reserved.
* @param headers a list of name value pairs for additional http headers.
*/
publicHTTPClientInvokers["put"] = function (url, payload, successCallback, errorCallback) {
publicHTTPClientInvokers["put"] = function (url, payload, successCallback, errorCallback, headers) {
return privateMethods.
initiateHTTPClientRequest(constants["HTTP_PUT"], url, successCallback, errorCallback, payload);
initiateHTTPClientRequest(constants["HTTP_PUT"], url, successCallback, errorCallback, payload, headers);
};
/**
@ -360,11 +384,12 @@ var invokers = function () {
* @param url target url.
* @param successCallback a function to be called if the respond if successful.
* @param errorCallback a function to be called if en error is reserved.
* @param headers a list of name value pairs for additional http headers.
*/
publicHTTPClientInvokers["delete"] = function (url, successCallback, errorCallback) {
publicHTTPClientInvokers["delete"] = function (url, successCallback, errorCallback, headers) {
var requestPayload = null;
return privateMethods.
initiateHTTPClientRequest(constants["HTTP_DELETE"], url, successCallback, errorCallback, requestPayload);
initiateHTTPClientRequest(constants["HTTP_DELETE"], url, successCallback, errorCallback, requestPayload, headers);
};
var publicMethods = {};

@ -26,25 +26,26 @@
{{/zone}}
{{#zone "content"}}
<div class="wr-content">
<div class="row">
{{#if permissions.VIEW_DASHBOARD}}
<div class="row wr-stats-board">
<div class="col-md-4">
<div class="wr-stats-board-tile">
<div class="tile-name">Devices</div>
<div>
<div class="tile-icon"><i class="fw fw-mobile"></i></div>
<div class="tile-stats">
<span id="device-count">{{device_count}}</span>
<div class="col-md-3 wr-stats-board">
<div class="wr-stats-board-tile">
<div class="tile-name">Devices</div>
<div>
<div class="tile-icon"><i class="fw fw-mobile"></i></div>
<div class="tile-stats">
<span id="device-count">{{deviceCount}}</span>
<span class="tile-stats-free">
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/devices">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-view fw-stack-1x"></i>
</span>
View
</a>
{{#if deviceCount}}
<a href="{{@app.context}}/devices">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-view fw-stack-1x"></i>
</span>
View
</a>
{{/if}}
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/device/enroll">
<span class="fw-stack">
@ -54,20 +55,19 @@
Add
</a>
</span>
</div>
</div>
</div>
</div>
</div>
<div class="row wr-stats-board">
<div class="col-md-4">
<div class="wr-stats-board-tile">
<div class="tile-name">Groups</div>
<div>
<div class="tile-icon"><i class="fw fw-grouping"></i></div>
<div class="tile-stats">
<span id="group-count">{{group_count}}</span>
<div class="col-md-3 wr-stats-board">
<div class="wr-stats-board-tile">
<div class="tile-name">Groups</div>
<div>
<div class="tile-icon"><i class="fw fw-grouping"></i></div>
<div class="tile-stats">
<span id="group-count">{{groupCount}}</span>
<span class="tile-stats-free">
{{#if groupCount}}
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/groups">
<span class="fw-stack">
@ -76,6 +76,7 @@
</span>
View
</a>
{{/if}}
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/group/add">
<span class="fw-stack">
@ -85,20 +86,19 @@
Add
</a>
</span>
</div>
</div>
</div>
</div>
</div>
<div class="row wr-stats-board">
<div class="col-md-4">
<div class="wr-stats-board-tile">
<div class="tile-name">Users</div>
<div>
<div class="tile-icon"><i class="fw fw-user"></i></div>
<div class="tile-stats">
<span id="user-count">{{user_count}}</span>
<div class="col-md-3 wr-stats-board">
<div class="wr-stats-board-tile">
<div class="tile-name">Users</div>
<div>
<div class="tile-icon"><i class="fw fw-user"></i></div>
<div class="tile-stats">
<span id="user-count">{{userCount}}</span>
<span class="tile-stats-free">
{{#if userCount}}
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/users">
<span class="fw-stack">
@ -107,6 +107,7 @@
</span>
View
</a>
{{/if}}
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/user/add">
<span class="fw-stack">
@ -116,20 +117,19 @@
Add
</a>
</span>
</div>
</div>
</div>
</div>
</div>
<div class="row wr-stats-board">
<div class="col-md-4">
<div class="wr-stats-board-tile">
<div class="tile-name">Policies</div>
<div>
<div class="tile-icon"><i class="fw fw-policy"></i></div>
<div class="tile-stats">
<span id="policy-count">{{policy_count}}</span>
<div class="col-md-3 wr-stats-board">
<div class="wr-stats-board-tile">
<div class="tile-name">Policies</div>
<div>
<div class="tile-icon"><i class="fw fw-policy"></i></div>
<div class="tile-stats">
<span id="policy-count">{{policyCount}}</span>
<span class="tile-stats-free">
{{#if policyCount}}
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/policies">
<span class="fw-stack">
@ -138,6 +138,7 @@
</span>
View
</a>
{{/if}}
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/policy/add">
<span class="fw-stack">
@ -147,20 +148,19 @@
Add
</a>
</span>
</div>
</div>
</div>
</div>
</div>
<div class="row wr-stats-board">
<div class="col-md-4">
<div class="wr-stats-board-tile">
<div class="tile-name">Roles</div>
<div>
<div class="tile-icon"><i class="fw fw-bookmark"></i></div>
<div class="tile-stats">
<span id="role-count">{{role_count}}</span>
<div class="col-md-3 wr-stats-board">
<div class="wr-stats-board-tile">
<div class="tile-name">Roles</div>
<div>
<div class="tile-icon"><i class="fw fw-bookmark"></i></div>
<div class="tile-stats">
<span id="role-count">{{roleCount}}</span>
<span class="tile-stats-free">
{{#if roleCount}}
<!--suppress HtmlUnknownTarget -->
<a id="device-count-view-btn" href="{{@app.context}}/roles">
<span class="fw-stack">
@ -169,6 +169,7 @@
</span>
View
</a>
{{/if}}
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/roles/add-role">
<span class="fw-stack">
@ -178,32 +179,14 @@
Add
</a>
</span>
</div>
</div>
</div>
</div>
</div>
{{else}}
Permission denied
<h1 class="page-sub-title">
Permitted None
</h1>
{{/if}}
</div>
<div id="qr-code-modal" data-enrollment-url="{{enrollmentURL}}" class="hidden">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
Scan QR code to start enrollment
</h3>
<h4>
Please scan the QR code using your mobile device to retrieve enrollment URL.
</h4>
<div class="panel panel-default">
<div class="panel-body col-centered ">
<div class="qr-code"></div>
</div>
</div>
</div>
</div>
</div>
</div>
{{/zone}}

@ -32,16 +32,16 @@ function onRequest() {
return;
}
var page = {};
page.permissions = permissions;
page.enrollmentURL = devicemgtProps.enrollmentURL;
page.device_count = deviceModule.getDevicesCount();
var viewModel = {};
viewModel.permissions = permissions;
viewModel.enrollmentURL = devicemgtProps.enrollmentURL;
viewModel.deviceCount = deviceModule.getDevicesCount();
//TODO: Enable Group Management Service API on CDMF
//page.group_count = groupModule.getGroupCount();
page.group_count = -1;
page.user_count = userModule.getUsersCount();
page.policy_count = policyModule.getPoliciesCount();
page.role_count = userModule.getRolesCount();
viewModel.groupCount = -1;
viewModel.userCount = userModule.getUsersCount();
viewModel.policyCount = policyModule.getPoliciesCount();
viewModel.roleCount = userModule.getRolesCount();
return page;
return viewModel;
}

@ -24,22 +24,22 @@ function onRequest(context) {
var groupName = request.getParameter("groupName");
var groupOwner = request.getParameter("groupOwner");
var page = {};
var viewModel = {};
var title = "Devices";
if (groupName) {
title = groupName + " " + title;
page.groupName = groupName;
viewModel.groupName = groupName;
}
page.title = title;
viewModel.title = title;
var currentUser = session.get(constants.USER_SESSION_KEY);
if (currentUser) {
page.permissions = {};
viewModel.permissions = {};
var uiPermissions = userModule.getUIPermissions();
page.permissions.list = stringify(uiPermissions);
viewModel.permissions.list = stringify(uiPermissions);
if (uiPermissions.ADD_DEVICE) {
page.permissions.enroll = true;
viewModel.permissions.enroll = true;
}
page.currentUser = currentUser;
viewModel.currentUser = currentUser;
var deviceCount = 0;
if (groupName && groupOwner) {
var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"];
@ -48,30 +48,30 @@ function onRequest(context) {
deviceCount = deviceModule.getDevicesCount();
}
if (deviceCount > 0) {
page.deviceCount = deviceCount;
viewModel.deviceCount = deviceCount;
var utility = require("/app/modules/utility.js").utility;
var typesListResponse = deviceModule.getDeviceTypes();
var deviceTypes = [];
if (typesListResponse["status"] == "success") {
var data = typesListResponse["content"];
var data = typesListResponse.content.deviceTypes;
if (data) {
for (var i = 0; i < data.length; i++) {
var config = utility.getDeviceTypeConfig(data[i].name);
var config = utility.getDeviceTypeConfig(data[i]);
if (!config) {
continue;
}
var deviceType = config.deviceType;
deviceTypes.push({
"type": data[i].name,
"category": deviceType.category,
"label": deviceType.label,
"thumb": utility.getDeviceThumb(data[i].name)
});
"type": data[i],
"category": deviceType.category,
"label": deviceType.label,
"thumb": utility.getDeviceThumb(data[i])
});
}
}
}
page.deviceTypes = stringify(deviceTypes);
viewModel.deviceTypes = stringify(deviceTypes);
}
}
return page;
return viewModel;
}

@ -37,6 +37,10 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
if (InitiateViewOption) {
$(".viewEnabledIcon").bind("click", InitiateViewOption);
}
var deviceType;
var ownership;
//--- End of EMM related codes
$(elem).DataTable(
@ -108,14 +112,32 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
.draw();
if (filterColumn.eq(column.index()).hasClass('data-platform')) {
if (!val) {
deviceType = val;
if (!deviceType || !ownership) {
$("#operation-bar").addClass("hidden");
$("#operation-guide").removeClass("hidden");
} else {
$("#operation-guide").addClass("hidden");
$("#operation-bar").removeClass("hidden");
//noinspection JSUnresolvedFunction
loadOperationBar(val);
if (deviceType && ownership) {
loadOperationBar(deviceType, ownership);
}
}
}
if (filterColumn.eq(column.index()).hasClass('data-ownership')) {
ownership = val;
if (!deviceType || !ownership) {
$("#operation-bar").addClass("hidden");
$("#operation-guide").removeClass("hidden");
} else {
$("#operation-guide").addClass("hidden");
$("#operation-bar").removeClass("hidden");
//noinspection JSUnresolvedFunction
if (deviceType && ownership) {
loadOperationBar(deviceType, ownership);
}
}
}
});

@ -107,7 +107,6 @@ var operationModule = function () {
"NOTIFICATION_OPERATION_CODE": "NOTIFICATION",
"CALENDAR_SUBSCRIPTION_OPERATION_CODE": "CALENDAR_SUBSCRIPTION",
"APN_OPERATION_CODE": "APN",
"DOMAIN_CODE": "DOMAIN",
"CELLULAR_OPERATION_CODE": "CELLULAR",
"PER_APP_VPN_OPERATION_CODE": "PER_APP_VPN",
"APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE": "APP_TO_PER_APP_VPN_MAPPING"
@ -116,20 +115,10 @@ var operationModule = function () {
publicMethods.getIOSServiceEndpoint = function (operationCode) {
var featureMap = {
"DEVICE_LOCK": "lock",
"VPN": "vpn",
"PER_APP_VPN": "per-app-vpn",
"APP_TO_PER_APP_VPN_MAPPING": "app-to-per-app-vpn-mapping",
"RING": "ring",
"LOCATION": "location",
"ENTERPRISE_WIPE": "enterprise-wipe",
"NOTIFICATION": "notification",
"AIR_PLAY": "airplay",
"RESTRICTION": "restriction",
"CELLULAR": "cellular",
"WIFI": "wifi",
"INSTALL_STORE_APPLICATION": "store-application",
"INSTALL_ENTERPRISE_APPLICATION": "enterprise-application",
"REMOVE_APPLICATION": "remove-application",
"ENTERPRISE_WIPE": "enterprise-wipe"
"RING": "ring"
};
return "/api/device-mgt/ios/v1.0/admin/devices/" + featureMap[operationCode];
};
@ -851,6 +840,24 @@ var operationModule = function () {
"restrictedApplications": operationPayload["restricted-applications"]
};
break;
case androidOperationConstants["SYSTEM_UPDATE_POLICY_CODE"]:
if (operationPayload["type"] != "window") {
payload = {
"cosuSystemUpdatePolicyType": operationPayload["type"]
};
} else {
payload = {
"cosuSystemUpdatePolicyType": operationPayload["type"],
"cosuSystemUpdatePolicyWindowStartTime": operationPayload["startTime"],
"cosuSystemUpdatePolicyWindowEndTime": operationPayload["endTime"]
};
}
break;
case androidOperationConstants["KIOSK_APPS_CODE"]:
payload = {
"cosuWhitelistedApplications": operationPayload["whitelistedApplications"]
};
break;
}
return payload;
};
@ -1187,12 +1194,13 @@ var operationModule = function () {
publicMethods.getWindowsServiceEndpoint = function (operationCode) {
var featureMap = {
"DEVICE_LOCK": "lock-devices",
"DISENROLL": "disenroll",
"DEVICE_RING": "ring-devices",
"LOCK_RESET": "lock-reset-devices",
"WIPE_DATA": "wipe-devices"
};
//return "/mdm-windows-agent/services/windows/operation/" + featureMap[operationCode];
return "/api/device-mgt/windows/v1.0/admin/devices/" + featureMap[operationCode];
return "/api/device-mgt/windows/v1.0/services/windows/admin/devices/" + featureMap[operationCode];
};
/**
* Get the icon for the featureCode
@ -1203,16 +1211,16 @@ var operationModule = function () {
var featureMap = {
"DEVICE_LOCK": "fw-lock",
"DEVICE_LOCATION": "fw-map-location",
"CLEAR_PASSWORD": "fw-key",
"ENTERPRISE_WIPE": "fw-clear",
"WIPE_DATA": "fw-database",
"CLEAR_PASSWORD": "fw-clear",
"ENTERPRISE_WIPE": "fw-block",
"WIPE_DATA": "fw-delete",
"DEVICE_RING": "fw-dial-up",
"DEVICE_REBOOT": "fw-refresh",
"UPGRADE_FIRMWARE": "fw-up-arrow",
"UPGRADE_FIRMWARE": "fw-hardware",
"DEVICE_MUTE": "fw-mute",
"NOTIFICATION": "fw-message",
"CHANGE_LOCK_CODE": "fw-security",
"DEVICE_UNLOCK": "fw-lock"
"DEVICE_UNLOCK": "fw-key"
};
return featureMap[operationCode];
};
@ -1226,8 +1234,9 @@ var operationModule = function () {
var featureMap = {
"DEVICE_LOCK": "fw-lock",
"DEVICE_RING": "fw-dial-up",
"DISENROLL": "fw-export",
"LOCK_RESET": "fw-key",
"WIPE_DATA": "fw-clear"
"WIPE_DATA": "fw-delete"
};
return featureMap[operationCode];
};
@ -1241,7 +1250,7 @@ var operationModule = function () {
var featureMap = {
"DEVICE_LOCK": "fw-lock",
"LOCATION": "fw-map-location",
"ENTERPRISE_WIPE": "fw-clear",
"ENTERPRISE_WIPE": "fw-block",
"NOTIFICATION": "fw-message",
"RING": "fw-dial-up"
};
@ -1576,7 +1585,7 @@ var operationModule = function () {
var operationCode = operationCodes[i];
var payload = publicMethods.generatePayload(platformType, operationCode, null);
if(platformType == platformTypeConstants["ANDROID"] &&
if (platformType == platformTypeConstants["ANDROID"] &&
operationCodes[i] == androidOperationConstants["CAMERA_OPERATION_CODE"]){
var operations = payload["operation"];
for (var key in operations){

@ -27,12 +27,12 @@ function onRequest(context) {
var utility = require("/app/modules/utility.js").utility;
var typesListResponse = deviceModule.getDeviceTypes();
if (typesListResponse["status"] == "success") {
var deviceTypes = typesListResponse["content"];
var deviceTypes = typesListResponse.content.deviceTypes;
if (deviceTypes) {
var deviceTypesList = [], virtualDeviceTypesList = [];
for (var i = 0; i < deviceTypes.length; i++) {
var deviceTypeLabel = deviceTypes[i].name;
var deviceType = deviceTypes[i];
var deviceTypeLabel = deviceType;
var configs = utility.getDeviceTypeConfig(deviceTypeLabel);
var deviceCategory = "device";
if (configs) {
@ -45,22 +45,20 @@ function onRequest(context) {
}
if (deviceCategory == 'virtual') {
virtualDeviceTypesList.push({
"hasCustTemplate": false,
"deviceTypeLabel": deviceTypeLabel,
"deviceTypeName": deviceTypes[i].name,
"deviceCategory": deviceCategory,
"deviceTypeId": deviceTypes[i].id,
"thumb": utility.getDeviceThumb(deviceTypes[i].name)
});
"hasCustTemplate": false,
"deviceTypeLabel": deviceTypeLabel,
"deviceTypeName": deviceType,
"deviceCategory": deviceCategory,
"thumb": utility.getDeviceThumb(deviceType)
});
} else {
deviceTypesList.push({
"hasCustTemplate": false,
"deviceTypeLabel": deviceTypeLabel,
"deviceTypeName": deviceTypes[i].name,
"deviceCategory": deviceCategory,
"deviceTypeId": deviceTypes[i].id,
"thumb": utility.getDeviceThumb(deviceTypes[i].name)
});
"hasCustTemplate": false,
"deviceTypeLabel": deviceTypeLabel,
"deviceTypeName": deviceType,
"deviceCategory": deviceCategory,
"thumb": utility.getDeviceThumb(deviceType)
});
}
}
if (virtualDeviceTypesList.length > 0) {

@ -1,3 +1,21 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Checks if provided input is valid against RegEx input.
*
@ -21,34 +39,33 @@ $(document).ready(function () {
showPopup();
$("a#change-password-yes-link").click(function () {
var oldPassword = $("#old-password").val();
var currentPassword = $("#current-password").val();
var newPassword = $("#new-password").val();
var confirmedPassword = $("#confirmed-password").val();
var retypedNewPassword = $("#retyped-new-password").val();
var user = $("#user").val();
var errorMsgWrapper = "#notification-error-msg";
var errorMsg = "#notification-error-msg span";
if (!oldPassword) {
$(errorMsg).text("Old password is a required field. It cannot be empty.");
var errorMsgWrapper = "#change-password-error-msg";
var errorMsg = "#change-password-error-msg span";
if (!currentPassword) {
$(errorMsg).text("Typing your current password is required. It cannot be empty.");
$(errorMsgWrapper).removeClass("hidden");
} else if (!newPassword) {
$(errorMsg).text("New password is a required field. It cannot be empty.");
$(errorMsg).text("Typing your new password is required. It cannot be empty.");
$(errorMsgWrapper).removeClass("hidden");
} else if (!confirmedPassword) {
$(errorMsg).text("Retyping the new password is required.");
} else if (!retypedNewPassword) {
$(errorMsg).text("Confirming your new password is required. It cannot be empty.");
$(errorMsgWrapper).removeClass("hidden");
} else if (confirmedPassword != newPassword) {
$(errorMsg).text("New password doesn't match the confirmation.");
} else if (retypedNewPassword != newPassword) {
$(errorMsg).text("Password confirmation failed. Please check.");
$(errorMsgWrapper).removeClass("hidden");
} else if (!inputIsValid(/^[\S]{5,30}$/, confirmedPassword)) {
$(errorMsg).text("Password should be minimum 5 characters long, should not include any whitespaces.");
} else if (!inputIsValid(/^[\S]{5,30}$/, newPassword)) {
$(errorMsg).text("Password should be minimum 5 characters long and " +
"should not include any whitespaces. Please check.");
$(errorMsgWrapper).removeClass("hidden");
} else {
var changePasswordFormData = {};
//changePasswordFormData.username = user;
changePasswordFormData.newPassword = unescape((confirmedPassword));
changePasswordFormData.oldPassword = unescape((oldPassword));
changePasswordFormData["oldPassword"] = unescape((currentPassword));
changePasswordFormData["newPassword"] = unescape((newPassword));
var changePasswordAPI = "/api/device-mgt/v1.0/users/" + user + "/credentials";
@ -64,7 +81,7 @@ $(document).ready(function () {
}
}, function (jqXHR) {
if (jqXHR.status == 400) {
$(errorMsg).text("Old password does not match with the provided value.");
$(errorMsg).text("Your current password does not match with the provided value.");
$(errorMsgWrapper).removeClass("hidden");
} else {
$(errorMsg).text("An unexpected error occurred. Please try again later.");

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

@ -1,3 +1,21 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function onRequest() {
var constants = require("/app/modules/constants.js");
return session.get(constants["USER_SESSION_KEY"]);

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

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

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>email-sender</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -57,16 +57,17 @@
org.osgi.service.component,
org.apache.commons.logging,
javax.xml.*,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
org.wso2.carbon.context,
org.wso2.carbon.utils.*,
org.wso2.carbon.registry.api,
org.w3c.dom,
org.apache.velocity,
org.apache.velocity.app,
org.apache.velocity.context,
org.apache.velocity.exception,
org.apache.velocity.runtime.resource,
org.apache.velocity.runtime.resource.loader,
org.apache.velocity;version="${velocity.version}",
org.apache.velocity.app;version="${velocity.version}",
org.apache.velocity.context;version="${velocity.version}",
org.apache.velocity.exception;version="${velocity.version}",
org.apache.velocity.runtime.resource;version="${velocity.version}",
org.apache.velocity.runtime.resource.loader;version="${velocity.version}",
org.apache.commons.io,
org.apache.axis2.transport.mail,
org.wso2.carbon.registry.core.service,
@ -129,7 +130,7 @@
<artifactId>axis2</artifactId>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<groupId>org.wso2.orbit.org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
</dependency>
<dependency>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

@ -21,14 +21,14 @@
<parent>
<artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.mdm</groupId>
<artifactId>dynamic-client-web-proxy</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<name>WSO2 Carbon - Proxy endpoint of Dynamic Client Registration Web Service</name>
<description>WSO2 Carbon - Dynamic Client Registration Web Proxy</description>
<packaging>war</packaging>
@ -55,16 +55,16 @@
<artifactId>org.wso2.carbon.utils</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<!--dependency>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom-impl</artifactId>
<scope>provided</scope>
</dependency>
</dependency-->
<dependency>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom</artifactId>

@ -21,14 +21,14 @@
<parent>
<artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.mdm</groupId>
<artifactId>dynamic-client-web</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<name>WSO2 Carbon - Dynamic Client Registration Web Service</name>
<description>WSO2 Carbon - Dynamic Client Registration Web</description>
<packaging>war</packaging>
@ -60,16 +60,16 @@
</build>
<dependencies>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<!--dependency>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom-impl</artifactId>
<scope>provided</scope>
</dependency>
</dependency-->
<dependency>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom</artifactId>

@ -21,13 +21,13 @@
<parent>
<artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.dynamic.client.registration</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Dynamic client registration service</name>
<description>WSO2 Carbon - Dynamic Client Registration Service</description>

@ -21,13 +21,13 @@
<parent>
<artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.dynamic.client.web.app.registration</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Dynamic client web app registration</name>
<description>WSO2 Carbon - Dynamic Client Web-app Registration Service</description>

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>dynamic-client-registration</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - Dynamic client registration</name>
<url>http://wso2.org</url>

@ -22,13 +22,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.oauth.extensions</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - OAuth Extensions</name>
<url>http://wso2.org</url>
@ -125,7 +125,7 @@
org.wso2.carbon.device.mgt.core.*,
javax.xml.bind,
javax.xml.bind.annotation,
javax.xml.parsers,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
org.w3c.dom,
org.wso2.carbon.apimgt.keymgt,
org.wso2.carbon.apimgt.keymgt.handlers,
@ -133,7 +133,7 @@
org.apache.commons.codec.binary,
org.wso2.carbon.identity.application.authentication.framework.model,
org.apache.oltu.oauth2.common,
org.wso2.carbon.base
org.wso2.carbon.base,
</Import-Package>
</instructions>
</configuration>

@ -96,7 +96,7 @@ public class OAuthExtensionServiceComponent {
List<String> whiteList;
// Read scope whitelist from Configuration.
whiteList = configuration.getProperty(APIConstants.API_KEY_MANGER_SCOPE_WHITELIST);
whiteList = configuration.getProperty(APIConstants.WHITELISTED_SCOPES);
// If whitelist is null, default scopes will be put.
if (whiteList == null) {

@ -21,7 +21,7 @@
<parent>
<artifactId>identity-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -51,8 +51,8 @@
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
@ -175,4 +175,4 @@
</plugins>
</build>
</project>
</project>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.complex.policy.decision.point</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Decision Point</name>
<description>WSO2 Carbon - Policy Decision Point</description>

@ -3,7 +3,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -11,7 +11,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.information.point</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Information Point</name>
<description>WSO2 Carbon - Policy Information Point</description>

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Management Common</name>
<description>WSO2 Carbon - Policy Management Common</description>

@ -32,6 +32,8 @@ public interface ComplianceDecisionPoint {
void setDevicesAsUnreachable(List<DeviceIdentifier> deviceIdentifiers) throws PolicyComplianceException;
void setDevicesAsInactive(List<DeviceIdentifier> deviceIdentifiers) throws PolicyComplianceException;
void setDevicesAsUnreachableWith(List<Device> devices) throws PolicyComplianceException;
void setDeviceAsReachable(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException;

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Management Core</name>
<description>WSO2 Carbon - Policy Management Core</description>
@ -61,6 +61,7 @@
javax.cache,
javax.naming,
javax.xml.*,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
org.w3c.dom,
org.wso2.carbon.policy.mgt.common.*,
org.wso2.carbon.user.core.*,

@ -54,6 +54,8 @@ public class PolicyManagerServiceImpl implements PolicyManagerService {
policyAdministratorPoint = new PolicyAdministratorPointImpl();
monitoringManager = new MonitoringManagerImpl();
policyManager = new PolicyManagerImpl();
PolicyManagementDataHolder.getInstance().setMonitoringManager(monitoringManager);
PolicyManagementDataHolder.getInstance().setPolicyManager(policyManager);
}
@Override
@ -202,4 +204,4 @@ public class PolicyManagerServiceImpl implements PolicyManagerService {
public boolean isCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException {
return monitoringManager.isCompliance(deviceIdentifier);
}
}
}

@ -60,9 +60,8 @@ public interface MonitoringDAO {
void deleteNoneComplianceData(int policyComplianceStatusId) throws MonitoringDAOException;
void updateAttempts(int deviceId, boolean reset) throws MonitoringDAOException;
boolean updateAttempts(int deviceId, boolean reset) throws MonitoringDAOException;
void updateAttempts(List<Integer> deviceId, boolean reset) throws MonitoringDAOException;
}
}

@ -400,7 +400,8 @@ public class MonitoringDAOImpl implements MonitoringDAO {
}
@Override
public void updateAttempts(int deviceId, boolean reset) throws MonitoringDAOException {
public boolean updateAttempts(int deviceId, boolean reset) throws MonitoringDAOException {
boolean status = false;
Connection conn;
PreparedStatement stmt = null;
Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
@ -420,11 +421,13 @@ public class MonitoringDAOImpl implements MonitoringDAO {
stmt.setInt(2, deviceId);
stmt.setInt(3, tenantId);
stmt.executeUpdate();
status = true;
} catch (SQLException e) {
throw new MonitoringDAOException("Unable to update the attempts data in database.", e);
} finally {
PolicyManagementDAOUtil.cleanupResources(stmt, null);
}
return status;
}
@Override

@ -66,6 +66,22 @@ public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint {
}
@Override
public void setDevicesAsInactive(List<DeviceIdentifier> deviceIdentifiers) throws PolicyComplianceException {
try {
DeviceManagementProviderService service = this.getDeviceManagementProviderService();
for (DeviceIdentifier deviceIdentifier : deviceIdentifiers) {
Device device = service.getDevice(deviceIdentifier);
service.setStatus(deviceIdentifier, device.getEnrolmentInfo().getOwner(),
EnrolmentInfo.Status.INACTIVE);
}
} catch (DeviceManagementException e) {
String msg = "Error occurred while setting the device as inactive";
log.error(msg, e);
throw new PolicyComplianceException(msg, e);
}
}
@Override
public void setDevicesAsUnreachableWith(List<Device> devices) throws PolicyComplianceException {
try {

@ -23,6 +23,8 @@ import org.wso2.carbon.ntask.core.service.TaskService;
import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint;
import org.wso2.carbon.policy.mgt.common.PolicyInformationPoint;
import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService;
import org.wso2.carbon.policy.mgt.core.mgt.MonitoringManager;
import org.wso2.carbon.policy.mgt.core.mgt.PolicyManager;
import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.user.core.tenant.TenantManager;
@ -36,6 +38,8 @@ public class PolicyManagementDataHolder {
private PolicyEvaluationPoint policyEvaluationPoint;
private PolicyInformationPoint policyInformationPoint;
private DeviceManagementProviderService deviceManagementService;
private MonitoringManager monitoringManager;
private PolicyManager policyManager;
private Map<String, PolicyMonitoringService> policyMonitoringServiceMap = new HashMap<>();
private TaskService taskService;
@ -47,6 +51,22 @@ public class PolicyManagementDataHolder {
return thisInstance;
}
public PolicyManager getPolicyManager() {
return policyManager;
}
public void setPolicyManager(PolicyManager policyManager) {
this.policyManager = policyManager;
}
public MonitoringManager getMonitoringManager() {
return monitoringManager;
}
public void setMonitoringManager(MonitoringManager monitoringManager) {
this.monitoringManager = monitoringManager;
}
public RealmService getRealmService() {
return realmService;
}

@ -21,7 +21,6 @@ package org.wso2.carbon.policy.mgt.core.mgt;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
@ -40,6 +39,6 @@ public interface MonitoringManager {
void addMonitoringOperation(List<Device> devices) throws PolicyComplianceException;
List<DeviceType> getDeviceTypes() throws PolicyComplianceException;
List<String> getDeviceTypes() throws PolicyComplianceException;
}

@ -16,12 +16,10 @@
* under the License.
*/
package org.wso2.carbon.policy.mgt.core.mgt.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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.DeviceManagementException;
@ -30,12 +28,8 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
import org.wso2.carbon.policy.mgt.common.Policy;
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
import org.wso2.carbon.policy.mgt.common.ProfileFeature;
@ -56,8 +50,6 @@ import java.util.Map;
public class MonitoringManagerImpl implements MonitoringManager {
private PolicyDAO policyDAO;
// private DeviceDAO deviceDAO;
private DeviceTypeDAO deviceTypeDAO;
private MonitoringDAO monitoringDAO;
private ComplianceDecisionPoint complianceDecisionPoint;
private PolicyConfiguration policyConfiguration;
@ -69,8 +61,6 @@ public class MonitoringManagerImpl implements MonitoringManager {
public MonitoringManagerImpl() {
this.policyDAO = PolicyManagementDAOFactory.getPolicyDAO();
// this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
this.monitoringDAO = PolicyManagementDAOFactory.getMonitoringDAO();
this.complianceDecisionPoint = new ComplianceDecisionPointImpl();
this.policyConfiguration =
@ -84,8 +74,9 @@ public class MonitoringManagerImpl implements MonitoringManager {
List<ComplianceFeature> complianceFeatures = new ArrayList<>();
try {
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
PolicyManager manager = new PolicyManagerImpl();
DeviceManagementProviderService service =
PolicyManagementDataHolder.getInstance().getDeviceManagementService();
PolicyManager manager = PolicyManagementDataHolder.getInstance().getPolicyManager();
Device device = service.getDevice(deviceIdentifier);
Policy policy = manager.getAppliedPolicyToDevice(deviceIdentifier);
if (policy != null) {
@ -99,7 +90,7 @@ public class MonitoringManagerImpl implements MonitoringManager {
PolicyManagementDAOFactory.openConnection();
ComplianceData cmd = monitoringDAO.getCompliance(device.getId(), device.getEnrolmentInfo().getId());
complianceData = monitoringService.checkPolicyCompliance(deviceIdentifier,
policy, deviceResponse);
policy, deviceResponse);
complianceData.setId(cmd.getId());
complianceData.setPolicy(policy);
@ -109,8 +100,9 @@ public class MonitoringManagerImpl implements MonitoringManager {
} catch (SQLException e) {
throw new PolicyComplianceException("Error occurred while opening a data source connection", e);
} catch (MonitoringDAOException e) {
throw new PolicyComplianceException("Unable to add the none compliance features to database for device " +
deviceIdentifier.getId() + " - " + deviceIdentifier.getType(), e);
throw new PolicyComplianceException(
"Unable to add the none compliance features to database for device " +
deviceIdentifier.getId() + " - " + deviceIdentifier.getType(), e);
} finally {
PolicyManagementDAOFactory.closeConnection();
}
@ -121,19 +113,20 @@ public class MonitoringManagerImpl implements MonitoringManager {
try {
PolicyManagementDAOFactory.beginTransaction();
monitoringDAO.setDeviceAsNoneCompliance(device.getId(), device.getEnrolmentInfo().getId(),
policy.getId());
policy.getId());
if (log.isDebugEnabled()) {
log.debug("Compliance status primary key " + complianceData.getId());
}
monitoringDAO.deleteNoneComplianceData(complianceData.getId());
monitoringDAO.addNonComplianceFeatures(complianceData.getId(), device.getId(),
complianceFeatures);
complianceFeatures);
PolicyManagementDAOFactory.commitTransaction();
} catch (MonitoringDAOException e) {
PolicyManagementDAOFactory.rollbackTransaction();
throw new PolicyComplianceException("Unable to add the none compliance features to database for device " +
deviceIdentifier.getId() + " - " + deviceIdentifier.getType(), e);
throw new PolicyComplianceException(
"Unable to add the none compliance features to database for device " +
deviceIdentifier.getId() + " - " + deviceIdentifier.getType(), e);
} finally {
PolicyManagementDAOFactory.closeConnection();
}
@ -155,8 +148,9 @@ public class MonitoringManagerImpl implements MonitoringManager {
PolicyManagementDAOFactory.commitTransaction();
} catch (MonitoringDAOException e) {
PolicyManagementDAOFactory.rollbackTransaction();
throw new PolicyComplianceException("Unable to remove the none compliance features from database for device " +
deviceIdentifier.getId() + " - " + deviceIdentifier.getType(), e);
throw new PolicyComplianceException(
"Unable to remove the none compliance features from database for device " +
deviceIdentifier.getId() + " - " + deviceIdentifier.getType(), e);
} finally {
PolicyManagementDAOFactory.closeConnection();
}
@ -168,10 +162,10 @@ public class MonitoringManagerImpl implements MonitoringManager {
}
} catch (DeviceManagementException e) {
throw new PolicyComplianceException("Unable tor retrieve device data from DB for " +
deviceIdentifier.getId() + " - " + deviceIdentifier.getType(), e);
deviceIdentifier.getId() + " - " + deviceIdentifier.getType(), e);
} catch (PolicyManagerDAOException | PolicyManagementException e) {
throw new PolicyComplianceException("Unable tor retrieve policy data from DB for device " +
deviceIdentifier.getId() + " - " + deviceIdentifier.getType(), e);
deviceIdentifier.getId() + " - " + deviceIdentifier.getType(), e);
}
return complianceFeatures;
}
@ -179,21 +173,22 @@ public class MonitoringManagerImpl implements MonitoringManager {
@Override
public boolean isCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException {
try {
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
DeviceManagementProviderService service =
PolicyManagementDataHolder.getInstance().getDeviceManagementService();
Device device = service.getDevice(deviceIdentifier);
PolicyManagementDAOFactory.openConnection();
ComplianceData complianceData = monitoringDAO.getCompliance(device.getId(), device.getEnrolmentInfo()
.getId());
.getId());
if (complianceData == null || !complianceData.isStatus()) {
return false;
}
} catch (DeviceManagementException e) {
throw new PolicyComplianceException("Unable to retrieve device data for " + deviceIdentifier.getId() +
" - " + deviceIdentifier.getType(), e);
" - " + deviceIdentifier.getType(), e);
} catch (MonitoringDAOException e) {
throw new PolicyComplianceException("Unable to retrieve compliance status for " + deviceIdentifier.getId() +
" - " + deviceIdentifier.getType(), e);
" - " + deviceIdentifier.getType(), e);
} catch (SQLException e) {
throw new PolicyComplianceException("Error occurred while opening a connection to the data source", e);
} finally {
@ -204,12 +199,12 @@ public class MonitoringManagerImpl implements MonitoringManager {
@Override
public ComplianceData getDevicePolicyCompliance(DeviceIdentifier deviceIdentifier) throws
PolicyComplianceException {
PolicyComplianceException {
ComplianceData complianceData;
try {
PolicyManagementDAOFactory.openConnection();
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
DeviceManagementProviderService service =
PolicyManagementDataHolder.getInstance().getDeviceManagementService();
Device device = service.getDevice(deviceIdentifier);
complianceData = monitoringDAO.getCompliance(device.getId(), device.getEnrolmentInfo().getId());
List<ComplianceFeature> complianceFeatures =
@ -218,11 +213,11 @@ public class MonitoringManagerImpl implements MonitoringManager {
} catch (DeviceManagementException e) {
throw new PolicyComplianceException("Unable to retrieve device data for " + deviceIdentifier.getId() +
" - " + deviceIdentifier.getType(), e);
" - " + deviceIdentifier.getType(), e);
} catch (MonitoringDAOException e) {
throw new PolicyComplianceException("Unable to retrieve compliance data for " + deviceIdentifier.getId() +
" - " + deviceIdentifier.getType(), e);
" - " + deviceIdentifier.getType(), e);
} catch (SQLException e) {
throw new PolicyComplianceException("Error occurred while opening a connection to the data source", e);
} finally {
@ -241,6 +236,7 @@ public class MonitoringManagerImpl implements MonitoringManager {
try {
PolicyManagementDAOFactory.openConnection();
//TODO: Return a map from getCompliance to reduce O(n^2) -> O(n)
List<ComplianceData> cd = monitoringDAO.getCompliance();
for (Device device : devices) {
@ -275,7 +271,7 @@ public class MonitoringManagerImpl implements MonitoringManager {
Map<Integer, Device> deviceIdsToAddOperation = new HashMap<>();
Map<Integer, Device> deviceIdsWithExistingOperation = new HashMap<>();
Map<Integer, Device> inactiveDeviceIds = new HashMap<>();
Map<Integer, Device> deviceToMarkUnreachable = new HashMap<>();
Map<Integer, Device> devicesToMarkUnreachable = new HashMap<>();
//Map<Integer, Integer> firstTimeDeviceIdsWithPolicyIds = new HashMap<>();
List<PolicyDeviceWrapper> firstTimeDevices = new ArrayList<>();
@ -290,18 +286,18 @@ public class MonitoringManagerImpl implements MonitoringManager {
if (complianceData.getAttempts() == 0) {
deviceIdsToAddOperation.put(complianceData.getDeviceId(),
deviceIds.get(complianceData.getDeviceId()));
deviceIds.get(complianceData.getDeviceId()));
} else {
deviceIdsWithExistingOperation.put(complianceData.getDeviceId(),
deviceIds.get(complianceData.getDeviceId()));
deviceIds.get(complianceData.getDeviceId()));
if (complianceData.getAttempts() >= policyConfiguration.getMinRetriesToMarkUnreachable()) {
deviceToMarkUnreachable.put(complianceData.getDeviceId(),
deviceIds.get(complianceData.getDeviceId()));
devicesToMarkUnreachable.put(complianceData.getDeviceId(),
deviceIds.get(complianceData.getDeviceId()));
}
}
if (complianceData.getAttempts() >= policyConfiguration.getMinRetriesToMarkInactive()) {
inactiveDeviceIds.put(complianceData.getDeviceId(),
deviceIds.get(complianceData.getDeviceId()));
deviceIds.get(complianceData.getDeviceId()));
}
}
}
@ -325,14 +321,14 @@ public class MonitoringManagerImpl implements MonitoringManager {
log.debug("These devices are in the system for the first time");
for (PolicyDeviceWrapper wrapper : firstTimeDevices) {
log.debug("First time device primary key : " + wrapper.getDeviceId() + " & policy id " +
wrapper.getPolicyId());
wrapper.getPolicyId());
}
}
PolicyManagementDAOFactory.beginTransaction();
if (!deviceIdsToAddOperation.isEmpty()) {
// monitoringDAO.addComplianceDetails(firstTimeDeviceIdsWithPolicyIds);
// monitoringDAO.addComplianceDetails(firstTimeDeviceIdsWithPolicyIds);
monitoringDAO.addComplianceDetails(firstTimeDevices);
monitoringDAO.updateAttempts(new ArrayList<>(deviceIdsToAddOperation.keySet()), false);
}
@ -365,26 +361,29 @@ public class MonitoringManagerImpl implements MonitoringManager {
// TODO : This should be uncommented, this is to mark the device as unreachable, But given the current
// implementation we are not able to do so.
// if(!deviceToMarkUnreachable.isEmpty()) {
// ComplianceDecisionPoint decisionPoint = new ComplianceDecisionPointImpl();
// decisionPoint.setDevicesAsUnreachable(this.getDeviceIdentifiersFromDevices(
// new ArrayList<>(deviceToMarkUnreachable.values())));
// }
if (!devicesToMarkUnreachable.isEmpty()) {
ComplianceDecisionPoint decisionPoint = new ComplianceDecisionPointImpl();
decisionPoint.setDevicesAsUnreachable(this.getDeviceIdentifiersFromDevices(
new ArrayList<>(devicesToMarkUnreachable.values())));
}
if (!inactiveDeviceIds.isEmpty()) {
ComplianceDecisionPoint decisionPoint = new ComplianceDecisionPointImpl();
decisionPoint.setDevicesAsInactive(this.getDeviceIdentifiersFromDevices(
new ArrayList<>(inactiveDeviceIds.values())));
}
}
@Override
public List<DeviceType> getDeviceTypes() throws PolicyComplianceException {
public List<String> getDeviceTypes() throws PolicyComplianceException {
List<DeviceType> deviceTypes = new ArrayList<>();
List<String> deviceTypes = new ArrayList<>();
try {
DeviceManagementDAOFactory.openConnection();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
deviceTypes = deviceTypeDAO.getDeviceTypes(tenantId);
} catch (Exception e) {
log.error("Error occurred while getting the device types.", e);
} finally {
DeviceManagementDAOFactory.closeConnection();
deviceTypes =
PolicyManagementDataHolder.getInstance().getDeviceManagementService().getAvailableDeviceTypes();
} catch (DeviceManagementException e) {
throw new PolicyComplianceException("Error occurred while getting the device types.", e);
}
return deviceTypes;
}
@ -397,24 +396,24 @@ public class MonitoringManagerImpl implements MonitoringManager {
monitoringOperation.setEnabled(true);
monitoringOperation.setType(Operation.Type.COMMAND);
monitoringOperation.setCode(OPERATION_MONITOR);
// CommandOperation infoOperation = new CommandOperation();
// infoOperation.setEnabled(true);
// infoOperation.setType(Operation.Type.COMMAND);
// infoOperation.setCode(OPERATION_INFO);
// CommandOperation appListOperation = new CommandOperation();
// appListOperation.setEnabled(true);
// appListOperation.setType(Operation.Type.COMMAND);
// appListOperation.setCode(OPERATION_APP_LIST);
// CommandOperation infoOperation = new CommandOperation();
// infoOperation.setEnabled(true);
// infoOperation.setType(Operation.Type.COMMAND);\\
// infoOperation.setCode(OPERATION_INFO);
// CommandOperation appListOperation = new CommandOperation();
// appListOperation.setEnabled(true);
// appListOperation.setType(Operation.Type.COMMAND);
// appListOperation.setCode(OPERATION_APP_LIST);
//TODO: Fix this properly later adding device type to be passed in when the task manage executes "addOperations()"
String type = null;
if (deviceIdentifiers.size() > 0) {
type = deviceIdentifiers.get(0).getType();
}
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
DeviceManagementProviderService service = PolicyManagementDataHolder.getInstance().getDeviceManagementService();
service.addOperation(type, monitoringOperation, deviceIdentifiers);
// service.addOperation(infoOperation, deviceIdentifiers);
// service.addOperation(appListOperation, deviceIdentifiers);
// service.addOperation(infoOperation, deviceIdentifiers);
// service.addOperation(appListOperation, deviceIdentifiers);
}
private List<DeviceIdentifier> getDeviceIdentifiersFromDevices(List<Device> devices) {

@ -26,9 +26,6 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException;
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
@ -50,14 +47,12 @@ public class PolicyManagerImpl implements PolicyManager {
private ProfileDAO profileDAO;
private FeatureDAO featureDAO;
private ProfileManager profileManager;
private DeviceDAO deviceDAO;
private static Log log = LogFactory.getLog(PolicyManagerImpl.class);
public PolicyManagerImpl() {
this.policyDAO = PolicyManagementDAOFactory.getPolicyDAO();
this.profileDAO = PolicyManagementDAOFactory.getProfileDAO();
this.featureDAO = PolicyManagementDAOFactory.getFeatureDAO();
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
this.profileManager = new ProfileManagerImpl();
}

@ -1,146 +0,0 @@
/*
* 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.policy.mgt.core.service;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.policy.mgt.common.*;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
import org.wso2.carbon.policy.mgt.core.PolicyManagerServiceImpl;
import org.wso2.carbon.policy.mgt.core.task.TaskScheduleService;
import java.util.List;
public class PolicyManagementService implements PolicyManagerService {
PolicyManagerService policyManagerService;
public PolicyManagementService() {
policyManagerService = new PolicyManagerServiceImpl();
}
@Override
public Profile addProfile(Profile profile) throws PolicyManagementException {
return policyManagerService.addProfile(profile);
}
@Override
public Profile updateProfile(Profile profile) throws PolicyManagementException {
return policyManagerService.updateProfile(profile);
}
@Override
public Policy addPolicy(Policy policy) throws PolicyManagementException {
return policyManagerService.addPolicy(policy);
}
@Override
public Policy updatePolicy(Policy policy) throws PolicyManagementException {
return policyManagerService.updatePolicy(policy);
}
@Override
public boolean deletePolicy(Policy policy) throws PolicyManagementException {
return policyManagerService.deletePolicy(policy);
}
@Override
public boolean deletePolicy(int policyId) throws PolicyManagementException {
return policyManagerService.deletePolicy(policyId);
}
@Override
public Policy getEffectivePolicy(DeviceIdentifier deviceIdentifier) throws PolicyManagementException {
return policyManagerService.getEffectivePolicy(deviceIdentifier);
}
@Override
public List<ProfileFeature> getEffectiveFeatures(DeviceIdentifier deviceIdentifier) throws
FeatureManagementException {
return policyManagerService.getEffectiveFeatures(deviceIdentifier);
}
@Override
public List<Policy> getPolicies(String deviceType) throws PolicyManagementException {
return policyManagerService.getPolicies(deviceType);
}
@Override
public List<Feature> getFeatures() throws FeatureManagementException {
return policyManagerService.getFeatures();
}
@Override
public PolicyAdministratorPoint getPAP() throws PolicyManagementException {
return policyManagerService.getPAP();
}
@Override
public PolicyInformationPoint getPIP() throws PolicyManagementException {
return policyManagerService.getPIP();
}
@Override
public PolicyEvaluationPoint getPEP() throws PolicyManagementException {
return policyManagerService.getPEP();
}
@Override
public TaskScheduleService getTaskScheduleService() throws PolicyMonitoringTaskException {
return policyManagerService.getTaskScheduleService();
}
@Override
public int getPolicyCount() throws PolicyManagementException {
return policyManagerService.getPolicyCount();
}
@Override
public Policy getAppliedPolicyToDevice(
DeviceIdentifier deviceIdentifier) throws PolicyManagementException {
return policyManagerService.getAppliedPolicyToDevice(deviceIdentifier);
}
@Override
public List<ComplianceFeature> checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Object
deviceResponse) throws PolicyComplianceException {
return policyManagerService.checkPolicyCompliance(deviceIdentifier, deviceResponse);
}
@Override
public boolean checkCompliance(DeviceIdentifier deviceIdentifier, Object response) throws
PolicyComplianceException {
return policyManagerService.checkCompliance(deviceIdentifier, response);
}
@Override
public ComplianceData getDeviceCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException {
return policyManagerService.getDeviceCompliance(deviceIdentifier);
}
@Override
public boolean isCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException {
return policyManagerService.isCompliance(deviceIdentifier);
}
}

@ -40,7 +40,6 @@ import java.util.Map;
public class MonitoringTask implements Task {
private DeviceTypeDAO deviceTypeDAO;
private static Log log = LogFactory.getLog(MonitoringTask.class);
Map<String, String> properties;
@ -53,7 +52,6 @@ public class MonitoringTask implements Task {
@Override
public void init() {
deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
}
@Override
@ -63,9 +61,9 @@ public class MonitoringTask implements Task {
log.debug("Monitoring task started to run.");
}
MonitoringManager monitoringManager = new MonitoringManagerImpl();
MonitoringManager monitoringManager = PolicyManagementDataHolder.getInstance().getMonitoringManager();
List<DeviceType> deviceTypes = new ArrayList<>();
List<String> deviceTypes = new ArrayList<>();
try {
deviceTypes = monitoringManager.getDeviceTypes();
} catch (PolicyComplianceException e) {
@ -79,15 +77,15 @@ public class MonitoringTask implements Task {
DeviceManagementProviderService deviceManagementProviderService =
PolicyManagementDataHolder.getInstance().getDeviceManagementService();
for (DeviceType deviceType : deviceTypes) {
for (String deviceType : deviceTypes) {
if (log.isDebugEnabled()) {
log.debug("Running task for device type : " + deviceType.getName());
log.debug("Running task for device type : " + deviceType);
}
PolicyMonitoringService monitoringService =
PolicyManagementDataHolder.getInstance().getPolicyMonitoringService(deviceType.getName());
List<Device> devices = deviceManagementProviderService.getAllDevices(deviceType.getName());
PolicyManagementDataHolder.getInstance().getPolicyMonitoringService(deviceType);
List<Device> devices = deviceManagementProviderService.getAllDevices(deviceType);
if (monitoringService != null && !devices.isEmpty()) {
@ -95,12 +93,11 @@ public class MonitoringTask implements Task {
if (log.isDebugEnabled()) {
log.debug("Removing inactive and blocked devices from the list for the device type : " +
deviceType.getName());
deviceType);
}
for (Device device : devices) {
EnrolmentInfo.Status status = device.getEnrolmentInfo().getStatus();
if (status.equals(EnrolmentInfo.Status.INACTIVE) ||
status.equals(EnrolmentInfo.Status.BLOCKED) ||
if (status.equals(EnrolmentInfo.Status.BLOCKED) ||
status.equals(EnrolmentInfo.Status.REMOVED) ||
status.equals(EnrolmentInfo.Status.UNCLAIMED) ||
status.equals(EnrolmentInfo.Status.DISENROLLMENT_REQUESTED) ||
@ -111,14 +108,15 @@ public class MonitoringTask implements Task {
}
}
if (log.isDebugEnabled()) {
log.debug("Following devices selected to send the notification for " +
deviceType.getName());
log.debug("Following devices selected to send the notification for " + deviceType);
for (Device device : notifiableDevices) {
log.debug(device.getDeviceIdentifier());
}
}
monitoringManager.addMonitoringOperation(notifiableDevices);
monitoringService.notifyDevices(notifiableDevices);
if (!notifiableDevices.isEmpty()) {
monitoringManager.addMonitoringOperation(notifiableDevices);
monitoringService.notifyDevices(notifiableDevices);
}
}
}
if (log.isDebugEnabled()) {

@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;

@ -3,14 +3,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.simple.policy.decision.point</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Simple Policy Decision Point</name>
<description>WSO2 Carbon - Simple Policy Decision Point</description>

@ -23,13 +23,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>policy-mgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - Policy Management Component</name>
<url>http://wso2.org</url>

@ -21,14 +21,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>webapp-authenticator-framework</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.webapp.authenticator.framework</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Web Application Authenticator Framework Bundle</name>
<description>WSO2 Carbon - Web Application Authenticator Framework Bundle</description>
@ -61,9 +61,8 @@
com.nimbusds.jwt,
javax.xml.bind,
javax.xml.bind.annotation,
javax.xml.parsers,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
javax.xml.validation,
org.apache.axiom.util.base64,
org.apache.catalina,
org.apache.catalina.connector,
org.apache.catalina.util,
@ -110,13 +109,9 @@
org.apache.commons.pool.impl,
org.apache.http.conn,
org.apache.http.impl.conn,
javax.xml.soap,
javax.xml.soap; version="${javax.xml.soap.imp.pkg.version}",
javax.xml.stream,
org.apache.axiom.soap,
org.apache.axiom.soap.impl.builder,
org.apache.axiom.om,
org.apache.axiom.om.impl.builder,
org.apache.axiom.om.util,
org.apache.axiom.*; version="${axiom.osgi.version.range}",
org.wso2.carbon.registry.core.*,
org.wso2.carbon.registry.common.*;version="${carbon.registry.imp.pkg.version.range}",
org.wso2.carbon.registry.indexing.*; version="${carbon.registry.imp.pkg.version.range}",
@ -166,10 +161,10 @@
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.tomcat.ext</artifactId>
</dependency>
<dependency>
<!--dependency>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom</artifactId>
</dependency>
</dependency-->
<dependency>
<groupId>org.wso2.carbon.identity</groupId>
<artifactId>org.wso2.carbon.identity.base</artifactId>

@ -57,7 +57,7 @@ public class AuthenticationFrameworkUtil {
}
APITokenValidator tokenValidator = new APITokenValidator();
APIKeyValidationInfoDTO apiKeyValidationDTO = tokenValidator.validateKey(context, version, accessToken,
requiredAuthenticationLevel, clientDomain);
requiredAuthenticationLevel);
if (apiKeyValidationDTO.isAuthorized()) {
String username = apiKeyValidationDTO.getEndUserName();
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username);

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>webapp-authenticator-framework</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - Webapp Authenticator Framework</name>
<url>http://wso2.org</url>

@ -21,14 +21,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.application.extension.feature</artifactId>
<packaging>pom</packaging>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<name>WSO2 Carbon - API Management Application Extension Feature</name>
<url>http://wso2.org</url>
<description>This feature contains an implementation of a api application registration, which takes care of subscription

@ -21,14 +21,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher.feature</artifactId>
<packaging>pom</packaging>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<name>WSO2 Carbon - API Management Webapp Publisher Feature</name>
<url>http://wso2.org</url>
<description>This feature contains an implementation of a Tomcat lifecycle listener, which takes care of publishing

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - API Management Extensions Feature</name>
<url>http://wso2.org</url>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.certificate.mgt.server.feature</artifactId>
<packaging>pom</packaging>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<name>WSO2 Carbon - Certificate Management Server Feature</name>
<url>http://wso2.org</url>
<description>This feature contains the core bundles required for back-end Certificate Management functionality
@ -41,19 +41,15 @@
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle.wso2</groupId>
<groupId>org.wso2.orbit.org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle.wso2</groupId>
<groupId>org.wso2.orbit.org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle.wso2</groupId>
<artifactId>bcmail-jdk15on</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.jscep.wso2</groupId>
<groupId>org.wso2.orbit.com.google.code.jscep</groupId>
<artifactId>jscep</artifactId>
</dependency>
<dependency>
@ -68,6 +64,10 @@
<groupId>commons-codec.wso2</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.registry</groupId>
<artifactId>org.wso2.carbon.registry.indexing</artifactId>
</dependency>
</dependencies>
<build>
@ -122,16 +122,10 @@
org.wso2.carbon.devicemgt:org.wso2.carbon.certificate.mgt.core:${carbon.device.mgt.version}
</bundleDef>
<bundleDef>
org.bouncycastle.wso2:bcprov-jdk15on:${bcprov.wso2.version}
</bundleDef>
<bundleDef>
org.bouncycastle.wso2:bcpkix-jdk15on:${bcpkix.wso2.version}
</bundleDef>
<bundleDef>
org.bouncycastle.wso2:bcmail-jdk15on:${bcmail.wso2.version}
org.wso2.orbit.org.bouncycastle:bcpkix-jdk15on:${bcpkix.wso2.version}
</bundleDef>
<bundleDef>
com.google.code.jscep.wso2:jscep:${jscep.version}
org.wso2.orbit.com.google.code.jscep:jscep:${jscep.version}
</bundleDef>
<bundleDef>
commons-io.wso2:commons-io:${version.commons.io}
@ -146,6 +140,9 @@
<importFeatures>
<importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}</importFeatureDef>
</importFeatures>
<importBundles>
<importBundleDef>org.wso2.carbon.registry:org.wso2.carbon.registry.indexing:${carbon.registry.version}</importBundleDef>
</importBundles>
</configuration>
</execution>
</executions>

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - Certificate Management Feature</name>
<url>http://wso2.org</url>

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-extensions-feature</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.feature</artifactId>
<packaging>pom</packaging>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<name>WSO2 Carbon - GCM Based Push Notification Provider Feature</name>
<url>http://wso2.org</url>
<description>WSO2 Carbon - MQTT Based Push Notification Provider Feature</description>

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-extensions-feature</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature</artifactId>
<packaging>pom</packaging>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<name>WSO2 Carbon - MQTT Based Push Notification Provider Feature</name>
<url>http://wso2.org</url>
<description>WSO2 Carbon - MQTT Based Push Notification Provider Feature</description>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save