Merge branch 'release-2.0.x' of https://github.com/wso2/carbon-device-mgt into release-2.0.x

revert-70aa11f8
ayyoob 8 years ago
commit 505f281f9d

@ -27,7 +27,15 @@ import org.wso2.carbon.apimgt.webapp.publisher.config.APIResource;
import org.wso2.carbon.apimgt.webapp.publisher.config.APIResourceConfiguration; import org.wso2.carbon.apimgt.webapp.publisher.config.APIResourceConfiguration;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.ws.rs.*; import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.OPTIONS;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;

@ -21,7 +21,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
class ExtendedFileProtocolIteratorFactory implements DirectoryIteratorFactory { final class ExtendedFileProtocolIteratorFactory implements DirectoryIteratorFactory {
private static final String ENCODING_SCHEME = "UTF-8"; private static final String ENCODING_SCHEME = "UTF-8";

@ -21,8 +21,6 @@ import org.apache.commons.codec.binary.Base64;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.bouncycastle.asn1.ASN1Encodable; import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.pkcs.Attribute; import org.bouncycastle.asn1.pkcs.Attribute;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.x500.RDN; import org.bouncycastle.asn1.x500.RDN;
@ -65,13 +63,13 @@ import org.wso2.carbon.context.PrivilegedCarbonContext;
import javax.security.auth.x500.X500Principal; import javax.security.auth.x500.X500Principal;
import javax.xml.bind.DatatypeConverter; import javax.xml.bind.DatatypeConverter;
import java.io.*; import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger; import java.math.BigInteger;
import java.security.*; import java.security.*;
import java.security.cert.Certificate; import java.security.cert.Certificate;
import java.security.cert.*; import java.security.cert.*;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;

@ -115,6 +115,10 @@
<build> <build>
<plugins> <plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin> <plugin>
<groupId>org.apache.felix</groupId> <groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId> <artifactId>maven-bundle-plugin</artifactId>

@ -29,14 +29,29 @@ import java.util.List;
"role or devices the application is associated with.") "role or devices the application is associated with.")
public class ApplicationWrapper { public class ApplicationWrapper {
@ApiModelProperty(name = "userNameList", value = "List of user names.", required = true) @ApiModelProperty(
name = "userNameList",
value = "List of user names.",
required = true)
private List<String> userNameList; private List<String> userNameList;
@ApiModelProperty(name = "roleNameList", value = "List of role names.", required = true)
@ApiModelProperty(
name = "roleNameList",
value = "List of role names.",
required = true)
private List<String> roleNameList; private List<String> roleNameList;
@ApiModelProperty(name = "deviceIdentifiers", value = "List of device identifiers.", required = true,
@ApiModelProperty(
name = "deviceIdentifiers",
value = "List of device identifiers.",
required = true,
dataType = "List[org.wso2.carbon.device.mgt.common.DeviceIdentifier]") dataType = "List[org.wso2.carbon.device.mgt.common.DeviceIdentifier]")
private List<DeviceIdentifier> deviceIdentifiers; private List<DeviceIdentifier> deviceIdentifiers;
@ApiModelProperty(name = "application", value = "Details of the mobile application.", required = true)
@ApiModelProperty(
name = "application",
value = "Details of the mobile application.",
required = true)
private MobileApp application; private MobileApp application;
public MobileApp getApplication() { public MobileApp getApplication() {

@ -26,7 +26,9 @@ public class BasePaginatedResult {
/** /**
* Number of Resources returned. * Number of Resources returned.
*/ */
@ApiModelProperty(value = "Number of total resources.", example = "2") @ApiModelProperty(
value = "Number of total resources.",
example = "1")
@JsonProperty("count") @JsonProperty("count")
private int count; private int count;

@ -27,7 +27,10 @@ public class OldPasswordResetWrapper extends PasswordResetWrapper{
/* /*
Base64 encoded password Base64 encoded password
*/ */
@ApiModelProperty(name = "oldPassword", value = "Old password of the user.", required = true ) @ApiModelProperty(
name = "oldPassword",
value = "Old password of the user.",
required = true )
private String oldPassword; private String oldPassword;
public String getOldPassword() { public String getOldPassword() {

@ -27,7 +27,10 @@ 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") example = "JiM&100%pW")
private String newPassword; private String newPassword;

@ -30,49 +30,71 @@ import java.util.List;
+ "Wrappers") + "Wrappers")
public class PolicyWrapper { public class PolicyWrapper {
@ApiModelProperty(name = "policyName", value = "The name of the policy", required = true) @ApiModelProperty(
name = "policyName",
value = "The name of the policy",
required = true)
@Size(max = 45) @Size(max = 45)
private String policyName; private String policyName;
@ApiModelProperty(name = "description", value = "Gives a description on the policy", required = true) @ApiModelProperty(
name = "description",
value = "Gives a description on the policy",
required = true)
@Size(max = 1000) @Size(max = 1000)
private String description; private String description;
@ApiModelProperty(name = "compliance", value = "Provides the non-compliance rules. WSO2 EMM provides the" @ApiModelProperty(
+ " following non-compliance rules:\n" name = "compliance",
value = "Provides the non-compliance rules. WSO2 EMM provides the following non-compliance rules:\n"
+ "Enforce - Forcefully enforce the policies on the devices\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" + "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 " + "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" + "violation unknown to the user and the administrator can take the necessary actions with regard"
+ " to the reported", required = true) + " to the reported",
required = true)
@Size(max = 100) @Size(max = 100)
private String compliance; private String compliance;
@ApiModelProperty(name = "ownershipType", value = "The policy ownership type. It can be any of the " @ApiModelProperty(
+ "following values:\n" name = "ownershipType",
value = "The policy ownership type. It can be any of the following values:\n"
+ "ANY - The policy will be applied on the BYOD and COPE device types\n" + "ANY - The policy will be applied on the BYOD and COPE device types\n"
+ "BYOD (Bring Your Own Device) - The policy will only be applied on the BYOD device type\n" + "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 " + "COPE (Corporate-Owned, Personally-Enabled) - The policy will only be applied on the COPE "
+ "device type", required = true) + "device type",
required = true)
@Size(max = 45) @Size(max = 45)
private String ownershipType; private String ownershipType;
@ApiModelProperty(name = "active", value = "If the value is true it indicates that the policy is active. " @ApiModelProperty(
+ "If the value is false it indicates that the policy is inactive", required = true) 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)
private boolean active; private boolean active;
@ApiModelProperty(name = "profile", value = "Contains the details of the profile that is included in the" @ApiModelProperty(
+ " policy", required = true) name = "profile",
value = "Contains the details of the profile that is included in the policy",
required = true)
private Profile profile; private Profile profile;
@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)
private List<String> roles; private List<String> roles;
@ApiModelProperty(name = "deviceIdentifiers", value = "Lists out the devices the policy is enforced on", @ApiModelProperty(
name = "deviceIdentifiers",
value = "Lists out the devices the policy is enforced on",
required = true) required = true)
private List<DeviceIdentifier> deviceIdentifiers; private List<DeviceIdentifier> deviceIdentifiers;
@ApiModelProperty(name = "users", value = "Lists out the users on whose devices the policy is enforced", @ApiModelProperty(
name = "users",
value = "Lists out the users on whose devices the policy is enforced",
required = true) required = true)
private List<String> users; private List<String> users;

@ -27,7 +27,15 @@ import org.wso2.carbon.apimgt.api.model.Scope;
import org.wso2.carbon.device.mgt.common.permission.mgt.Permission; import org.wso2.carbon.device.mgt.common.permission.mgt.Permission;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.ws.rs.*; import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.OPTIONS;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
@ -332,7 +340,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;
File fp = new File(path); File fp = new File(path);

@ -26,7 +26,10 @@ import org.wso2.carbon.device.mgt.common.TransactionManagementException;
import org.wso2.carbon.device.mgt.common.UnsupportedDatabaseEngineException; import org.wso2.carbon.device.mgt.common.UnsupportedDatabaseEngineException;
import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig;
import org.wso2.carbon.device.mgt.core.config.datasource.JNDILookupDefinition; import org.wso2.carbon.device.mgt.core.config.datasource.JNDILookupDefinition;
import org.wso2.carbon.device.mgt.core.dao.impl.*; import org.wso2.carbon.device.mgt.core.dao.impl.ApplicationDAOImpl;
import org.wso2.carbon.device.mgt.core.dao.impl.ApplicationMappingDAOImpl;
import org.wso2.carbon.device.mgt.core.dao.impl.DeviceTypeDAOImpl;
import org.wso2.carbon.device.mgt.core.dao.impl.EnrollmentDAOImpl;
import org.wso2.carbon.device.mgt.core.dao.impl.device.GenericDeviceDAOImpl; import org.wso2.carbon.device.mgt.core.dao.impl.device.GenericDeviceDAOImpl;
import org.wso2.carbon.device.mgt.core.dao.impl.device.OracleDeviceDAOImpl; import org.wso2.carbon.device.mgt.core.dao.impl.device.OracleDeviceDAOImpl;
import org.wso2.carbon.device.mgt.core.dao.impl.device.PostgreSQLDeviceDAOImpl; import org.wso2.carbon.device.mgt.core.dao.impl.device.PostgreSQLDeviceDAOImpl;
@ -34,8 +37,6 @@ import org.wso2.carbon.device.mgt.core.dao.impl.device.SQLServerDeviceDAOImpl;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsDAO; import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsDAO;
import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.impl.DeviceDetailsDAOImpl; import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.impl.DeviceDetailsDAOImpl;
import org.wso2.carbon.device.mgt.core.search.mgt.dao.SearchDAO;
import org.wso2.carbon.device.mgt.core.search.mgt.dao.impl.SearchDAOImpl;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.sql.Connection; import java.sql.Connection;
@ -135,10 +136,6 @@ public class DeviceManagementDAOFactory {
return new DeviceDetailsDAOImpl(); return new DeviceDetailsDAOImpl();
} }
public static SearchDAO getSearchDAO() {
return new SearchDAOImpl();
}
public static void init(DataSourceConfig config) { public static void init(DataSourceConfig config) {
dataSource = resolveDataSource(config); dataSource = resolveDataSource(config);
try { try {

@ -1,29 +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.
*/
package org.wso2.carbon.device.mgt.core.search.mgt.dao;
public interface SearchDAO {
// List<Device> searchDeviceDetailsTable(String query) throws SearchDAOException;
//
// List<Device> searchDevicePropertyTable(String query) throws SearchDAOException;
}

@ -1,238 +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.
*/
package org.wso2.carbon.device.mgt.core.search.mgt.dao.impl;
import org.wso2.carbon.device.mgt.core.search.mgt.dao.SearchDAO;
public class SearchDAOImpl implements SearchDAO {
//
// private static final Log log = LogFactory.getLog(SearchDAOImpl.class);
//
// @Override
// public List<Device> searchDeviceDetailsTable(String query) throws SearchDAOException {
// if (log.isDebugEnabled()) {
// log.debug("Query : " + query);
// }
// Connection conn;
// PreparedStatement stmt = null;
// ResultSet rs;
// 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("NAME");
// device.setType(rs.getString("DEVICE_TYPE_NAME"));
// device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
//
// 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 acquiring the device details.", e);
// } finally {
// DeviceManagementDAOUtil.cleanupResources(stmt, null);
// }
//
// this.fillPropertiesOfDevices(devices);
//
// if (log.isDebugEnabled()) {
// log.debug("Number of the device returned from the query : " + devices.size());
// }
// return devices;
// }
//
// @Override
// public List<Device> searchDevicePropertyTable(String query) throws SearchDAOException {
// if (log.isDebugEnabled()) {
// log.debug("Query : " + query);
// }
//
// Connection conn;
// PreparedStatement stmt = null;
// ResultSet rs;
// 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"));
//
// 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, null);
// }
//
// 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;
// ResultSet rs;
//
// try {
// conn = this.getConnection();
// String query = "SELECT * FROM DM_DEVICE_INFO WHERE DEVICE_ID IN (?) ORDER BY DEVICE_ID ;";
// stmt = conn.prepareStatement(query);
// if (conn.getMetaData().getDatabaseProductName().contains("H2") ||
// conn.getMetaData().getDatabaseProductName().contains("MySQL")) {
// String inData = Utils.getDeviceIdsAsString(devices);
// stmt.setString(1, inData);
// } else {
// 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);
// }
// 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;
// }
}

@ -17,18 +17,16 @@
*/ */
package org.wso2.carbon.device.mgt.core.search; package org.wso2.carbon.device.mgt.core.Search;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest; import org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest;
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
import org.wso2.carbon.device.mgt.core.device.details.mgt.impl.DeviceInformationManagerImpl; import org.wso2.carbon.device.mgt.core.device.details.mgt.impl.DeviceInformationManagerImpl;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.search.util.Utils;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;

@ -1,183 +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.
*/
package org.wso2.carbon.device.mgt.core.search;
import com.google.gson.Gson;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.search.Condition;
import org.wso2.carbon.device.mgt.common.search.SearchContext;
import org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService;
import org.wso2.carbon.device.mgt.core.search.mgt.impl.SearchManagerServiceImpl;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
import java.util.ArrayList;
import java.util.List;
public class SearchDevice extends BaseDeviceManagementTest {
private static final Log log = LogFactory.getLog(DeviceDetails.class);
@BeforeClass
@Override
public void init() throws Exception {
DeviceManagementProviderService deviceManagementProviderService = new DeviceManagementProviderServiceImpl();
DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceManagementProviderService);
}
@Test
public void searchDeviceDetails() throws Exception {
SearchContext context = new SearchContext();
List<Condition> conditions = new ArrayList<>();
Condition cond = new Condition();
cond.setKey("BATTERY_VOLTAGE");
cond.setOperator("=");
cond.setValue("40");
cond.setState(Condition.State.AND);
conditions.add(cond);
// Condition cond2 = new Condition();
// cond2.setKey("CPU_USAGE");
// cond2.setOperator(">");
// cond2.setValue("40");
// cond2.setState(Condition.State.OR);
// conditions.add(cond2);
//
// Condition cond3 = new Condition();
// cond3.setKey("LOCATION");
// cond3.setOperator("=");
// cond3.setValue("Colombo");
// cond3.setState(Condition.State.AND);
// conditions.add(cond3);
context.setConditions(conditions);
SearchManagerService service = new SearchManagerServiceImpl();
List<Device> devices = service.search(context);
Gson gson = new Gson();
String bbbb = gson.toJson(devices);
log.info(bbbb);
for (Device device : devices) {
log.debug(device.getDescription());
log.debug(device.getDeviceIdentifier());
}
}
@Test
public void doValidLocationSearch() throws Exception {
SearchContext context = new SearchContext();
List<Condition> conditions = new ArrayList<>();
Condition cond = new Condition();
cond.setKey("LOCATION");
cond.setOperator("=");
cond.setValue("Karan");
cond.setState(Condition.State.AND);
conditions.add(cond);
context.setConditions(conditions);
SearchManagerService service = new SearchManagerServiceImpl();
List<Device> devices = service.search(context);
Gson gson = new Gson();
String bbbb = gson.toJson(devices);
log.info("Valid Search " + bbbb);
for (Device device : devices) {
log.debug(device.getDescription());
log.debug(device.getDeviceIdentifier());
}
}
@Test
public void doInvalidLocationSearch() throws Exception {
SearchContext context = new SearchContext();
List<Condition> conditions = new ArrayList<>();
Condition cond = new Condition();
cond.setKey("LOCATION");
cond.setOperator("=");
cond.setValue("Colombo");
cond.setState(Condition.State.AND);
conditions.add(cond);
context.setConditions(conditions);
SearchManagerService service = new SearchManagerServiceImpl();
List<Device> devices = service.search(context);
Gson gson = new Gson();
String bbbb = gson.toJson(devices);
log.info("Invalid Search " + bbbb);
for (Device device : devices) {
log.debug(device.getDescription());
log.debug(device.getDeviceIdentifier());
}
}
@Test
public void doStringSearch() throws Exception {
SearchContext context = new SearchContext();
List<Condition> conditions = new ArrayList<>();
Condition cond = new Condition();
cond.setKey("deviceModel");
cond.setOperator("=");
cond.setValue("SM-T520");
cond.setState(Condition.State.AND);
conditions.add(cond);
context.setConditions(conditions);
SearchManagerService service = new SearchManagerServiceImpl();
List<Device> devices = service.search(context);
Gson gson = new Gson();
String bbbb = gson.toJson(devices);
log.info("Invalid Search " + bbbb);
for (Device device : devices) {
log.debug(device.getDescription());
log.debug(device.getDeviceIdentifier());
}
}
}

@ -1,106 +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.
*/
package org.wso2.carbon.device.mgt.core.search.util;
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.common.TestDataHolder;
import java.util.HashMap;
import java.util.Map;
public class Utils {
public static DeviceInfo getDeviceInfo() {
DeviceInfo deviceInfo = new DeviceInfo();
deviceInfo.setIMSI("e6f236ac82537a8e");
deviceInfo.setSsid("FAFDA");
deviceInfo.setAvailableRAMMemory(1.24);
deviceInfo.setBatteryLevel(27.3);
deviceInfo.setConnectionType("GSM");
deviceInfo.setCpuUsage(82.34);
deviceInfo.setDeviceModel("SM-T520");
deviceInfo.setExternalAvailableMemory(2.45);
deviceInfo.setExternalTotalMemory(16.23);
deviceInfo.setIMEI("e6f236ac82537a8e");
deviceInfo.setIMSI("GT-0WDA");
deviceInfo.setInternalAvailableMemory(3.56);
deviceInfo.setInternalTotalMemory(7.89);
deviceInfo.setMobileSignalStrength(0.67);
deviceInfo.setOperator("Dialog");
deviceInfo.setOsVersion("Lolipop");
deviceInfo.setOsBuildDate("1467366458");
deviceInfo.setPluggedIn(true);
deviceInfo.setSsid("SSSSSS");
deviceInfo.setTotalRAMMemory(4.00);
deviceInfo.setVendor("SAMSUNG");
Map<String, String> propertyMap = new HashMap<>();
propertyMap.put("BATTERY_VOLTAGE", "40");
propertyMap.put("BATTERY_HEALTH", "Good");
propertyMap.put("BATTERY_STATUS", "SWElLED");
propertyMap.put("LOW_MEMORY", "false");
propertyMap.put("MEMORY_THRESHOLD", "100663296");
propertyMap.put("CPU_IOW", "12");
propertyMap.put("CPU_IRQ", "1");
deviceInfo.setDeviceDetailsMap(propertyMap);
return deviceInfo;
}
public static DeviceLocation getSampleDeviceLocation(){
DeviceLocation deviceLocation = new DeviceLocation();
deviceLocation.setDeviceIdentifier(Utils.getDeviceIdentifier());
deviceLocation.setLatitude(76.2422);
deviceLocation.setLongitude(81.43);
deviceLocation.setStreet1("4");
deviceLocation.setStreet2("Isuru Uyana");
deviceLocation.setCity("Karanadeniya");
deviceLocation.setState("Karandeniya");
deviceLocation.setZip("80360");
deviceLocation.setCountry("Sri Lanka");
deviceLocation.setDeviceId(1);
return deviceLocation;
}
public static DeviceIdentifier getDeviceIdentifier(){
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
deviceIdentifier.setType(TestDataHolder.TEST_DEVICE_TYPE);
deviceIdentifier.setId("12345");
return deviceIdentifier;
}
}

@ -2,10 +2,9 @@
"appContext": "/devicemgt/", "appContext": "/devicemgt/",
"httpsURL" : "%https.ip%", "httpsURL" : "%https.ip%",
"httpURL" : "%http.ip%", "httpURL" : "%http.ip%",
"httpsWebURL" : "%https.ip%",
"wssURL" : "https://localhost:9445", "wssURL" : "https://localhost:9445",
"wsURL" : "%http.ip%", "wsURL" : "%http.ip%",
"portalURL": "https://${server.ip}:9445", "portalURL": "https://%server.ip%:9445",
"dashboardServerURL" : "%https.ip%", "dashboardServerURL" : "%https.ip%",
"androidEnrollmentDir": "/android-web-agent/enrollment", "androidEnrollmentDir": "/android-web-agent/enrollment",
"windowsEnrollmentDir": "/windows-web-agent/enrollment", "windowsEnrollmentDir": "/windows-web-agent/enrollment",

@ -674,6 +674,7 @@ var userModule = function () {
*/ */
publicMethods.getSecondaryUserStores = function () { publicMethods.getSecondaryUserStores = function () {
var returnVal = []; var returnVal = [];
// To call the userstore admin service, user needs to have admin permission
if (publicMethods.isAuthorized("/permission/admin")) { if (publicMethods.isAuthorized("/permission/admin")) {
var endpoint = devicemgtProps["adminService"] + constants["USER_STORE_CONFIG_ADMIN_SERVICE_END_POINT"]; var endpoint = devicemgtProps["adminService"] + constants["USER_STORE_CONFIG_ADMIN_SERVICE_END_POINT"];
var wsPayload = "<xsd:getSecondaryRealmConfigurations xmlns:xsd='http://org.apache.axis2/xsd'/>"; var wsPayload = "<xsd:getSecondaryRealmConfigurations xmlns:xsd='http://org.apache.axis2/xsd'/>";

@ -33,6 +33,9 @@ var conf = function () {
} else if ((typeof value === "string") && value.indexOf("%date-year%") > -1) { } else if ((typeof value === "string") && value.indexOf("%date-year%") > -1) {
var year = new Date().getFullYear(); var year = new Date().getFullYear();
return value.replace("%date-year%", year); return value.replace("%date-year%", year);
} else if ((typeof value === "string") && value.indexOf("%server.ip%") > -1) {
var getProperty = require("process").getProperty;
return value.replace("%server.ip%", getProperty("carbon.local.ip"));
} }
return value; return value;
} }

@ -119,10 +119,9 @@
<div id="user-names"> <div id="user-names">
<h4> <h4>
Select user role(s) Select user role(s)
<br><br>
<div style="max-height: 200px; overflow: auto" id="rolesListing">
</div>
</h4> </h4>
<div class="wr-input-control" id="rolesListing">
</div>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
@ -402,3 +401,19 @@
{{js "js/listing.js"}} {{js "js/listing.js"}}
{{/if}} {{/if}}
{{/zone}} {{/zone}}
{{#zone "topCss"}}
<style>
.select2-dropdown {
z-index: 999999999;
}
.wr-input-control {
color: black;
}
.select2-selection__choice {
font-size: medium;
}
</style>
{{/zone}}

@ -391,14 +391,7 @@ function attachEvents() {
listAllRoles(groupId); listAllRoles(groupId);
var shareGroupNextLink = $("a#share-group-next-link"); var shareGroupNextLink = $("a#share-group-next-link");
shareGroupNextLink.click(function () { shareGroupNextLink.click(function () {
var roles = []; var roles = $("#roles").val();
$('.modal .roleCheckBoxes').each(
function () {
if ($(this).is(':checked')) {
roles.push($(this).data('role-name'));
}
}
);
updateGroupShare(groupId, roles); updateGroupShare(groupId, roles);
}); });
@ -505,15 +498,11 @@ function markAlreadySavedUsersRoles(groupId) {
data = JSON.parse(data); data = JSON.parse(data);
if (xhr.status == 200) { if (xhr.status == 200) {
if (data.roles.length > 0) { if (data.roles.length > 0) {
var selectedValues = [];
for (var i = 0; i < data.roles.length; i++) { for (var i = 0; i < data.roles.length; i++) {
$('.roleCheckBoxes').each( selectedValues.push(data.roles[i]);
function () {
if (data.roles[i] == $(this).data('role-name')) {
$(this).attr('checked', true);
}
}
);
} }
$("#roles").val(selectedValues).trigger("change");
} else { } else {
return; return;
} }
@ -533,22 +522,16 @@ function listAllRoles(groupId) {
data = JSON.parse(data); data = JSON.parse(data);
if (xhr.status == 200) { if (xhr.status == 200) {
if (data.roles.length > 0) { if (data.roles.length > 0) {
var html = "<br/>"; var html = '<select id="roles" class="form-control select2" multiple="multiple">';
for (var i = 0; i < data.roles.length; i++) { for (var i = 0; i < data.roles.length; i++) {
html += '<div class="wr-input-control"><label class="wr-input-control checkbox">' + html += '<option value="' + data.roles[i] + '">' + data.roles[i] + '</option>';
'<input class="roleCheckBoxes" type="checkbox" data-role-name="' + data.roles[i] + '" />' +
'<span class="helper" title="' + data.roles[i] + '">' + data.roles[i] +
'</span></label></div>';
$('.roleCheckBoxes').each(
function () {
if (data.roles[i] == $(this).data('role-name')) {
$(this).attr('checked', true);
}
}
);
} }
html += '</select>';
$("#rolesListing").html(html); $("#rolesListing").html(html);
markAlreadySavedUsersRoles(groupId); markAlreadySavedUsersRoles(groupId);
$("select.select2[multiple=multiple]").select2({
tags: false
});
} else { } else {
$("#rolesListing").html("No roles available"); $("#rolesListing").html("No roles available");
} }

@ -68,8 +68,8 @@ $("a#invite-user-link").click(function () {
modalDialog.showAsError(); modalDialog.showAsError();
} else { } else {
modalDialog.header(""); modalDialog.header("");
modalDialog.content("An invitation mail will be sent to the selected user(s) to initiate an enrolment process." + modalDialog.content("An invitation mail will be sent to the selected user(s) to initiate an enrolment " +
" Do you wish to continue ?"); "process. Do you wish to continue ?");
modalDialog.footer('<div class="buttons"><a href="#" id="invite-user-yes-link" class="btn-operations">yes</a>' + modalDialog.footer('<div class="buttons"><a href="#" id="invite-user-yes-link" class="btn-operations">yes</a>' +
'<a href="#" id="invite-user-cancel-link" class="btn-operations btn-default">No</a></div>'); '<a href="#" id="invite-user-cancel-link" class="btn-operations btn-default">No</a></div>');
modalDialog.show(); modalDialog.show();

@ -513,9 +513,18 @@ var module = {};
KEY_STORE_PASSWORD: keyStorePassword, KEY_STORE_PASSWORD: keyStorePassword,
IDP_ALIAS: identityAlias IDP_ALIAS: identityAlias
}; };
var rsEnabled = ssoConfigs[constants.APP_CONF_AUTH_MODULE_SSO_RESPONSE_SIGNING_ENABLED];
if (utils.parseBoolean(rsEnabled)) {
if (!ssoClient.validateSignature(samlResponseObj, keyStoreParams)) {
var msg = "Invalid signature found in the SAML response.";
log.error(msg);
response.sendError(500, msg);
return;
}
}
if (!ssoClient.validateSamlResponse(samlResponseObj, ssoConfigs, keyStoreParams)) { if (!ssoClient.validateSamlResponse(samlResponseObj, ssoConfigs, keyStoreParams)) {
var msg = "Invalid signature found in the SAML response."; var msg = "Invalid SAML response found.";
log.error(msg); log.error(msg);
response.sendError(500, msg); response.sendError(500, msg);
return; return;
@ -531,10 +540,9 @@ var module = {};
var ssoSessions = getSsoSessions(); var ssoSessions = getSsoSessions();
ssoSessions[ssoSession.sessionId] = ssoSession; ssoSessions[ssoSession.sessionId] = ssoSession;
if (ssoSession.sessionIndex) { if (ssoSession.sessionIndex) {
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);
module.loadTenant(ssoSession.loggedInUser);
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);
} }

@ -1581,7 +1581,7 @@
<dependency> <dependency>
<groupId>io.swagger</groupId> <groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId> <artifactId>swagger-annotations</artifactId>
<version>${swagger.version}</version> <version>${swagger.annotations.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.swagger</groupId> <groupId>io.swagger</groupId>

Loading…
Cancel
Save