mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge branch 'merge-master' of https://github.com/geethkokila/carbon-device-mgt into release-2.0.x
This commit is contained in:
commit
78dfddbbed
@ -359,7 +359,7 @@ public class AnnotationProcessor {
|
|||||||
* @param servletContext
|
* @param servletContext
|
||||||
* @return null if cannot determin /WEB-INF/classes
|
* @return null if cannot determin /WEB-INF/classes
|
||||||
*/
|
*/
|
||||||
public static URL findWebInfClassesPath(ServletContext servletContext)
|
private static URL findWebInfClassesPath(ServletContext servletContext)
|
||||||
{
|
{
|
||||||
String path = servletContext.getRealPath("/WEB-INF/classes");
|
String path = servletContext.getRealPath("/WEB-INF/classes");
|
||||||
if (path == null) return null;
|
if (path == null) return null;
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
public class ExtendedFileProtocolIteratorFactory implements DirectoryIteratorFactory {
|
class ExtendedFileProtocolIteratorFactory implements DirectoryIteratorFactory {
|
||||||
|
|
||||||
private static final String ENCODING_SCHEME = "UTF-8";
|
private static final String ENCODING_SCHEME = "UTF-8";
|
||||||
|
|
||||||
|
|||||||
@ -25,11 +25,11 @@ import java.io.IOException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class ExtendedIteratorFactory {
|
class ExtendedIteratorFactory {
|
||||||
|
|
||||||
private static final ConcurrentHashMap<String, DirectoryIteratorFactory> registry = new ConcurrentHashMap();
|
private static final ConcurrentHashMap<String, DirectoryIteratorFactory> registry = new ConcurrentHashMap();
|
||||||
|
|
||||||
public static StreamIterator create(URL url, Filter filter) throws IOException {
|
static StreamIterator create(URL url, Filter filter) throws IOException {
|
||||||
String urlString = url.toString();
|
String urlString = url.toString();
|
||||||
if(urlString.endsWith("!/")) {
|
if(urlString.endsWith("!/")) {
|
||||||
urlString = urlString.substring(4);
|
urlString = urlString.substring(4);
|
||||||
|
|||||||
@ -50,14 +50,16 @@
|
|||||||
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||||
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
|
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
|
||||||
<Bundle-Description>Device Management Core Bundle</Bundle-Description>
|
<Bundle-Description>Device Management Core Bundle</Bundle-Description>
|
||||||
<Private-Package>org.wso2.carbon.certificate.mgt.core.internal</Private-Package>
|
<Private-Package>
|
||||||
|
org.wso2.carbon.certificate.mgt.core.internal
|
||||||
|
</Private-Package>
|
||||||
<Import-Package>
|
<Import-Package>
|
||||||
org.osgi.framework,
|
org.osgi.framework,
|
||||||
org.osgi.service.component,
|
org.osgi.service.component,
|
||||||
org.apache.commons.logging,
|
org.apache.commons.logging,
|
||||||
javax.security.auth.x500,
|
javax.security.auth.x500,
|
||||||
javax.xml.*,
|
javax.xml.*,
|
||||||
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
|
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
|
||||||
org.apache.commons.codec.binary,
|
org.apache.commons.codec.binary,
|
||||||
org.bouncycastle.asn1,
|
org.bouncycastle.asn1,
|
||||||
org.bouncycastle.asn1.x500,
|
org.bouncycastle.asn1.x500,
|
||||||
|
|||||||
@ -526,61 +526,61 @@ public class CertificateGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PrivateKey getSignerKey(String signerPrivateKeyPath) throws KeystoreException {
|
// private PrivateKey getSignerKey(String signerPrivateKeyPath) throws KeystoreException {
|
||||||
|
//
|
||||||
File file = new File(signerPrivateKeyPath);
|
// File file = new File(signerPrivateKeyPath);
|
||||||
FileInputStream fis;
|
// FileInputStream fis;
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
fis = new FileInputStream(file);
|
// fis = new FileInputStream(file);
|
||||||
DataInputStream dis = new DataInputStream(fis);
|
// DataInputStream dis = new DataInputStream(fis);
|
||||||
byte[] keyBytes = new byte[(int) file.length()];
|
// byte[] keyBytes = new byte[(int) file.length()];
|
||||||
dis.readFully(keyBytes);
|
// dis.readFully(keyBytes);
|
||||||
dis.close();
|
// dis.close();
|
||||||
|
//
|
||||||
String temp = new String(keyBytes);
|
// String temp = new String(keyBytes);
|
||||||
String privateKeyPEM = temp.replace(
|
// String privateKeyPEM = temp.replace(
|
||||||
CertificateManagementConstants.RSA_PRIVATE_KEY_BEGIN_TEXT, CertificateManagementConstants.EMPTY_TEXT);
|
// CertificateManagementConstants.RSA_PRIVATE_KEY_BEGIN_TEXT, CertificateManagementConstants.EMPTY_TEXT);
|
||||||
privateKeyPEM = privateKeyPEM
|
// privateKeyPEM = privateKeyPEM
|
||||||
.replace(CertificateManagementConstants.RSA_PRIVATE_KEY_END_TEXT, CertificateManagementConstants.EMPTY_TEXT);
|
// .replace(CertificateManagementConstants.RSA_PRIVATE_KEY_END_TEXT, CertificateManagementConstants.EMPTY_TEXT);
|
||||||
|
//
|
||||||
byte[] decoded = Base64.decodeBase64(privateKeyPEM);
|
// byte[] decoded = Base64.decodeBase64(privateKeyPEM);
|
||||||
PKCS8EncodedKeySpec encodedKeySpec = new PKCS8EncodedKeySpec(decoded);
|
// PKCS8EncodedKeySpec encodedKeySpec = new PKCS8EncodedKeySpec(decoded);
|
||||||
KeyFactory keyFactory = KeyFactory.getInstance(CertificateManagementConstants.RSA);
|
// KeyFactory keyFactory = KeyFactory.getInstance(CertificateManagementConstants.RSA);
|
||||||
|
//
|
||||||
return keyFactory.generatePrivate(encodedKeySpec);
|
// return keyFactory.generatePrivate(encodedKeySpec);
|
||||||
} catch (FileNotFoundException e) {
|
// } catch (FileNotFoundException e) {
|
||||||
String errorMsg = "Private key file not found in getSignerKey";
|
// String errorMsg = "Private key file not found in getSignerKey";
|
||||||
throw new KeystoreException(errorMsg, e);
|
// throw new KeystoreException(errorMsg, e);
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
String errorMsg = "Input output issue in getSignerKey";
|
// String errorMsg = "Input output issue in getSignerKey";
|
||||||
throw new KeystoreException(errorMsg, e);
|
// throw new KeystoreException(errorMsg, e);
|
||||||
} catch (NoSuchAlgorithmException e) {
|
// } catch (NoSuchAlgorithmException e) {
|
||||||
String errorMsg = "Algorithm not not found in getSignerKey";
|
// String errorMsg = "Algorithm not not found in getSignerKey";
|
||||||
throw new KeystoreException(errorMsg, e);
|
// throw new KeystoreException(errorMsg, e);
|
||||||
} catch (InvalidKeySpecException e) {
|
// } catch (InvalidKeySpecException e) {
|
||||||
String errorMsg = "Invalid key found in getSignerKey";
|
// String errorMsg = "Invalid key found in getSignerKey";
|
||||||
throw new KeystoreException(errorMsg, e);
|
// throw new KeystoreException(errorMsg, e);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private X509Certificate getSigner(String signerCertificatePath) throws KeystoreException {
|
// private X509Certificate getSigner(String signerCertificatePath) throws KeystoreException {
|
||||||
|
//
|
||||||
X509Certificate certificate;
|
// X509Certificate certificate;
|
||||||
try {
|
// try {
|
||||||
CertificateFactory certificateFactory = CertificateFactory.getInstance(CertificateManagementConstants.X_509);
|
// CertificateFactory certificateFactory = CertificateFactory.getInstance(CertificateManagementConstants.X_509);
|
||||||
certificate = (X509Certificate) certificateFactory.generateCertificate(
|
// certificate = (X509Certificate) certificateFactory.generateCertificate(
|
||||||
new FileInputStream(signerCertificatePath));
|
// new FileInputStream(signerCertificatePath));
|
||||||
|
//
|
||||||
return certificate;
|
// return certificate;
|
||||||
} catch (CertificateException e) {
|
// } catch (CertificateException e) {
|
||||||
String errorMsg = "Certificate related issue occurred in getSigner";
|
// String errorMsg = "Certificate related issue occurred in getSigner";
|
||||||
throw new KeystoreException(errorMsg, e);
|
// throw new KeystoreException(errorMsg, e);
|
||||||
} catch (FileNotFoundException e) {
|
// } catch (FileNotFoundException e) {
|
||||||
String errorMsg = "Signer certificate path not found in getSigner";
|
// String errorMsg = "Signer certificate path not found in getSigner";
|
||||||
throw new KeystoreException(errorMsg, e);
|
// throw new KeystoreException(errorMsg, e);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public SCEPResponse getCACert() throws KeystoreException {
|
public SCEPResponse getCACert() throws KeystoreException {
|
||||||
|
|
||||||
@ -657,28 +657,28 @@ public class CertificateGenerator {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ASN1Primitive toASN1Primitive(byte[] data) {
|
// private ASN1Primitive toASN1Primitive(byte[] data) {
|
||||||
|
//
|
||||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(data);
|
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(data);
|
||||||
ASN1InputStream inputStream = new ASN1InputStream(byteArrayInputStream);
|
// ASN1InputStream inputStream = new ASN1InputStream(byteArrayInputStream);
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
return inputStream.readObject();
|
// return inputStream.readObject();
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
String errorMsg = "IOException occurred when converting binary array to ASN1Primitive";
|
// String errorMsg = "IOException occurred when converting binary array to ASN1Primitive";
|
||||||
log.error(errorMsg, e);
|
// log.error(errorMsg, e);
|
||||||
} finally {
|
// } finally {
|
||||||
try {
|
// try {
|
||||||
byteArrayInputStream.close();
|
// byteArrayInputStream.close();
|
||||||
inputStream.close();
|
// inputStream.close();
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
String errorMsg = "IOException occurred when closing streams";
|
// String errorMsg = "IOException occurred when closing streams";
|
||||||
log.error(errorMsg, e);
|
// log.error(errorMsg, e);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used to retrieve signed certificate from certificate signing request.
|
* This method is used to retrieve signed certificate from certificate signing request.
|
||||||
|
|||||||
@ -38,7 +38,7 @@ import java.util.List;
|
|||||||
public class GCMNotificationStrategy implements NotificationStrategy {
|
public class GCMNotificationStrategy implements NotificationStrategy {
|
||||||
|
|
||||||
private static final String GCM_TOKEN = "GCM_TOKEN";
|
private static final String GCM_TOKEN = "GCM_TOKEN";
|
||||||
private final static String GCM_ENDPOINT = "https://gcm-http.googleapis.com/gcm/send";
|
private final static String GCM_ENDPOINT = "https://fcm.googleapis.com/fcm/send";
|
||||||
private static final String GCM_API_KEY = "gcmAPIKey";
|
private static final String GCM_API_KEY = "gcmAPIKey";
|
||||||
private static final int TIME_TO_LIVE = 60;
|
private static final int TIME_TO_LIVE = 60;
|
||||||
private static final int HTTP_STATUS_CODE_OK = 200;
|
private static final int HTTP_STATUS_CODE_OK = 200;
|
||||||
@ -84,13 +84,10 @@ public class GCMNotificationStrategy implements NotificationStrategy {
|
|||||||
HttpURLConnection conn = null;
|
HttpURLConnection conn = null;
|
||||||
try {
|
try {
|
||||||
conn = (HttpURLConnection) new URL(GCM_ENDPOINT).openConnection();
|
conn = (HttpURLConnection) new URL(GCM_ENDPOINT).openConnection();
|
||||||
conn.setDoOutput(true);
|
|
||||||
conn.setUseCaches(false);
|
|
||||||
conn.setFixedLengthStreamingMode(bytes.length);
|
|
||||||
conn.setRequestMethod("POST");
|
|
||||||
conn.setRequestProperty("Content-Type", "application/json");
|
conn.setRequestProperty("Content-Type", "application/json");
|
||||||
conn.setRequestProperty("Authorization", "key=" + config.getProperty(GCM_API_KEY));
|
conn.setRequestProperty("Authorization", "key=" + config.getProperty(GCM_API_KEY));
|
||||||
|
conn.setRequestMethod("POST");
|
||||||
|
conn.setDoOutput(true);
|
||||||
os = conn.getOutputStream();
|
os = conn.getOutputStream();
|
||||||
os.write(bytes);
|
os.write(bytes);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@ -27,7 +27,8 @@ public class PasswordResetWrapper {
|
|||||||
/*
|
/*
|
||||||
Base64 encoded password
|
Base64 encoded password
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(name = "newPassword", value = "New password of the user.", required = true )
|
@ApiModelProperty(name = "newPassword", value = "New password of the user.", required = true,
|
||||||
|
example = "JiM&100%pW")
|
||||||
private String newPassword;
|
private String newPassword;
|
||||||
|
|
||||||
public String getNewPassword() {
|
public String getNewPassword() {
|
||||||
|
|||||||
@ -30,7 +30,8 @@ public class PolicyList extends BasePaginatedResult {
|
|||||||
|
|
||||||
private List<Policy> policies;
|
private List<Policy> policies;
|
||||||
|
|
||||||
@ApiModelProperty(value = "List of policies returned")
|
@ApiModelProperty(value = "Returns the list of policies that match the offset and limit parameter values" +
|
||||||
|
" that were specified.")
|
||||||
@JsonProperty("policies")
|
@JsonProperty("policies")
|
||||||
public List<Policy> getList() {
|
public List<Policy> getList() {
|
||||||
return policies;
|
return policies;
|
||||||
|
|||||||
@ -30,23 +30,39 @@ import java.util.List;
|
|||||||
@ApiModel(value = "Profile", description = "This class carries all information related to policy profiles")
|
@ApiModel(value = "Profile", description = "This class carries all information related to policy profiles")
|
||||||
public class Profile {
|
public class Profile {
|
||||||
|
|
||||||
@ApiModelProperty(name = "profileId", value = "The ID of each profile that is in the selected policy",
|
@ApiModelProperty(name = "profileId",
|
||||||
required = true)
|
value = "The ID of each profile that is in the selected policy",
|
||||||
|
required = true,
|
||||||
|
example = "1")
|
||||||
private int profileId;
|
private int profileId;
|
||||||
@ApiModelProperty(name = "profileName", value = "The name of the profile", required = true)
|
@ApiModelProperty(name = "profileName",
|
||||||
|
value = "The name of the profile",
|
||||||
|
required = true,
|
||||||
|
example = "Block Camera")
|
||||||
private String profileName;
|
private String profileName;
|
||||||
@ApiModelProperty(name = "tenantId", value = "The ID of the tenant that added the policy", required = true)
|
@ApiModelProperty(name = "tenantId",
|
||||||
|
value = "The ID of the tenant that added the policy",
|
||||||
|
required = true,
|
||||||
|
example = "-1234")
|
||||||
private int tenantId;
|
private int tenantId;
|
||||||
@ApiModelProperty(name = "deviceType", value = "Contains the device type details the policy was created "
|
@ApiModelProperty(name = "deviceType",
|
||||||
+ "for", required = true)
|
value = "Contains the device type details the policy was created for",
|
||||||
|
required = true,
|
||||||
|
example = "android")
|
||||||
private String deviceType;
|
private String deviceType;
|
||||||
@ApiModelProperty(name = "createdDate", value = "The date the policy was created", required = true)
|
@ApiModelProperty(name = "createdDate",
|
||||||
|
value = "The date the policy was created",
|
||||||
|
required = true,
|
||||||
|
example = "Thu, 6 Oct 2016 14:39:32 +0530")
|
||||||
private Timestamp createdDate;
|
private Timestamp createdDate;
|
||||||
@ApiModelProperty(name = "updatedDate", value = "The date the changes made to the policy was published to"
|
@ApiModelProperty(name = "updatedDate",
|
||||||
+ " the devices registered with the EMM", required = true)
|
value = "The date the changes made to the policy was published to the devices registered with the EMM",
|
||||||
|
required = true,
|
||||||
|
example = "Thu, 6 Oct 2016 14:39:32 +0530")
|
||||||
private Timestamp updatedDate;
|
private Timestamp updatedDate;
|
||||||
@ApiModelProperty(name = "profileFeaturesList", value = "Contains the features specific to each profile "
|
@ApiModelProperty(name = "profileFeaturesList",
|
||||||
+ "in the policy", required = true)
|
value = "Contains the features specific to each profile in the policy",
|
||||||
|
required = true)
|
||||||
private List<ProfileFeature> profileFeaturesList; // Features included in the policies.
|
private List<ProfileFeature> profileFeaturesList; // Features included in the policies.
|
||||||
|
|
||||||
public String getDeviceType() {
|
public String getDeviceType() {
|
||||||
|
|||||||
@ -28,20 +28,33 @@ import java.io.Serializable;
|
|||||||
+ "features")
|
+ "features")
|
||||||
public class ProfileFeature implements Serializable {
|
public class ProfileFeature implements Serializable {
|
||||||
|
|
||||||
@ApiModelProperty(name = "id", value = "Define the ID", required = true)
|
@ApiModelProperty(name = "id",
|
||||||
|
value = "Define the ID",
|
||||||
|
required = true,
|
||||||
|
example = "1")
|
||||||
private int id;
|
private int id;
|
||||||
@ApiModelProperty(name = "featureCode", value = "Provide the code that defines the policy you wish to add",
|
@ApiModelProperty(name = "featureCode",
|
||||||
required = true)
|
value = "Provide the code that defines the policy you wish to add",
|
||||||
|
required = true,
|
||||||
|
example = "CAMERA")
|
||||||
private String featureCode;
|
private String featureCode;
|
||||||
@ApiModelProperty(name = "profileId", value = "Define the ID of the profile", required = true)
|
@ApiModelProperty(name = "profileId",
|
||||||
|
value = "Define the ID of the profile",
|
||||||
|
required = true,
|
||||||
|
example = "1")
|
||||||
private int profileId;
|
private int profileId;
|
||||||
@ApiModelProperty(name = "deviceTypeId", value = "The ID used to define the type of the device platform",
|
@ApiModelProperty(name = "deviceTypeId",
|
||||||
required = true)
|
value = "The ID used to define the type of the device platform",
|
||||||
|
required = true,
|
||||||
|
example = "android")
|
||||||
private String deviceType;
|
private String deviceType;
|
||||||
@ApiModelProperty(name = "content", value = "The list of parameters that define the policy",
|
@ApiModelProperty(name = "content",
|
||||||
required = true)
|
value = "The list of parameters that define the policy",
|
||||||
|
required = true,
|
||||||
|
example = "{\\\"enabled\\\":false}")
|
||||||
private Object content;
|
private Object content;
|
||||||
@ApiModelProperty(name = "payLoad", value = "The payload which is submitted to each feature",
|
@ApiModelProperty(name = "payLoad",
|
||||||
|
value = "The payload which is submitted to each feature",
|
||||||
required = true)
|
required = true)
|
||||||
private String payLoad;
|
private String payLoad;
|
||||||
|
|
||||||
|
|||||||
@ -1,57 +1,24 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
||||||
*
|
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
|
||||||
* in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.jaxrs.service.api;
|
package org.wso2.carbon.device.mgt.jaxrs.service.api;
|
||||||
|
|
||||||
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.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import io.swagger.annotations.ApiResponse;
|
||||||
|
import io.swagger.annotations.ApiResponses;
|
||||||
|
import io.swagger.annotations.ResponseHeader;
|
||||||
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
||||||
|
import org.wso2.carbon.device.mgt.analytics.dashboard.bean.DeviceCountByGroup;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.DashboardGadgetDataWrapper;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.DashboardPaginationGadgetDataWrapper;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||||
|
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.Path;
|
|
||||||
import javax.ws.rs.Produces;
|
|
||||||
import javax.ws.rs.QueryParam;
|
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Device Analytics Dashboard related REST-APIs. This can be used to obtain device related analytics.
|
* Device Analytics Dashboard related REST-APIs. This can be used to obtain device related analytics.
|
||||||
*/
|
*/
|
||||||
@SwaggerDefinition(
|
|
||||||
info = @Info(
|
|
||||||
version = "1.0.0",
|
|
||||||
title = "",
|
|
||||||
extensions = {
|
|
||||||
@Extension(properties = {
|
|
||||||
@ExtensionProperty(name = "name", value = "DeviceAnalyticsDashboard"),
|
|
||||||
@ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/dashboard"),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
),
|
|
||||||
tags = {
|
|
||||||
@Tag(name = "device_management", description = "")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
@Path("/dashboard")
|
@Path("/dashboard")
|
||||||
@Api(value = "Device Analytics Dashboard",
|
@Api(value = "Device Analytics Dashboard",
|
||||||
description = "Device Analytics Dashboard related information APIs are described here.")
|
description = "Device Analytics Dashboard related information APIs are described here.")
|
||||||
@ -71,67 +38,667 @@ public interface Dashboard {
|
|||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("device-count-overview")
|
@Path("device-count-overview")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Get the details of registered devices in WSO2 EMM.",
|
||||||
|
notes = "Get the details of active, inactive, removed and total number of registered devices in"
|
||||||
|
+ " WSO2 EMM.",
|
||||||
|
tags = "Dashboard")
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK.",
|
||||||
|
response = DashboardGadgetDataWrapper.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. \n Empty body because the client has already the latest version of " +
|
||||||
|
"the requested resource."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request. \n Invalid request or validation error.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 401,
|
||||||
|
message = "Unauthorized. \n Unauthorized request."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "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 ErrorResponse in retrieving requested data.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
})
|
||||||
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
|
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
|
||||||
Response getOverviewDeviceCounts();
|
Response getOverviewDeviceCounts();
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("device-counts-by-potential-vulnerabilities")
|
@Path("device-counts-by-potential-vulnerabilities")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Get the number of unmonitored and non-compliant devices in WSO2 EMM.",
|
||||||
|
tags = "Dashboard")
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK.",
|
||||||
|
response = DashboardGadgetDataWrapper.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. \n Empty body because the client has already the latest version of " +
|
||||||
|
"the requested resource."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request. \n Invalid request or validation error.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 401,
|
||||||
|
message = "Unauthorized. \n Unauthorized request."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "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 fetching activity data.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
})
|
||||||
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
|
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
|
||||||
Response getDeviceCountsByPotentialVulnerabilities();
|
Response getDeviceCountsByPotentialVulnerabilities();
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("non-compliant-device-counts-by-features")
|
@Path("non-compliant-device-counts-by-features")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Get the number of devices that have not complied to a policy that was enforced on a "
|
||||||
|
+ "device.",
|
||||||
|
tags = "Dashboard")
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK.",
|
||||||
|
response = DashboardPaginationGadgetDataWrapper.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. \n Empty body because the client has already the latest version of " +
|
||||||
|
"the requested resource."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request. \n",
|
||||||
|
response = ErrorResponse.class),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 401,
|
||||||
|
message = "Unauthorized. \n Unauthorized request."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "Not Found. \n",
|
||||||
|
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 ErrorResponse in retrieving requested data.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
})
|
||||||
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
|
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
|
||||||
Response getNonCompliantDeviceCountsByFeatures(@QueryParam(START_INDEX) int startIndex,
|
Response getNonCompliantDeviceCountsByFeatures(
|
||||||
@QueryParam(RESULT_COUNT) int resultCount);
|
@ApiParam(
|
||||||
|
name = "start",
|
||||||
|
value = "Provide the starting pagination index. Example 10",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(START_INDEX) int startIndex,
|
||||||
|
@ApiParam(
|
||||||
|
name = "length",
|
||||||
|
value = "Provide how many policy details you require from the starting pagination index."
|
||||||
|
+ " For example if you require the non-compliant policy details from the 10th "
|
||||||
|
+ "pagination index to the 15th, you must define 10 as the value for start and "
|
||||||
|
+ "5 as the value for length.",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(RESULT_COUNT) int resultCount);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("device-counts-by-groups")
|
@Path("device-counts-by-groups")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Get the number of devices for a given device type, such as connectivity status, "
|
||||||
|
+ "potential vulnerability, platform, and ownership.\n",
|
||||||
|
tags = "Dashboard")
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK.",
|
||||||
|
response = DeviceCountByGroup.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. \n Empty body because the client has already the latest version of " +
|
||||||
|
"the requested resource."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 401,
|
||||||
|
message = "Unauthorized. \n Unauthorized request."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "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 ErrorResponse in retrieving requested data.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
})
|
||||||
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
|
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
|
||||||
Response getDeviceCountsByGroups(@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus,
|
Response getDeviceCountsByGroups(
|
||||||
@QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability,
|
@ApiParam(
|
||||||
@QueryParam(PLATFORM) String platform,
|
name = "connectivity-status",
|
||||||
@QueryParam(OWNERSHIP) String ownership);
|
value = "Provide the connectivity status of the device. The following values can be assigned:\n"
|
||||||
|
+ "active: The devices that are registered with WSO2 EMM and are actively "
|
||||||
|
+ "communicating with the server.\n"
|
||||||
|
+ "inactive: The devices that are registered with WSO2 EMM but unable to "
|
||||||
|
+ "actively communicate with the server.\n"
|
||||||
|
+ "removed: The devices that have unregistered from WSO2 EMM",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus,
|
||||||
|
@ApiParam(
|
||||||
|
name = "potential-vulnerability",
|
||||||
|
value = "Provide details of the potential vulnerabilities of the device. The following "
|
||||||
|
+ "values can be assigned:\n"
|
||||||
|
+ "non-compliant: Devices that have not complied to the policies enforced on the "
|
||||||
|
+ "device by WSO2 EMM.\n"
|
||||||
|
+ "unmonitored: Devices that have no policy assigned to them.",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability,
|
||||||
|
@ApiParam(
|
||||||
|
name = "platform",
|
||||||
|
value = "Provide the platform that the device is running on. The following values can "
|
||||||
|
+ "be assigned:\n"
|
||||||
|
+ "iOS\n" + "Android\n" + "Windows",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(PLATFORM) String platform,
|
||||||
|
@ApiParam(
|
||||||
|
name = "ownership",
|
||||||
|
value = "Provide the ownership status of the device. The following values can be assigned:\n"
|
||||||
|
+ "BYOD: Bring Your Own Device\n" + "COPE: Corporate-Owned, Personally-Enabled",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(OWNERSHIP) String ownership);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("feature-non-compliant-device-counts-by-groups")
|
@Path("feature-non-compliant-device-counts-by-groups")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Get the number of devices that have not complied to a given policy based on a particular"
|
||||||
|
+ " device type.",
|
||||||
|
tags = "Dashboard")
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK.",
|
||||||
|
response = DeviceCountByGroup.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. \n Empty body because the client has already the latest version of " +
|
||||||
|
"the requested resource."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 401,
|
||||||
|
message = "Unauthorized. \n Unauthorized request."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "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 ErrorResponse in retrieving requested data.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
})
|
||||||
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
|
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
|
||||||
Response getFeatureNonCompliantDeviceCountsByGroups(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode,
|
Response getFeatureNonCompliantDeviceCountsByGroups(
|
||||||
@QueryParam(PLATFORM) String platform,
|
@ApiParam(
|
||||||
@QueryParam(OWNERSHIP) String ownership);
|
name = "non-compliant-feature-code",
|
||||||
|
value = "As the value for this parameter, the policy feature code or ID can be used. Some"
|
||||||
|
+ " examples for feature codes are: PASSCODE_POLICY,CAMERA and WIFI.",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode,
|
||||||
|
@ApiParam(
|
||||||
|
name = "platform",
|
||||||
|
value = "Provide the platform that the device is running on. The following values can "
|
||||||
|
+ "be assigned:\n"
|
||||||
|
+ "iOS\n" + "Android\n" + "Windows",
|
||||||
|
required = false)
|
||||||
|
@QueryParam(PLATFORM) String platform,
|
||||||
|
@ApiParam(
|
||||||
|
name = "ownership",
|
||||||
|
value = "Provide the ownership status of the device. The following values can be assigned:\n"
|
||||||
|
+ "BYOD: Bring Your Own Device\n" + "COPE: Corporate-Owned, Personally-Enabled",
|
||||||
|
required = false)
|
||||||
|
@QueryParam(OWNERSHIP) String ownership);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("filtered-device-count-over-total")
|
@Path("filtered-device-count-over-total")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Get the number of devices that are registered with WSO2 EMM filtered by one of the "
|
||||||
|
+ "following attributes:\n"
|
||||||
|
+ "Connectivity status of the device, such as active, inactive or removed.\n"
|
||||||
|
+ "The device ownership type, such as BYOD or COPE.\n" + "The device platform.\n"
|
||||||
|
+ "The potential vulnerabilities faced by the devices.",
|
||||||
|
tags = "Dashboard")
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK.",
|
||||||
|
response = DashboardGadgetDataWrapper.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. \n Empty body because the client has already the latest version of " +
|
||||||
|
"the requested resource."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 401,
|
||||||
|
message = "Unauthorized. \n Unauthorized request."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "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 ErrorResponse in retrieving requested data.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
})
|
||||||
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
|
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
|
||||||
Response getFilteredDeviceCountOverTotal(@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus,
|
Response getFilteredDeviceCountOverTotal(
|
||||||
@QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability,
|
@ApiParam(
|
||||||
@QueryParam(PLATFORM) String platform,
|
name = "connectivity-status",
|
||||||
@QueryParam(OWNERSHIP) String ownership);
|
value = "Provide the connectivity status of the device. You can assign any of the values "
|
||||||
|
+ "given below:\n"
|
||||||
|
+ "Total: All the devices that have registered with WSO2 EMM.\n"
|
||||||
|
+ "active: The devices that are registered with WSO2 EMM and are actively "
|
||||||
|
+ "communicating with the server.\n"
|
||||||
|
+ "inactive: The devices that are registered with WSO2 EMM but unable to actively"
|
||||||
|
+ " communicate with the server.\n"
|
||||||
|
+ "removed: The devices that have unregistered from WSO2 EMM.",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus,
|
||||||
|
@ApiParam(
|
||||||
|
name = "potential-vulnerability",
|
||||||
|
value = "Provide details of the potential vulnerabilities of the device. You can assign"
|
||||||
|
+ " any of the values given below:\n"
|
||||||
|
+ "non-compliant: Devices that have not complied to the policies enforced on the "
|
||||||
|
+ "device by WSO2 EMM.\n"
|
||||||
|
+ "unmonitored: Devices that have no policy assigned to them.",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability,
|
||||||
|
@ApiParam(
|
||||||
|
name = "platform",
|
||||||
|
value = "Provide the platform that the device is running on. You can assign any of the "
|
||||||
|
+ "values given below:\n"
|
||||||
|
+ "iOS\n" + "Android\n" + "Windows",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(PLATFORM) String platform,
|
||||||
|
@ApiParam(
|
||||||
|
name = "ownership",
|
||||||
|
value = "Provide the ownership status of the device. You can assign any of the values "
|
||||||
|
+ "given below:\n"
|
||||||
|
+ "BYOD: Bring Your Own Device\n" + "COPE: Corporate-Owned, Personally-Enabled",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(OWNERSHIP) String ownership);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("feature-non-compliant-device-count-over-total")
|
@Path("feature-non-compliant-device-count-over-total")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Get the number of devices that have not complied to a given policy over the total"
|
||||||
|
+ " number of devices registered with WSO2 EMM.\n",
|
||||||
|
tags = "Dashboard")
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK.",
|
||||||
|
response = DashboardGadgetDataWrapper.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. \n Empty body because the client has already the latest version of " +
|
||||||
|
"the requested resource."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 401,
|
||||||
|
message = "Unauthorized. \n Unauthorized request."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "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 ErrorResponse in retrieving requested data.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
})
|
||||||
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
|
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
|
||||||
Response getFeatureNonCompliantDeviceCountOverTotal(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode,
|
Response getFeatureNonCompliantDeviceCountOverTotal(
|
||||||
@QueryParam(PLATFORM) String platform,
|
@ApiParam(
|
||||||
@QueryParam(OWNERSHIP) String ownership);
|
name = "non-compliant-feature-code",
|
||||||
|
value = "Provide the feature code or ID of the policy. Some examples for feature codes "
|
||||||
|
+ "are: WIFI, PASSCODE_POLICY, CAMERA and ENCRYPT_STORAGE.",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode,
|
||||||
|
@ApiParam(
|
||||||
|
name = "platform",
|
||||||
|
value = "Provide the platform that the device is running on. You can assign the values "
|
||||||
|
+ "given below:\n"
|
||||||
|
+ "iOS\n" + "Android\n" + "Windows",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(PLATFORM) String platform,
|
||||||
|
@ApiParam(
|
||||||
|
name = "ownership",
|
||||||
|
value = "Provide the ownership status of the device. You can assign the values given below:\n"
|
||||||
|
+ "BYOD: Bring Your Own Device\n" + "COPE: Corporate-Owned, Personally-Enabled",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(OWNERSHIP) String ownership);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("devices-with-details")
|
@Path("devices-with-details")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Get device details of devices based on a particular device type.",
|
||||||
|
tags = "Dashboard")
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK.",
|
||||||
|
response = DashboardPaginationGadgetDataWrapper.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. \n Empty body because the client has already the latest version of " +
|
||||||
|
"the requested resource."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 401,
|
||||||
|
message = "Unauthorized. \n Unauthorized request."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "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 ErrorResponse in retrieving requested data.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
})
|
||||||
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
|
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
|
||||||
Response getDevicesWithDetails(@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus,
|
Response getDevicesWithDetails(
|
||||||
@QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability,
|
@ApiParam(
|
||||||
@QueryParam(PLATFORM) String platform,
|
name = "connectivity-status",
|
||||||
@QueryParam(OWNERSHIP) String ownership,
|
value = "Provide the connectivity status of the device. This can be one of the following:\n"
|
||||||
@QueryParam(PAGINATION_ENABLED) String paginationEnabled,
|
+ "Total: All the devices that have registered with WSO2 EMM.\n"
|
||||||
@QueryParam(START_INDEX) int startIndex,
|
+ "active: The devices that are registered with WSO2 EMM and are actively "
|
||||||
@QueryParam(RESULT_COUNT) int resultCount);
|
+ "communicating with the server.\n"
|
||||||
|
+ "inactive: The devices that are registered with WSO2 EMM but unable to actively"
|
||||||
|
+ " communicate with the server.\n"
|
||||||
|
+ "removed: The devices that have unregistered from WSO2 EMM.",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus,
|
||||||
|
@ApiParam(
|
||||||
|
name = "potential-vulnerability",
|
||||||
|
value = "Provide details of the potential vulnerabilities of the device. This can be:\n"
|
||||||
|
+ "non-compliant: Devices that have not complied to the policies enforced on "
|
||||||
|
+ "the device by WSO2 EMM.\n"
|
||||||
|
+ "unmonitored: Devices that have no policy assigned to them. ",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability,
|
||||||
|
@ApiParam(
|
||||||
|
name = "platform",
|
||||||
|
value = "Provide the platform that the device is running on. This can be one of the following:\n"
|
||||||
|
+ "iOS\n" + "Android\n" + "Windows",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(PLATFORM) String platform,
|
||||||
|
@ApiParam(
|
||||||
|
name = "ownership",
|
||||||
|
value = "Provide the ownership status of the device. This can be one of the following:\n"
|
||||||
|
+ "BYOD: Bring Your Own Device\n" + "COPE: Corporate-Owned, Personally-Enabled",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(OWNERSHIP) String ownership,
|
||||||
|
@ApiParam(
|
||||||
|
name = "pagination-enabled",
|
||||||
|
value = "To enable/disable pagination set the value as true or false",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(PAGINATION_ENABLED) String paginationEnabled,
|
||||||
|
@ApiParam(
|
||||||
|
name = "start",
|
||||||
|
value = "Provide the starting pagination index.",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(START_INDEX) int startIndex,
|
||||||
|
@ApiParam(
|
||||||
|
name = "length",
|
||||||
|
value = "Provide how many policy details you require from the starting pagination index.",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(RESULT_COUNT) int resultCount);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("feature-non-compliant-devices-with-details")
|
@Path("feature-non-compliant-devices-with-details")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Get device details of non-compliant devices which do not comply to a given policy.",
|
||||||
|
tags = "Dashboard")
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK.",
|
||||||
|
response = DashboardPaginationGadgetDataWrapper.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. \n Empty body because the client has already the latest version of " +
|
||||||
|
"the requested resource."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 401,
|
||||||
|
message = "Unauthorized. \n Unauthorized request."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "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 ErrorResponse in retrieving requested data.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
})
|
||||||
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
|
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
|
||||||
Response getFeatureNonCompliantDevicesWithDetails(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode,
|
Response getFeatureNonCompliantDevicesWithDetails(
|
||||||
@QueryParam(PLATFORM) String platform,
|
@ApiParam(
|
||||||
@QueryParam(OWNERSHIP) String ownership,
|
name = "non-compliant-feature-code",
|
||||||
@QueryParam(PAGINATION_ENABLED) String paginationEnabled,
|
value = "Provide the code specific to the feature "
|
||||||
@QueryParam(START_INDEX) int startIndex,
|
+ "(examples for feature codes are: WIFI,PASSCODE_POLICY, CAMERA and ENCRYPT_STORAGE.)",
|
||||||
@QueryParam(RESULT_COUNT) int resultCount);
|
required = true)
|
||||||
|
@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode,
|
||||||
|
@ApiParam(
|
||||||
|
name = "platform",
|
||||||
|
value = "Provide the platform that the device is running on. This can be one of the following:\n"
|
||||||
|
+ "iOS\n" + "Android\n" + "Windows",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(PLATFORM) String platform,
|
||||||
|
@ApiParam(
|
||||||
|
name = "ownership",
|
||||||
|
value = "Provide the ownership status of the device. This can be one of the following:\n"
|
||||||
|
+ "BYOD: Bring Your Own Device\n" + "COPE: Corporate-Owned, Personally-Enabled",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(OWNERSHIP) String ownership,
|
||||||
|
@ApiParam(
|
||||||
|
name = "pagination-enabled",
|
||||||
|
value = "To enable/disable pagination set the value as true or false",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(PAGINATION_ENABLED) String paginationEnabled,
|
||||||
|
@ApiParam(
|
||||||
|
name = "start",
|
||||||
|
value = "Provide the starting pagination index.",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(START_INDEX) int startIndex,
|
||||||
|
@ApiParam(
|
||||||
|
name = "length",
|
||||||
|
value = "Provide how many policy details you require from the starting pagination index.",
|
||||||
|
required = true)
|
||||||
|
@QueryParam(RESULT_COUNT) int resultCount);
|
||||||
}
|
}
|
||||||
@ -87,6 +87,17 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("User by username: " + userInfo.getUsername() + " was found.");
|
log.debug("User by username: " + userInfo.getUsername() + " was found.");
|
||||||
}
|
}
|
||||||
|
DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService();
|
||||||
|
String[] bits = userInfo.getUsername().split("/");
|
||||||
|
String username = bits[bits.length - 1];
|
||||||
|
String recipient = userInfo.getEmailAddress();
|
||||||
|
Properties props = new Properties();
|
||||||
|
props.setProperty("first-name", userInfo.getFirstname());
|
||||||
|
props.setProperty("username", username);
|
||||||
|
props.setProperty("password", initialUserPassword);
|
||||||
|
|
||||||
|
EmailMetaInfo metaInfo = new EmailMetaInfo(recipient, props);
|
||||||
|
dms.sendRegistrationEmail(metaInfo);
|
||||||
return Response.created(new URI(API_BASE_PATH + "/" + URIEncoder.encode(userInfo.getUsername(), "UTF-8")))
|
return Response.created(new URI(API_BASE_PATH + "/" + URIEncoder.encode(userInfo.getUsername(), "UTF-8")))
|
||||||
.entity(
|
.entity(
|
||||||
createdUserInfo).build();
|
createdUserInfo).build();
|
||||||
@ -108,6 +119,12 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
return Response.serverError().entity(
|
return Response.serverError().entity(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String msg = "Error occurred while sending registration email to the user " +
|
||||||
|
userInfo.getUsername();
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.serverError().entity(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
public class ExtendedFileProtocolIteratorFactory implements DirectoryIteratorFactory {
|
final class ExtendedFileProtocolIteratorFactory implements DirectoryIteratorFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StreamIterator create(URL url, Filter filter) throws IOException {
|
public StreamIterator create(URL url, Filter filter) throws IOException {
|
||||||
|
|||||||
@ -24,11 +24,11 @@ import java.io.IOException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class ExtendedIteratorFactory {
|
class ExtendedIteratorFactory {
|
||||||
|
|
||||||
private static final ConcurrentHashMap<String, DirectoryIteratorFactory> registry = new ConcurrentHashMap();
|
private static final ConcurrentHashMap<String, DirectoryIteratorFactory> registry = new ConcurrentHashMap();
|
||||||
|
|
||||||
public static StreamIterator create(URL url, Filter filter) throws IOException {
|
static StreamIterator create(URL url, Filter filter) throws IOException {
|
||||||
String urlString = url.toString();
|
String urlString = url.toString();
|
||||||
if(urlString.endsWith("!/")) {
|
if(urlString.endsWith("!/")) {
|
||||||
urlString = urlString.substring(4);
|
urlString = urlString.substring(4);
|
||||||
|
|||||||
@ -218,6 +218,17 @@ public interface DeviceDAO {
|
|||||||
*/
|
*/
|
||||||
List<Device> getDevicesOfUser(String username, int tenantId) throws DeviceManagementDAOException;
|
List<Device> getDevicesOfUser(String username, int tenantId) throws DeviceManagementDAOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to retrieve the devices of given user of given device type.
|
||||||
|
* @param username user name.
|
||||||
|
* @param type device type.
|
||||||
|
* @param tenantId tenant id.
|
||||||
|
* @return
|
||||||
|
* @throws DeviceManagementDAOException
|
||||||
|
*/
|
||||||
|
List<Device> getDevicesOfUser(String username, String type, int tenantId) throws DeviceManagementDAOException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used to retrieve devices of a given user as a paginated result.
|
* This method is used to retrieve devices of a given user as a paginated result.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -369,6 +369,40 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Device> getDevicesOfUser(String username, String type, int tenantId) throws DeviceManagementDAOException {
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
List<Device> devices = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String sql = "SELECT e1.OWNER, e1.OWNERSHIP, e1.ENROLMENT_ID, e1.DEVICE_ID, e1.STATUS, e1.DATE_OF_LAST_UPDATE," +
|
||||||
|
" e1.DATE_OF_ENROLMENT, d.DESCRIPTION, d.NAME AS DEVICE_NAME, d.DEVICE_IDENTIFICATION, t.NAME " +
|
||||||
|
"AS DEVICE_TYPE FROM DM_DEVICE d, (SELECT e.OWNER, e.OWNERSHIP, e.ID AS ENROLMENT_ID, " +
|
||||||
|
"e.DEVICE_ID, e.STATUS, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT FROM DM_ENROLMENT e WHERE " +
|
||||||
|
"e.TENANT_ID = ? AND e.OWNER = ?) e1, DM_DEVICE_TYPE t WHERE d.ID = e1.DEVICE_ID " +
|
||||||
|
"AND t.ID = d.DEVICE_TYPE_ID AND t.NAME= ?";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setInt(1, tenantId);
|
||||||
|
stmt.setString(2, username);
|
||||||
|
stmt.setString(3, type);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
Device device = DeviceManagementDAOUtil.loadDevice(rs);
|
||||||
|
devices.add(device);
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new DeviceManagementDAOException("Error occurred while fetching the list of devices belongs to '" +
|
||||||
|
username + "'", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||||
|
}
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
|
||||||
private Connection getConnection() throws SQLException {
|
private Connection getConnection() throws SQLException {
|
||||||
return DeviceManagementDAOFactory.getConnection();
|
return DeviceManagementDAOFactory.getConnection();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,14 +19,11 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.core.search.mgt.dao;
|
package org.wso2.carbon.device.mgt.core.search.mgt.dao;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface SearchDAO {
|
public interface SearchDAO {
|
||||||
|
|
||||||
List<Device> searchDeviceDetailsTable(String query) throws SearchDAOException;
|
// List<Device> searchDeviceDetailsTable(String query) throws SearchDAOException;
|
||||||
|
//
|
||||||
List<Device> searchDevicePropertyTable(String query) throws SearchDAOException;
|
// List<Device> searchDevicePropertyTable(String query) throws SearchDAOException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,235 +19,220 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.core.search.mgt.dao.impl;
|
package org.wso2.carbon.device.mgt.core.search.mgt.dao.impl;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
||||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
|
|
||||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
|
|
||||||
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.search.mgt.dao.SearchDAO;
|
import org.wso2.carbon.device.mgt.core.search.mgt.dao.SearchDAO;
|
||||||
import org.wso2.carbon.device.mgt.core.search.mgt.dao.SearchDAOException;
|
|
||||||
import org.wso2.carbon.device.mgt.core.search.mgt.impl.Utils;
|
|
||||||
|
|
||||||
import java.sql.*;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class SearchDAOImpl implements SearchDAO {
|
public class SearchDAOImpl implements SearchDAO {
|
||||||
|
//
|
||||||
private static final Log log = LogFactory.getLog(SearchDAOImpl.class);
|
// private static final Log log = LogFactory.getLog(SearchDAOImpl.class);
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public List<Device> searchDeviceDetailsTable(String query) throws SearchDAOException {
|
// public List<Device> searchDeviceDetailsTable(String query) throws SearchDAOException {
|
||||||
if (log.isDebugEnabled()) {
|
// if (log.isDebugEnabled()) {
|
||||||
log.debug("Query : " + query);
|
// log.debug("Query : " + query);
|
||||||
}
|
// }
|
||||||
Connection conn;
|
// Connection conn;
|
||||||
PreparedStatement stmt = null;
|
// PreparedStatement stmt = null;
|
||||||
ResultSet rs;
|
// ResultSet rs;
|
||||||
List<Device> devices = new ArrayList<>();
|
// List<Device> devices = new ArrayList<>();
|
||||||
Map<Integer, Integer> devs = new HashMap<>();
|
// Map<Integer, Integer> devs = new HashMap<>();
|
||||||
try {
|
// try {
|
||||||
conn = this.getConnection();
|
// conn = this.getConnection();
|
||||||
stmt = conn.prepareStatement(query);
|
// stmt = conn.prepareStatement(query);
|
||||||
rs = stmt.executeQuery();
|
// rs = stmt.executeQuery();
|
||||||
while (rs.next()) {
|
// while (rs.next()) {
|
||||||
if (!devs.containsKey(rs.getInt("ID"))) {
|
// if (!devs.containsKey(rs.getInt("ID"))) {
|
||||||
Device device = new Device();
|
// Device device = new Device();
|
||||||
device.setId(rs.getInt("ID"));
|
// device.setId(rs.getInt("ID"));
|
||||||
device.setDescription(rs.getString("DESCRIPTION"));
|
// device.setDescription(rs.getString("DESCRIPTION"));
|
||||||
device.setName("NAME");
|
// device.setName("NAME");
|
||||||
device.setType(rs.getString("DEVICE_TYPE_NAME"));
|
// device.setType(rs.getString("DEVICE_TYPE_NAME"));
|
||||||
device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
|
// device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
|
||||||
|
//
|
||||||
DeviceIdentifier identifier = new DeviceIdentifier();
|
// DeviceIdentifier identifier = new DeviceIdentifier();
|
||||||
identifier.setType(rs.getString("DEVICE_TYPE_NAME"));
|
// identifier.setType(rs.getString("DEVICE_TYPE_NAME"));
|
||||||
identifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
|
// identifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
|
||||||
|
//
|
||||||
DeviceInfo deviceInfo = new DeviceInfo();
|
// DeviceInfo deviceInfo = new DeviceInfo();
|
||||||
deviceInfo.setAvailableRAMMemory(rs.getDouble("AVAILABLE_RAM_MEMORY"));
|
// deviceInfo.setAvailableRAMMemory(rs.getDouble("AVAILABLE_RAM_MEMORY"));
|
||||||
deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
// deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
||||||
deviceInfo.setConnectionType(rs.getString("CONNECTION_TYPE"));
|
// deviceInfo.setConnectionType(rs.getString("CONNECTION_TYPE"));
|
||||||
deviceInfo.setCpuUsage(rs.getDouble("CPU_USAGE"));
|
// deviceInfo.setCpuUsage(rs.getDouble("CPU_USAGE"));
|
||||||
deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
// deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
||||||
deviceInfo.setExternalAvailableMemory(rs.getDouble("EXTERNAL_AVAILABLE_MEMORY"));
|
// deviceInfo.setExternalAvailableMemory(rs.getDouble("EXTERNAL_AVAILABLE_MEMORY"));
|
||||||
deviceInfo.setExternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
// deviceInfo.setExternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
||||||
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
// deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
||||||
deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
// deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
||||||
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
// deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
||||||
deviceInfo.setOsBuildDate(rs.getString("OS_BUILD_DATE"));
|
// deviceInfo.setOsBuildDate(rs.getString("OS_BUILD_DATE"));
|
||||||
deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
// deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
||||||
deviceInfo.setSsid(rs.getString("SSID"));
|
// deviceInfo.setSsid(rs.getString("SSID"));
|
||||||
deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
// deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
||||||
deviceInfo.setVendor(rs.getString("VENDOR"));
|
// deviceInfo.setVendor(rs.getString("VENDOR"));
|
||||||
deviceInfo.setUpdatedTime(new java.util.Date(rs.getLong("UPDATE_TIMESTAMP")));
|
// deviceInfo.setUpdatedTime(new java.util.Date(rs.getLong("UPDATE_TIMESTAMP")));
|
||||||
|
//
|
||||||
DeviceLocation deviceLocation = new DeviceLocation();
|
// DeviceLocation deviceLocation = new DeviceLocation();
|
||||||
deviceLocation.setLatitude(rs.getDouble("LATITUDE"));
|
// deviceLocation.setLatitude(rs.getDouble("LATITUDE"));
|
||||||
deviceLocation.setLongitude(rs.getDouble("LONGITUDE"));
|
// deviceLocation.setLongitude(rs.getDouble("LONGITUDE"));
|
||||||
deviceLocation.setStreet1(rs.getString("STREET1"));
|
// deviceLocation.setStreet1(rs.getString("STREET1"));
|
||||||
deviceLocation.setStreet2(rs.getString("STREET2"));
|
// deviceLocation.setStreet2(rs.getString("STREET2"));
|
||||||
deviceLocation.setCity(rs.getString("CITY"));
|
// deviceLocation.setCity(rs.getString("CITY"));
|
||||||
deviceLocation.setState(rs.getString("STATE"));
|
// deviceLocation.setState(rs.getString("STATE"));
|
||||||
deviceLocation.setZip(rs.getString("ZIP"));
|
// deviceLocation.setZip(rs.getString("ZIP"));
|
||||||
deviceLocation.setCountry(rs.getString("COUNTRY"));
|
// deviceLocation.setCountry(rs.getString("COUNTRY"));
|
||||||
deviceLocation.setDeviceId(rs.getInt("ID"));
|
// deviceLocation.setDeviceId(rs.getInt("ID"));
|
||||||
deviceLocation.setUpdatedTime(new java.util.Date(rs.getLong("DL_UPDATED_TIMESTAMP")));
|
// deviceLocation.setUpdatedTime(new java.util.Date(rs.getLong("DL_UPDATED_TIMESTAMP")));
|
||||||
|
//
|
||||||
deviceInfo.setLocation(deviceLocation);
|
// deviceInfo.setLocation(deviceLocation);
|
||||||
device.setDeviceInfo(deviceInfo);
|
// device.setDeviceInfo(deviceInfo);
|
||||||
devices.add(device);
|
// devices.add(device);
|
||||||
devs.put(device.getId(), device.getId());
|
// devs.put(device.getId(), device.getId());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} catch (SQLException e) {
|
// } catch (SQLException e) {
|
||||||
throw new SearchDAOException("Error occurred while acquiring the device details.", e);
|
// throw new SearchDAOException("Error occurred while acquiring the device details.", e);
|
||||||
} finally {
|
// } finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
// DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
this.fillPropertiesOfDevices(devices);
|
// this.fillPropertiesOfDevices(devices);
|
||||||
|
//
|
||||||
if (log.isDebugEnabled()) {
|
// if (log.isDebugEnabled()) {
|
||||||
log.debug("Number of the device returned from the query : " + devices.size());
|
// log.debug("Number of the device returned from the query : " + devices.size());
|
||||||
}
|
// }
|
||||||
return devices;
|
// return devices;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public List<Device> searchDevicePropertyTable(String query) throws SearchDAOException {
|
// public List<Device> searchDevicePropertyTable(String query) throws SearchDAOException {
|
||||||
if (log.isDebugEnabled()) {
|
// if (log.isDebugEnabled()) {
|
||||||
log.debug("Query : " + query);
|
// log.debug("Query : " + query);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Connection conn;
|
// Connection conn;
|
||||||
PreparedStatement stmt = null;
|
// PreparedStatement stmt = null;
|
||||||
ResultSet rs;
|
// ResultSet rs;
|
||||||
List<Device> devices = new ArrayList<>();
|
// List<Device> devices = new ArrayList<>();
|
||||||
Map<Integer, Integer> devs = new HashMap<>();
|
// Map<Integer, Integer> devs = new HashMap<>();
|
||||||
try {
|
// try {
|
||||||
conn = this.getConnection();
|
// conn = this.getConnection();
|
||||||
stmt = conn.prepareStatement(query);
|
// stmt = conn.prepareStatement(query);
|
||||||
rs = stmt.executeQuery();
|
// rs = stmt.executeQuery();
|
||||||
while (rs.next()) {
|
// while (rs.next()) {
|
||||||
if (!devs.containsKey(rs.getInt("ID"))) {
|
// if (!devs.containsKey(rs.getInt("ID"))) {
|
||||||
Device device = new Device();
|
// Device device = new Device();
|
||||||
device.setId(rs.getInt("ID"));
|
// device.setId(rs.getInt("ID"));
|
||||||
device.setDescription(rs.getString("DESCRIPTION"));
|
// device.setDescription(rs.getString("DESCRIPTION"));
|
||||||
device.setName(rs.getString("NAME"));
|
// device.setName(rs.getString("NAME"));
|
||||||
device.setType(rs.getString("DEVICE_TYPE_NAME"));
|
// device.setType(rs.getString("DEVICE_TYPE_NAME"));
|
||||||
device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
|
// device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
|
||||||
|
//
|
||||||
DeviceIdentifier identifier = new DeviceIdentifier();
|
// DeviceIdentifier identifier = new DeviceIdentifier();
|
||||||
identifier.setType(rs.getString("DEVICE_TYPE_NAME"));
|
// identifier.setType(rs.getString("DEVICE_TYPE_NAME"));
|
||||||
identifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
|
// identifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
|
||||||
|
//
|
||||||
DeviceInfo deviceInfo = new DeviceInfo();
|
// DeviceInfo deviceInfo = new DeviceInfo();
|
||||||
deviceInfo.setAvailableRAMMemory(rs.getDouble("AVAILABLE_RAM_MEMORY"));
|
// deviceInfo.setAvailableRAMMemory(rs.getDouble("AVAILABLE_RAM_MEMORY"));
|
||||||
deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
// deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
||||||
deviceInfo.setConnectionType(rs.getString("CONNECTION_TYPE"));
|
// deviceInfo.setConnectionType(rs.getString("CONNECTION_TYPE"));
|
||||||
deviceInfo.setCpuUsage(rs.getDouble("CPU_USAGE"));
|
// deviceInfo.setCpuUsage(rs.getDouble("CPU_USAGE"));
|
||||||
deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
// deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
||||||
deviceInfo.setExternalAvailableMemory(rs.getDouble("EXTERNAL_AVAILABLE_MEMORY"));
|
// deviceInfo.setExternalAvailableMemory(rs.getDouble("EXTERNAL_AVAILABLE_MEMORY"));
|
||||||
deviceInfo.setExternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
// deviceInfo.setExternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
||||||
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
// deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
||||||
deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
// deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
||||||
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
// deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
||||||
deviceInfo.setOsBuildDate(rs.getString("OS_BUILD_DATE"));
|
// deviceInfo.setOsBuildDate(rs.getString("OS_BUILD_DATE"));
|
||||||
deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
// deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
||||||
deviceInfo.setSsid(rs.getString("SSID"));
|
// deviceInfo.setSsid(rs.getString("SSID"));
|
||||||
deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
// deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
||||||
deviceInfo.setVendor(rs.getString("VENDOR"));
|
// deviceInfo.setVendor(rs.getString("VENDOR"));
|
||||||
deviceInfo.setUpdatedTime(new java.util.Date(rs.getLong("UPDATE_TIMESTAMP")));
|
// deviceInfo.setUpdatedTime(new java.util.Date(rs.getLong("UPDATE_TIMESTAMP")));
|
||||||
|
//
|
||||||
DeviceLocation deviceLocation = new DeviceLocation();
|
// DeviceLocation deviceLocation = new DeviceLocation();
|
||||||
deviceLocation.setLatitude(rs.getDouble("LATITUDE"));
|
// deviceLocation.setLatitude(rs.getDouble("LATITUDE"));
|
||||||
deviceLocation.setLongitude(rs.getDouble("LONGITUDE"));
|
// deviceLocation.setLongitude(rs.getDouble("LONGITUDE"));
|
||||||
deviceLocation.setStreet1(rs.getString("STREET1"));
|
// deviceLocation.setStreet1(rs.getString("STREET1"));
|
||||||
deviceLocation.setStreet2(rs.getString("STREET2"));
|
// deviceLocation.setStreet2(rs.getString("STREET2"));
|
||||||
deviceLocation.setCity(rs.getString("CITY"));
|
// deviceLocation.setCity(rs.getString("CITY"));
|
||||||
deviceLocation.setState(rs.getString("STATE"));
|
// deviceLocation.setState(rs.getString("STATE"));
|
||||||
deviceLocation.setZip(rs.getString("ZIP"));
|
// deviceLocation.setZip(rs.getString("ZIP"));
|
||||||
deviceLocation.setCountry(rs.getString("COUNTRY"));
|
// deviceLocation.setCountry(rs.getString("COUNTRY"));
|
||||||
deviceLocation.setDeviceId(rs.getInt("ID"));
|
// deviceLocation.setDeviceId(rs.getInt("ID"));
|
||||||
deviceLocation.setUpdatedTime(new java.util.Date(rs.getLong("DL_UPDATED_TIMESTAMP")));
|
// deviceLocation.setUpdatedTime(new java.util.Date(rs.getLong("DL_UPDATED_TIMESTAMP")));
|
||||||
|
//
|
||||||
deviceInfo.setLocation(deviceLocation);
|
// deviceInfo.setLocation(deviceLocation);
|
||||||
device.setDeviceInfo(deviceInfo);
|
// device.setDeviceInfo(deviceInfo);
|
||||||
devices.add(device);
|
// devices.add(device);
|
||||||
devs.put(device.getId(), device.getId());
|
// devs.put(device.getId(), device.getId());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
} catch (SQLException e) {
|
// } catch (SQLException e) {
|
||||||
throw new SearchDAOException("Error occurred while aquiring the device details.", e);
|
// throw new SearchDAOException("Error occurred while aquiring the device details.", e);
|
||||||
} finally {
|
// } finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
// DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
this.fillPropertiesOfDevices(devices);
|
// this.fillPropertiesOfDevices(devices);
|
||||||
|
//
|
||||||
if (log.isDebugEnabled()) {
|
// if (log.isDebugEnabled()) {
|
||||||
log.debug("Number of the device returned from the query : " + devices.size());
|
// log.debug("Number of the device returned from the query : " + devices.size());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return devices;
|
// return devices;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
private Connection getConnection() throws SQLException {
|
// private Connection getConnection() throws SQLException {
|
||||||
return DeviceManagementDAOFactory.getConnection();
|
// return DeviceManagementDAOFactory.getConnection();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private List<Device> fillPropertiesOfDevices(List<Device> devices) throws SearchDAOException {
|
// private List<Device> fillPropertiesOfDevices(List<Device> devices) throws SearchDAOException {
|
||||||
if (devices.isEmpty()) {
|
// if (devices.isEmpty()) {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Connection conn;
|
// Connection conn;
|
||||||
PreparedStatement stmt;
|
// PreparedStatement stmt;
|
||||||
ResultSet rs;
|
// ResultSet rs;
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
conn = this.getConnection();
|
// conn = this.getConnection();
|
||||||
String query = "SELECT * FROM DM_DEVICE_INFO WHERE DEVICE_ID IN (?) ORDER BY DEVICE_ID ;";
|
// String query = "SELECT * FROM DM_DEVICE_INFO WHERE DEVICE_ID IN (?) ORDER BY DEVICE_ID ;";
|
||||||
stmt = conn.prepareStatement(query);
|
// stmt = conn.prepareStatement(query);
|
||||||
if (conn.getMetaData().getDatabaseProductName().contains("H2") ||
|
// if (conn.getMetaData().getDatabaseProductName().contains("H2") ||
|
||||||
conn.getMetaData().getDatabaseProductName().contains("MySQL")) {
|
// conn.getMetaData().getDatabaseProductName().contains("MySQL")) {
|
||||||
String inData = Utils.getDeviceIdsAsString(devices);
|
// String inData = Utils.getDeviceIdsAsString(devices);
|
||||||
stmt.setString(1, inData);
|
// stmt.setString(1, inData);
|
||||||
} else {
|
// } else {
|
||||||
Array array = conn.createArrayOf("INT", Utils.getArrayOfDeviceIds(devices));
|
// Array array = conn.createArrayOf("INT", Utils.getArrayOfDeviceIds(devices));
|
||||||
stmt.setArray(1, array);
|
// stmt.setArray(1, array);
|
||||||
}
|
// }
|
||||||
rs = stmt.executeQuery();
|
// rs = stmt.executeQuery();
|
||||||
|
//
|
||||||
DeviceInfo dInfo;
|
// DeviceInfo dInfo;
|
||||||
while (rs.next()) {
|
// while (rs.next()) {
|
||||||
dInfo = this.getDeviceInfo(devices, rs.getInt("DEVICE_ID"));
|
// dInfo = this.getDeviceInfo(devices, rs.getInt("DEVICE_ID"));
|
||||||
dInfo.getDeviceDetailsMap().put(rs.getString("KEY_FIELD"), rs.getString("VALUE_FIELD"));
|
// dInfo.getDeviceDetailsMap().put(rs.getString("KEY_FIELD"), rs.getString("VALUE_FIELD"));
|
||||||
}
|
// }
|
||||||
} catch (SQLException e) {
|
// } catch (SQLException e) {
|
||||||
throw new SearchDAOException("Error occurred while retrieving the device properties.", e);
|
// throw new SearchDAOException("Error occurred while retrieving the device properties.", e);
|
||||||
}
|
// }
|
||||||
return devices;
|
// return devices;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private DeviceInfo getDeviceInfo(List<Device> devices, int deviceId) {
|
// private DeviceInfo getDeviceInfo(List<Device> devices, int deviceId) {
|
||||||
for (Device device : devices) {
|
// for (Device device : devices) {
|
||||||
if (device.getId() == deviceId) {
|
// if (device.getId() == deviceId) {
|
||||||
if (device.getDeviceInfo() == null) {
|
// if (device.getDeviceInfo() == null) {
|
||||||
device.setDeviceInfo(new DeviceInfo());
|
// device.setDeviceInfo(new DeviceInfo());
|
||||||
}
|
// }
|
||||||
return device.getDeviceInfo();
|
// return device.getDeviceInfo();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,29 +19,44 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.core.search.mgt.impl;
|
package org.wso2.carbon.device.mgt.core.search.mgt.impl;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||||
|
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
|
||||||
|
import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
|
||||||
|
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
|
||||||
import org.wso2.carbon.device.mgt.common.search.SearchContext;
|
import org.wso2.carbon.device.mgt.common.search.SearchContext;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.ApplicationDAO;
|
import org.wso2.carbon.device.mgt.core.dao.ApplicationDAO;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
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.internal.DeviceManagementDataHolder;
|
||||||
import org.wso2.carbon.device.mgt.core.search.mgt.*;
|
import org.wso2.carbon.device.mgt.core.search.mgt.*;
|
||||||
import org.wso2.carbon.device.mgt.core.search.mgt.dao.SearchDAO;
|
|
||||||
import org.wso2.carbon.device.mgt.core.search.mgt.dao.SearchDAOException;
|
import org.wso2.carbon.device.mgt.core.search.mgt.dao.SearchDAOException;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class ProcessorImpl implements Processor {
|
public class ProcessorImpl implements Processor {
|
||||||
|
|
||||||
private SearchDAO searchDAO;
|
|
||||||
private ApplicationDAO applicationDAO;
|
private ApplicationDAO applicationDAO;
|
||||||
|
private static final Log log = LogFactory.getLog(ProcessorImpl.class);
|
||||||
|
private DeviceAccessAuthorizationService deviceAccessAuthorizationService;
|
||||||
|
|
||||||
public ProcessorImpl() {
|
public ProcessorImpl() {
|
||||||
searchDAO = DeviceManagementDAOFactory.getSearchDAO();
|
|
||||||
applicationDAO = DeviceManagementDAOFactory.getApplicationDAO();
|
applicationDAO = DeviceManagementDAOFactory.getApplicationDAO();
|
||||||
|
deviceAccessAuthorizationService = DeviceManagementDataHolder.getInstance()
|
||||||
|
.getDeviceAccessAuthorizationService();
|
||||||
|
if (deviceAccessAuthorizationService == null) {
|
||||||
|
String msg = "DeviceAccessAuthorization service has not initialized.";
|
||||||
|
log.error(msg);
|
||||||
|
throw new IllegalStateException(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -57,23 +72,22 @@ public class ProcessorImpl implements Processor {
|
|||||||
DeviceManagementDAOFactory.openConnection();
|
DeviceManagementDAOFactory.openConnection();
|
||||||
|
|
||||||
if (queries.containsKey(Constants.GENERAL)) {
|
if (queries.containsKey(Constants.GENERAL)) {
|
||||||
generalDevices = searchDAO.searchDeviceDetailsTable(queries.get(Constants.GENERAL).get(0));
|
generalDevices = searchDeviceDetailsTable(queries.get(Constants.GENERAL).get(0));
|
||||||
}
|
}
|
||||||
if (queries.containsKey(Constants.PROP_AND)) {
|
if (queries.containsKey(Constants.PROP_AND)) {
|
||||||
for (String query : queries.get(Constants.PROP_AND)) {
|
for (String query : queries.get(Constants.PROP_AND)) {
|
||||||
List<Device> andDevices = searchDAO.searchDevicePropertyTable(query);
|
List<Device> andDevices = searchDeviceDetailsTable(query);
|
||||||
allANDDevices.add(andDevices);
|
allANDDevices.add(andDevices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (queries.containsKey(Constants.PROP_OR)) {
|
if (queries.containsKey(Constants.PROP_OR)) {
|
||||||
for (String query : queries.get(Constants.PROP_OR)) {
|
for (String query : queries.get(Constants.PROP_OR)) {
|
||||||
List<Device> orDevices = searchDAO.searchDevicePropertyTable(query);
|
List<Device> orDevices = searchDeviceDetailsTable(query);
|
||||||
allORDevices.add(orDevices);
|
allORDevices.add(orDevices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (queries.containsKey(Constants.LOCATION)) {
|
if (queries.containsKey(Constants.LOCATION)) {
|
||||||
locationDevices = searchDAO.searchDevicePropertyTable(
|
locationDevices = searchDeviceDetailsTable(queries.get(Constants.LOCATION).get(0));
|
||||||
queries.get(Constants.LOCATION).get(0));
|
|
||||||
}
|
}
|
||||||
} catch (InvalidOperatorException e) {
|
} catch (InvalidOperatorException e) {
|
||||||
throw new SearchMgtException("Invalid operator was provided, so cannot execute the search.", e);
|
throw new SearchMgtException("Invalid operator was provided, so cannot execute the search.", e);
|
||||||
@ -95,10 +109,35 @@ public class ProcessorImpl implements Processor {
|
|||||||
devices.put(Constants.LOCATION, locationDevices);
|
devices.put(Constants.LOCATION, locationDevices);
|
||||||
|
|
||||||
List<Device> finalDevices = aggregator.aggregate(devices);
|
List<Device> finalDevices = aggregator.aggregate(devices);
|
||||||
|
finalDevices = authorizedDevices(finalDevices);
|
||||||
this.setApplicationListOfDevices(finalDevices);
|
this.setApplicationListOfDevices(finalDevices);
|
||||||
return finalDevices;
|
return finalDevices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To get the authorized devices for a particular user
|
||||||
|
*
|
||||||
|
* @param devices Devices that satisfy search results
|
||||||
|
* @return Devices that satisfy search results and authorized to be viewed by particular user
|
||||||
|
*/
|
||||||
|
private List<Device> authorizedDevices(List<Device> devices) throws SearchMgtException {
|
||||||
|
List<Device> filteredList = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
for (Device device : devices) {
|
||||||
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(),
|
||||||
|
device.getType());
|
||||||
|
if (deviceAccessAuthorizationService != null && deviceAccessAuthorizationService
|
||||||
|
.isUserAuthorized(deviceIdentifier)) {
|
||||||
|
filteredList.add(device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filteredList;
|
||||||
|
} catch (DeviceAccessAuthorizationException e) {
|
||||||
|
log.error("Error getting authorized search results for logged in user");
|
||||||
|
throw new SearchMgtException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Device> getUpdatedDevices(long epochTime) throws SearchMgtException {
|
public List<Device> getUpdatedDevices(long epochTime) throws SearchMgtException {
|
||||||
|
|
||||||
@ -107,9 +146,9 @@ public class ProcessorImpl implements Processor {
|
|||||||
}
|
}
|
||||||
QueryBuilder queryBuilder = new QueryBuilderImpl();
|
QueryBuilder queryBuilder = new QueryBuilderImpl();
|
||||||
try {
|
try {
|
||||||
String query = queryBuilder.processUpdatedDevices(epochTime);
|
String query = queryBuilder.processUpdatedDevices(epochTime);
|
||||||
DeviceManagementDAOFactory.openConnection();
|
DeviceManagementDAOFactory.openConnection();
|
||||||
return searchDAO.searchDeviceDetailsTable(query);
|
return searchDeviceDetailsTable(query);
|
||||||
} catch (InvalidOperatorException e) {
|
} catch (InvalidOperatorException e) {
|
||||||
throw new SearchMgtException("Invalid operator was provided, so cannot execute the search.", e);
|
throw new SearchMgtException("Invalid operator was provided, so cannot execute the search.", e);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -202,5 +241,142 @@ public class ProcessorImpl implements Processor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
private List<Device> searchDeviceDetailsTable(String query) throws SearchDAOException {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Query : " + query);
|
||||||
|
}
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
List<Device> devices = new ArrayList<>();
|
||||||
|
Map<Integer, Integer> devs = new HashMap<>();
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
stmt = conn.prepareStatement(query);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
while (rs.next()) {
|
||||||
|
if (!devs.containsKey(rs.getInt("ID"))) {
|
||||||
|
Device device = new Device();
|
||||||
|
device.setId(rs.getInt("ID"));
|
||||||
|
device.setDescription(rs.getString("DESCRIPTION"));
|
||||||
|
device.setName(rs.getString("NAME"));
|
||||||
|
device.setType(rs.getString("DEVICE_TYPE_NAME"));
|
||||||
|
device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
|
||||||
|
|
||||||
|
EnrolmentInfo enrolmentInfo = new EnrolmentInfo();
|
||||||
|
enrolmentInfo.setStatus(EnrolmentInfo.Status.valueOf(rs.getString("DE_STATUS")));
|
||||||
|
enrolmentInfo.setOwner(rs.getString("OWNER"));
|
||||||
|
enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.valueOf(rs.getString("OWNERSHIP")));
|
||||||
|
device.setEnrolmentInfo(enrolmentInfo);
|
||||||
|
|
||||||
|
DeviceIdentifier identifier = new DeviceIdentifier();
|
||||||
|
identifier.setType(rs.getString("DEVICE_TYPE_NAME"));
|
||||||
|
identifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
|
||||||
|
|
||||||
|
DeviceInfo deviceInfo = new DeviceInfo();
|
||||||
|
deviceInfo.setAvailableRAMMemory(rs.getDouble("AVAILABLE_RAM_MEMORY"));
|
||||||
|
deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
||||||
|
deviceInfo.setConnectionType(rs.getString("CONNECTION_TYPE"));
|
||||||
|
deviceInfo.setCpuUsage(rs.getDouble("CPU_USAGE"));
|
||||||
|
deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
||||||
|
deviceInfo.setExternalAvailableMemory(rs.getDouble("EXTERNAL_AVAILABLE_MEMORY"));
|
||||||
|
deviceInfo.setExternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
||||||
|
deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
||||||
|
deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
||||||
|
deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
||||||
|
deviceInfo.setOsBuildDate(rs.getString("OS_BUILD_DATE"));
|
||||||
|
deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
||||||
|
deviceInfo.setSsid(rs.getString("SSID"));
|
||||||
|
deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
||||||
|
deviceInfo.setVendor(rs.getString("VENDOR"));
|
||||||
|
deviceInfo.setUpdatedTime(new java.util.Date(rs.getLong("UPDATE_TIMESTAMP")));
|
||||||
|
|
||||||
|
DeviceLocation deviceLocation = new DeviceLocation();
|
||||||
|
deviceLocation.setLatitude(rs.getDouble("LATITUDE"));
|
||||||
|
deviceLocation.setLongitude(rs.getDouble("LONGITUDE"));
|
||||||
|
deviceLocation.setStreet1(rs.getString("STREET1"));
|
||||||
|
deviceLocation.setStreet2(rs.getString("STREET2"));
|
||||||
|
deviceLocation.setCity(rs.getString("CITY"));
|
||||||
|
deviceLocation.setState(rs.getString("STATE"));
|
||||||
|
deviceLocation.setZip(rs.getString("ZIP"));
|
||||||
|
deviceLocation.setCountry(rs.getString("COUNTRY"));
|
||||||
|
deviceLocation.setDeviceId(rs.getInt("ID"));
|
||||||
|
deviceLocation.setUpdatedTime(new java.util.Date(rs.getLong("DL_UPDATED_TIMESTAMP")));
|
||||||
|
|
||||||
|
deviceInfo.setLocation(deviceLocation);
|
||||||
|
device.setDeviceInfo(deviceInfo);
|
||||||
|
devices.add(device);
|
||||||
|
devs.put(device.getId(), device.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new SearchDAOException("Error occurred while aquiring the device details.", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||||
|
}
|
||||||
|
this.fillPropertiesOfDevices(devices);
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Number of the device returned from the query : " + devices.size());
|
||||||
|
}
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Connection getConnection() throws SQLException {
|
||||||
|
return DeviceManagementDAOFactory.getConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Device> fillPropertiesOfDevices(List<Device> devices) throws SearchDAOException {
|
||||||
|
if (devices.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String query = "SELECT * FROM DM_DEVICE_INFO WHERE DEVICE_ID IN (";
|
||||||
|
if (conn.getMetaData().getDatabaseProductName().contains("H2") || conn.getMetaData()
|
||||||
|
.getDatabaseProductName().contains("MySQL")) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
for (int i = 0; i < devices.size(); i++) {
|
||||||
|
builder.append("?,");
|
||||||
|
}
|
||||||
|
query += builder.deleteCharAt(builder.length() - 1).toString() + ") ORDER BY DEVICE_ID";
|
||||||
|
stmt = conn.prepareStatement(query);
|
||||||
|
for (int i = 0; i < devices.size(); i++) {
|
||||||
|
stmt.setInt(i + 1, devices.get(i).getId());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
query += "?) ORDER BY DEVICE_ID";
|
||||||
|
stmt = conn.prepareStatement(query);
|
||||||
|
Array array = conn.createArrayOf("INT", Utils.getArrayOfDeviceIds(devices));
|
||||||
|
stmt.setArray(1, array);
|
||||||
|
}
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
|
DeviceInfo dInfo;
|
||||||
|
while (rs.next()) {
|
||||||
|
dInfo = this.getDeviceInfo(devices, rs.getInt("DEVICE_ID"));
|
||||||
|
dInfo.getDeviceDetailsMap().put(rs.getString("KEY_FIELD"), rs.getString("VALUE_FIELD"));
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new SearchDAOException("Error occurred while retrieving the device properties.", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(stmt,rs);
|
||||||
|
}
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DeviceInfo getDeviceInfo(List<Device> devices, int deviceId) {
|
||||||
|
for (Device device : devices) {
|
||||||
|
if (device.getId() == deviceId) {
|
||||||
|
if (device.getDeviceInfo() == null) {
|
||||||
|
device.setDeviceInfo(new DeviceInfo());
|
||||||
|
}
|
||||||
|
return device.getDeviceInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -36,10 +36,12 @@ public class QueryBuilderImpl implements QueryBuilder {
|
|||||||
|
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(QueryBuilderImpl.class);
|
private static final Log log = LogFactory.getLog(QueryBuilderImpl.class);
|
||||||
|
private final String WILDCARD_OPERATOR = "%";
|
||||||
|
private String current_username;
|
||||||
|
private boolean isDeviceAdminUser;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, List<String>> buildQueries(List<Condition> conditions) throws InvalidOperatorException {
|
public Map<String, List<String>> buildQueries(List<Condition> conditions) throws InvalidOperatorException {
|
||||||
|
|
||||||
List<Condition> andColumns = new ArrayList<>();
|
List<Condition> andColumns = new ArrayList<>();
|
||||||
List<Condition> orColumns = new ArrayList<>();
|
List<Condition> orColumns = new ArrayList<>();
|
||||||
List<Condition> otherANDColumns = new ArrayList<>();
|
List<Condition> otherANDColumns = new ArrayList<>();
|
||||||
@ -107,34 +109,40 @@ public class QueryBuilderImpl implements QueryBuilder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String processAND(List<Condition> conditions) throws InvalidOperatorException {
|
public String processAND(List<Condition> conditions) throws InvalidOperatorException {
|
||||||
|
|
||||||
String querySuffix = "";
|
String querySuffix = "";
|
||||||
|
|
||||||
for (Condition con : conditions) {
|
for (Condition con : conditions) {
|
||||||
if (Utils.checkDeviceDetailsColumns(con.getKey().toLowerCase())) {
|
if (Utils.checkDeviceDetailsColumns(con.getKey())) {
|
||||||
querySuffix = querySuffix + " AND DD." + Utils.getDeviceDetailsColumnNames().get(con.getKey().toLowerCase()) +
|
if (con.operator.equals(WILDCARD_OPERATOR)){
|
||||||
con.getOperator() + Utils.getConvertedValue(con.getKey().toLowerCase(), con.getValue());
|
querySuffix = querySuffix + " OR DD." + Utils.getDeviceDetailsColumnNames().get(con.getKey())
|
||||||
|
+ " LIKE \'%" + con.getValue() + "%\'";
|
||||||
|
} else {
|
||||||
|
querySuffix = querySuffix + " AND DD." + Utils.getDeviceDetailsColumnNames().get(con.getKey()) + con
|
||||||
|
.getOperator() + Utils.getConvertedValue(con.getKey(), con.getValue());
|
||||||
|
}
|
||||||
} else if (Utils.checkDeviceLocationColumns(con.getKey().toLowerCase())) {
|
} else if (Utils.checkDeviceLocationColumns(con.getKey().toLowerCase())) {
|
||||||
querySuffix = querySuffix + " AND DL." + Utils.getDeviceLocationColumnNames().get(con.getKey().toLowerCase()) +
|
querySuffix = querySuffix + " AND DL." + Utils.getDeviceLocationColumnNames().get(con.getKey().toLowerCase()) +
|
||||||
con.getOperator() + con.getValue();
|
con.getOperator() + con.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return querySuffix;
|
return querySuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String processOR(List<Condition> conditions) throws InvalidOperatorException {
|
public String processOR(List<Condition> conditions) throws InvalidOperatorException {
|
||||||
|
|
||||||
String querySuffix = "";
|
String querySuffix = "";
|
||||||
|
|
||||||
for (Condition con : conditions) {
|
for (Condition con : conditions) {
|
||||||
if (Utils.checkDeviceDetailsColumns(con.getKey().toLowerCase())) {
|
if (Utils.checkDeviceDetailsColumns(con.getKey())) {
|
||||||
querySuffix = querySuffix + " OR DD." + Utils.getDeviceDetailsColumnNames().get(con.getKey().toLowerCase()) +
|
if (con.operator.equals(WILDCARD_OPERATOR)) {
|
||||||
con.getOperator() + Utils.getConvertedValue(con.getKey(), con.getValue());
|
querySuffix = querySuffix + " OR DD." + Utils.getDeviceDetailsColumnNames().get(con.getKey())
|
||||||
|
+ " LIKE \'%" + con.getValue() + "%\'";
|
||||||
|
} else {
|
||||||
|
querySuffix = querySuffix + " OR DD." + Utils.getDeviceDetailsColumnNames().get(con.getKey()) + con
|
||||||
|
.getOperator() + Utils.getConvertedValue(con.getKey(), con.getValue());
|
||||||
|
}
|
||||||
} else if (Utils.checkDeviceLocationColumns(con.getKey().toLowerCase())) {
|
} else if (Utils.checkDeviceLocationColumns(con.getKey().toLowerCase())) {
|
||||||
querySuffix = querySuffix + " OR DL." + Utils.getDeviceLocationColumnNames().get(con.getKey().toLowerCase()) +
|
querySuffix =
|
||||||
con.getOperator() + con.getValue();
|
querySuffix + " OR DL." + Utils.getDeviceLocationColumnNames().get(con.getKey().toLowerCase())
|
||||||
|
+ con.getOperator() + con.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return querySuffix;
|
return querySuffix;
|
||||||
@ -177,17 +185,16 @@ public class QueryBuilderImpl implements QueryBuilder {
|
|||||||
private String buildLocationQuery(String location) {
|
private String buildLocationQuery(String location) {
|
||||||
|
|
||||||
String query = this.getGenericQueryPart();
|
String query = this.getGenericQueryPart();
|
||||||
query = query + " AND DL.STREET1 LIKE \'%" + location + "%\'";
|
query = query + " AND (DL.STREET1 LIKE \'%" + location + "%\'";
|
||||||
query = query + " OR DL.STREET2 LIKE \'%" + location + "%\'";
|
query = query + " OR DL.STREET2 LIKE \'%" + location + "%\'";
|
||||||
query = query + " OR DL.CITY LIKE \'%" + location + "%\'";
|
query = query + " OR DL.CITY LIKE \'%" + location + "%\'";
|
||||||
query = query + " OR DL.STATE LIKE \'%" + location + "%\'";
|
query = query + " OR DL.STATE LIKE \'%" + location + "%\'";
|
||||||
query = query + " OR DL.COUNTRY LIKE \'%" + location + "%\'";
|
query = query + " OR DL.COUNTRY LIKE \'%" + location + "%\'";
|
||||||
query = query + " OR DL.ZIP LIKE \'%" + location + "%\'";
|
query = query + " OR DL.ZIP LIKE \'%" + location + "%\')";
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getGenericQueryPart() {
|
private String getGenericQueryPart() {
|
||||||
|
|
||||||
return "SELECT D.ID, D.DESCRIPTION, D.NAME, \n" +
|
return "SELECT D.ID, D.DESCRIPTION, D.NAME, \n" +
|
||||||
"D.DEVICE_TYPE_ID, D.DEVICE_IDENTIFICATION, DT.ID AS DEVICE_TYPE_ID, \n" +
|
"D.DEVICE_TYPE_ID, D.DEVICE_IDENTIFICATION, DT.ID AS DEVICE_TYPE_ID, \n" +
|
||||||
"DT.NAME AS DEVICE_TYPE_NAME, DD.DEVICE_ID, DD.DEVICE_MODEL, DD.VENDOR, \n" +
|
"DT.NAME AS DEVICE_TYPE_NAME, DD.DEVICE_ID, DD.DEVICE_MODEL, DD.VENDOR, \n" +
|
||||||
@ -195,18 +202,15 @@ public class QueryBuilderImpl implements QueryBuilder {
|
|||||||
"DD.EXTERNAL_TOTAL_MEMORY, DD.EXTERNAL_AVAILABLE_MEMORY, DD.CONNECTION_TYPE, \n" +
|
"DD.EXTERNAL_TOTAL_MEMORY, DD.EXTERNAL_AVAILABLE_MEMORY, DD.CONNECTION_TYPE, \n" +
|
||||||
"DD.SSID, DD.CPU_USAGE, DD.TOTAL_RAM_MEMORY, DD.AVAILABLE_RAM_MEMORY, \n" +
|
"DD.SSID, DD.CPU_USAGE, DD.TOTAL_RAM_MEMORY, DD.AVAILABLE_RAM_MEMORY, \n" +
|
||||||
"DD.PLUGGED_IN, DD.UPDATE_TIMESTAMP, DL.LATITUDE, DL.LONGITUDE, DL.STREET1, DL.STREET2, DL.CITY, DL.ZIP, \n" +
|
"DD.PLUGGED_IN, DD.UPDATE_TIMESTAMP, DL.LATITUDE, DL.LONGITUDE, DL.STREET1, DL.STREET2, DL.CITY, DL.ZIP, \n" +
|
||||||
"DL.STATE, DL.COUNTRY, DL.UPDATE_TIMESTAMP AS DL_UPDATED_TIMESTAMP \n" +
|
"DL.STATE, DL.COUNTRY, DL.UPDATE_TIMESTAMP AS DL_UPDATED_TIMESTAMP, DE.OWNER, DE.OWNERSHIP, DE.STATUS " +
|
||||||
"FROM DM_DEVICE_DETAIL AS DD INNER JOIN DM_DEVICE AS D ON D.ID=DD.DEVICE_ID\n" +
|
"AS DE_STATUS FROM DM_DEVICE_DETAIL AS DD INNER JOIN DM_DEVICE AS D ON D.ID=DD.DEVICE_ID\n" +
|
||||||
"LEFT JOIN DM_DEVICE_LOCATION AS DL ON DL.DEVICE_ID=D.ID \n" +
|
"LEFT JOIN DM_DEVICE_LOCATION AS DL ON DL.DEVICE_ID=D.ID \n" +
|
||||||
"INNER JOIN DM_DEVICE_TYPE AS DT ON DT.ID=D.DEVICE_TYPE_ID\n" +
|
"INNER JOIN DM_DEVICE_TYPE AS DT ON DT.ID=D.DEVICE_TYPE_ID\n" +
|
||||||
"WHERE D.TENANT_ID = " +
|
"INNER JOIN DM_ENROLMENT AS DE ON D.ID=DE.DEVICE_ID\n" +
|
||||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
"WHERE D.TENANT_ID = " + PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPropertyQueryPart() {
|
private String getPropertyQueryPart() {
|
||||||
|
|
||||||
return "SELECT D.ID, D.DESCRIPTION, D.NAME, \n" +
|
return "SELECT D.ID, D.DESCRIPTION, D.NAME, \n" +
|
||||||
"D.DEVICE_TYPE_ID, D.DEVICE_IDENTIFICATION, DT.ID AS DEVICE_TYPE_ID, \n" +
|
"D.DEVICE_TYPE_ID, D.DEVICE_IDENTIFICATION, DT.ID AS DEVICE_TYPE_ID, \n" +
|
||||||
"DT.NAME AS DEVICE_TYPE_NAME, DD.DEVICE_ID, DD.DEVICE_MODEL, DD.VENDOR, \n" +
|
"DT.NAME AS DEVICE_TYPE_NAME, DD.DEVICE_ID, DD.DEVICE_MODEL, DD.VENDOR, \n" +
|
||||||
@ -214,13 +218,14 @@ public class QueryBuilderImpl implements QueryBuilder {
|
|||||||
"DD.EXTERNAL_TOTAL_MEMORY, DD.EXTERNAL_AVAILABLE_MEMORY, DD.CONNECTION_TYPE, \n" +
|
"DD.EXTERNAL_TOTAL_MEMORY, DD.EXTERNAL_AVAILABLE_MEMORY, DD.CONNECTION_TYPE, \n" +
|
||||||
"DD.SSID, DD.CPU_USAGE, DD.TOTAL_RAM_MEMORY, DD.AVAILABLE_RAM_MEMORY, \n" +
|
"DD.SSID, DD.CPU_USAGE, DD.TOTAL_RAM_MEMORY, DD.AVAILABLE_RAM_MEMORY, \n" +
|
||||||
"DD.PLUGGED_IN, DD.UPDATE_TIMESTAMP, DL.LATITUDE, DL.LONGITUDE, DL.STREET1, DL.STREET2, DL.CITY, DL.ZIP, \n" +
|
"DD.PLUGGED_IN, DD.UPDATE_TIMESTAMP, DL.LATITUDE, DL.LONGITUDE, DL.STREET1, DL.STREET2, DL.CITY, DL.ZIP, \n" +
|
||||||
"DL.STATE, DL.COUNTRY, DL.UPDATE_TIMESTAMP AS DL_UPDATED_TIMESTAMP, DI.KEY_FIELD, DI.VALUE_FIELD \n" +
|
"DL.STATE, DL.COUNTRY, DL.UPDATE_TIMESTAMP AS DL_UPDATED_TIMESTAMP, DI.KEY_FIELD, DI.VALUE_FIELD, \n" +
|
||||||
|
"DE.OWNER, DE.OWNERSHIP, DE.STATUS AS DE_STATUS " +
|
||||||
"FROM DM_DEVICE_DETAIL AS DD INNER JOIN DM_DEVICE AS D ON D.ID=DD.DEVICE_ID\n" +
|
"FROM DM_DEVICE_DETAIL AS DD INNER JOIN DM_DEVICE AS D ON D.ID=DD.DEVICE_ID\n" +
|
||||||
"LEFT JOIN DM_DEVICE_LOCATION AS DL ON DL.DEVICE_ID=D.ID \n" +
|
"LEFT JOIN DM_DEVICE_LOCATION AS DL ON DL.DEVICE_ID=D.ID \n" +
|
||||||
"INNER JOIN DM_DEVICE_TYPE AS DT ON DT.ID=D.DEVICE_TYPE_ID\n" +
|
"INNER JOIN DM_DEVICE_TYPE AS DT ON DT.ID=D.DEVICE_TYPE_ID\n" +
|
||||||
|
"INNER JOIN DM_ENROLMENT AS DE ON D.ID=DE.DEVICE_ID\n" +
|
||||||
"LEFT JOIN DM_DEVICE_INFO AS DI ON DI.DEVICE_ID=D.ID\n" +
|
"LEFT JOIN DM_DEVICE_INFO AS DI ON DI.DEVICE_ID=D.ID\n" +
|
||||||
"WHERE D.TENANT_ID = " +
|
"WHERE D.TENANT_ID = " +
|
||||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,6 +127,15 @@ public interface DeviceManagementProviderService {
|
|||||||
*/
|
*/
|
||||||
List<Device> getDevicesOfUser(String userName) throws DeviceManagementException;
|
List<Device> getDevicesOfUser(String userName) throws DeviceManagementException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the list of device owned by a user of given device type.
|
||||||
|
* @param userName user name.
|
||||||
|
* @param deviceType device type name
|
||||||
|
* @return
|
||||||
|
* @throws DeviceManagementException
|
||||||
|
*/
|
||||||
|
List<Device> getDevicesOfUser(String userName, String deviceType) throws DeviceManagementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to get the list of devices owned by users of a particular user-role.
|
* Method to get the list of devices owned by users of a particular user-role.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1321,6 +1321,74 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Device> getDevicesOfUser(String username, String deviceType) throws DeviceManagementException {
|
||||||
|
List<Device> devices = new ArrayList<>();
|
||||||
|
List<Device> userDevices;
|
||||||
|
try {
|
||||||
|
DeviceManagementDAOFactory.openConnection();
|
||||||
|
userDevices = deviceDAO.getDevicesOfUser(username, deviceType, this.getTenantId());
|
||||||
|
} catch (DeviceManagementDAOException e) {
|
||||||
|
throw new DeviceManagementException("Error occurred while retrieving the list of devices that " +
|
||||||
|
"belong to the user '" + username + "'", e);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new DeviceManagementException("Error occurred while opening a connection to the data source", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Device device : userDevices) {
|
||||||
|
DeviceInfo info = null;
|
||||||
|
try {
|
||||||
|
DeviceManagementDAOFactory.openConnection();
|
||||||
|
info = deviceInfoDAO.getDeviceInformation(device.getId());
|
||||||
|
DeviceLocation location = deviceInfoDAO.getDeviceLocation(device.getId());
|
||||||
|
if (info != null) {
|
||||||
|
info.setLocation(location);
|
||||||
|
}
|
||||||
|
} catch (DeviceDetailsMgtDAOException e) {
|
||||||
|
log.error("Error occurred while retrieving advance info of '" + device.getType() +
|
||||||
|
"' that carries the id '" + device.getDeviceIdentifier() + "'");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Error occurred while opening a connection to the data source", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
|
device.setDeviceInfo(info);
|
||||||
|
|
||||||
|
try {
|
||||||
|
DeviceManagementDAOFactory.openConnection();
|
||||||
|
List<Application> applications = applicationDAO.getInstalledApplications(device.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);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Error occurred while opening a connection to the data source", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceManager deviceManager = this.getDeviceManager(device.getType());
|
||||||
|
if (deviceManager == null) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Device Manager associated with the device type '" + device.getType() + "' is null. " +
|
||||||
|
"Therefore, not attempting method 'isEnrolled'");
|
||||||
|
}
|
||||||
|
devices.add(device);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Device dmsDevice =
|
||||||
|
deviceManager.getDevice(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
||||||
|
if (dmsDevice != null) {
|
||||||
|
device.setFeatures(dmsDevice.getFeatures());
|
||||||
|
device.setProperties(dmsDevice.getProperties());
|
||||||
|
}
|
||||||
|
devices.add(device);
|
||||||
|
}
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PaginationResult getDevicesOfUser(PaginationRequest request)
|
public PaginationResult getDevicesOfUser(PaginationRequest request)
|
||||||
throws DeviceManagementException {
|
throws DeviceManagementException {
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
<class name="org.wso2.carbon.device.mgt.core.app.mgt.AppManagementConfigurationManagerTest"/>
|
<class name="org.wso2.carbon.device.mgt.core.app.mgt.AppManagementConfigurationManagerTest"/>
|
||||||
<class name="org.wso2.carbon.device.mgt.core.dao.ApplicationPersistenceTests"/>
|
<class name="org.wso2.carbon.device.mgt.core.dao.ApplicationPersistenceTests"/>
|
||||||
<class name="org.wso2.carbon.device.mgt.core.search.DeviceDetails"/>
|
<class name="org.wso2.carbon.device.mgt.core.search.DeviceDetails"/>
|
||||||
<class name="org.wso2.carbon.device.mgt.core.search.SearchDevice"/>
|
<!--<class name="org.wso2.carbon.device.mgt.core.search.SearchDevice"/>-->
|
||||||
<class name="org.wso2.carbon.device.mgt.core.dao.GroupPersistTests"/>
|
<class name="org.wso2.carbon.device.mgt.core.dao.GroupPersistTests"/>
|
||||||
</classes>
|
</classes>
|
||||||
</test>
|
</test>
|
||||||
|
|||||||
@ -33,8 +33,10 @@
|
|||||||
"identityProviderUrl" : "https://localhost:9443/samlsso",
|
"identityProviderUrl" : "https://localhost:9443/samlsso",
|
||||||
"acs": "https://localhost:9443/devicemgt/uuf/sso/acs",
|
"acs": "https://localhost:9443/devicemgt/uuf/sso/acs",
|
||||||
"identityAlias": "wso2carbon",
|
"identityAlias": "wso2carbon",
|
||||||
"responseSigningEnabled" : "true",
|
"responseSigningEnabled" : true,
|
||||||
"useTenantKey": false
|
"validateAssertionValidityPeriod": true,
|
||||||
|
"validateAudienceRestriction": true,
|
||||||
|
"assertionSigningEnabled": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"errorPages": {
|
"errorPages": {
|
||||||
|
|||||||
@ -340,6 +340,7 @@ var userModule = function () {
|
|||||||
* @returns {object} a response object with status and content on success.
|
* @returns {object} a response object with status and content on success.
|
||||||
*/
|
*/
|
||||||
publicMethods.getRolesByUserStore = function (userStore) {
|
publicMethods.getRolesByUserStore = function (userStore) {
|
||||||
|
userStore = userStore ? userStore : "all";
|
||||||
var carbonUser = session.get(constants["USER_SESSION_KEY"]);
|
var carbonUser = session.get(constants["USER_SESSION_KEY"]);
|
||||||
var utility = require("/app/modules/utility.js")["utility"];
|
var utility = require("/app/modules/utility.js")["utility"];
|
||||||
if (!carbonUser) {
|
if (!carbonUser) {
|
||||||
@ -673,23 +674,29 @@ var userModule = function () {
|
|||||||
*/
|
*/
|
||||||
publicMethods.getSecondaryUserStores = function () {
|
publicMethods.getSecondaryUserStores = function () {
|
||||||
var returnVal = [];
|
var returnVal = [];
|
||||||
var endpoint = devicemgtProps["adminService"] + constants["USER_STORE_CONFIG_ADMIN_SERVICE_END_POINT"];
|
if (publicMethods.isAuthorized("/permission/admin")) {
|
||||||
var wsPayload = "<xsd:getSecondaryRealmConfigurations xmlns:xsd='http://org.apache.axis2/xsd'/>";
|
var endpoint = devicemgtProps["adminService"] + constants["USER_STORE_CONFIG_ADMIN_SERVICE_END_POINT"];
|
||||||
serviceInvokers.WS.soapRequest(
|
var wsPayload = "<xsd:getSecondaryRealmConfigurations xmlns:xsd='http://org.apache.axis2/xsd'/>";
|
||||||
"urn:getSecondaryRealmConfigurations",
|
serviceInvokers.WS.soapRequest(
|
||||||
wsPayload,
|
"urn:getSecondaryRealmConfigurations",
|
||||||
endpoint,
|
wsPayload,
|
||||||
function (wsResponse) {
|
endpoint,
|
||||||
var domainIDs = stringify(wsResponse.*::['return']. *::domainId.text());
|
function (wsResponse) {
|
||||||
if (domainIDs != "\"\"") {
|
var domainIDs = stringify(wsResponse.*::['return']. *::domainId.text());
|
||||||
var regExpForSearch = new RegExp(constants["USER_STORES_NOISY_CHAR"], "g");
|
if (domainIDs != "\"\"") {
|
||||||
domainIDs = domainIDs.replace(regExpForSearch, "");
|
var regExpForSearch = new RegExp(constants["USER_STORES_NOISY_CHAR"], "g");
|
||||||
returnVal = domainIDs.split(constants["USER_STORES_SPLITTING_CHAR"]);
|
domainIDs = domainIDs.replace(regExpForSearch, "");
|
||||||
|
returnVal = domainIDs.split(constants["USER_STORES_SPLITTING_CHAR"]);
|
||||||
|
}
|
||||||
|
}, function (e) {
|
||||||
|
log.error("Error retrieving secondary user stores", e);
|
||||||
|
},
|
||||||
|
constants["SOAP_VERSION"]);
|
||||||
|
} else {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("User does not have admin permission to get the secondary user store details.");
|
||||||
}
|
}
|
||||||
}, function (e) {
|
}
|
||||||
log.error("Error retrieving secondary user stores", e);
|
|
||||||
},
|
|
||||||
constants["SOAP_VERSION"]);
|
|
||||||
return returnVal;
|
return returnVal;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -15,12 +15,12 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
}}
|
}}
|
||||||
{{unit "cdmf.unit.ui.title" pageTitle="Resource Dashboard"}}
|
{{unit "cdmf.unit.ui.title" pageTitle="Home"}}
|
||||||
|
|
||||||
{{#zone "breadcrumbs"}}
|
{{#zone "breadcrumbs"}}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{@app.context}}/">
|
<a href="{{@app.context}}/">
|
||||||
Resource Dashboard
|
<i class="icon fw fw-home"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{{/zone}}
|
{{/zone}}
|
||||||
|
|||||||
@ -1,13 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
|
||||||
WSO2 Inc. licenses this file to you under the Apache License,
|
WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
Version 2.0 (the "License"); you may not use this file except
|
Version 2.0 (the "License"); you may not use this file except
|
||||||
in compliance with the License.
|
in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
@ -46,17 +43,23 @@ var dynamicForm = '<div class="dynamic-search-param row"><div class="row"><a cla
|
|||||||
'</a></div><div class="form-group wr-input-control col-md-2"><label class="wr-input-label ">State</label>' +
|
'</a></div><div class="form-group wr-input-control col-md-2"><label class="wr-input-label ">State</label>' +
|
||||||
'<select class="state no-tag form-control select2-custom"><option>AND</option><option>OR</option></select></div><div ' +
|
'<select class="state no-tag form-control select2-custom"><option>AND</option><option>OR</option></select></div><div ' +
|
||||||
'class="form-group wr-input-control col-md-4"><label class="wr-input-label ">Key</label><select class=' +
|
'class="form-group wr-input-control col-md-4"><label class="wr-input-label ">Key</label><select class=' +
|
||||||
'"txt-key form-control select2-custom"><option>deviceModel</option><option>vendor</option><option>osVersion' +
|
'"txt-key form-control select2-custom"><option value = "deviceModel">Device Model' +
|
||||||
'</option><option>batteryLevel</option><option>internalTotalMemory</option> <option>' +
|
'</option><option value = "vendor">Vendor</option><option value = "osVersion">OS Version' +
|
||||||
'internalAvailableMemory</option> <option>externalTotalMemory</option> <option>externalAvailableMemory' +
|
'</option><option value = "batteryLevel">Battery Level</option><option value =' +
|
||||||
'</option> <option>connectionType</option> <option>ssid</option> <option>cpuUsage</option> <option>' +
|
' "internalTotalMemory">Internal Total Memory</option> <option value ="internalAvailableMemory">' +
|
||||||
'totalRAMMemory</option> <option>availableRAMMemory</option> <option>pluggedIn</option></select></div>' +
|
'Internal Available Memory</option> <option value = "externalTotalMemory">externalTotalMemory</option>' +
|
||||||
|
' <option value = "externalAvailableMemory">External Available Memory' +
|
||||||
|
'</option> <option value = "connectionType">Connection Type</option> <option value =' +
|
||||||
|
' "ssid">SSID</option><option value = "cpuUsage">CPU Usage</option><option value = "totalRAMMemory">' +
|
||||||
|
'Total RAM Memory</option> <option value = "availableRAMMemory">Available RAM Memory</option>' +
|
||||||
|
'<option value = "pluggedIn">Plugged In</option></select></div>' +
|
||||||
'<div class="form-group wr-input-control col-md-2">' +
|
'<div class="form-group wr-input-control col-md-2">' +
|
||||||
'<label class="wr-input-label ">Operator</label><select class="form-control select2-custom no-tag operator">' +
|
'<label class="wr-input-label ">Operator</label><select id = "operators" class="form-control' +
|
||||||
'<option>=</option><option> !=</option><option> <</option>' +
|
' select2-custom no-tag operator"><option>=</option><option> !=</option><option> %</option>' +
|
||||||
'<option> =<</option><option> ></option><option> >=</option></select></div><div class="form-group ' +
|
'</select></div><div class="form-group ' + 'wr-input-control col-md-4"><label class="wr-input-label">Value</label>' +
|
||||||
'wr-input-control col-md-4"><label class="wr-input-label' +
|
'<input type="text" class="form-control txt-value"/></div></div>';
|
||||||
' ">Value</label><input type="text" class="form-control txt-value"/></div></div>';
|
|
||||||
|
var nonNumericKeyValuePair = ["deviceModel", "vendor", "osVersion", "connectionType", "ssid", "pluggedIn"];
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
var isInit = true;
|
var isInit = true;
|
||||||
@ -64,14 +67,49 @@ $(document).ready(function () {
|
|||||||
$("#customSearchParam").prepend(dynamicForm);
|
$("#customSearchParam").prepend(dynamicForm);
|
||||||
$(".close-button-div").unbind("click");
|
$(".close-button-div").unbind("click");
|
||||||
$(".close-button-div").bind("click", removeCustomParam);
|
$(".close-button-div").bind("click", removeCustomParam);
|
||||||
$(".txt-key").select2({tags: true});
|
|
||||||
$(".no-tag").select2({tags: false});
|
$(".no-tag").select2({tags: false});
|
||||||
|
$(".txt-key").select2({tags: true}).on('change', function() {
|
||||||
|
// Based on the selected key, relevant operations are changed
|
||||||
|
var operationsForSelectedKey = getOperators($(this).val());
|
||||||
|
$("#operators").empty();
|
||||||
|
$("#operators").append(operationsForSelectedKey);
|
||||||
|
$("#operators").select2("val", "=");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** Function to get operators based on the key Value
|
||||||
|
*
|
||||||
|
* @param keyValue
|
||||||
|
*/
|
||||||
|
function getOperators(keyValue) {
|
||||||
|
if (nonNumericKeyValuePair.indexOf(keyValue) < 0) {
|
||||||
|
return '<option> =</option><option> !=</option><option> <</option><option> =<</option><option>' +
|
||||||
|
' ></option><option> >=</option>';
|
||||||
|
} else {
|
||||||
|
return '<option> =</option><option> !=</option><option><option> %</option>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** To validate the key and value before sending that to back-end
|
||||||
|
*
|
||||||
|
* @param key Key of the search
|
||||||
|
* @param value value given for the search
|
||||||
|
*/
|
||||||
|
function isValidKeyAndValue(key, value) {
|
||||||
|
if (nonNumericKeyValuePair.indexOf(key) < 0) {
|
||||||
|
if (!isNaN(parseFloat(value)) && isFinite(value)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$("#device-search-btn").click(function () {
|
$("#device-search-btn").click(function () {
|
||||||
var location = $("#location").val();
|
var location = $("#location").val();
|
||||||
var payload_obj = {};
|
var payload_obj = {};
|
||||||
var conditions = [];
|
var conditions = [];
|
||||||
|
var hasError = false;
|
||||||
if (location) {
|
if (location) {
|
||||||
var conditionObject = {};
|
var conditionObject = {};
|
||||||
conditionObject.key = "LOCATION";
|
conditionObject.key = "LOCATION";
|
||||||
@ -83,93 +121,104 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
$("#customSearchParam .dynamic-search-param").each(function () {
|
$("#customSearchParam .dynamic-search-param").each(function () {
|
||||||
var value = $(this).find(".txt-value").val();
|
var value = $(this).find(".txt-value").val();
|
||||||
var key = $(this).find(".txt-key").val()
|
var key = $(this).find(".txt-key").val();
|
||||||
if (value && key) {
|
if (!hasError && value && key ) {
|
||||||
var conditionObject = {};
|
if (isValidKeyAndValue(key, value)) {
|
||||||
conditionObject.key = key;
|
var conditionObject = {};
|
||||||
conditionObject.value = value;
|
conditionObject.key = key;
|
||||||
conditionObject.operator = $(this).find(".operator").val();
|
conditionObject.value = value;
|
||||||
conditionObject.state = $(this).find(".state").val();
|
conditionObject.operator = $(this).find(".operator").val();
|
||||||
conditions.push(conditionObject)
|
conditionObject.state = $(this).find(".state").val();
|
||||||
|
conditions.push(conditionObject);
|
||||||
|
} else {
|
||||||
|
hasError = true;
|
||||||
|
$("#advance-search-result").addClass("hidden");
|
||||||
|
$("#advance-search-form").removeClass(" hidden");
|
||||||
|
$('#device-listing-status').removeClass('hidden');
|
||||||
|
$('#device-listing-status-msg').text('Error in user input values. ' + key + " requires a" +
|
||||||
|
" numerical value as the search value");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
payload_obj.conditions = conditions;
|
|
||||||
var deviceSearchAPI = "/api/device-mgt/v1.0/devices/search-devices";
|
|
||||||
$("#advance-search-form").addClass(" hidden");
|
|
||||||
$("#loading-content").removeClass('hidden');
|
|
||||||
var deviceListing = $("#device-listing");
|
|
||||||
var deviceListingSrc = deviceListing.attr("src");
|
|
||||||
$.template("device-listing", deviceListingSrc, function (template) {
|
|
||||||
|
|
||||||
var successCallback = function (data) {
|
// Sent the search conditions to back-end only, if all the values compliant with there key values
|
||||||
if (!data) {
|
if (hasError) {
|
||||||
$("#loading-content").addClass('hidden');
|
hasError = false;
|
||||||
$("#advance-search-result").addClass("hidden");
|
} else {
|
||||||
$("#advance-search-form").removeClass(" hidden");
|
payload_obj.conditions = conditions;
|
||||||
$('#device-listing-status').removeClass('hidden');
|
var deviceSearchAPI = "/api/device-mgt/v1.0/devices/search-devices";
|
||||||
$('#device-listing-status-msg').text('No Device are available to be displayed.');
|
$("#advance-search-form").addClass(" hidden");
|
||||||
return;
|
$("#loading-content").removeClass('hidden');
|
||||||
}
|
var deviceListing = $("#device-listing");
|
||||||
data = JSON.parse(data);
|
var deviceListingSrc = deviceListing.attr("src");
|
||||||
if (data.devices.length == 0) {
|
$.template("device-listing", deviceListingSrc, function (template) {
|
||||||
$("#loading-content").addClass('hidden');
|
var successCallback = function (data) {
|
||||||
$("#advance-search-result").addClass("hidden");
|
if (!data) {
|
||||||
$("#advance-search-form").removeClass(" hidden");
|
$("#loading-content").addClass('hidden');
|
||||||
$('#device-listing-status').removeClass('hidden');
|
$("#advance-search-result").addClass("hidden");
|
||||||
$('#device-listing-status-msg').text('No Device are available to be displayed.');
|
$("#advance-search-form").removeClass(" hidden");
|
||||||
return;
|
$('#device-listing-status').removeClass('hidden');
|
||||||
}
|
$('#device-listing-status-msg').text('No Device are available to be displayed.');
|
||||||
var viewModel = {};
|
return;
|
||||||
var devices = [];
|
|
||||||
if (data.devices.length > 0) {
|
|
||||||
for (i = 0; i < data.devices.length; i++) {
|
|
||||||
var tempDevice = data.devices[i];
|
|
||||||
var device = {};
|
|
||||||
device.type = tempDevice.type;
|
|
||||||
device.name = tempDevice.name;
|
|
||||||
device.deviceIdentifier = tempDevice.deviceIdentifier;
|
|
||||||
var properties = {} ;
|
|
||||||
var enrolmentInfo = {};
|
|
||||||
properties.VENDOR = tempDevice.deviceInfo.vendor;
|
|
||||||
properties.DEVICE_MODEL = tempDevice.deviceInfo.deviceModel;
|
|
||||||
enrolmentInfo.status = "ACTIVE";
|
|
||||||
enrolmentInfo.owner = "N/A";
|
|
||||||
enrolmentInfo.ownership = "N/A";
|
|
||||||
device.enrolmentInfo = enrolmentInfo;
|
|
||||||
device.properties = properties;
|
|
||||||
devices.push(device);
|
|
||||||
}
|
}
|
||||||
viewModel.devices = devices;
|
data = JSON.parse(data);
|
||||||
$('#advance-search-result').removeClass('hidden');
|
if (data.devices.length == 0) {
|
||||||
$("#view-search-param").removeClass('hidden');
|
$("#loading-content").addClass('hidden');
|
||||||
$("#back-to-search").removeClass('hidden');
|
$("#advance-search-result").addClass("hidden");
|
||||||
$('#device-grid').removeClass('hidden');
|
$("#advance-search-form").removeClass(" hidden");
|
||||||
$('#ast-container').removeClass('hidden');
|
$('#device-listing-status').removeClass('hidden');
|
||||||
$('#user-listing-status-msg').text("");
|
$('#device-listing-status-msg').text('No Device are available to be displayed.');
|
||||||
var content = template(viewModel);
|
return;
|
||||||
$("#ast-container").html(content);
|
}
|
||||||
} else {
|
var viewModel = {};
|
||||||
$('#device-listing-status').removeClass('hidden');
|
var devices = [];
|
||||||
$('#device-listing-status-msg').text('No Device are available to be displayed.');
|
if (data.devices.length > 0) {
|
||||||
}
|
for (i = 0; i < data.devices.length; i++) {
|
||||||
$("#loading-content").addClass('hidden');
|
var tempDevice = data.devices[i];
|
||||||
if (isInit) {
|
var device = {};
|
||||||
$('#device-grid').datatables_extended();
|
device.type = tempDevice.type;
|
||||||
isInit = false;
|
device.name = tempDevice.name;
|
||||||
}
|
device.deviceIdentifier = tempDevice.deviceIdentifier;
|
||||||
$(".icon .text").res_text(0.2);
|
var properties = {};
|
||||||
};
|
var enrolmentInfo = {};
|
||||||
invokerUtil.post(deviceSearchAPI,
|
properties.VENDOR = tempDevice.deviceInfo.vendor;
|
||||||
payload_obj,
|
properties.DEVICE_MODEL = tempDevice.deviceInfo.deviceModel;
|
||||||
successCallback,
|
device.enrolmentInfo = tempDevice.enrolmentInfo;
|
||||||
function (message) {
|
device.properties = properties;
|
||||||
$("#loading-content").addClass('hidden');
|
devices.push(device);
|
||||||
$("#advance-search-result").addClass("hidden");
|
}
|
||||||
$("#advance-search-form").removeClass(" hidden");
|
viewModel.devices = devices;
|
||||||
$('#device-listing-status').removeClass('hidden');
|
$('#advance-search-result').removeClass('hidden');
|
||||||
$('#device-listing-status-msg').text('Server is unable to perform the search please enroll at least one device or check the search query');
|
$("#view-search-param").removeClass('hidden');
|
||||||
}
|
$("#back-to-search").removeClass('hidden');
|
||||||
);
|
$('#device-grid').removeClass('hidden');
|
||||||
});
|
$('#ast-container').removeClass('hidden');
|
||||||
|
$('#user-listing-status-msg').text("");
|
||||||
|
var content = template(viewModel);
|
||||||
|
$("#ast-container").html(content);
|
||||||
|
} else {
|
||||||
|
$('#device-listing-status').removeClass('hidden');
|
||||||
|
$('#device-listing-status-msg').text('No Device are available to be displayed.');
|
||||||
|
}
|
||||||
|
$("#loading-content").addClass('hidden');
|
||||||
|
if (isInit) {
|
||||||
|
$('#device-grid').datatables_extended();
|
||||||
|
isInit = false;
|
||||||
|
}
|
||||||
|
$(".icon .text").res_text(0.2);
|
||||||
|
};
|
||||||
|
invokerUtil.post(deviceSearchAPI,
|
||||||
|
payload_obj,
|
||||||
|
successCallback,
|
||||||
|
function (message) {
|
||||||
|
$("#loading-content").addClass('hidden');
|
||||||
|
$("#advance-search-result").addClass("hidden");
|
||||||
|
$("#advance-search-form").removeClass(" hidden");
|
||||||
|
$('#device-listing-status').removeClass('hidden');
|
||||||
|
$('#device-listing-status-msg').text('Server is unable to perform the search please enroll at least one device or check the search query');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -5,7 +5,7 @@
|
|||||||
<tr data-type="selectable" data-deviceid="{{deviceIdentifier}}" data-devicetype="{{type}}">
|
<tr data-type="selectable" data-deviceid="{{deviceIdentifier}}" data-devicetype="{{type}}">
|
||||||
<td class="remove-padding icon-only content-fill viewEnabledIcon"
|
<td class="remove-padding icon-only content-fill viewEnabledIcon"
|
||||||
{{#unequal enrolmentInfo.status "REMOVED"}}
|
{{#unequal enrolmentInfo.status "REMOVED"}}
|
||||||
data-url="view?type={{type}}&id={{deviceIdentifier}}"
|
data-url="../device/{{type}}?id={{deviceIdentifier}}"
|
||||||
{{/unequal}}
|
{{/unequal}}
|
||||||
>
|
>
|
||||||
<div class="thumbnail icon">
|
<div class="thumbnail icon">
|
||||||
|
|||||||
@ -1,13 +1,10 @@
|
|||||||
<!--
|
<!--
|
||||||
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
|
||||||
WSO2 Inc. licenses this file to you under the Apache License,
|
WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
Version 2.0 (the "License"); you may not use this file except
|
Version 2.0 (the "License"); you may not use this file except
|
||||||
in compliance with the License.
|
in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
@ -15,6 +12,8 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
-->
|
-->
|
||||||
|
{{unit "cdmf.unit.ui.modal"}}
|
||||||
|
{{unit "cdmf.unit.data-tables-extended"}}
|
||||||
{{#zone "breadcrumbs"}}
|
{{#zone "breadcrumbs"}}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{@app.context}}/">
|
<a href="{{@app.context}}/">
|
||||||
@ -96,6 +95,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- /content -->
|
<!-- /content -->
|
||||||
|
<div id="group-error-content" class="hide">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-7 col-centered center-container">
|
||||||
|
<h4 id="error-msg">Unexpected error occurred!</h4>
|
||||||
|
<br/>
|
||||||
|
<div class="buttons">
|
||||||
|
<a href="#" id="group-unexpected-error-link" class="btn-operations">
|
||||||
|
Ok
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<!-- loading -->
|
<!-- loading -->
|
||||||
<div id="loading-content" class="col-centered hidden">
|
<div id="loading-content" class="col-centered hidden">
|
||||||
<i class="fw fw-settings fw-spin fw-2x"></i>
|
<i class="fw fw-settings fw-spin fw-2x"></i>
|
||||||
@ -143,4 +157,3 @@
|
|||||||
<script id="device-listing" src="{{@page.publicUri}}/templates/device-listing.hbs"
|
<script id="device-listing" src="{{@page.publicUri}}/templates/device-listing.hbs"
|
||||||
type="text/x-handlebars-template"></script>
|
type="text/x-handlebars-template"></script>
|
||||||
{{/zone}}
|
{{/zone}}
|
||||||
|
|
||||||
|
|||||||
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
||||||
|
|
||||||
WSO2 Inc. licenses this file to you under the Apache License,
|
|
||||||
Version 2.0 (the "License"); you may not use this file except
|
|
||||||
in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
||||||
either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the dynamic state to be populated by add-user page.
|
|
||||||
*
|
|
||||||
* @param context Object that gets updated with the dynamic state of this page to be presented
|
|
||||||
* @returns {*} A context object that returns the dynamic state of this page to be presented
|
|
||||||
*/
|
|
||||||
function onRequest(context) {
|
|
||||||
var log = new Log("units/user-create/certificate-create.js");
|
|
||||||
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
|
|
||||||
var response = userModule.getRolesByUserStore();
|
|
||||||
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
|
|
||||||
if (response["status"] == "success") {
|
|
||||||
context["roles"] = response["content"];
|
|
||||||
}
|
|
||||||
|
|
||||||
context["charLimit"] = mdmProps["usernameLength"];
|
|
||||||
context["usernameJSRegEx"] = mdmProps["userValidationConfig"]["usernameJSRegEx"];
|
|
||||||
context["usernameHelpText"] = mdmProps["userValidationConfig"]["usernameHelpMsg"];
|
|
||||||
context["usernameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["usernameRegExViolationErrorMsg"];
|
|
||||||
context["firstnameJSRegEx"] = mdmProps["userValidationConfig"]["firstnameJSRegEx"];
|
|
||||||
context["firstnameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["firstnameRegExViolationErrorMsg"];
|
|
||||||
context["lastnameJSRegEx"] = mdmProps["userValidationConfig"]["lastnameJSRegEx"];
|
|
||||||
context["lastnameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["lastnameRegExViolationErrorMsg"];
|
|
||||||
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
@ -39,8 +39,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="password">Password *</label>
|
<label for="password">Password *</label>
|
||||||
<input type="password" name="password" class="form-control" placeholder="Enter your password"
|
<input type="password" name="password" class="form-control" autocomplete="off"
|
||||||
required="required" />
|
placeholder="Enter your password" required="required" />
|
||||||
</div>
|
</div>
|
||||||
{{#if sessionDataKey}}
|
{{#if sessionDataKey}}
|
||||||
<input type="hidden" name="sessionDataKey" value="{{sessionDataKey}}" />
|
<input type="hidden" name="sessionDataKey" value="{{sessionDataKey}}" />
|
||||||
|
|||||||
@ -85,7 +85,7 @@ $("a#invite-user-link").click(function () {
|
|||||||
modalDialog.footer('<div class="buttons"> <a href="#" id="invite-user-success-link" ' +
|
modalDialog.footer('<div class="buttons"> <a href="#" id="invite-user-success-link" ' +
|
||||||
'class="btn-operations">Ok </a> </div>');
|
'class="btn-operations">Ok </a> </div>');
|
||||||
$("a#invite-user-success-link").click(function () {
|
$("a#invite-user-success-link").click(function () {
|
||||||
modalPopup.hide();
|
modalDialog.hide();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function () {
|
function () {
|
||||||
@ -95,14 +95,14 @@ $("a#invite-user-link").click(function () {
|
|||||||
modalDialog.footer('<div class="buttons"> <a href="#" id="invite-user-error-link" ' +
|
modalDialog.footer('<div class="buttons"> <a href="#" id="invite-user-error-link" ' +
|
||||||
'class="btn-operations">Ok </a> </div>');
|
'class="btn-operations">Ok </a> </div>');
|
||||||
$("a#invite-user-error-link").click(function () {
|
$("a#invite-user-error-link").click(function () {
|
||||||
modalPopup.hide();
|
modalDialog.hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("a#invite-user-cancel-link").click(function () {
|
$("a#invite-user-cancel-link").click(function () {
|
||||||
modalPopup.hide();
|
modalDialog.hide();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -108,14 +108,14 @@
|
|||||||
Enter new password
|
Enter new password
|
||||||
<br><br>
|
<br><br>
|
||||||
<div>
|
<div>
|
||||||
<input type="password" class="form-control modal-input operationDataKeys new-password"
|
<input type="password" autocomplete="off" class="form-control modal-input operationDataKeys new-password"
|
||||||
data-key="message"/>
|
data-key="message"/>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
Retype new password
|
Retype new password
|
||||||
<br><br>
|
<br><br>
|
||||||
<div>
|
<div>
|
||||||
<input type="password" class="form-control modal-input operationDataKeys confirmed-password"
|
<input type="password" autocomplete="off" class="form-control modal-input operationDataKeys confirmed-password"
|
||||||
data-key="message"/>
|
data-key="message"/>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
@ -82,7 +82,7 @@
|
|||||||
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||||
</span>
|
</span>
|
||||||
<br>
|
<br>
|
||||||
( Should be in milliseconds )
|
( Should be in seconds )
|
||||||
</label>
|
</label>
|
||||||
<input id="monitoring-config-frequency" type="text"
|
<input id="monitoring-config-frequency" type="text"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
|
|||||||
@ -67,20 +67,20 @@
|
|||||||
Type your current password *
|
Type your current password *
|
||||||
<br><br>
|
<br><br>
|
||||||
<div>
|
<div>
|
||||||
<input id="current-password" type="password" class="form-control modal-input"/>
|
<input id="current-password" type="password" autocomplete="off" class="form-control modal-input"/>
|
||||||
</div>
|
</div>
|
||||||
<br><br>
|
<br><br>
|
||||||
Type a new password *
|
Type a new password *
|
||||||
<br><br>
|
<br><br>
|
||||||
<div>
|
<div>
|
||||||
<input id="new-password" type="password" class="form-control modal-input"
|
<input id="new-password" type="password" autocomplete="off" class="form-control modal-input"
|
||||||
placeholder="[ Password should be in minimum 5 characters long and should not include any whitespaces ]"/>
|
placeholder="[ Password should be in minimum 5 characters long and should not include any whitespaces ]"/>
|
||||||
</div>
|
</div>
|
||||||
<br><br>
|
<br><br>
|
||||||
Reconfirm your new password *
|
Reconfirm your new password *
|
||||||
<br><br>
|
<br><br>
|
||||||
<div>
|
<div>
|
||||||
<input id="retyped-new-password" type="password" class="form-control modal-input"/>
|
<input id="retyped-new-password" type="password" autocomplete="off" class="form-control modal-input"/>
|
||||||
</div>
|
</div>
|
||||||
<br><br>
|
<br><br>
|
||||||
</h5>
|
</h5>
|
||||||
|
|||||||
@ -0,0 +1,33 @@
|
|||||||
|
<!--
|
||||||
|
~ Copyright 2016 WSO2, Inc. (http://wso2.com)
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Bad request - Error 400</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta name="description" content="">
|
||||||
|
<meta name="author" content="">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<i class="icon-unlink error-icon"></i>
|
||||||
|
<h1>Error 400</h1>
|
||||||
|
<h3>We are unable to understand the request and process it. Please re-check your request.</h3>
|
||||||
|
<h4 id="link"><a href="/emm">Go to EMM</a></h4>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
<!--
|
||||||
|
~ Copyright 2016 WSO2, Inc. (http://wso2.com)
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Unauthorized - Error 401</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta name="description" content="">
|
||||||
|
<meta name="author" content="">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<i class="icon-unlink error-icon"></i>
|
||||||
|
<h1>Error 401</h1>
|
||||||
|
<h3>You do not have permission to access this page.Please contact your administrator and request permission.</h3>
|
||||||
|
<h4 id="link"><a href="/emm">Go to EMM</a></h4>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
<!--
|
||||||
|
~ Copyright 2016 WSO2, Inc. (http://wso2.com)
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Forbidden - Error 403</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta name="description" content="">
|
||||||
|
<meta name="author" content="">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<i class="icon-unlink error-icon"></i>
|
||||||
|
<h1>Error 403</h1>
|
||||||
|
<h3>We cannot process this request.</h3>
|
||||||
|
<h4 id="link"><a href="/emm">Go to EMM</a></h4>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
<!--
|
||||||
|
~ Copyright 2016 WSO2, Inc. (http://wso2.com)
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Page not found - Error 404</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta name="description" content="">
|
||||||
|
<meta name="author" content="">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<i class="icon-unlink error-icon"></i>
|
||||||
|
<h1>Error 404</h1>
|
||||||
|
<h3>We can't find what you are looking for.</h3>
|
||||||
|
<h4 id="link"><a href="/emm">Go to EMM</a></h4>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
<!--
|
||||||
|
~ Copyright 2016 WSO2, Inc. (http://wso2.com)
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Method not allowed - Error 405</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta name="description" content="">
|
||||||
|
<meta name="author" content="">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<i class="icon-unlink error-icon"></i>
|
||||||
|
<h1>Error 405</h1>
|
||||||
|
<h3>Method not allowed.</h3>
|
||||||
|
<h4 id="link"><a href="/emm">Go to EMM</a></h4>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
<!--
|
||||||
|
~ Copyright 2016 WSO2, Inc. (http://wso2.com)
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Internal Server Error - Error 500</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta name="description" content="">
|
||||||
|
<meta name="author" content="">
|
||||||
|
<body>
|
||||||
|
<i class="icon-ambulance error-icon"></i>
|
||||||
|
<h1>Error 500</h1>
|
||||||
|
<h3>Something went wrong and we're trying to fix it.</h3>
|
||||||
|
<h4 id="link"><a href="/emm">Go to EMM</a></h4>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
@ -56,51 +56,59 @@
|
|||||||
"path": "/api/operation-api.jag"
|
"path": "/api/operation-api.jag"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"errorPages": {
|
||||||
|
"500": "/error-pages/error500.html",
|
||||||
|
"404": "/error-pages/error404.html",
|
||||||
|
"401": "/error-pages/error401.html",
|
||||||
|
"405": "/error-pages/error405.html",
|
||||||
|
"403": "/error-pages/error403.html",
|
||||||
|
"400": "/error-pages/error400.html"
|
||||||
|
},
|
||||||
"filters": [
|
"filters": [
|
||||||
|
{
|
||||||
|
"name": "URLBasedCachePreventionFilter",
|
||||||
|
"class": "org.wso2.carbon.ui.filters.cache.URLBasedCachePreventionFilter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"HttpHeaderSecurityFilter",
|
||||||
|
"class":"org.apache.catalina.filters.HttpHeaderSecurityFilter",
|
||||||
|
"params" : [{"name" : "hstsEnabled", "value" : "false"}]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"filterMappings": [
|
||||||
|
{
|
||||||
|
"name": "URLBasedCachePreventionFilter",
|
||||||
|
"url": "/api/*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"HttpHeaderSecurityFilter",
|
||||||
|
"url":"*"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"listeners" : [
|
||||||
{
|
{
|
||||||
"name": "URLBasedCachePreventionFilter",
|
"class" : "org.owasp.csrfguard.CsrfGuardServletContextListener"
|
||||||
"class": "org.wso2.carbon.ui.filters.cache.URLBasedCachePreventionFilter"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"HttpHeaderSecurityFilter",
|
"class" : "org.owasp.csrfguard.CsrfGuardHttpSessionListener"
|
||||||
"class":"org.apache.catalina.filters.HttpHeaderSecurityFilter",
|
|
||||||
"params" : [{"name" : "hstsEnabled", "value" : "false"}]
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"filterMappings": [
|
"servlets" : [
|
||||||
{
|
{
|
||||||
"name": "URLBasedCachePreventionFilter",
|
"name" : "JavaScriptServlet",
|
||||||
"url": "/api/*"
|
"class" : "org.owasp.csrfguard.servlet.JavaScriptServlet"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name":"HttpHeaderSecurityFilter",
|
|
||||||
"url":"*"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"listeners" : [
|
"servletMappings" : [
|
||||||
{
|
{
|
||||||
"class" : "org.owasp.csrfguard.CsrfGuardServletContextListener"
|
"name" : "JavaScriptServlet",
|
||||||
},
|
"url" : "/csrf.js"
|
||||||
{
|
}
|
||||||
"class" : "org.owasp.csrfguard.CsrfGuardHttpSessionListener"
|
],
|
||||||
}
|
"contextParams" : [
|
||||||
],
|
{
|
||||||
"servlets" : [
|
"name" : "Owasp.CsrfGuard.Config",
|
||||||
{
|
"value" : "/repository/conf/security/Owasp.CsrfGuard.dashboard.properties"
|
||||||
"name" : "JavaScriptServlet",
|
}
|
||||||
"class" : "org.owasp.csrfguard.servlet.JavaScriptServlet"
|
]
|
||||||
}
|
|
||||||
],
|
|
||||||
"servletMappings" : [
|
|
||||||
{
|
|
||||||
"name" : "JavaScriptServlet",
|
|
||||||
"url" : "/csrf.js"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"contextParams" : [
|
|
||||||
{
|
|
||||||
"name" : "Owasp.CsrfGuard.Config",
|
|
||||||
"value" : "/repository/conf/security/Owasp.CsrfGuard.Carbon.properties"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@
|
|||||||
placeholder="User Name" required="required" autofocus="autofocus" />
|
placeholder="User Name" required="required" autofocus="autofocus" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="password" name="password" class="form-control"
|
<input type="password" name="password" class="form-control" autocomplete="off"
|
||||||
placeholder="Password" required="required" />
|
placeholder="Password" required="required" />
|
||||||
</div>
|
</div>
|
||||||
{{#if referer}}
|
{{#if referer}}
|
||||||
|
|||||||
@ -26,5 +26,52 @@
|
|||||||
"url": "/*",
|
"url": "/*",
|
||||||
"path": "/lib/pages.jag"
|
"path": "/lib/pages.jag"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"filters": [
|
||||||
|
{
|
||||||
|
"name": "URLBasedCachePreventionFilter",
|
||||||
|
"class": "org.wso2.carbon.ui.filters.cache.URLBasedCachePreventionFilter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"HttpHeaderSecurityFilter",
|
||||||
|
"class":"org.apache.catalina.filters.HttpHeaderSecurityFilter",
|
||||||
|
"params" : [{"name" : "hstsEnabled", "value" : "false"}]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"filterMappings": [
|
||||||
|
{
|
||||||
|
"name": "URLBasedCachePreventionFilter",
|
||||||
|
"url": "/api/*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"HttpHeaderSecurityFilter",
|
||||||
|
"url":"*"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"listeners" : [
|
||||||
|
{
|
||||||
|
"class" : "org.owasp.csrfguard.CsrfGuardServletContextListener"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"class" : "org.owasp.csrfguard.CsrfGuardHttpSessionListener"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"servlets" : [
|
||||||
|
{
|
||||||
|
"name" : "JavaScriptServlet",
|
||||||
|
"class" : "org.owasp.csrfguard.servlet.JavaScriptServlet"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"servletMappings" : [
|
||||||
|
{
|
||||||
|
"name" : "JavaScriptServlet",
|
||||||
|
"url" : "/csrf.js"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"contextParams" : [
|
||||||
|
{
|
||||||
|
"name" : "Owasp.CsrfGuard.Config",
|
||||||
|
"value" : "/repository/conf/security/Owasp.CsrfGuard.dashboard.properties"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
@ -502,27 +502,25 @@ var module = {};
|
|||||||
// This is a logout response.
|
// This is a logout response.
|
||||||
module.logout(response);
|
module.logout(response);
|
||||||
} else {
|
} else {
|
||||||
// This is a login response.
|
// This is a login response.
|
||||||
var ssoConfigs = getSsoConfigurations();
|
var ssoConfigs = getSsoConfigurations();
|
||||||
var rsEnabled = ssoConfigs[constants.APP_CONF_AUTH_MODULE_SSO_RESPONSE_SIGNING_ENABLED];
|
var CarbonUtils = Packages.org.wso2.carbon.utils.CarbonUtils;
|
||||||
if (utils.parseBoolean(rsEnabled)) {
|
var keyStorePassword = CarbonUtils.getServerConfiguration().getFirstProperty("Security.TrustStore.Password");
|
||||||
var CarbonUtils = Packages.org.wso2.carbon.utils.CarbonUtils;
|
var keyStoreName = CarbonUtils.getServerConfiguration().getFirstProperty("Security.TrustStore.Location");
|
||||||
var keyStorePassword = CarbonUtils.getServerConfiguration().getFirstProperty("Security.TrustStore.Password");
|
var identityAlias = ssoConfigs[constants.APP_CONF_AUTH_MODULE_SSO_IDENTITY_ALIAS];
|
||||||
var keyStoreName = CarbonUtils.getServerConfiguration().getFirstProperty("Security.TrustStore.Location");
|
var keyStoreParams = {
|
||||||
var identityAlias = ssoConfigs[constants.APP_CONF_AUTH_MODULE_SSO_IDENTITY_ALIAS];
|
KEY_STORE_NAME: keyStoreName,
|
||||||
var keyStoreParams = {
|
KEY_STORE_PASSWORD: keyStorePassword,
|
||||||
KEY_STORE_NAME: keyStoreName,
|
IDP_ALIAS: identityAlias
|
||||||
KEY_STORE_PASSWORD: keyStorePassword,
|
};
|
||||||
IDP_ALIAS: identityAlias,
|
|
||||||
USE_ST_KEY: !ssoConfigs[constants.APP_CONF_AUTH_MODULE_SSO_USE_ST_KEY]
|
if (!ssoClient.validateSamlResponse(samlResponseObj, ssoConfigs, keyStoreParams)) {
|
||||||
};
|
var msg = "Invalid signature found in the SAML response.";
|
||||||
if (!ssoClient.validateSignature(samlResponseObj, keyStoreParams)) {
|
log.error(msg);
|
||||||
var msg = "Invalid signature found in the SAML response.";
|
response.sendError(500, msg);
|
||||||
log.error(msg);
|
return;
|
||||||
response.sendError(500, msg);
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @type {{sessionId: string, loggedInUser: string, sessionIndex: string, samlToken:
|
* @type {{sessionId: string, loggedInUser: string, sessionIndex: string, samlToken:
|
||||||
* string}}
|
* string}}
|
||||||
@ -532,9 +530,10 @@ var module = {};
|
|||||||
if (ssoSession.sessionId) {
|
if (ssoSession.sessionId) {
|
||||||
var ssoSessions = getSsoSessions();
|
var ssoSessions = getSsoSessions();
|
||||||
ssoSessions[ssoSession.sessionId] = ssoSession;
|
ssoSessions[ssoSession.sessionId] = ssoSession;
|
||||||
if (ssoSession.sessionIndex != null || ssoSession.sessionIndex != 'undefined') {
|
if (ssoSession.sessionIndex) {
|
||||||
module.loadTenant(ssoSession.loggedInUser);
|
module.loadTenant(ssoSession.loggedInUser);
|
||||||
var carbonUser = (require("carbon")).server.tenantUser(ssoSession.loggedInUser);
|
var carbonUser = (require("carbon")).server.tenantUser(ssoSession.loggedInUser);
|
||||||
|
module.loadTenant(ssoSession.loggedInUser);
|
||||||
utils.setCurrentUser(carbonUser.username, carbonUser.domain, carbonUser.tenantId);
|
utils.setCurrentUser(carbonUser.username, carbonUser.domain, carbonUser.tenantId);
|
||||||
var scriptArgument = {input: {samlToken: ssoSession.samlToken}, user: module.getCurrentUser()};
|
var scriptArgument = {input: {samlToken: ssoSession.samlToken}, user: module.getCurrentUser()};
|
||||||
handleEvent(OPERATION_LOGIN, EVENT_SUCCESS, scriptArgument);
|
handleEvent(OPERATION_LOGIN, EVENT_SUCCESS, scriptArgument);
|
||||||
|
|||||||
@ -116,6 +116,8 @@
|
|||||||
org.wso2.carbon.identity.application.authentication.framework.model,
|
org.wso2.carbon.identity.application.authentication.framework.model,
|
||||||
org.apache.oltu.oauth2.common,
|
org.apache.oltu.oauth2.common,
|
||||||
org.wso2.carbon.base,
|
org.wso2.carbon.base,
|
||||||
|
org.apache.xerces.impl; resolution:=optional,
|
||||||
|
org.apache.xerces.util; resolution:=optional
|
||||||
</Import-Package>
|
</Import-Package>
|
||||||
</instructions>
|
</instructions>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@ -36,55 +36,133 @@ public class Policy implements Comparable<Policy>, Serializable {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 19981017L;
|
private static final long serialVersionUID = 19981017L;
|
||||||
|
|
||||||
@ApiModelProperty(name = "id", value = "The policy ID", required = true)
|
@ApiModelProperty(
|
||||||
|
name = "id",
|
||||||
|
value = "The policy ID",
|
||||||
|
required = true,
|
||||||
|
example = "1")
|
||||||
private int id; // Identifier of the policy.
|
private int id; // Identifier of the policy.
|
||||||
@ApiModelProperty(name = "priorityId", value = "The priority order of the policy. 1 indicates the highest"
|
|
||||||
+ " priority", required = true)
|
@ApiModelProperty(
|
||||||
|
name = "priorityId",
|
||||||
|
value = "The priority order of the policy. 1 indicates the highest priority",
|
||||||
|
required = true,
|
||||||
|
example = "1")
|
||||||
private int priorityId; // Priority of the policies. This will be used only for simple evaluation.
|
private int priorityId; // Priority of the policies. This will be used only for simple evaluation.
|
||||||
@ApiModelProperty(name = "profile", value = "Contains the details of the profile that is included in the "
|
|
||||||
+ "policy", required = true)
|
@ApiModelProperty(
|
||||||
|
name = "profile",
|
||||||
|
value = "Contains the details of the profile that is included in the policy",
|
||||||
|
required = true)
|
||||||
private Profile profile; // Profile
|
private Profile profile; // Profile
|
||||||
@ApiModelProperty(name = "policyName", value = "The name of the policy", required = true)
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
name = "policyName",
|
||||||
|
value = "The name of the policy",
|
||||||
|
required = true,
|
||||||
|
example = "Block Camera")
|
||||||
private String policyName; // Name of the policy.
|
private String policyName; // Name of the policy.
|
||||||
@ApiModelProperty(name = "generic", value = "If true, this should be applied to all related device",
|
|
||||||
required = true)
|
@ApiModelProperty(
|
||||||
|
name = "generic",
|
||||||
|
value = "If true, this should be applied to all related device",
|
||||||
|
required = true,
|
||||||
|
example = "false")
|
||||||
private boolean generic; // If true, this should be applied to all related device.
|
private boolean generic; // If true, this should be applied to all related device.
|
||||||
@ApiModelProperty(name = "roles", value = "The roles to whom the policy is applied on", required = true)
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
name = "roles",
|
||||||
|
value = "The roles to whom the policy is applied on",
|
||||||
|
required = true,
|
||||||
|
example = "[ \n" + " \"ANY\"\n" + " ]")
|
||||||
private List<String> roles; // Roles which this policy should be applied.
|
private List<String> roles; // Roles which this policy should be applied.
|
||||||
@ApiModelProperty(name = "ownershipType", value = "The policy ownership type. It can be any of the "
|
|
||||||
+ "following values:\n"
|
@ApiModelProperty(
|
||||||
+ "ANY - The policy will be applied on the BYOD and COPE device types\n"
|
name = "ownershipType",
|
||||||
+ "BYOD (Bring Your Own Device) - The policy will only be applied on the BYOD device type\n"
|
value = "The policy ownership type. It can be any of the following values:\n"
|
||||||
+ "COPE (Corporate-Owned, Personally-Enabled) - The policy will only be applied on the COPE "
|
+ "ANY - The policy will be applied on the BYOD and COPE device types\n"
|
||||||
+ "device type\n", required = true)
|
+ "BYOD (Bring Your Own Device) - The policy will only be applied on the BYOD device type\n"
|
||||||
|
+ "COPE (Corporate-Owned, Personally-Enabled) - The policy will only be applied on the COPE "
|
||||||
|
+ "device type\n",
|
||||||
|
required = true,
|
||||||
|
example = "BYOD")
|
||||||
private String ownershipType; // Ownership type (COPE, BYOD, CPE)
|
private String ownershipType; // Ownership type (COPE, BYOD, CPE)
|
||||||
@ApiModelProperty(name = "devices", value = "Lists out the devices the policy is enforced on",
|
|
||||||
required = true)
|
@ApiModelProperty(
|
||||||
|
name = "devices",
|
||||||
|
value = "Lists out the devices the policy is enforced on",
|
||||||
|
required = true,
|
||||||
|
example = "[]")
|
||||||
private List<Device> devices; // Individual devices this policy should be applied
|
private List<Device> devices; // Individual devices this policy should be applied
|
||||||
@ApiModelProperty(name = "users", value = "Lists out the users on whose devices the policy is enforced",
|
|
||||||
required = true)
|
@ApiModelProperty(
|
||||||
|
name = "users",
|
||||||
|
value = "Lists out the users on whose devices the policy is enforced",
|
||||||
|
required = true,
|
||||||
|
example = "[]")
|
||||||
private List<String> users;
|
private List<String> users;
|
||||||
@ApiModelProperty(name = "active", value = "If the value is true it indicates that the policy is active. "
|
|
||||||
+ "If the value is false it indicates that the policy is inactive", required = true)
|
@ApiModelProperty(
|
||||||
|
name = "active",
|
||||||
|
value = "If the value is true it indicates that the policy is active. "
|
||||||
|
+ "If the value is false it indicates that the policy is inactive",
|
||||||
|
required = true,
|
||||||
|
example = "false")
|
||||||
private boolean active;
|
private boolean active;
|
||||||
@ApiModelProperty(name = "updated", value = "If you have made changes to the policy but have not applied"
|
|
||||||
+ " these changes to the devices that are registered with EMM, then the value is defined as true."
|
@ApiModelProperty(
|
||||||
+ " But if you have already applied any changes made to the policy then the value is defined as"
|
name = "updated",
|
||||||
+ " false.", required = true)
|
value = "If you have made changes to the policy but have not applied"
|
||||||
|
+ " these changes to the devices that are registered with EMM, then the value is defined as true."
|
||||||
|
+ " But if you have already applied any changes made to the policy then the value is defined as"
|
||||||
|
+ " false.",
|
||||||
|
required = true,
|
||||||
|
example = "false")
|
||||||
private boolean updated;
|
private boolean updated;
|
||||||
@ApiModelProperty(name = "description", value = "Gives a description on the policy", required = true)
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
name = "description",
|
||||||
|
value = "Gives a description on the policy",
|
||||||
|
required = true,
|
||||||
|
example = "This will block the camera functionality")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
/* Compliance data*/
|
@ApiModelProperty(
|
||||||
private String compliance;
|
name = "compliance",
|
||||||
|
value = "Define the non-compliance rules. WSO2 EMM provides the following non-compliance rules:\n"
|
||||||
|
+ "Enforce - Forcefully enforce the policies on the devices.\n"
|
||||||
|
+ "Warning - If the device does not adhere to the given policies a warning message will "
|
||||||
|
+ "be sent.\n"
|
||||||
|
+ "Monitor - If the device does not adhere to the given policies the server is notified "
|
||||||
|
+ "of the violation unknown to the user and the administrator can take the necessary "
|
||||||
|
+ "actions with regard to the reported",
|
||||||
|
required = true,
|
||||||
|
example = "enforce")
|
||||||
|
private String compliance; /* Compliance data*/
|
||||||
|
|
||||||
/*Dynamic policy attributes*/
|
/*Dynamic policy attributes*/
|
||||||
|
|
||||||
/* This is related criteria based policy */
|
/* This is related criteria based policy */
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
name = "policyCriterias",
|
||||||
|
value = "",
|
||||||
|
required = true,
|
||||||
|
example = "[]")
|
||||||
private List<PolicyCriterion> policyCriterias;
|
private List<PolicyCriterion> policyCriterias;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
name = "tenantId",
|
||||||
|
value = "",
|
||||||
|
required = true,
|
||||||
|
example = "-1234")
|
||||||
private int tenantId;
|
private int tenantId;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
name = "profileId",
|
||||||
|
value = "",
|
||||||
|
required = true,
|
||||||
|
example = "1")
|
||||||
private int profileId;
|
private int profileId;
|
||||||
|
|
||||||
/*This will be used to record attributes which will be used by customer extended PDPs and PIPs*/
|
/*This will be used to record attributes which will be used by customer extended PDPs and PIPs*/
|
||||||
@ -92,7 +170,11 @@ public class Policy implements Comparable<Policy>, Serializable {
|
|||||||
private Map<String, Object> attributes;
|
private Map<String, Object> attributes;
|
||||||
|
|
||||||
/*This will keep the list of groups to which the policy will be applied. */
|
/*This will keep the list of groups to which the policy will be applied. */
|
||||||
|
@ApiModelProperty(
|
||||||
|
name = "deviceGroups",
|
||||||
|
value = "This will keep the list of groups to which the policy will be applied",
|
||||||
|
required = true,
|
||||||
|
example = "[]")
|
||||||
private List<DeviceGroupWrapper> deviceGroups;
|
private List<DeviceGroupWrapper> deviceGroups;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.common;
|
package org.wso2.carbon.policy.mgt.common;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
@ -28,17 +28,61 @@ import java.io.Serializable;
|
|||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@XmlRootElement
|
@XmlRootElement
|
||||||
|
@ApiModel(value = "Profile", description = "This class carries all information related to policy profiles")
|
||||||
|
|
||||||
public class Profile implements Serializable {
|
public class Profile implements Serializable {
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
name = "profileId",
|
||||||
|
value = "The ID of each profile that is in the selected policy",
|
||||||
|
required = true,
|
||||||
|
example = "1")
|
||||||
private int profileId;
|
private int profileId;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
name = "profileName",
|
||||||
|
value = "The name of the profile",
|
||||||
|
required = true,
|
||||||
|
example = "Block Camera")
|
||||||
private String profileName;
|
private String profileName;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
name = "tenantId",
|
||||||
|
value = "The ID of the tenant that added the policy",
|
||||||
|
required = true,
|
||||||
|
example = "-1234")
|
||||||
private int tenantId;
|
private int tenantId;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
name = "deviceType",
|
||||||
|
value = "Contains the device type details the policy was created for",
|
||||||
|
required = true,
|
||||||
|
example = "android")
|
||||||
private String deviceType;
|
private String deviceType;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
name = "createdDate",
|
||||||
|
value = "The date the policy was created",
|
||||||
|
required = true,
|
||||||
|
example = "Thu, 6 Oct 2016 14:39:32 +0530")
|
||||||
private Timestamp createdDate;
|
private Timestamp createdDate;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
name = "updatedDate",
|
||||||
|
value = "The date the changes made to the policy was published to"
|
||||||
|
+ " the devices registered with the EMM",
|
||||||
|
required = true,
|
||||||
|
example = "Thu, 6 Oct 2016 14:39:32 +0530")
|
||||||
private Timestamp updatedDate;
|
private Timestamp updatedDate;
|
||||||
// private List<Feature> featuresList; // Features included in the policies.
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
name = "profileFeaturesList",
|
||||||
|
value = "Contains the features specific to each profile in the policy",
|
||||||
|
required = true)
|
||||||
private List<ProfileFeature> profileFeaturesList; // Features included in the policies.
|
private List<ProfileFeature> profileFeaturesList; // Features included in the policies.
|
||||||
|
|
||||||
|
// private List<Feature> featuresList; // Features included in the policies.
|
||||||
|
|
||||||
public String getDeviceType() {
|
public String getDeviceType() {
|
||||||
return deviceType;
|
return deviceType;
|
||||||
}
|
}
|
||||||
@ -55,13 +99,12 @@ public class Profile implements Serializable {
|
|||||||
this.tenantId = tenantId;
|
this.tenantId = tenantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public List<Feature> getFeaturesList() {
|
/* public List<Feature> getFeaturesList() {
|
||||||
return featuresList;
|
return featuresList;
|
||||||
}
|
}
|
||||||
|
public void setFeaturesList(List<Feature> featuresList) {
|
||||||
public void setFeaturesList(List<Feature> featuresList) {
|
this.featuresList = featuresList;
|
||||||
this.featuresList = featuresList;
|
}*/
|
||||||
}*/
|
|
||||||
@XmlElement
|
@XmlElement
|
||||||
public int getProfileId() {
|
public int getProfileId() {
|
||||||
return profileId;
|
return profileId;
|
||||||
|
|||||||
@ -29,18 +29,39 @@ public class ProfileFeature implements Serializable {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 19981018L;
|
private static final long serialVersionUID = 19981018L;
|
||||||
|
|
||||||
@ApiModelProperty(name = "id", value = "Define the ID", required = true)
|
@ApiModelProperty(
|
||||||
|
name = "id",
|
||||||
|
value = "Define the ID",
|
||||||
|
required = true,
|
||||||
|
example = "1")
|
||||||
private int id;
|
private int id;
|
||||||
@ApiModelProperty(name = "featureCode", value = "Provide the code that defines the policy you wish to add",
|
|
||||||
required = true)
|
@ApiModelProperty(
|
||||||
|
name = "featureCode",
|
||||||
|
value = "Provide the code that defines the policy you wish to add",
|
||||||
|
required = true,
|
||||||
|
example = "CAMERA")
|
||||||
private String featureCode;
|
private String featureCode;
|
||||||
@ApiModelProperty(name = "profileId", value = "Define the ID of the profile", required = true)
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
name = "profileId",
|
||||||
|
value = "Define the ID of the profile",
|
||||||
|
required = true,
|
||||||
|
example = "1")
|
||||||
private int profileId;
|
private int profileId;
|
||||||
@ApiModelProperty(name = "deviceTypeId", value = "The ID used to define the type of the device platform",
|
|
||||||
required = true)
|
@ApiModelProperty(
|
||||||
|
name = "deviceType",
|
||||||
|
value = "The ID used to define the type of the device platform",
|
||||||
|
required = true,
|
||||||
|
example = "android")
|
||||||
private String deviceType;
|
private String deviceType;
|
||||||
@ApiModelProperty(name = "content", value = "The list of parameters that define the policy",
|
|
||||||
required = true)
|
@ApiModelProperty(
|
||||||
|
name = "content",
|
||||||
|
value = "The list of parameters that define the policy",
|
||||||
|
required = true,
|
||||||
|
example = "{\\\"enabled\\\":false}")
|
||||||
private Object content;
|
private Object content;
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
|
|||||||
@ -19,6 +19,7 @@ package org.wso2.carbon.webapp.authenticator.framework.authenticator.oauth.impl;
|
|||||||
|
|
||||||
import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationRequestDTO;
|
import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationRequestDTO;
|
||||||
import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationResponseDTO;
|
import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationResponseDTO;
|
||||||
|
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
|
||||||
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
|
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
|
||||||
import org.wso2.carbon.webapp.authenticator.framework.AuthenticatorFrameworkDataHolder;
|
import org.wso2.carbon.webapp.authenticator.framework.AuthenticatorFrameworkDataHolder;
|
||||||
import org.wso2.carbon.webapp.authenticator.framework.authenticator.oauth.OAuth2TokenValidator;
|
import org.wso2.carbon.webapp.authenticator.framework.authenticator.oauth.OAuth2TokenValidator;
|
||||||
@ -64,6 +65,9 @@ public class LocalOAuthValidator implements OAuth2TokenValidator {
|
|||||||
tokenValidationResponse.getAuthorizedUser());
|
tokenValidationResponse.getAuthorizedUser());
|
||||||
tenantDomain =
|
tenantDomain =
|
||||||
MultitenantUtils.getTenantDomain(tokenValidationResponse.getAuthorizedUser());
|
MultitenantUtils.getTenantDomain(tokenValidationResponse.getAuthorizedUser());
|
||||||
|
if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
|
||||||
|
tenantDomain = MultitenantUtils.getTenantDomain(userName);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
OAuthValidationResponse oAuthValidationResponse = new OAuthValidationResponse();
|
OAuthValidationResponse oAuthValidationResponse = new OAuthValidationResponse();
|
||||||
oAuthValidationResponse.setErrorMsg(tokenValidationResponse.getErrorMsg());
|
oAuthValidationResponse.setErrorMsg(tokenValidationResponse.getErrorMsg());
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
</ManagementRepository>
|
</ManagementRepository>
|
||||||
<PushNotificationProviders>
|
<PushNotificationProviders>
|
||||||
<Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.GCMBasedPushNotificationProvider</Provider>
|
<Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.GCMBasedPushNotificationProvider</Provider>
|
||||||
|
<!--<Provider>org.wso2.carbon.device.mgt.mobile.impl.ios.apns.APNSBasedPushNotificationProvider</Provider>-->
|
||||||
<!--<Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider</Provider>-->
|
<!--<Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider</Provider>-->
|
||||||
<!--<Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider</Provider>-->
|
<!--<Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider</Provider>-->
|
||||||
</PushNotificationProviders>
|
</PushNotificationProviders>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user