Resolve conflicts

revert-70aa11f8
geethkokila 7 years ago
commit f261bc2e88

@ -22,13 +22,13 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Annotations</name>
<description>WSO2 Carbon - API Management Custom Annotation Module</description>

@ -21,12 +21,12 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-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>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<artifactId>org.wso2.carbon.apimgt.application.extension</artifactId>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Application Management</name>

@ -21,13 +21,13 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.handlers</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Security Handler Component</name>
<description>WSO2 Carbon - API Management Security Handler Module</description>

@ -13,13 +13,13 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Integration Client</name>
<description>WSO2 Carbon - API Management Integration Client</description>

@ -13,13 +13,13 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Integration Generated Client</name>
<description>WSO2 Carbon - API Management Integration Client</description>

@ -22,13 +22,13 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Webapp Publisher</name>
<description>WSO2 Carbon - API Management Webapp Publisher</description>

@ -22,13 +22,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apimgt-extensions</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-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>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

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

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ /*
~ * Copyright (c) ${date}, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ *
~ * WSO2 Inc. licenses this file to you under the Apache License,
~ * Version 2.0 (the "License"); you may not use this file except
@ -24,7 +24,7 @@
<parent>
<artifactId>certificate-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -1,6 +1,6 @@
/*
*
* Copyright (c) ${date}, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
@ -16,6 +16,7 @@
* under the License.
*
*/
package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans;
import com.fasterxml.jackson.annotation.JsonProperty;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
@ -16,6 +16,7 @@
* under the License.
*
*/
package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -43,7 +44,6 @@ public class CertificateList extends BasePaginatedResult {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{\n");
sb.append(" count: ").append(getCount()).append(",\n");
sb.append(" next: ").append(getNext()).append(",\n");
sb.append(" previous: ").append(getPrevious()).append(",\n");
@ -51,5 +51,5 @@ public class CertificateList extends BasePaginatedResult {
sb.append("]}\n");
return sb.toString();
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
@ -16,6 +16,7 @@
* under the License.
*
*/
package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans;
import com.fasterxml.jackson.annotation.JsonProperty;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
@ -16,6 +16,7 @@
* under the License.
*
*/
package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans;
import com.fasterxml.jackson.annotation.JsonProperty;

@ -16,7 +16,6 @@
* under the License.
*/
package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans;
public class ValidationResponse {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
/*
*
* Copyright (c) ${date}, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
@ -17,6 +17,7 @@
* under the License.
* /
*/
package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.swagger.extension;
import io.swagger.annotations.SwaggerDefinition;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
@ -16,6 +16,7 @@
* under the License.
*
*/
package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.util;
import javax.servlet.*;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
@ -16,6 +16,7 @@
* under the License.
*
*/
package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.util;
import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans.ErrorResponse;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ /*
~ * Copyright (c) ${date}, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ *
~ * WSO2 Inc. licenses this file to you under the Apache License,
~ * Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except

@ -21,13 +21,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Certificate Management Core</name>
<description>WSO2 Carbon - Certificate Management Core</description>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ /*
~ * Copyright (c) ${date}, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ *
~ * WSO2 Inc. licenses this file to you under the Apache License,
~ * Version 2.0 (the "License"); you may not use this file except
@ -24,7 +24,7 @@
<parent>
<artifactId>certificate-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -1,6 +1,6 @@
/*
*
* Copyright (c) ${date}, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,3 +1,21 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.certificate.mgt.jaxrs.api.impl;
import org.apache.commons.codec.binary.Base64;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
@ -16,6 +16,7 @@
* under the License.
*
*/
package org.wso2.carbon.certificate.mgt.jaxrs.beans;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -69,11 +70,9 @@ public class ErrorListItem {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("errorItem {\n");
sb.append(" code: ").append(code).append("\n");
sb.append(" message: ").append(message).append("\n");
sb.append("}\n");
return sb.toString();
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ /*
~ * Copyright (c) ${date}, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ *
~ * WSO2 Inc. licenses this file to you under the Apache License,
~ * Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-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>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

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

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

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

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

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

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

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

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

@ -18,18 +18,11 @@
*/
package org.wso2.carbon.device.mgt.jaxrs.service.api.admin;
import io.swagger.annotations.SwaggerDefinition;
import io.swagger.annotations.Info;
import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Extension;
import io.swagger.annotations.Tag;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.*;
import org.apache.axis2.transport.http.HTTPConstants;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
@ -61,6 +54,12 @@ import javax.ws.rs.core.Response;
description = "View Users",
key = "perm:admin-users:view",
permissions = {"/device-mgt/users/manage"}
),
@Scope(
name = "Delete Users Device Information",
description = "Delete users device details",
key = "perm:admin-users:remove",
permissions = {"/device-mgt/users/manage"}
)
}
)
@ -127,4 +126,131 @@ public interface UserManagementAdminService {
value = "Credential.",
required = true) PasswordResetWrapper credentials);
@Path("/{username}/devices")
@DELETE
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = HTTPConstants.HEADER_DELETE,
value = "Delete a users associated devices.",
notes = "If you wish to remove an device details to comply with the privacy requirements, can be done with " +
"this resource.",
tags = "Device details remove",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:admin-users:remove")
})
}
)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK. \n Users devices and details has been deleted successfully.",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body."),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of " +
"the requested resource."),
@ApiResponse(
code = 404,
message = "Group not found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while removing the group.",
response = ErrorResponse.class)
})
Response deleteDeviceOfUser(@ApiParam(
name = "username",
value = "Username of the users devices to be deleted.",
required = true)
@PathParam("username") String username);
//device remove request would looks like follows
//DELETE devices/type/virtual_firealarm/id/us06ww93auzp
@DELETE
@Path("/type/{device-type}/id/{device-id}")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
consumes = MediaType.APPLICATION_JSON,
httpMethod = "DELETE",
value = "Remove the information of device specified by device id",
notes = "Returns the status of the deleted device information.",
tags = "Device details remove privacy compliance",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:admin-users:remove")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully deleted the device information.",
response = Device.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. Empty body because the client already has the latest " +
"version of the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
response = ErrorResponse.class),
@ApiResponse(
code = 404,
message = "Not Found. \n No device is found under the provided type and id.",
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while retrieving information requested device.",
response = ErrorResponse.class)
})
Response deleteDevice(
@ApiParam(
name = "device-type",
value = "The device type, such as ios, android or windows.",
required = true)
@PathParam("device-type")
@Size(max = 45)
String deviceType,
@ApiParam(
name = "device-id",
value = "The device identifier of the device.",
required = true)
@PathParam("device-id")
@Size(max = 45)
String deviceId);
}

@ -178,6 +178,10 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
String error = "Error occurred while creating the geo alert for " + deviceType + " with id: " + deviceId;
log.error(error, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
} catch (AlertAlreadyExistException e) {
String error = "A geo alert with this name already exists.";
log.error(error,e);
return Response.status(Response.Status.BAD_REQUEST).entity(error).build();
}
}
@ -211,6 +215,10 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
String error = "Error occurred while creating the geo alert for " + deviceType + " with id: " + deviceId;
log.error(error, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
} catch (AlertAlreadyExistException e) {
String error = "A geo alert with this name already exists.";
log.error(error,e);
return Response.status(Response.Status.BAD_REQUEST).entity(error).build();
}
}

@ -18,9 +18,17 @@
*/
package org.wso2.carbon.device.mgt.jaxrs.service.impl.admin;
import io.swagger.annotations.ApiParam;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.netbeans.lib.cvsclient.commandLine.command.log;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.PrivacyComplianceException;
import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper;
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.UserManagementAdminService;
import org.wso2.carbon.device.mgt.jaxrs.util.CredentialManagementResponseBuilder;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import javax.validation.constraints.Size;
import javax.ws.rs.*;
@ -32,16 +40,45 @@ import javax.ws.rs.core.Response;
@Consumes(MediaType.APPLICATION_JSON)
public class UserManagementAdminServiceImpl implements UserManagementAdminService {
private static final Log log = LogFactory.getLog(UserManagementAdminServiceImpl.class);
@POST
@Path("/{username}/credentials")
@Override
public Response resetUserPassword(@PathParam("username")
@Size(max = 45)
String user, @QueryParam("domain") String domain, PasswordResetWrapper credentials) {
String user, @QueryParam("domain") String domain, PasswordResetWrapper credentials) {
if (domain != null && !domain.isEmpty()) {
user = domain + '/' + user;
}
return CredentialManagementResponseBuilder.buildResetPasswordResponse(user, credentials);
}
@Override
public Response deleteDeviceOfUser(@PathParam("username") String username) {
try {
DeviceMgtAPIUtils.getPrivacyComplianceProvider().deleteDevicesOfUser(username);
return Response.status(Response.Status.OK).build();
} catch (PrivacyComplianceException e) {
String msg = "Error occurred while deleting the devices belongs to the user.";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
@Override
public Response deleteDevice(@PathParam("device-type") @Size(max = 45) String deviceType,
@PathParam("device-id") @Size(max = 45) String deviceId) {
try {
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, deviceType);
DeviceMgtAPIUtils.getPrivacyComplianceProvider().deleteDeviceDetails(deviceIdentifier);
return Response.status(Response.Status.OK).build();
} catch (PrivacyComplianceException e) {
String msg = "Error occurred while deleting the devices information.";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
}

@ -49,6 +49,7 @@ import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagement
import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService;
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
import org.wso2.carbon.device.mgt.core.privacy.PrivacyComplianceProvider;
import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
@ -297,6 +298,19 @@ public class DeviceMgtAPIUtils {
return realmService;
}
public static PrivacyComplianceProvider getPrivacyComplianceProvider() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
PrivacyComplianceProvider privacyComplianceProvider =
(PrivacyComplianceProvider) ctx.getOSGiService(PrivacyComplianceProvider.class, null);
if (privacyComplianceProvider == null) {
String msg = "PrivacyComplianceProvider service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg);
}
return privacyComplianceProvider;
}
public static IntegrationClientService getIntegrationClientService() {
if (integrationClientService == null) {
synchronized (DeviceMgtAPIUtils.class) {

@ -21,7 +21,7 @@
<parent>
<artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -0,0 +1,47 @@
/*
* Copyright (c) 2018, 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.device.mgt.common;
public class PrivacyComplianceException extends Exception {
private static final long serialVersionUID = -3127931192903344297L;
public PrivacyComplianceException(String msg, Exception nestedEx) {
super(msg, nestedEx);
}
public PrivacyComplianceException(String message, Throwable cause) {
super(message, cause);
}
public PrivacyComplianceException(String msg) {
super(msg);
}
public PrivacyComplianceException() {
super();
}
public PrivacyComplianceException(Throwable cause) {
super(cause);
}
}

@ -0,0 +1,41 @@
/*
* Copyright (c) 2018, 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.device.mgt.common.geo.service;
/**
* Custom exception class for geo alert definition operations.
*/
public class AlertAlreadyExistException extends Exception {
private static final long serialVersionUID = 4709355511911265093L;
private String errorMessage;
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
public AlertAlreadyExistException(String msg) {
super(msg);
setErrorMessage(msg);
}
}

@ -33,10 +33,10 @@ public interface GeoLocationProviderService {
List<GeoFence> getExitAlerts(DeviceIdentifier identifier) throws GeoLocationBasedServiceException;
boolean createGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType)
throws GeoLocationBasedServiceException;
throws GeoLocationBasedServiceException, AlertAlreadyExistException;
boolean updateGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType)
throws GeoLocationBasedServiceException;
throws GeoLocationBasedServiceException, AlertAlreadyExistException;
boolean removeGeoAlert(String alertType, DeviceIdentifier identifier, String queryName)
throws GeoLocationBasedServiceException;

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

@ -222,7 +222,8 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
}
}
DeviceManagementDAOFactory.beginTransaction();
applicationMappingDAO.removeApplicationMapping(device.getId(), appIdsToRemove, tenantId);
applicationMappingDAO.removeApplicationMapping(device.getId(), device.getEnrolmentInfo().getId(),
appIdsToRemove, tenantId);
Application installedApp;
List<Integer> applicationIds = new ArrayList<>();
List<Application> applicationsToMap = new ArrayList<>();
@ -263,7 +264,8 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
if (log.isDebugEnabled()) {
log.debug("num of app Ids:" + applicationIds.size());
}
applicationMappingDAO.addApplicationMappingsWithApps(device.getId(), applicationsToMap, tenantId);
applicationMappingDAO.addApplicationMappingsWithApps(device.getId(), device.getEnrolmentInfo().getId(),
applicationsToMap, tenantId);
if (log.isDebugEnabled()) {
log.debug("num of remove app Ids:" + appIdsToRemove.size());
@ -312,7 +314,7 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
}
try {
DeviceManagementDAOFactory.openConnection();
return applicationDAO.getInstalledApplications(device.getId());
return applicationDAO.getInstalledApplications(device.getId(), device.getEnrolmentInfo().getId());
} catch (DeviceManagementDAOException e) {
String msg = "Error occurred while fetching the Application List of device " + deviceId.toString();
log.error(msg, e);

@ -34,7 +34,8 @@ public interface ApplicationDAO {
Application getApplication(String identifier, String version,int tenantId) throws DeviceManagementDAOException;
Application getApplication(String identifier, String version, int deviceId, int tenantId) throws DeviceManagementDAOException;
Application getApplication(String identifier, String version, int deviceId, int enrolmentId, int tenantId)
throws DeviceManagementDAOException;
List<Application> getInstalledApplications(int deviceId) throws DeviceManagementDAOException;
List<Application> getInstalledApplications(int deviceId, int enrolmentId) throws DeviceManagementDAOException;
}

@ -29,9 +29,9 @@ public interface ApplicationMappingDAO {
void addApplicationMappings(int deviceId, List<Integer> applicationIds, int tenantId)
throws DeviceManagementDAOException;
void addApplicationMappingsWithApps(int deviceId, List<Application> applications, int tenantId)
void addApplicationMappingsWithApps(int deviceId, int enrolmentId, List<Application> applications, int tenantId)
throws DeviceManagementDAOException;
void removeApplicationMapping(int deviceId, List<Integer> appIdList, int tenantId)
void removeApplicationMapping(int deviceId, int enrolmentId, List<Integer> appIdList, int tenantId)
throws DeviceManagementDAOException;
}

@ -39,6 +39,8 @@ import org.wso2.carbon.device.mgt.core.dao.impl.device.SQLServerDeviceDAOImpl;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsDAO;
import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.impl.DeviceDetailsDAOImpl;
import org.wso2.carbon.device.mgt.core.privacy.dao.PrivacyComplianceDAO;
import org.wso2.carbon.device.mgt.core.privacy.dao.impl.PrivacyComplianceDAOImpl;
import javax.sql.DataSource;
import java.sql.Connection;
@ -151,6 +153,10 @@ public class DeviceManagementDAOFactory {
return new DeviceDetailsDAOImpl();
}
public static PrivacyComplianceDAO getPrivacyComplianceDAO() {
return new PrivacyComplianceDAOImpl();
}
public static void init(DataSourceConfig config) {
dataSource = resolveDataSource(config);
try {

@ -152,8 +152,8 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
try {
conn = this.getConnection();
stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID FROM DM_APPLICATION WHERE APP_IDENTIFIER = ? " +
"AND TENANT_ID = ?");
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID FROM " +
"DM_APPLICATION WHERE APP_IDENTIFIER = ? AND TENANT_ID = ?");
stmt.setString(1, identifier);
stmt.setInt(2, tenantId);
rs = stmt.executeQuery();
@ -171,7 +171,8 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
}
@Override
public Application getApplication(String identifier, String version, int tenantId) throws DeviceManagementDAOException {
public Application getApplication(String identifier, String version, int tenantId)
throws DeviceManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
@ -179,8 +180,8 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
try {
conn = this.getConnection();
stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID FROM DM_APPLICATION WHERE APP_IDENTIFIER = ? " +
"AND VERSION = ? AND TENANT_ID = ?");
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID FROM " +
"DM_APPLICATION WHERE APP_IDENTIFIER = ? AND VERSION = ? AND TENANT_ID = ?");
stmt.setString(1, identifier);
stmt.setString(2, version);
stmt.setInt(3, tenantId);
@ -199,7 +200,8 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
}
@Override
public Application getApplication(String identifier, String version, int deviceId, int tenantId) throws DeviceManagementDAOException {
public Application getApplication(String identifier, String version, int deviceId, int enrolmentId, int tenantId)
throws DeviceManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
@ -208,14 +210,15 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
conn = this.getConnection();
stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
"LOCATION_URL, IMAGE_URL, appmap.APP_PROPERTIES, appmap.MEMORY_USAGE, appmap.IS_ACTIVE, TENANT_ID " +
"FROM DM_APPLICATION app INNER JOIN " +
"(SELECT APPLICATION_ID, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE FROM DM_DEVICE_APPLICATION_MAPPING W" +
"HERE DEVICE_ID = ?) appmap WHERE app.APP_IDENTIFIER = ? AND app.VERSION = ? AND " +
"FROM DM_APPLICATION app INNER JOIN (SELECT APPLICATION_ID, APP_PROPERTIES, MEMORY_USAGE, " +
"IS_ACTIVE FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?) appmap " +
"WHERE app.APP_IDENTIFIER = ? AND app.VERSION = ? AND " +
"appmap.APPLICATION_ID = app.id AND TENANT_ID = ?");
stmt.setInt(1, deviceId);
stmt.setString(2, identifier);
stmt.setString(3, version);
stmt.setInt(4, tenantId);
stmt.setInt(2, enrolmentId);
stmt.setString(3, identifier);
stmt.setString(4, version);
stmt.setInt(5, tenantId);
rs = stmt.executeQuery();
if (rs.next()) {
@ -235,7 +238,7 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
}
@Override
public List<Application> getInstalledApplications(int deviceId) throws DeviceManagementDAOException {
public List<Application> getInstalledApplications(int deviceId, int enrolmentId) throws DeviceManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
List<Application> applications = new ArrayList<>();
@ -247,11 +250,12 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
"LOCATION_URL, IMAGE_URL, APPMAP.APP_PROPERTIES, APPMAP.MEMORY_USAGE, APPMAP.IS_ACTIVE, " +
"TENANT_ID From DM_APPLICATION app INNER JOIN " +
"(Select APPLICATION_ID, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE" +
" From DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID=?) APPMAP " +
" From DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID=? AND ENROLMENT_ID = ?) APPMAP " +
"ON " +
"app.ID = APPMAP.APPLICATION_ID ");
stmt.setInt(1, deviceId);
stmt.setInt(2, enrolmentId);
rs = stmt.executeQuery();
while (rs.next()) {

@ -97,7 +97,7 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO {
}
@Override
public void addApplicationMappingsWithApps(int deviceId, List<Application> applications, int tenantId)
public void addApplicationMappingsWithApps(int deviceId, int enrolmentId, List<Application> applications, int tenantId)
throws DeviceManagementDAOException {
Connection conn;
@ -108,25 +108,26 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO {
try {
conn = this.getConnection();
String sql = "INSERT INTO DM_DEVICE_APPLICATION_MAPPING (DEVICE_ID, APPLICATION_ID, APP_PROPERTIES, " +
"MEMORY_USAGE, IS_ACTIVE, TENANT_ID) VALUES (?, ?, ?, ?, ?, ?)";
String sql = "INSERT INTO DM_DEVICE_APPLICATION_MAPPING (DEVICE_ID, ENROLMENT_ID, APPLICATION_ID, " +
"APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID) VALUES (?, ?, ?, ?, ?, ?, ?)";
conn.setAutoCommit(false);
stmt = conn.prepareStatement(sql);
for (Application application : applications) {
stmt.setInt(1, deviceId);
stmt.setInt(2, application.getId());
stmt.setInt(2, enrolmentId);
stmt.setInt(3, application.getId());
bao = new ByteArrayOutputStream();
oos = new ObjectOutputStream(bao);
oos.writeObject(application.getAppProperties());
stmt.setBytes(3, bao.toByteArray());
stmt.setBytes(4, bao.toByteArray());
stmt.setInt(4, application.getMemoryUsage());
stmt.setBoolean(5, application.isActive());
stmt.setInt(5, application.getMemoryUsage());
stmt.setBoolean(6, application.isActive());
stmt.setInt(6, tenantId);
stmt.setInt(7, tenantId);
stmt.addBatch();
}
stmt.executeBatch();
@ -155,13 +156,13 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO {
}
@Override
public void removeApplicationMapping(int deviceId, List<Integer> appIdList,
public void removeApplicationMapping(int deviceId, int enrolmentId, List<Integer> appIdList,
int tenantId) throws DeviceManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID = ? AND " +
"APPLICATION_ID = ? AND TENANT_ID = ?";
"APPLICATION_ID = ? AND TENANT_ID = ? AND ENROLMENT_ID = ?";
conn = this.getConnection();
for (int appId : appIdList) {
@ -169,6 +170,7 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO {
stmt.setInt(1, deviceId);
stmt.setInt(2, appId);
stmt.setInt(3, tenantId);
stmt.setInt(4, enrolmentId);
stmt.execute();
}
} catch (SQLException e) {

@ -38,14 +38,15 @@ public interface DeviceDetailsDAO {
* @param deviceInfo - Device information object.
* @throws DeviceDetailsMgtDAOException
*/
void addDeviceInformation(int deviceId, DeviceInfo deviceInfo) throws DeviceDetailsMgtDAOException;
void addDeviceInformation(int deviceId, int enrolmentId, DeviceInfo deviceInfo) throws DeviceDetailsMgtDAOException;
/**
* This method will add the device properties to the database.
* @param propertyMap - device properties.
* @throws DeviceDetailsMgtDAOException
*/
void addDeviceProperties(Map<String, String> propertyMap, int deviceId) throws DeviceDetailsMgtDAOException;
void addDeviceProperties(Map<String, String> propertyMap, int deviceId, int enrolmentId)
throws DeviceDetailsMgtDAOException;
/**
* This method will return the device information when device id is provided.
@ -53,7 +54,7 @@ public interface DeviceDetailsDAO {
* @return DeviceInfo
* @throws DeviceDetailsMgtDAOException
*/
DeviceInfo getDeviceInformation(int deviceId) throws DeviceDetailsMgtDAOException;
DeviceInfo getDeviceInformation(int deviceId, int enrolmentId) throws DeviceDetailsMgtDAOException;
/**
* This method will return the device properties from database.
@ -61,28 +62,28 @@ public interface DeviceDetailsDAO {
* @return - device properties map.
* @throws DeviceDetailsMgtDAOException
*/
Map<String, String> getDeviceProperties(int deviceId) throws DeviceDetailsMgtDAOException;
Map<String, String> getDeviceProperties(int deviceId, int enrolmentId) throws DeviceDetailsMgtDAOException;
/**
* This method will delete the device information from the database.
* @param deviceId - Integer.
* @throws DeviceDetailsMgtDAOException
*/
void deleteDeviceInformation(int deviceId) throws DeviceDetailsMgtDAOException;
void deleteDeviceInformation(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException;
/**
* This method will delete the device properties from database.
* @param deviceId - Integer.
* @throws DeviceDetailsMgtDAOException
*/
void deleteDeviceProperties(int deviceId) throws DeviceDetailsMgtDAOException;
void deleteDeviceProperties(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException;
/**
* This method will add device location to database.
* @param deviceLocation - Device location with latitude and longitude.
* @throws DeviceDetailsMgtDAOException
*/
void addDeviceLocation(DeviceLocation deviceLocation) throws DeviceDetailsMgtDAOException;
void addDeviceLocation(DeviceLocation deviceLocation, int enrollmentId) throws DeviceDetailsMgtDAOException;
/**
* This method will return the device location object when the device id is provided.
@ -90,14 +91,14 @@ public interface DeviceDetailsDAO {
* @return - Device location object.
* @throws DeviceDetailsMgtDAOException
*/
DeviceLocation getDeviceLocation(int deviceId) throws DeviceDetailsMgtDAOException;
DeviceLocation getDeviceLocation(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException;
/**
* This method will delete the device location from the database.
* @param deviceId
* @throws DeviceDetailsMgtDAOException
*/
void deleteDeviceLocation(int deviceId) throws DeviceDetailsMgtDAOException;
void deleteDeviceLocation(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException;
// /**
// * This method will add device application to database.

@ -41,7 +41,8 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
private static Log log = LogFactory.getLog(DeviceDetailsDAOImpl.class);
@Override
public void addDeviceInformation(int deviceId, DeviceInfo deviceInfo) throws DeviceDetailsMgtDAOException {
public void addDeviceInformation(int deviceId, int enrolmentId, DeviceInfo deviceInfo)
throws DeviceDetailsMgtDAOException {
Connection conn;
PreparedStatement stmt = null;
@ -51,8 +52,8 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_DETAIL (DEVICE_ID, DEVICE_MODEL, " +
"VENDOR, OS_VERSION, OS_BUILD_DATE, BATTERY_LEVEL, INTERNAL_TOTAL_MEMORY, INTERNAL_AVAILABLE_MEMORY, " +
"EXTERNAL_TOTAL_MEMORY, EXTERNAL_AVAILABLE_MEMORY, CONNECTION_TYPE, " +
"SSID, CPU_USAGE, TOTAL_RAM_MEMORY, AVAILABLE_RAM_MEMORY, PLUGGED_IN, UPDATE_TIMESTAMP) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
"SSID, CPU_USAGE, TOTAL_RAM_MEMORY, AVAILABLE_RAM_MEMORY, PLUGGED_IN, UPDATE_TIMESTAMP, ENROLMENT_ID) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
stmt.setInt(1, deviceId);
stmt.setString(2, deviceInfo.getDeviceModel());
@ -71,6 +72,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
stmt.setDouble(15, deviceInfo.getAvailableRAMMemory());
stmt.setBoolean(16, deviceInfo.isPluggedIn());
stmt.setLong(17, System.currentTimeMillis());
stmt.setInt(18, enrolmentId);
stmt.execute();
@ -83,7 +85,8 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
}
@Override
public void addDeviceProperties(Map<String, String> propertyMap, int deviceId) throws DeviceDetailsMgtDAOException {
public void addDeviceProperties(Map<String, String> propertyMap, int deviceId, int enrolmentId)
throws DeviceDetailsMgtDAOException {
if (propertyMap.isEmpty()) {
if(log.isDebugEnabled()) {
@ -95,12 +98,14 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
PreparedStatement stmt = null;
try {
conn = this.getConnection();
stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_INFO (DEVICE_ID, KEY_FIELD, VALUE_FIELD) VALUES (?, ?, ?)");
stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_INFO (DEVICE_ID, KEY_FIELD, VALUE_FIELD, ENROLMENT_ID) " +
"VALUES (?, ?, ?, ?)");
for (Map.Entry<String, String> entry : propertyMap.entrySet()) {
stmt.setInt(1, deviceId);
stmt.setString(2, entry.getKey());
stmt.setString(3, entry.getValue());
stmt.setInt(4, enrolmentId);
stmt.addBatch();
}
stmt.executeBatch();
@ -113,7 +118,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
}
@Override
public DeviceInfo getDeviceInformation(int deviceId) throws DeviceDetailsMgtDAOException {
public DeviceInfo getDeviceInformation(int deviceId, int enrolmentId) throws DeviceDetailsMgtDAOException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
@ -121,9 +126,10 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
try {
conn = this.getConnection();
String sql = "SELECT * FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ?";
String sql = "SELECT * FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setInt(2, enrolmentId);
rs = stmt.executeQuery();
if (rs.next()) {
@ -159,7 +165,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
}
@Override
public Map<String, String> getDeviceProperties(int deviceId) throws DeviceDetailsMgtDAOException {
public Map<String, String> getDeviceProperties(int deviceId, int enrolmentId) throws DeviceDetailsMgtDAOException {
Connection conn;
PreparedStatement stmt = null;
@ -167,9 +173,10 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
Map<String, String> map = new HashMap<>();
try {
conn = this.getConnection();
String sql = "SELECT * FROM DM_DEVICE_INFO WHERE DEVICE_ID = ?";
String sql = "SELECT * FROM DM_DEVICE_INFO WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setInt(2, enrolmentId);
rs = stmt.executeQuery();
while (rs.next()) {
@ -184,15 +191,16 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
}
@Override
public void deleteDeviceInformation(int deviceId) throws DeviceDetailsMgtDAOException {
public void deleteDeviceInformation(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String query = "DELETE FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ?";
String query = "DELETE FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(query);
stmt.setInt(1, deviceId);
stmt.setInt(2, enrollmentId);
stmt.executeUpdate();
} catch (SQLException e) {
@ -203,15 +211,16 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
}
@Override
public void deleteDeviceProperties(int deviceId) throws DeviceDetailsMgtDAOException {
public void deleteDeviceProperties(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String query = "DELETE FROM DM_DEVICE_INFO WHERE DEVICE_ID = ?";
String query = "DELETE FROM DM_DEVICE_INFO WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(query);
stmt.setInt(1, deviceId);
stmt.setInt(2, enrollmentId);
stmt.executeUpdate();
} catch (SQLException e) {
@ -222,14 +231,15 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
}
@Override
public void addDeviceLocation(DeviceLocation deviceLocation) throws DeviceDetailsMgtDAOException {
public void addDeviceLocation(DeviceLocation deviceLocation, int enrollmentId) throws DeviceDetailsMgtDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_LOCATION (DEVICE_ID, LATITUDE, LONGITUDE, STREET1, " +
"STREET2, CITY, ZIP, STATE, COUNTRY, GEO_HASH, UPDATE_TIMESTAMP) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)");
"STREET2, CITY, ZIP, STATE, COUNTRY, GEO_HASH, UPDATE_TIMESTAMP, ENROLMENT_ID) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
stmt.setInt(1, deviceLocation.getDeviceId());
stmt.setDouble(2, deviceLocation.getLatitude());
stmt.setDouble(3, deviceLocation.getLongitude());
@ -241,6 +251,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
stmt.setString(9, deviceLocation.getCountry());
stmt.setString(10, GeoHashGenerator.encodeGeohash(deviceLocation));
stmt.setLong(11, System.currentTimeMillis());
stmt.setInt(12, enrollmentId);
stmt.execute();
} catch (SQLException e) {
throw new DeviceDetailsMgtDAOException("Error occurred while adding the device location to database.", e);
@ -250,7 +261,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
}
@Override
public DeviceLocation getDeviceLocation(int deviceId) throws DeviceDetailsMgtDAOException {
public DeviceLocation getDeviceLocation(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException {
Connection conn;
PreparedStatement stmt = null;
@ -258,9 +269,10 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
DeviceLocation location = new DeviceLocation();
try {
conn = this.getConnection();
String sql = "SELECT * FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ?";
String sql = "SELECT * FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setInt(2, enrollmentId);
rs = stmt.executeQuery();
while (rs.next()) {
@ -286,15 +298,16 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
}
@Override
public void deleteDeviceLocation(int deviceId) throws DeviceDetailsMgtDAOException {
public void deleteDeviceLocation(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String query = "DELETE FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ?";
String query = "DELETE FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(query);
stmt.setInt(1, deviceId);
stmt.setInt(2, enrollmentId);
stmt.executeUpdate();
} catch (SQLException e) {

@ -68,12 +68,14 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
DeviceManagementDAOFactory.beginTransaction();
deviceDAO.updateDevice(device, CarbonContext.getThreadLocalCarbonContext().getTenantId());
deviceDetailsDAO.deleteDeviceInformation(device.getId());
deviceDetailsDAO.deleteDeviceProperties(device.getId());
deviceDetailsDAO.addDeviceInformation(device.getId(), deviceInfo);
deviceDetailsDAO.addDeviceProperties(deviceInfo.getDeviceDetailsMap(), device.getId());
deviceDetailsDAO.deleteDeviceInformation(device.getId(), device.getEnrolmentInfo().getId());
deviceDetailsDAO.deleteDeviceProperties(device.getId(), device.getEnrolmentInfo().getId());
deviceDetailsDAO.addDeviceInformation(device.getId(), device.getEnrolmentInfo().getId(), deviceInfo);
deviceDetailsDAO.addDeviceProperties(deviceInfo.getDeviceDetailsMap(), device.getId(),
device.getEnrolmentInfo().getId());
DeviceManagementDAOFactory.commitTransaction();
//TODO :: This has to be fixed by adding the enrollment ID.
if (DeviceManagerUtil.isPublishDeviceInfoResponseEnabled()) {
Object[] metaData = {device.getDeviceIdentifier(), device.getType()};
Object[] payload = new Object[]{
@ -131,8 +133,10 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
}
try {
DeviceManagementDAOFactory.openConnection();
DeviceInfo deviceInfo = deviceDetailsDAO.getDeviceInformation(device.getId());
deviceInfo.setDeviceDetailsMap(deviceDetailsDAO.getDeviceProperties(device.getId()));
DeviceInfo deviceInfo = deviceDetailsDAO.getDeviceInformation(device.getId(),
device.getEnrolmentInfo().getId());
deviceInfo.setDeviceDetailsMap(deviceDetailsDAO.getDeviceProperties(device.getId(),
device.getEnrolmentInfo().getId()));
return deviceInfo;
} catch (SQLException e) {
@ -154,19 +158,21 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
identifierMap.put(identifier.getId(), identifier);
}
try {
List<Integer> deviceIds = new ArrayList<>();
List<Device> deviceIds = new ArrayList<>();
List<Device> devices = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().
getAllDevices(false);
for (Device device : devices) {
if (identifierMap.containsKey(device.getDeviceIdentifier()) &&
device.getType().equals(identifierMap.get(device.getDeviceIdentifier()).getType())) {
deviceIds.add(device.getId());
deviceIds.add(device);
}
}
DeviceManagementDAOFactory.openConnection();
for (Integer id : deviceIds) {
DeviceInfo deviceInfo = deviceDetailsDAO.getDeviceInformation(id);
deviceInfo.setDeviceDetailsMap(deviceDetailsDAO.getDeviceProperties(id));
for (Device device : deviceIds) {
DeviceInfo deviceInfo = deviceDetailsDAO.getDeviceInformation(device.getId(),
device.getEnrolmentInfo().getId());
deviceInfo.setDeviceDetailsMap(deviceDetailsDAO.getDeviceProperties(device.getId(),
device.getEnrolmentInfo().getId()));
deviceInfos.add(deviceInfo);
}
} catch (SQLException e) {
@ -190,8 +196,9 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
deviceLocation.setDeviceId(device.getId());
DeviceManagementDAOFactory.beginTransaction();
deviceDAO.updateDevice(device, CarbonContext.getThreadLocalCarbonContext().getTenantId());
deviceDetailsDAO.deleteDeviceLocation(deviceLocation.getDeviceId());
deviceDetailsDAO.addDeviceLocation(deviceLocation);
deviceDetailsDAO.deleteDeviceLocation(deviceLocation.getDeviceId(), device.getEnrolmentInfo().getId());
deviceDetailsDAO.addDeviceLocation(deviceLocation, device.getEnrolmentInfo().getId());
//TODO: This has to be fixed with enrollment id or username should include in the stream def.
if (DeviceManagerUtil.isPublishLocationResponseEnabled()) {
Object[] metaData = {device.getDeviceIdentifier(), device.getType()};
Object[] payload = new Object[]{
@ -233,7 +240,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
}
try {
DeviceManagementDAOFactory.openConnection();
return deviceDetailsDAO.getDeviceLocation(device.getId());
return deviceDetailsDAO.getDeviceLocation(device.getId(), device.getEnrolmentInfo().getId());
} catch (SQLException e) {
throw new DeviceDetailsMgtException("SQL error occurred while retrieving device from database.", e);
} catch (DeviceDetailsMgtDAOException e) {
@ -270,7 +277,8 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
List<DeviceLocation> deviceLocations = new ArrayList<>();
DeviceManagementDAOFactory.openConnection();
for (Device device : devices) {
deviceLocations.add(deviceDetailsDAO.getDeviceLocation(device.getId()));
deviceLocations.add(deviceDetailsDAO.getDeviceLocation(device.getId(),
device.getEnrolmentInfo().getId()));
}
return deviceLocations;
} catch (DeviceManagementException e) {

@ -41,8 +41,10 @@ import org.wso2.carbon.device.mgt.common.geo.service.Alert;
import org.wso2.carbon.device.mgt.common.geo.service.GeoFence;
import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService;
import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationBasedServiceException;
import org.wso2.carbon.device.mgt.common.geo.service.AlertAlreadyExistException;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub;
import org.wso2.carbon.event.processor.stub.types.ExecutionPlanConfigurationDto;
import org.wso2.carbon.identity.jwt.client.extension.JWTClient;
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;
import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService;
@ -207,18 +209,18 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
@Override
public boolean createGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType)
throws GeoLocationBasedServiceException {
throws GeoLocationBasedServiceException, AlertAlreadyExistException {
return saveGeoAlert(alert, identifier, alertType, false);
}
@Override
public boolean updateGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType)
throws GeoLocationBasedServiceException {
throws GeoLocationBasedServiceException, AlertAlreadyExistException {
return saveGeoAlert(alert, identifier, alertType, true);
}
public boolean saveGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType, boolean isUpdate)
throws GeoLocationBasedServiceException {
throws GeoLocationBasedServiceException, AlertAlreadyExistException {
Type type = new TypeToken<Map<String, String>>() {
}.getType();
@ -260,23 +262,38 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
"Unrecognized execution plan type: " + alertType + " while creating geo alert");
}
//persist alert in registry
updateRegistry(getRegistryPath(alertType, identifier, alert.getQueryName()), identifier, content,
options);
//deploy alert into event processor
EventProcessorAdminServiceStub eventprocessorStub = null;
String action = (isUpdate ? "updating" : "creating");
try {
ExecutionPlanConfigurationDto[] allActiveExecutionPlanConfigs = null;
String activeExecutionPlan = null;
String executionPlanName = getExecutionPlanName(alertType, alert.getQueryName(),
identifier.getId());
eventprocessorStub = getEventProcessorAdminServiceStub();
String parsedTemplate = parseTemplate(alertType, parseMap);
String validationResponse = eventprocessorStub.validateExecutionPlan(parsedTemplate);
if (validationResponse.equals("success")) {
allActiveExecutionPlanConfigs = eventprocessorStub.getAllActiveExecutionPlanConfigurations();
if (isUpdate) {
String executionPlanName = getExecutionPlanName(alertType, alert.getQueryName(),
identifier.getId());
eventprocessorStub.editActiveExecutionPlan(parsedTemplate, executionPlanName);
for (ExecutionPlanConfigurationDto activeExectionPlanConfig:allActiveExecutionPlanConfigs) {
activeExecutionPlan = activeExectionPlanConfig.getExecutionPlan();
if (activeExecutionPlan.contains(executionPlanName)) {
eventprocessorStub.editActiveExecutionPlan(parsedTemplate, executionPlanName);
return true;
}
}
eventprocessorStub.deployExecutionPlan(parsedTemplate);
} else {
for (ExecutionPlanConfigurationDto activeExectionPlanConfig:allActiveExecutionPlanConfigs) {
activeExecutionPlan = activeExectionPlanConfig.getExecutionPlan();
if (activeExecutionPlan.contains(executionPlanName)) {
throw new AlertAlreadyExistException("Execution plan already exists with name "
+ executionPlanName);
}
}
updateRegistry(getRegistryPath(alertType, identifier, alert.getQueryName()), identifier, content,
options);
eventprocessorStub.deployExecutionPlan(parsedTemplate);
}
} else {
@ -344,6 +361,8 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
private String getExecutionPlanName(String alertType, String queryName, String deviceId) {
if ("Traffic".equals(alertType)) {
return "Geo-ExecutionPlan-Traffic_" + queryName + "_alert";
} else if ("Speed".equals(alertType)) {
return "Geo-ExecutionPlan-" + alertType + "---" + deviceId + "_alert";
} else {
return "Geo-ExecutionPlan-" + alertType + "_" + queryName + "---_" + deviceId + "_alert";
}

@ -29,6 +29,7 @@ import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import org.wso2.carbon.device.mgt.core.dto.DeviceTypeServiceIdentifier;
import org.wso2.carbon.device.mgt.core.privacy.PrivacyComplianceProvider;
import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
@ -67,6 +68,7 @@ public class DeviceManagementDataHolder {
private DeviceTaskManagerService deviceTaskManagerService;
private DeviceStatusTaskManagerService deviceStatusTaskManagerService;
private DeviceTypeGeneratorService deviceTypeGeneratorService;
private PrivacyComplianceProvider privacyComplianceProvider;
private Map<DeviceType, DeviceStatusTaskPluginConfig> deviceStatusTaskPluginConfigs = Collections.synchronizedMap(
new HashMap<DeviceType, DeviceStatusTaskPluginConfig>());
@ -266,4 +268,12 @@ public class DeviceManagementDataHolder {
DeviceTypeGeneratorService deviceTypeGeneratorService) {
this.deviceTypeGeneratorService = deviceTypeGeneratorService;
}
public PrivacyComplianceProvider getPrivacyComplianceProvider() {
return privacyComplianceProvider;
}
public void setPrivacyComplianceProvider(PrivacyComplianceProvider privacyComplianceProvider) {
this.privacyComplianceProvider = privacyComplianceProvider;
}
}

@ -51,6 +51,8 @@ import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationManageme
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.permission.mgt.PermissionManagerServiceImpl;
import org.wso2.carbon.device.mgt.core.privacy.PrivacyComplianceProvider;
import org.wso2.carbon.device.mgt.core.privacy.impl.PrivacyComplianceProviderImpl;
import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository;
import org.wso2.carbon.device.mgt.core.push.notification.mgt.task.PushNotificationSchedulerTask;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
@ -225,6 +227,12 @@ public class DeviceManagementServiceComponent {
.getPushNotificationConfiguration().getSchedulerTaskInitialDelay(), config
.getPushNotificationConfiguration().getSchedulerBatchDelayMills(), TimeUnit.MILLISECONDS);
}
PrivacyComplianceProvider privacyComplianceProvider = new PrivacyComplianceProviderImpl();
DeviceManagementDataHolder.getInstance().setPrivacyComplianceProvider(privacyComplianceProvider);
componentContext.getBundleContext().registerService(PrivacyComplianceProvider.class.getName(),
privacyComplianceProvider, null);
if (log.isDebugEnabled()) {
log.debug("Device management core bundle has been successfully initialized");
}

@ -0,0 +1,32 @@
/*
* Copyright (c) 2018, 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.device.mgt.core.privacy;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.PrivacyComplianceException;
public interface PrivacyComplianceProvider {
void deleteDevicesOfUser(String username) throws PrivacyComplianceException;
void deleteDeviceDetails(DeviceIdentifier deviceIdentifier) throws PrivacyComplianceException;
}

@ -0,0 +1,50 @@
/*
* Copyright (c) 2018, 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.device.mgt.core.privacy.dao;
import org.wso2.carbon.device.mgt.core.privacy.impl.DeviceEnrollmentMapping;
import java.util.List;
public interface PrivacyComplianceDAO {
List<DeviceEnrollmentMapping> getDevicesOfUser(String username, int tenantId) throws PrivacyComplianceDAOException;
void deleteDevice(int deviceId, int tenantId) throws PrivacyComplianceDAOException;
void deleteDeviceEnrollments(int deviceId, int tenantId) throws PrivacyComplianceDAOException;
void deleteDeviceEnrollments(int deviceId, int enrolmentId, int tenantId) throws PrivacyComplianceDAOException;
void deleteDeviceDetails(int deviceId, int enrolmentId) throws PrivacyComplianceDAOException;
void deleteDeviceApplications(int deviceId, int enrolmentId, int tenantId) throws PrivacyComplianceDAOException;
void deleteDeviceProperties(int deviceId, int enrolmentId, int tenantId) throws PrivacyComplianceDAOException;
void deleteDeviceLocation(int deviceId, int enrolmentId) throws PrivacyComplianceDAOException;
void updateDeviceOperationResponses(int enrolmentId) throws PrivacyComplianceDAOException;
void deleteDeviceOperationDetails(int enrolmentId) throws PrivacyComplianceDAOException;
void deleteOperationEnrolmentMappings(int enrolmentId) throws PrivacyComplianceDAOException;
}

@ -0,0 +1,46 @@
/*
* Copyright (c) 2018, 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.device.mgt.core.privacy.dao;
public class PrivacyComplianceDAOException extends Exception {
private static final long serialVersionUID = -3127931192903344297L;
public PrivacyComplianceDAOException(String msg, Exception nestedEx) {
super(msg, nestedEx);
}
public PrivacyComplianceDAOException(String message, Throwable cause) {
super(message, cause);
}
public PrivacyComplianceDAOException(String msg) {
super(msg);
}
public PrivacyComplianceDAOException() {
super();
}
public PrivacyComplianceDAOException(Throwable cause) {
super(cause);
}
}

@ -0,0 +1,280 @@
/*
* Copyright (c) 2018, 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.device.mgt.core.privacy.dao.impl;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.core.privacy.dao.PrivacyComplianceDAO;
import org.wso2.carbon.device.mgt.core.privacy.dao.PrivacyComplianceDAOException;
import org.wso2.carbon.device.mgt.core.privacy.impl.DeviceEnrollmentMapping;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class PrivacyComplianceDAOImpl implements PrivacyComplianceDAO {
@Override
public List<DeviceEnrollmentMapping> getDevicesOfUser(String username, int tenantId) throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
List<DeviceEnrollmentMapping> deviceIds = new ArrayList<>();
try {
conn = this.getConnection();
String sql = "SELECT * FROM DM_ENROLMENT WHERE OWNER = ? AND TENANT_ID = ? ORDER BY DEVICE_ID";
stmt = conn.prepareStatement(sql);
stmt.setString(1, username);
stmt.setInt(2, tenantId);
stmt.executeUpdate();
while (rs.next()) {
DeviceEnrollmentMapping mapping = new DeviceEnrollmentMapping();
mapping.setDeviceId(rs.getInt("DEVICE_ID"));
mapping.setEnrolmentId(rs.getInt("ENROLMENT_ID"));
deviceIds.add(mapping);
}
if (deviceIds.isEmpty()) {
return null;
}
return deviceIds;
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while retrieving device ids " +
"related to the given user.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
}
@Override
public void deleteDevice(int deviceId, int tenantId) throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "DELETE FROM DM_DEVICE WHERE ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setInt(2, tenantId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the devices", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void deleteDeviceEnrollments(int deviceId, int tenantId) throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "DELETE FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setInt(2, tenantId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the device enrolments", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void deleteDeviceEnrollments(int deviceId, int enrolmentId, int tenantId)
throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "DELETE FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND TENANT_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setInt(2, tenantId);
stmt.setInt(3, enrolmentId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the device enrolments", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void deleteDeviceDetails(int deviceId, int enrolmentId) throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "DELETE FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setInt(2, enrolmentId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the device details.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void deleteDeviceApplications(int deviceId, int enrolmentId, int tenantId)
throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID = ? " +
"AND ENROLMENT_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setInt(2, enrolmentId);
stmt.setInt(3, tenantId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the device applications.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void deleteDeviceProperties(int deviceId, int enrolmentId, int tenantId)
throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "DELETE FROM DM_DEVICE_INFO WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setInt(2, enrolmentId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the device information.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void deleteDeviceLocation(int deviceId, int enrolmentId) throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "DELETE FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setInt(2, enrolmentId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the device location.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void updateDeviceOperationResponses(int enrolmentId) throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "UPDATE DM_DEVICE_OPERATION_RESPONSE SET OPERATION_RESPONSE = ? WHERE ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setNull(1, java.sql.Types.BLOB);
stmt.setInt(2, enrolmentId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the device information.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void deleteDeviceOperationDetails(int enrolmentId) throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "DELETE FROM DM_DEVICE_OPERATION_RESPONSE WHERE ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, enrolmentId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the device information.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void deleteOperationEnrolmentMappings(int enrolmentId) throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "DELETE FROM DM_ENROLMENT_OP_MAPPING WHERE ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, enrolmentId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the device information.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
private Connection getConnection() throws SQLException {
return DeviceManagementDAOFactory.getConnection();
}
}

@ -0,0 +1,63 @@
/*
* Copyright (c) 2018, 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.device.mgt.core.privacy.impl;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
public class DeviceEnrollmentMapping {
private int deviceId;
private int enrolmentId;
private DeviceIdentifier deviceIdentifier;
private int tenantId;
public int getDeviceId() {
return deviceId;
}
public void setDeviceId(int deviceId) {
this.deviceId = deviceId;
}
public int getEnrolmentId() {
return enrolmentId;
}
public void setEnrolmentId(int enrolmentId) {
this.enrolmentId = enrolmentId;
}
public DeviceIdentifier getDeviceIdentifier() {
return deviceIdentifier;
}
public void setDeviceIdentifier(DeviceIdentifier deviceIdentifier) {
this.deviceIdentifier = deviceIdentifier;
}
public int getTenantId() {
return tenantId;
}
public void setTenantId(int tenantId) {
this.tenantId = tenantId;
}
}

@ -0,0 +1,146 @@
/*
* Copyright (c) 2018, 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.device.mgt.core.privacy.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;
import org.wso2.carbon.device.mgt.common.PrivacyComplianceException;
import org.wso2.carbon.device.mgt.common.TransactionManagementException;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.privacy.PrivacyComplianceProvider;
import org.wso2.carbon.device.mgt.core.privacy.dao.PrivacyComplianceDAO;
import org.wso2.carbon.device.mgt.core.privacy.dao.PrivacyComplianceDAOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PrivacyComplianceProviderImpl implements PrivacyComplianceProvider {
private static final Log log = LogFactory.getLog(PrivacyComplianceProviderImpl.class);
PrivacyComplianceDAO complianceDAO;
public PrivacyComplianceProviderImpl() {
complianceDAO = DeviceManagementDAOFactory.getPrivacyComplianceDAO();
}
@Override
public void deleteDevicesOfUser(String username) throws PrivacyComplianceException {
if (log.isDebugEnabled()) {
log.debug("Deleting the requested users.");
}
try {
DeviceManagementDAOFactory.beginTransaction();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
List<DeviceEnrollmentMapping> enrollmentMappings = complianceDAO.getDevicesOfUser(username, tenantId);
Map<Integer, List<Integer>> deviceMap = new HashMap<>();
int x = -1;
for (DeviceEnrollmentMapping m : enrollmentMappings) {
if (m.getDeviceId() != x) {
x = m.getDeviceId();
List<Integer> enrolments = new ArrayList<>();
enrolments.add(m.getEnrolmentId());
deviceMap.put(m.getDeviceId(), enrolments);
} else {
deviceMap.get(m.getDeviceId()).add(m.getEnrolmentId());
}
}
for (int deviceId : deviceMap.keySet()) {
List<Integer> enrollmentIds = deviceMap.get(deviceId);
for (Integer enrolmentId : enrollmentIds) {
complianceDAO.deleteDeviceOperationDetails(enrolmentId);
complianceDAO.deleteOperationEnrolmentMappings(enrolmentId);
complianceDAO.deleteDeviceApplications(deviceId, enrolmentId, tenantId);
complianceDAO.deleteDeviceDetails(deviceId, enrolmentId);
complianceDAO.deleteDeviceProperties(deviceId, enrolmentId, tenantId);
complianceDAO.deleteDeviceLocation(deviceId, enrolmentId);
complianceDAO.deleteDeviceEnrollments(deviceId, enrolmentId);
}
complianceDAO.deleteDevice(deviceId, tenantId);
}
DeviceManagementDAOFactory.commitTransaction();
} catch (PrivacyComplianceDAOException e) {
DeviceManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred while deleting the devices and details of the given user";
log.error(msg, e);
throw new PrivacyComplianceException(msg, e);
} catch (TransactionManagementException e) {
DeviceManagementDAOFactory.rollbackTransaction();
String msg = "Database error occurred while deleting the devices and details of the given user";
log.error(msg, e);
throw new PrivacyComplianceException(msg, e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
log.info("Requested users device has been successfully removed..!");
}
@Override
public void deleteDeviceDetails(DeviceIdentifier deviceIdentifier) throws PrivacyComplianceException {
if (log.isDebugEnabled()) {
log.debug("Deleting the requested device details.");
}
try {
Device device = this.getDevice(deviceIdentifier);
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
DeviceManagementDAOFactory.beginTransaction();
complianceDAO.deleteDeviceOperationDetails(device.getEnrolmentInfo().getId());
complianceDAO.deleteOperationEnrolmentMappings(device.getEnrolmentInfo().getId());
complianceDAO.deleteDeviceApplications(device.getId(), device.getEnrolmentInfo().getId(), tenantId);
complianceDAO.deleteDeviceDetails(device.getId(), device.getEnrolmentInfo().getId());
complianceDAO.deleteDeviceProperties(device.getId(), device.getEnrolmentInfo().getId(), tenantId);
complianceDAO.deleteDeviceLocation(device.getId(), device.getEnrolmentInfo().getId());
DeviceManagementDAOFactory.commitTransaction();
} catch (TransactionManagementException e) {
DeviceManagementDAOFactory.rollbackTransaction();
String msg = "Database error occurred while deleting the device details.";
log.error(msg, e);
throw new PrivacyComplianceException(msg, e);
} catch (PrivacyComplianceDAOException e) {
DeviceManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred while deleting the device details.";
log.error(msg, e);
throw new PrivacyComplianceException(msg, e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
}
private Device getDevice(DeviceIdentifier deviceId) throws PrivacyComplianceException {
try {
return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceId, false);
} catch (DeviceManagementException e) {
throw new PrivacyComplianceException(
"Error occurred while retrieving device info.", e);
}
}
}

@ -236,7 +236,8 @@ public class ProcessorImpl implements Processor {
try {
DeviceManagementDAOFactory.openConnection();
for (Device device : devices) {
device.setApplications(applicationDAO.getInstalledApplications(device.getId()));
device.setApplications(applicationDAO.getInstalledApplications(device.getId(),
device.getEnrolmentInfo().getId()));
}
} catch (DeviceManagementDAOException e) {
throw new SearchMgtException("Error occurred while fetching the Application List of devices ", e);

@ -2475,8 +2475,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
DeviceInfo info = null;
try {
DeviceManagementDAOFactory.openConnection();
info = deviceInfoDAO.getDeviceInformation(device.getId());
DeviceLocation location = deviceInfoDAO.getDeviceLocation(device.getId());
info = deviceInfoDAO.getDeviceInformation(device.getId(), device.getEnrolmentInfo().getId());
DeviceLocation location = deviceInfoDAO.getDeviceLocation(device.getId(),
device.getEnrolmentInfo().getId());
if (location != null) {
//There are some cases where the device-info is not updated properly. Hence returning a null value.
if (info != null) {
@ -2507,23 +2508,28 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
/**
* Returns all the installed apps of the given device.
*/
private List<Application> getInstalledApplications(Device device) {
private List<Application> getInstalledApplications(Device device) throws DeviceManagementException {
if (log.isDebugEnabled()) {
log.debug("Get installed applications of device: " + device.getId() + " of type '" + device.getType() + "'");
}
List<Application> applications = new ArrayList<>();
try {
DeviceManagementDAOFactory.openConnection();
applications = applicationDAO.getInstalledApplications(device.getId());
applications = applicationDAO.getInstalledApplications(device.getId(), device.getEnrolmentInfo().getId());
device.setApplications(applications);
} catch (DeviceManagementDAOException e) {
log.error("Error occurred while retrieving the application list of '" + device.getType() + "', " +
"which carries the id '" + device.getId() + "'", e);
String msg = "Error occurred while retrieving the application list of '" + device.getType() + "', " +
"which carries the id '" + device.getId() + "'";
log.error(msg, e);
throw new DeviceManagementException(msg, e);
} catch (SQLException e) {
log.error("Error occurred while opening a connection to the data source", e);
String msg = "Error occurred while opening a connection to the data source";
log.error(msg, e);
throw new DeviceManagementException(msg, e);
} catch (Exception e) {
String msg = "Error occurred in getInstalledApplications";
log.error(msg, e);
throw new DeviceManagementException(msg, e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}

@ -19,6 +19,7 @@
package org.wso2.carbon.device.mgt.core.geo.service;
import org.apache.axis2.AxisFault;
import org.mockito.Mockito;
import org.testng.Assert;
@ -31,11 +32,13 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.geo.service.Alert;
import org.wso2.carbon.device.mgt.common.geo.service.GeoFence;
import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationBasedServiceException;
import org.wso2.carbon.device.mgt.common.geo.service.AlertAlreadyExistException;
import org.wso2.carbon.device.mgt.core.TestDeviceManagementService;
import org.wso2.carbon.device.mgt.core.common.TestDataHolder;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub;
import org.wso2.carbon.event.processor.stub.types.ExecutionPlanConfigurationDto;
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
@ -57,6 +60,7 @@ public class GeoLocationProviderServiceTest {
private EventProcessorAdminServiceStub mockEventProcessorAdminServiceStub;
private GeoLocationProviderServiceImpl geoLocationProviderServiceImpl;
private ExecutionPlanConfigurationDto[] mockExecutionPlanConfigurationDto = new ExecutionPlanConfigurationDto[1];
@BeforeClass
public void init() throws Exception {
@ -65,42 +69,42 @@ public class GeoLocationProviderServiceTest {
}
@Test (description = "Create a sample geo exit-alert with relevant details.")
public void createGeoExitAlert() throws GeoLocationBasedServiceException {
public void createGeoExitAlert() throws GeoLocationBasedServiceException, AlertAlreadyExistException {
Boolean result = geoLocationProviderServiceImpl.
createGeoAlert(getExitAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_EXIT);
Assert.assertEquals(result, Boolean.TRUE);
}
@Test (description = "Create a sample geo within-alert with relevant details.")
public void createGeoWithinAlert() throws GeoLocationBasedServiceException {
public void createGeoWithinAlert() throws GeoLocationBasedServiceException, AlertAlreadyExistException {
Boolean result = geoLocationProviderServiceImpl.
createGeoAlert(getWithinAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_WITHIN);
Assert.assertEquals(result, Boolean.TRUE);
}
@Test (description = "Create a sample geo proximity-alert with relevant details.")
public void createGeoProximityAlert() throws GeoLocationBasedServiceException {
public void createGeoProximityAlert() throws GeoLocationBasedServiceException, AlertAlreadyExistException {
Boolean result = geoLocationProviderServiceImpl.
createGeoAlert(getProximityAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_PROXIMITY);
Assert.assertEquals(result, Boolean.TRUE);
}
@Test (description = "Create a sample geo speed-alert with relevant details.")
public void createGeoSpeedAlert() throws GeoLocationBasedServiceException {
public void createGeoSpeedAlert() throws GeoLocationBasedServiceException, AlertAlreadyExistException {
Boolean result = geoLocationProviderServiceImpl.
createGeoAlert(getSpeedAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_SPEED);
Assert.assertEquals(result, Boolean.TRUE);
}
@Test (description = "Create a sample geo stationary-alert with relevant details.")
public void createGeoStationaryAlert() throws GeoLocationBasedServiceException {
public void createGeoStationaryAlert() throws GeoLocationBasedServiceException, AlertAlreadyExistException {
Boolean result = geoLocationProviderServiceImpl.
createGeoAlert(getStationaryAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_STATIONARY);
Assert.assertEquals(result, Boolean.TRUE);
}
@Test (description = "Create a sample geo traffic-alert with relevant details.")
public void createGeoTrafficAlert() throws GeoLocationBasedServiceException {
public void createGeoTrafficAlert() throws GeoLocationBasedServiceException, AlertAlreadyExistException {
Boolean result = geoLocationProviderServiceImpl.
createGeoAlert(getTrafficAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_TRAFFIC);
Assert.assertEquals(result, Boolean.TRUE);
@ -139,10 +143,14 @@ public class GeoLocationProviderServiceTest {
private void initMocks() throws JWTClientException, RemoteException {
mockEventProcessorAdminServiceStub = Mockito.mock(EventProcessorAdminServiceStub.class);
geoLocationProviderServiceImpl = Mockito.mock(GeoLocationProviderServiceImpl.class, Mockito.CALLS_REAL_METHODS);
mockExecutionPlanConfigurationDto[0] = Mockito.mock(ExecutionPlanConfigurationDto.class);
Mockito.doReturn(mockEventProcessorAdminServiceStub).
when(geoLocationProviderServiceImpl).getEventProcessorAdminServiceStub();
Mockito.doReturn("success").
when(mockEventProcessorAdminServiceStub).validateExecutionPlan(Mockito.anyString());
Mockito.when(mockEventProcessorAdminServiceStub.getAllActiveExecutionPlanConfigurations()).
thenReturn(mockExecutionPlanConfigurationDto);
Mockito.when(mockExecutionPlanConfigurationDto[0].getExecutionPlan()).thenReturn("EXECUTION_PLAN");
}
private DeviceIdentifier getDeviceIdentifier() {

@ -506,7 +506,8 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
//Device details table will be reffered when looking for last updated time
//This dao entry is to mimic a device info operation
deviceDetailsDAO.addDeviceInformation(initialDevice.getId(), TestDataHolder
deviceDetailsDAO.addDeviceInformation(initialDevice.getId(), initialDevice.getEnrolmentInfo().getId(),
TestDataHolder
.generateDummyDeviceInfo());
DeviceManagementDAOFactory.closeConnection();

@ -301,7 +301,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES (
POLICY_CRITERION_ID INT NOT NULL,
PROP_KEY VARCHAR(45) NULL,
PROP_VALUE VARCHAR(100) NULL,
CONTENT BLOB NULL COMMENT 'This is used to ',
CONTENT BLOB NULL,
PRIMARY KEY (ID),
CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES
FOREIGN KEY (POLICY_CRITERION_ID)
@ -363,19 +363,32 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
PRIMARY KEY (ID)
);
CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
ID INTEGER AUTO_INCREMENT NOT NULL,
DEVICE_ID INTEGER NOT NULL,
ENROLMENT_ID INTEGER NOT NULL,
APPLICATION_ID INTEGER NOT NULL,
APP_PROPERTIES BLOB NULL,
MEMORY_USAGE INTEGER(10) NULL,
IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT fk_dm_application FOREIGN KEY (APPLICATION_ID) REFERENCES
DM_APPLICATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
CONSTRAINT fk_dm_device
FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT fk_dm_application
FOREIGN KEY (APPLICATION_ID)
REFERENCES DM_APPLICATION (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT FK_DM_APP_MAP_DM_ENROL
FOREIGN KEY (ENROLMENT_ID)
REFERENCES DM_ENROLMENT (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);
-- POLICY RELATED TABLES FINISHED --
@ -400,6 +413,7 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
ID INTEGER AUTO_INCREMENT NOT NULL,
DEVICE_ID INT NULL,
ENROLMENT_ID INT NOT NULL,
KEY_FIELD VARCHAR(45) NULL,
VALUE_FIELD VARCHAR(100) NULL,
PRIMARY KEY (ID),
@ -407,12 +421,18 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT DM_DEVICE_INFO_DEVICE_ENROLLMENT
FOREIGN KEY (ENROLMENT_ID)
REFERENCES DM_ENROLMENT (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
ID INTEGER AUTO_INCREMENT NOT NULL,
DEVICE_ID INT NULL,
ENROLMENT_ID INT NOT NULL,
LATITUDE DOUBLE NULL,
LONGITUDE DOUBLE NULL,
STREET1 VARCHAR(255) NULL,
@ -428,14 +448,19 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT DM_DEVICE_LOCATION_DM_ENROLLMENT
FOREIGN KEY (ENROLMENT_ID)
REFERENCES DM_ENROLMENT (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);
CREATE INDEX DM_DEVICE_LOCATION_GEO_hashx ON DM_DEVICE_LOCATION(GEO_HASH ASC);
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
ID INT NOT NULL AUTO_INCREMENT,
DEVICE_ID INT NOT NULL,
ENROLMENT_ID INT NOT NULL,
DEVICE_MODEL VARCHAR(45) NULL,
VENDOR VARCHAR(45) NULL,
OS_VERSION VARCHAR(45) NULL,
@ -457,6 +482,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT FK_DM_ENROLMENT_DEVICE_DETAILS
FOREIGN KEY (ENROLMENT_ID)
REFERENCES DM_ENROLMENT (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);

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

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

@ -59,6 +59,13 @@
class="form-control" placeholder="Confirm Password"/>
</div>
<div class="alert alert-warning" style="border-radius:5px"><p class="doc-link">
This site uses cookies. By logging in to the site, you are agreeing on the usage of cookies. For more information, refer <a href="{{@unit.publicUri}}/privacy-policies/cookie-policy" style="color:#ffffff;"
target="_blank"><u>cookie policy</u></a> and
<a href="{{@unit.publicUri}}/privacy-policies/privacy-policy" style="color:#ffffff;"
target="_blank"><u>privacy policy</u></a></p>
</div>
<div class="wr-input-control">
<button class="wr-btn" id="add-user-btn">Register</button>
<button class="wr-btn" onclick="document.location.href='{{@app.context}}/login';">

@ -23,7 +23,7 @@
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4 col-sm-offset-3 col-md-offset-3 col-lg-offset-4">
<p class="page-sub-title">Login</p>
<hr />
<hr/>
{{#if message}}
<div class="alert alert-danger" style="padding-right: 15px;">
<i class="icon fw fw-warning"></i> {{message}}!
@ -35,19 +35,27 @@
<div class="form-group">
<label for="username">Username *</label>
<input type="text" name="username" class="form-control" placeholder="Enter your username"
autofocus="autofocus" required="required" />
autofocus="autofocus" required="required"/>
</div>
<div class="form-group">
<label for="password">Password *</label>
<input type="password" name="password" class="form-control" autocomplete="off"
placeholder="Enter your password" required="required" />
placeholder="Enter your password" required="required"/>
</div>
{{#if sessionDataKey}}
<input type="hidden" name="sessionDataKey" value="{{sessionDataKey}}" />
<input type="hidden" name="sessionDataKey" value="{{sessionDataKey}}"/>
{{/if}}
{{#if referer}}
<input type="hidden" name="referer" value="{{referer}}" />
<input type="hidden" name="referer" value="{{referer}}"/>
{{/if}}
<div class="alert alert-warning" style="border-radius:5px"><p class="doc-link">
This site uses cookies. By logging in to the site, you are agreeing on the usage of cookies. For more information, refer <a href="{{@unit.publicUri}}/privacy-policies/cookie-policy" style="color:#ffffff;"
target="_blank"><u>cookie policy</u></a> and
<a href="{{@unit.publicUri}}/privacy-policies/privacy-policy" style="color:#ffffff;"
target="_blank"><u>privacy policy</u></a></p>
</div>
<div class="wr-input-control wr-btn-grp">
<button class="wr-btn btn-download-agent">
Log in

@ -17,7 +17,6 @@
*/
function onRequest(context) {
var log = new Log("geo-dashboard.js");
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var viewModel = {};
@ -41,14 +40,14 @@ function onRequest(context) {
wsEndpoint = devicemgtProps["wssURL"].replace("https", "wss") + "/secured-websocket/";
}
} else {
tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username + "@" + context.user.domain,"default", {});
tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username + "@" +
context.user.domain, "default", {});
if (tokenPair) {
token = tokenPair.accessToken;
wsEndpoint = devicemgtProps["wssURL"].replace("https", "wss") + "/secured-websocket/t/"+context.user.domain+"/";
wsEndpoint = devicemgtProps["wssURL"].replace("https", "wss") + "/secured-websocket/t/" +
context.user.domain + "/";
}
}
}
viewModel.device = device;
viewModel.wsToken = token;

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

Loading…
Cancel
Save