Merge pull request #1013 from chathurace/testcases

policy management test cases
4.x.x
Geeth 7 years ago committed by GitHub
commit f1e7d6e1de

@ -77,6 +77,7 @@
!org.wso2.carbon.policy.mgt.core.internal,
org.wso2.carbon.policy.mgt.core.*
</Export-Package>
<DynamicImport-Package>*</DynamicImport-Package>
</instructions>
</configuration>
</plugin>
@ -204,11 +205,29 @@
<artifactId>h2-database-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-dbcp.wso2</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4.0.wso2v1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-pool.wso2</groupId>
<artifactId>commons-pool</artifactId>
<version>1.5.6.wso2v1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.10.0</version>
</dependency>
</dependencies>
</project>

@ -232,7 +232,7 @@ public class PolicyManagerImpl implements PolicyManager {
policyDAO.addDeviceGroupsToPolicy(policy);
}
if (policy.getPolicyCriterias() != null) {
if (policy.getPolicyCriterias() != null && !policy.getPolicyCriterias().isEmpty()) {
List<PolicyCriterion> criteria = policy.getPolicyCriterias();
for (PolicyCriterion criterion : criteria) {
if (!policyDAO.checkCriterionExists(criterion.getName())) {
@ -794,7 +794,7 @@ public class PolicyManagerImpl implements PolicyManager {
List<Device> deviceList = new ArrayList<>();
List<Integer> deviceIds;
try {
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
DeviceManagementProviderService service = PolicyManagementDataHolder.getInstance().getDeviceManagementService();
List<Device> allDevices = service.getAllDevices();
PolicyManagementDAOFactory.openConnection();
deviceIds = policyDAO.getPolicyAppliedDevicesIds(policyId);
@ -1092,9 +1092,9 @@ public class PolicyManagerImpl implements PolicyManager {
String type = null;
if (deviceIdentifiers.size() > 0) {
type = deviceIdentifiers.get(0).getType();
}
PolicyManagementDataHolder.getInstance().getDeviceManagementService().addOperation(type,
this.getPolicyRevokeOperation(), deviceIdentifiers);
}
} catch (InvalidDeviceException e) {
String msg = "Invalid DeviceIdentifiers found.";
log.error(msg, e);

@ -122,7 +122,7 @@ public abstract class BasePolicyManagementDAOTest {
}
}
private void initSQLScript() throws Exception {
protected void initSQLScript() throws Exception {
Connection conn = null;
Statement stmt = null;
try {

@ -0,0 +1,334 @@
/*
* 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.policy.mgt.core;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceNotFoundException;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
import org.wso2.carbon.device.mgt.common.group.mgt.GroupAlreadyExistException;
import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
import org.wso2.carbon.device.mgt.common.policy.mgt.DeviceGroupWrapper;
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
import org.wso2.carbon.device.mgt.common.policy.mgt.Profile;
import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
import org.wso2.carbon.device.mgt.core.authorization.DeviceAccessAuthorizationServiceImpl;
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
import org.wso2.carbon.device.mgt.core.operation.mgt.PolicyOperation;
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderServiceImpl;
import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint;
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
import org.wso2.carbon.policy.mgt.core.enforcement.DelegationTask;
import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder;
import org.wso2.carbon.policy.mgt.core.mock.TypeADeviceManagementService;
import org.wso2.carbon.policy.mgt.core.services.SimplePolicyEvaluationTest;
import org.wso2.carbon.policy.mgt.core.task.MonitoringTask;
import org.wso2.carbon.policy.mgt.core.util.PolicyManagementConstants;
import org.wso2.carbon.registry.core.config.RegistryContext;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
import org.wso2.carbon.registry.core.internal.RegistryDataHolder;
import org.wso2.carbon.registry.core.jdbc.realm.InMemoryRealmService;
import org.wso2.carbon.registry.core.service.RegistryService;
import org.wso2.carbon.user.core.service.RealmService;
import java.io.InputStream;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
public class PolicyManagerServiceImplTest extends BasePolicyManagementDAOTest {
private static final Log log = LogFactory.getLog(PolicyManagerServiceImpl.class);
private static final String DEVICE_TYPE_A = "deviceTypeA";
private static final String DEVICE1 = "device1";
private static final String GROUP1 = "group1";
private static final String POLICY1 = "policy1";
private static final String POLICY1_FEATURE1_CODE = "DISALLOW_ADJUST_VOLUME";
private static final String ADMIN_USER = "admin";
private DeviceManagementProviderService deviceMgtService;
private GroupManagementProviderService groupMgtService;
private OperationManager operationManager;
private PolicyManagerService policyManagerService;
private Policy policy1;
@BeforeClass
public void init() throws Exception {
super.initSQLScript();
DeviceConfigurationManager.getInstance().initConfig();
log.info("Initializing policy tests");
deviceMgtService = new DeviceManagementProviderServiceImpl();
groupMgtService = new GroupManagementProviderServiceImpl();
DeviceManagementServiceComponent.notifyStartupListeners();
DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceMgtService);
DeviceManagementDataHolder.getInstance().setRegistryService(getRegistryService());
DeviceManagementDataHolder.getInstance().setDeviceAccessAuthorizationService(new DeviceAccessAuthorizationServiceImpl());
DeviceManagementDataHolder.getInstance().setGroupManagementProviderService(groupMgtService);
DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(null);
PolicyEvaluationPoint policyEvaluationPoint = new SimplePolicyEvaluationTest();
PolicyManagementDataHolder.getInstance().setPolicyEvaluationPoint("Simple", policyEvaluationPoint);
PolicyManagementDataHolder.getInstance().setDeviceManagementService(deviceMgtService);
}
private RegistryService getRegistryService() throws RegistryException {
RealmService realmService = new InMemoryRealmService();
RegistryDataHolder.getInstance().setRealmService(realmService);
DeviceManagementDataHolder.getInstance().setRealmService(realmService);
InputStream is = this.getClass().getClassLoader().getResourceAsStream("carbon-home/repository/conf/registry.xml");
RegistryContext context = RegistryContext.getBaseInstance(is, realmService);
context.setSetup(true);
return context.getEmbeddedRegistryService();
}
private boolean enrollDevice(String deviceName, String deviceType) {
boolean success = false;
EnrolmentInfo enrolmentInfo = new EnrolmentInfo(
ADMIN_USER, EnrolmentInfo.OwnerShip.BYOD, EnrolmentInfo.Status.ACTIVE);
Device device1 = new Device(deviceName, deviceType, deviceName, deviceName, enrolmentInfo, null, null);
try {
success = deviceMgtService.enrollDevice(device1);
} catch (DeviceManagementException e) {
String msg = "Failed to enroll a device.";
log.error(msg, e);
Assert.fail();
}
return success;
}
private void createDeviceGroup(String groupName) {
DeviceGroup deviceGroup = new DeviceGroup(groupName);
deviceGroup.setDescription(groupName);
deviceGroup.setOwner(ADMIN_USER);
try {
groupMgtService.createGroup(deviceGroup, null, null);
} catch (GroupAlreadyExistException | GroupManagementException e) {
String msg = "Failed to create group: " + groupName;
log.error(msg, e);
Assert.fail(msg);
}
}
private void addDeviceToGroup(DeviceIdentifier deviceIdentifier, String groupName) {
List<DeviceIdentifier> groupDevices = new ArrayList<>();
groupDevices.add(deviceIdentifier);
try {
DeviceGroup group = groupMgtService.getGroup(groupName);
groupMgtService.addDevices(group.getGroupId(), groupDevices);
} catch (DeviceNotFoundException | GroupManagementException e) {
String msg = "Failed to add device " + deviceIdentifier.getId() + " to group " + groupName;
log.error(msg, e);
Assert.fail(msg);
}
}
@Test
public void addPolicy() throws DeviceManagementException, GroupManagementException, PolicyManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
policyManagerService = new PolicyManagerServiceImpl();
deviceMgtService.registerDeviceType(new TypeADeviceManagementService());
operationManager = new OperationManagerImpl(DEVICE_TYPE_A);
enrollDevice(DEVICE1, DEVICE_TYPE_A);
createDeviceGroup(GROUP1);
DeviceGroup group1 = groupMgtService.getGroup(GROUP1);
addDeviceToGroup(new DeviceIdentifier(DEVICE1, DEVICE_TYPE_A), GROUP1);
Profile profile = new Profile();
profile.setTenantId(tenantId);
profile.setCreatedDate(new Timestamp(System.currentTimeMillis()));
profile.setDeviceType(DEVICE_TYPE_A);
List<ProfileFeature> profileFeatures = new ArrayList<ProfileFeature>();
ProfileFeature profileFeature = new ProfileFeature();
profileFeature.setContent("{'enable':'true'}");
profileFeature.setDeviceType(DEVICE_TYPE_A);
profileFeature.setFeatureCode(POLICY1_FEATURE1_CODE);
profileFeatures.add(profileFeature);
profile.setProfileFeaturesList(profileFeatures);
profile.setProfileName("tp_profile1");
profile.setUpdatedDate(new Timestamp(System.currentTimeMillis()));
DeviceGroupWrapper deviceGroupWrapper = new DeviceGroupWrapper();
deviceGroupWrapper.setId(group1.getGroupId());
deviceGroupWrapper.setName(GROUP1);
deviceGroupWrapper.setOwner(ADMIN_USER);
deviceGroupWrapper.setTenantId(tenantId);
List<DeviceGroupWrapper> deviceGroupWrappers = new ArrayList<>();
deviceGroupWrappers.add(deviceGroupWrapper);
policy1 = new Policy();
policy1.setPolicyName(POLICY1);
policy1.setDescription(POLICY1);
policy1.setProfile(profile);
policy1.setOwnershipType("BYOD");
policy1.setActive(false);
policy1.setRoles(new ArrayList<>());
policy1.setUsers(new ArrayList<>());
policy1.setCompliance(PolicyManagementConstants.ENFORCE);
policy1.setDeviceGroups(deviceGroupWrappers);
List<Device> devices = new ArrayList<Device>();
policy1.setDevices(devices);
policy1.setTenantId(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
policy1 = policyManagerService.addPolicy(policy1);
int policyCount = policyManagerService.getPolicyCount();
Assert.assertEquals(policyCount, 1, "Policy count should be 1");
List<Policy> allPolicies = policyManagerService.getPolicies(DEVICE_TYPE_A);
boolean policyFound = false;
for (Policy policy : allPolicies) {
String policyName = policy.getPolicyName();
if (POLICY1.equals(policyName)) {
policyFound = true;
break;
}
}
Assert.assertTrue(policyFound, POLICY1 + " was not added.");
}
@Test(dependsOnMethods = "addPolicy")
public void activatePolicy() throws PolicyManagementException {
policyManagerService.getPAP().activatePolicy(policy1.getId());
Policy effectivePolicy = policyManagerService.getEffectivePolicy(new DeviceIdentifier(DEVICE1, DEVICE_TYPE_A));
Assert.assertEquals(effectivePolicy.getPolicyName(), POLICY1, POLICY1 + " was not activated for " + DEVICE1);
}
@Test(dependsOnMethods = "activatePolicy")
public void applyPolicy() throws PolicyManagementException, OperationManagementException {
new DelegationTask().execute();
Policy appliedPolicy = policyManagerService.getAppliedPolicyToDevice(new DeviceIdentifier(DEVICE1, DEVICE_TYPE_A));
Assert.assertEquals(appliedPolicy.getPolicyName(), POLICY1, POLICY1 + " was not applied on " + DEVICE1);
List<? extends Operation> operations = operationManager.getPendingOperations(new DeviceIdentifier(DEVICE1, DEVICE_TYPE_A));
boolean policyOperationFound = false;
for (Operation operation : operations) {
if (policyOperationFound) {
break;
}
if (PolicyOperation.POLICY_OPERATION_CODE.equals(operation.getCode())) {
Object o = operation.getPayLoad();
if (o instanceof ArrayList) {
ArrayList profileOps = (ArrayList) o;
for (Object op : profileOps) {
if (op instanceof ProfileOperation) {
ProfileOperation profileOperation = (ProfileOperation) op;
if (POLICY1_FEATURE1_CODE.equals(profileOperation.getCode())) {
policyOperationFound = true;
break;
}
}
}
}
}
}
Assert.assertTrue(policyOperationFound, "Policy operation for " + POLICY1 + " was not added to " + DEVICE1);
}
@Test(dependsOnMethods = "applyPolicy")
public void checkCompliance() throws PolicyComplianceException {
new MonitoringTask().execute();
List<ComplianceFeature> complianceFeatures = new ArrayList<>();
ComplianceFeature complianceFeature = new ComplianceFeature();
ProfileFeature profileFeature = new ProfileFeature();
profileFeature.setContent("{'enable':'false'}");
profileFeature.setDeviceType(DEVICE_TYPE_A);
profileFeature.setFeatureCode(POLICY1_FEATURE1_CODE);
complianceFeature.setFeature(profileFeature);
complianceFeature.setFeatureCode(profileFeature.getFeatureCode());
complianceFeature.setMessage("Test message");
complianceFeature.setCompliance(true);
complianceFeatures.add(complianceFeature);
policyManagerService.checkCompliance(new DeviceIdentifier(DEVICE1, DEVICE_TYPE_A), complianceFeatures);
boolean deviceCompliance = policyManagerService.isCompliant(new DeviceIdentifier(DEVICE1, DEVICE_TYPE_A));
Assert.assertTrue(deviceCompliance, "Policy was not compliant");
}
@Test(dependsOnMethods = "checkCompliance")
public void checkNonCompliance() throws PolicyComplianceException {
new MonitoringTask().execute();
List<ComplianceFeature> complianceFeatures = new ArrayList<>();
ComplianceFeature complianceFeature = new ComplianceFeature();
ProfileFeature profileFeature = new ProfileFeature();
profileFeature.setContent("{'enable':'false'}");
profileFeature.setDeviceType(DEVICE_TYPE_A);
profileFeature.setFeatureCode(POLICY1_FEATURE1_CODE);
complianceFeature.setFeature(profileFeature);
complianceFeature.setFeatureCode(profileFeature.getFeatureCode());
complianceFeature.setMessage("Test message");
complianceFeature.setCompliance(false);
complianceFeatures.add(complianceFeature);
policyManagerService.checkCompliance(new DeviceIdentifier(DEVICE1, DEVICE_TYPE_A), complianceFeatures);
boolean deviceCompliance = policyManagerService.isCompliant(new DeviceIdentifier(DEVICE1, DEVICE_TYPE_A));
Assert.assertFalse(deviceCompliance, "Policy was compliant even though the response was not compliant");
}
@Test(dependsOnMethods = "inactivatePolicy")
public void updatePolicy() throws PolicyManagementException {
Policy policy1Temp = policyManagerService.getPAP().getPolicy(policy1.getId());
policy1Temp.setDescription("Updated policy1");
policy1Temp = policyManagerService.updatePolicy(policy1Temp);
Policy policy1Updated = policyManagerService.getPAP().getPolicy(policy1.getId());
Assert.assertEquals(policy1Updated.getDescription(), policy1Temp.getDescription(), "Policy was not updated successfully.");
}
@Test(dependsOnMethods = "checkNonCompliance")
public void inactivatePolicy() throws PolicyManagementException {
policyManagerService.getPAP().inactivatePolicy(policy1.getId());
new DelegationTask().execute();
Policy effectivePolicy = policyManagerService.getEffectivePolicy(new DeviceIdentifier(DEVICE1, DEVICE_TYPE_A));
Assert.assertNull(effectivePolicy, POLICY1 + " (after inactivation) is still applied for " + DEVICE1);
}
@Test(dependsOnMethods = "updatePolicy")
public void deletePolicy() throws PolicyManagementException {
policyManagerService.deletePolicy(policy1.getId());
Policy tempPolicy = policyManagerService.getPAP().getPolicy(policy1.getId());
Assert.assertNull(tempPolicy, "Policy was not deleted successfully");
}
}

@ -0,0 +1,60 @@
/*
* 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.policy.mgt.core.mock;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
import java.util.ArrayList;
import java.util.List;
public class TestPolicyMonitoringManager implements PolicyMonitoringManager {
private static Log log = LogFactory.getLog(TestPolicyMonitoringManager.class);
@Override
public NonComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object response)
throws PolicyComplianceException {
if (log.isDebugEnabled()) {
log.debug("Checking policy compliance status of device '" + deviceIdentifier.getId() + "'");
}
NonComplianceData nonComplianceData = new NonComplianceData();
if (response == null || policy == null) {
return nonComplianceData;
}
List<ComplianceFeature> complianceFeatures = (List<ComplianceFeature>) response;
List<ComplianceFeature> nonComplianceFeatures = new ArrayList<>();
for (ComplianceFeature complianceFeature : complianceFeatures) {
if (!complianceFeature.isCompliant()) {
nonComplianceFeatures.add(complianceFeature);
nonComplianceData.setStatus(false);
break;
}
}
nonComplianceData.setComplianceFeatures(nonComplianceFeatures);
return nonComplianceData;
}
}

@ -0,0 +1,99 @@
/*
* 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.policy.mgt.core.mock;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceManager;
import org.wso2.carbon.device.mgt.common.DeviceStatusTaskPluginConfig;
import org.wso2.carbon.device.mgt.common.InitialOperationConfig;
import org.wso2.carbon.device.mgt.common.MonitoringOperation;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationSubscriber;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import java.util.ArrayList;
public class TypeADeviceManagementService implements DeviceManagementService {
public static String DEVICE_TYPE = "deviceTypeA";
public TypeADeviceManagementService() {
super();
}
@Override
public void init() throws DeviceManagementException {
}
@Override
public String getType() {
return DEVICE_TYPE;
}
@Override
public OperationMonitoringTaskConfig getOperationMonitoringConfig() {
OperationMonitoringTaskConfig operationMonitoringTaskConfig = new OperationMonitoringTaskConfig();
operationMonitoringTaskConfig.setMonitoringOperation(new ArrayList<MonitoringOperation>());
return operationMonitoringTaskConfig;
}
@Override
public DeviceManager getDeviceManager() {
return new TypeADeviceManager();
}
@Override
public ApplicationManager getApplicationManager() {
return null;
}
@Override
public ProvisioningConfig getProvisioningConfig() {
return new ProvisioningConfig("carbon.super", true);
}
@Override
public PushNotificationConfig getPushNotificationConfig() {
return null;
}
@Override
public PolicyMonitoringManager getPolicyMonitoringManager() {
return new TestPolicyMonitoringManager();
}
@Override
public InitialOperationConfig getInitialOperationConfig() {
return null;
}
@Override
public PullNotificationSubscriber getPullNotificationSubscriber() {
return null;
}
@Override
public DeviceStatusTaskPluginConfig getDeviceStatusTaskPluginConfig() {
return null;
}
}

@ -0,0 +1,126 @@
/*
* 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.policy.mgt.core.mock;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceManager;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.FeatureManager;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
import java.util.List;
public class TypeADeviceManager implements DeviceManager {
@Override
public FeatureManager getFeatureManager() {
return null;
}
@Override
public boolean saveConfiguration(PlatformConfiguration configuration)
throws DeviceManagementException {
return false;
}
@Override public PlatformConfiguration getConfiguration() throws DeviceManagementException {
return null;
}
@Override
public boolean enrollDevice(Device device) throws DeviceManagementException {
return true;
}
@Override
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
return false;
}
@Override
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
return false;
}
@Override
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
return false;
}
@Override
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
return false;
}
@Override
public boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException {
return false;
}
@Override
public List<Device> getAllDevices() throws DeviceManagementException {
return null;
}
@Override
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
return null;
}
@Override
public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device)
throws DeviceManagementException {
return false;
}
@Override
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
throws DeviceManagementException {
return false;
}
@Override
public boolean isClaimable(DeviceIdentifier deviceId) throws DeviceManagementException {
return false;
}
@Override
public boolean setStatus(DeviceIdentifier deviceId, String currentOwner, EnrolmentInfo.Status status)
throws DeviceManagementException {
return false;
}
@Override
public License getLicense(String languageCode) throws LicenseManagementException {
return null;
}
@Override
public void addLicense(License license) throws LicenseManagementException {
}
@Override
public boolean requireDeviceAuthorization() {
return false;
}
}

@ -0,0 +1,429 @@
CREATE TABLE IF NOT EXISTS REG_CLUSTER_LOCK (
REG_LOCK_NAME VARCHAR (20),
REG_LOCK_STATUS VARCHAR (20),
REG_LOCKED_TIME TIMESTAMP,
REG_TENANT_ID INTEGER DEFAULT 0,
PRIMARY KEY (REG_LOCK_NAME)
);
CREATE TABLE IF NOT EXISTS REG_LOG (
REG_LOG_ID INTEGER AUTO_INCREMENT,
REG_PATH VARCHAR (2000),
REG_USER_ID VARCHAR (31) NOT NULL,
REG_LOGGED_TIME TIMESTAMP NOT NULL,
REG_ACTION INTEGER NOT NULL,
REG_ACTION_DATA VARCHAR (500),
REG_TENANT_ID INTEGER DEFAULT 0,
PRIMARY KEY (REG_LOG_ID, REG_TENANT_ID)
);
CREATE INDEX IF NOT EXISTS REG_LOG_IND_BY_REG_LOGTIME ON REG_LOG(REG_LOGGED_TIME, REG_TENANT_ID);
CREATE TABLE IF NOT EXISTS REG_PATH(
REG_PATH_ID INTEGER NOT NULL AUTO_INCREMENT,
REG_PATH_VALUE VARCHAR(2000) NOT NULL,
REG_PATH_PARENT_ID INT,
REG_TENANT_ID INTEGER DEFAULT 0,
CONSTRAINT PK_REG_PATH PRIMARY KEY(REG_PATH_ID, REG_TENANT_ID)
);
CREATE INDEX IF NOT EXISTS REG_PATH_IND_BY_NAME ON REG_PATH(REG_PATH_VALUE, REG_TENANT_ID);
CREATE INDEX IF NOT EXISTS REG_PATH_IND_BY_PARENT_ID ON REG_PATH(REG_PATH_PARENT_ID, REG_TENANT_ID);
CREATE TABLE IF NOT EXISTS REG_CONTENT (
REG_CONTENT_ID INTEGER NOT NULL AUTO_INCREMENT,
REG_CONTENT_DATA LONGBLOB,
REG_TENANT_ID INTEGER DEFAULT 0,
CONSTRAINT PK_REG_CONTENT PRIMARY KEY(REG_CONTENT_ID, REG_TENANT_ID)
);
CREATE TABLE IF NOT EXISTS REG_CONTENT_HISTORY (
REG_CONTENT_ID INTEGER NOT NULL,
REG_CONTENT_DATA LONGBLOB,
REG_DELETED SMALLINT,
REG_TENANT_ID INTEGER DEFAULT 0,
CONSTRAINT PK_REG_CONTENT_HISTORY PRIMARY KEY(REG_CONTENT_ID, REG_TENANT_ID)
);
CREATE TABLE IF NOT EXISTS REG_RESOURCE (
REG_PATH_ID INTEGER NOT NULL,
REG_NAME VARCHAR(256),
REG_VERSION INTEGER NOT NULL AUTO_INCREMENT,
REG_MEDIA_TYPE VARCHAR(500),
REG_CREATOR VARCHAR(31) NOT NULL,
REG_CREATED_TIME TIMESTAMP NOT NULL,
REG_LAST_UPDATOR VARCHAR(31),
REG_LAST_UPDATED_TIME TIMESTAMP NOT NULL,
REG_DESCRIPTION VARCHAR(1000),
REG_CONTENT_ID INTEGER,
REG_TENANT_ID INTEGER DEFAULT 0,
REG_UUID VARCHAR(100) NOT NULL,
CONSTRAINT PK_REG_RESOURCE PRIMARY KEY(REG_VERSION, REG_TENANT_ID)
);
ALTER TABLE REG_RESOURCE ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_FK_BY_PATH_ID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID);
ALTER TABLE REG_RESOURCE ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_FK_BY_CONTENT_ID FOREIGN KEY (REG_CONTENT_ID, REG_TENANT_ID) REFERENCES REG_CONTENT (REG_CONTENT_ID, REG_TENANT_ID);
CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_NAME ON REG_RESOURCE(REG_NAME, REG_TENANT_ID);
CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_PATH_ID_NAME ON REG_RESOURCE(REG_PATH_ID, REG_NAME, REG_TENANT_ID);
CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_UUID ON REG_RESOURCE(REG_UUID);
CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_TENANT ON REG_RESOURCE(REG_TENANT_ID, REG_UUID);
CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_TYPE ON REG_RESOURCE(REG_TENANT_ID, REG_MEDIA_TYPE);
CREATE TABLE IF NOT EXISTS REG_RESOURCE_HISTORY (
REG_PATH_ID INTEGER NOT NULL,
REG_NAME VARCHAR(256),
REG_VERSION INTEGER NOT NULL,
REG_MEDIA_TYPE VARCHAR(500),
REG_CREATOR VARCHAR(31) NOT NULL,
REG_CREATED_TIME TIMESTAMP NOT NULL,
REG_LAST_UPDATOR VARCHAR(31),
REG_LAST_UPDATED_TIME TIMESTAMP NOT NULL,
REG_DESCRIPTION VARCHAR(1000),
REG_CONTENT_ID INTEGER,
REG_DELETED SMALLINT,
REG_TENANT_ID INTEGER DEFAULT 0,
REG_UUID VARCHAR(100) NOT NULL,
CONSTRAINT PK_REG_RESOURCE_HISTORY PRIMARY KEY(REG_VERSION, REG_TENANT_ID)
);
ALTER TABLE REG_RESOURCE_HISTORY ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_HIST_FK_BY_PATHID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID);
ALTER TABLE REG_RESOURCE_HISTORY ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_HIST_FK_BY_CONTENT_ID FOREIGN KEY (REG_CONTENT_ID, REG_TENANT_ID) REFERENCES REG_CONTENT_HISTORY (REG_CONTENT_ID, REG_TENANT_ID);
CREATE INDEX IF NOT EXISTS REG_RESOURCE_HISTORY_IND_BY_NAME ON REG_RESOURCE_HISTORY(REG_NAME, REG_TENANT_ID);
CREATE INDEX IF NOT EXISTS REG_RESOURCE_HISTORY_IND_BY_PATH_ID_NAME ON REG_RESOURCE(REG_PATH_ID, REG_NAME, REG_TENANT_ID);
CREATE TABLE IF NOT EXISTS REG_COMMENT (
REG_ID INTEGER NOT NULL AUTO_INCREMENT,
REG_COMMENT_TEXT VARCHAR(500) NOT NULL,
REG_USER_ID VARCHAR(31) NOT NULL,
REG_COMMENTED_TIME TIMESTAMP NOT NULL,
REG_TENANT_ID INTEGER DEFAULT 0,
CONSTRAINT PK_REG_COMMENT PRIMARY KEY(REG_ID, REG_TENANT_ID)
);
CREATE TABLE IF NOT EXISTS REG_RESOURCE_COMMENT (
REG_COMMENT_ID INTEGER NOT NULL,
REG_VERSION INTEGER,
REG_PATH_ID INTEGER,
REG_RESOURCE_NAME VARCHAR(256),
REG_TENANT_ID INTEGER DEFAULT 0
);
ALTER TABLE REG_RESOURCE_COMMENT ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_COMMENT_FK_BY_PATH_ID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID);
ALTER TABLE REG_RESOURCE_COMMENT ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_COMMENT_FK_BY_COMMENT_ID FOREIGN KEY (REG_COMMENT_ID, REG_TENANT_ID) REFERENCES REG_COMMENT (REG_ID, REG_TENANT_ID);
CREATE INDEX IF NOT EXISTS REG_RESOURCE_COMMENT_IND_BY_PATH_ID_AND_RESOURCE_NAME ON REG_RESOURCE_COMMENT(REG_PATH_ID, REG_RESOURCE_NAME, REG_TENANT_ID);
CREATE INDEX IF NOT EXISTS REG_RESOURCE_COMMENT_IND_BY_VERSION ON REG_RESOURCE_COMMENT(REG_VERSION, REG_TENANT_ID);
CREATE TABLE IF NOT EXISTS REG_RATING (
REG_ID INTEGER NOT NULL AUTO_INCREMENT,
REG_RATING INTEGER NOT NULL,
REG_USER_ID VARCHAR(31) NOT NULL,
REG_RATED_TIME TIMESTAMP NOT NULL,
REG_TENANT_ID INTEGER DEFAULT 0,
CONSTRAINT PK_REG_RATING PRIMARY KEY(REG_ID, REG_TENANT_ID)
);
CREATE TABLE IF NOT EXISTS REG_RESOURCE_RATING (
REG_RATING_ID INTEGER NOT NULL,
REG_VERSION INTEGER,
REG_PATH_ID INTEGER,
REG_RESOURCE_NAME VARCHAR(256),
REG_TENANT_ID INTEGER DEFAULT 0
);
ALTER TABLE REG_RESOURCE_RATING ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_RATING_FK_BY_PATH_ID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID);
ALTER TABLE REG_RESOURCE_RATING ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_RATING_FK_BY_RATING_ID FOREIGN KEY (REG_RATING_ID, REG_TENANT_ID) REFERENCES REG_RATING (REG_ID, REG_TENANT_ID);
CREATE INDEX IF NOT EXISTS REG_RESOURCE_RATING_IND_BY_PATH_ID_AND_RESOURCE_NAME ON REG_RESOURCE_RATING(REG_PATH_ID, REG_RESOURCE_NAME, REG_TENANT_ID);
CREATE INDEX IF NOT EXISTS REG_RESOURCE_RATING_IND_BY_VERSION ON REG_RESOURCE_RATING(REG_VERSION, REG_TENANT_ID);
CREATE TABLE IF NOT EXISTS REG_TAG (
REG_ID INTEGER NOT NULL AUTO_INCREMENT,
REG_TAG_NAME VARCHAR(500) NOT NULL,
REG_USER_ID VARCHAR(31) NOT NULL,
REG_TAGGED_TIME TIMESTAMP NOT NULL,
REG_TENANT_ID INTEGER DEFAULT 0,
CONSTRAINT PK_REG_TAG PRIMARY KEY(REG_ID, REG_TENANT_ID)
);
CREATE TABLE IF NOT EXISTS REG_RESOURCE_TAG (
REG_TAG_ID INTEGER NOT NULL,
REG_VERSION INTEGER,
REG_PATH_ID INTEGER,
REG_RESOURCE_NAME VARCHAR(256),
REG_TENANT_ID INTEGER DEFAULT 0
);
ALTER TABLE REG_RESOURCE_TAG ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_TAG_FK_BY_PATH_ID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID);
ALTER TABLE REG_RESOURCE_TAG ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_TAG_FK_BY_TAG_ID FOREIGN KEY (REG_TAG_ID, REG_TENANT_ID) REFERENCES REG_TAG (REG_ID, REG_TENANT_ID);
CREATE INDEX IF NOT EXISTS REG_RESOURCE_TAG_IND_BY_PATH_ID_AND_RESOURCE_NAME ON REG_RESOURCE_TAG(REG_PATH_ID, REG_RESOURCE_NAME, REG_TENANT_ID);
CREATE INDEX IF NOT EXISTS REG_RESOURCE_TAG_IND_BY_VERSION ON REG_RESOURCE_TAG(REG_VERSION, REG_TENANT_ID);
CREATE TABLE IF NOT EXISTS REG_PROPERTY (
REG_ID INTEGER NOT NULL AUTO_INCREMENT,
REG_NAME VARCHAR(100) NOT NULL,
REG_VALUE VARCHAR(1000),
REG_TENANT_ID INTEGER DEFAULT 0,
CONSTRAINT PK_REG_PROPERTY PRIMARY KEY(REG_ID, REG_TENANT_ID)
);
CREATE TABLE IF NOT EXISTS REG_RESOURCE_PROPERTY (
REG_PROPERTY_ID INTEGER NOT NULL,
REG_VERSION INTEGER,
REG_PATH_ID INTEGER,
REG_RESOURCE_NAME VARCHAR(256),
REG_TENANT_ID INTEGER DEFAULT 0
);
ALTER TABLE REG_RESOURCE_PROPERTY ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_PROPERTY_FK_BY_PATH_ID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID);
ALTER TABLE REG_RESOURCE_PROPERTY ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_PROPERTY_FK_BY_TAG_ID FOREIGN KEY (REG_PROPERTY_ID, REG_TENANT_ID) REFERENCES REG_PROPERTY (REG_ID, REG_TENANT_ID);
CREATE INDEX IF NOT EXISTS REG_RESOURCE_PROPERTY_IND_BY_PATH_ID_AND_RESOURCE_NAME ON REG_RESOURCE_PROPERTY(REG_PATH_ID, REG_RESOURCE_NAME, REG_TENANT_ID);
CREATE INDEX IF NOT EXISTS REG_RESOURCE_PROPERTY_IND_BY_VERSION ON REG_RESOURCE_PROPERTY(REG_VERSION, REG_TENANT_ID);
CREATE TABLE IF NOT EXISTS REG_ASSOCIATION (
REG_ASSOCIATION_ID INTEGER AUTO_INCREMENT,
REG_SOURCEPATH VARCHAR (2000) NOT NULL,
REG_TARGETPATH VARCHAR (2000) NOT NULL,
REG_ASSOCIATION_TYPE VARCHAR (2000) NOT NULL,
REG_TENANT_ID INTEGER DEFAULT 0,
PRIMARY KEY (REG_ASSOCIATION_ID, REG_TENANT_ID)
);
CREATE TABLE IF NOT EXISTS REG_SNAPSHOT (
REG_SNAPSHOT_ID INTEGER NOT NULL AUTO_INCREMENT,
REG_PATH_ID INTEGER NOT NULL,
REG_RESOURCE_NAME VARCHAR (256),
REG_RESOURCE_VIDS LONGBLOB NOT NULL,
REG_TENANT_ID INTEGER DEFAULT 0,
CONSTRAINT PK_REG_SNAPSHOT PRIMARY KEY(REG_SNAPSHOT_ID, REG_TENANT_ID)
);
ALTER TABLE REG_SNAPSHOT ADD CONSTRAINT IF NOT EXISTS REG_SNAPSHOT_FK_BY_PATH_ID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID);
CREATE INDEX IF NOT EXISTS REG_SNAPSHOT_IND_BY_PATH_ID_AND_RESOURCE_NAME ON REG_SNAPSHOT(REG_PATH_ID, REG_RESOURCE_NAME, REG_TENANT_ID);
-- ################################
-- USER MANAGER TABLES
-- ################################
CREATE TABLE IF NOT EXISTS UM_TENANT (
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_DOMAIN_NAME VARCHAR(255) NOT NULL,
UM_EMAIL VARCHAR(255),
UM_ACTIVE BOOLEAN DEFAULT FALSE,
UM_CREATED_DATE TIMESTAMP NOT NULL,
UM_USER_CONFIG LONGBLOB NOT NULL,
PRIMARY KEY (UM_ID),
UNIQUE(UM_DOMAIN_NAME));
CREATE TABLE IF NOT EXISTS UM_DOMAIN(
UM_DOMAIN_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_DOMAIN_NAME VARCHAR(255),
UM_TENANT_ID INTEGER DEFAULT 0,
PRIMARY KEY (UM_DOMAIN_ID, UM_TENANT_ID)
);
CREATE INDEX IF NOT EXISTS INDEX_UM_TENANT_UM_DOMAIN_NAME ON UM_TENANT (UM_DOMAIN_NAME);
CREATE TABLE IF NOT EXISTS UM_USER (
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_USER_NAME VARCHAR(255) NOT NULL,
UM_USER_PASSWORD VARCHAR(255) NOT NULL,
UM_SALT_VALUE VARCHAR(31),
UM_REQUIRE_CHANGE BOOLEAN DEFAULT FALSE,
UM_CHANGED_TIME TIMESTAMP NOT NULL,
UM_TENANT_ID INTEGER DEFAULT 0,
PRIMARY KEY (UM_ID, UM_TENANT_ID),
UNIQUE(UM_USER_NAME, UM_TENANT_ID));
CREATE TABLE IF NOT EXISTS UM_SYSTEM_USER (
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_USER_NAME VARCHAR(255) NOT NULL,
UM_USER_PASSWORD VARCHAR(255) NOT NULL,
UM_SALT_VALUE VARCHAR(31),
UM_REQUIRE_CHANGE BOOLEAN DEFAULT FALSE,
UM_CHANGED_TIME TIMESTAMP NOT NULL,
UM_TENANT_ID INTEGER DEFAULT 0,
PRIMARY KEY (UM_ID, UM_TENANT_ID),
UNIQUE(UM_USER_NAME, UM_TENANT_ID));
CREATE TABLE IF NOT EXISTS UM_USER_ATTRIBUTE (
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_ATTR_NAME VARCHAR(255) NOT NULL,
UM_ATTR_VALUE VARCHAR(1024),
UM_PROFILE_ID VARCHAR(255),
UM_USER_ID INTEGER,
UM_TENANT_ID INTEGER DEFAULT 0,
PRIMARY KEY (UM_ID, UM_TENANT_ID),
FOREIGN KEY (UM_USER_ID, UM_TENANT_ID) REFERENCES UM_USER(UM_ID, UM_TENANT_ID));
CREATE INDEX IF NOT EXISTS UM_USER_ID_INDEX ON UM_USER_ATTRIBUTE(UM_USER_ID);
CREATE TABLE IF NOT EXISTS UM_ROLE (
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_ROLE_NAME VARCHAR(255) NOT NULL,
UM_TENANT_ID INTEGER DEFAULT 0,
UM_SHARED_ROLE BOOLEAN DEFAULT FALSE,
PRIMARY KEY (UM_ID, UM_TENANT_ID),
UNIQUE(UM_ROLE_NAME, UM_TENANT_ID));
CREATE TABLE IF NOT EXISTS UM_MODULE(
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_MODULE_NAME VARCHAR(100),
UNIQUE(UM_MODULE_NAME),
PRIMARY KEY(UM_ID)
);
CREATE TABLE IF NOT EXISTS UM_MODULE_ACTIONS(
UM_ACTION VARCHAR(255) NOT NULL,
UM_MODULE_ID INTEGER NOT NULL,
PRIMARY KEY(UM_ACTION, UM_MODULE_ID),
FOREIGN KEY (UM_MODULE_ID) REFERENCES UM_MODULE(UM_ID) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS UM_PERMISSION (
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_RESOURCE_ID VARCHAR(255) NOT NULL,
UM_ACTION VARCHAR(255) NOT NULL,
UM_TENANT_ID INTEGER DEFAULT 0,
UM_MODULE_ID INTEGER DEFAULT 0,
UNIQUE(UM_RESOURCE_ID,UM_ACTION, UM_TENANT_ID),
PRIMARY KEY (UM_ID, UM_TENANT_ID));
CREATE INDEX IF NOT EXISTS INDEX_UM_PERMISSION_UM_RESOURCE_ID_UM_ACTION ON UM_PERMISSION (UM_RESOURCE_ID, UM_ACTION, UM_TENANT_ID);
CREATE TABLE IF NOT EXISTS UM_ROLE_PERMISSION (
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_PERMISSION_ID INTEGER NOT NULL,
UM_ROLE_NAME VARCHAR(255) NOT NULL,
UM_IS_ALLOWED SMALLINT NOT NULL,
UM_TENANT_ID INTEGER DEFAULT 0,
UM_DOMAIN_ID INTEGER,
FOREIGN KEY (UM_PERMISSION_ID, UM_TENANT_ID) REFERENCES UM_PERMISSION(UM_ID, UM_TENANT_ID) ON DELETE CASCADE,
FOREIGN KEY (UM_DOMAIN_ID, UM_TENANT_ID) REFERENCES UM_DOMAIN(UM_DOMAIN_ID, UM_TENANT_ID) ON DELETE CASCADE,
PRIMARY KEY (UM_ID, UM_TENANT_ID));
CREATE TABLE IF NOT EXISTS UM_USER_PERMISSION (
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_PERMISSION_ID INTEGER NOT NULL,
UM_USER_NAME VARCHAR(255) NOT NULL,
UM_IS_ALLOWED SMALLINT NOT NULL,
UNIQUE (UM_PERMISSION_ID, UM_USER_NAME, UM_TENANT_ID),
UM_TENANT_ID INTEGER DEFAULT 0,
FOREIGN KEY (UM_PERMISSION_ID, UM_TENANT_ID) REFERENCES UM_PERMISSION(UM_ID, UM_TENANT_ID) ON DELETE CASCADE,
PRIMARY KEY (UM_ID, UM_TENANT_ID));
CREATE TABLE IF NOT EXISTS UM_USER_ROLE (
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_ROLE_ID INTEGER NOT NULL,
UM_USER_ID INTEGER NOT NULL,
UM_TENANT_ID INTEGER DEFAULT 0,
UNIQUE (UM_USER_ID, UM_ROLE_ID, UM_TENANT_ID),
FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_ROLE(UM_ID, UM_TENANT_ID),
FOREIGN KEY (UM_USER_ID, UM_TENANT_ID) REFERENCES UM_USER(UM_ID, UM_TENANT_ID),
PRIMARY KEY (UM_ID, UM_TENANT_ID));
CREATE TABLE IF NOT EXISTS UM_SHARED_USER_ROLE(
UM_ROLE_ID INTEGER NOT NULL,
UM_USER_ID INTEGER NOT NULL,
UM_USER_TENANT_ID INTEGER NOT NULL,
UM_ROLE_TENANT_ID INTEGER NOT NULL,
UNIQUE(UM_USER_ID,UM_ROLE_ID,UM_USER_TENANT_ID, UM_ROLE_TENANT_ID),
FOREIGN KEY(UM_ROLE_ID,UM_ROLE_TENANT_ID) REFERENCES UM_ROLE(UM_ID,UM_TENANT_ID) ON DELETE CASCADE ,
FOREIGN KEY(UM_USER_ID,UM_USER_TENANT_ID) REFERENCES UM_USER(UM_ID,UM_TENANT_ID) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS UM_ACCOUNT_MAPPING(
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_USER_NAME VARCHAR(255) NOT NULL,
UM_TENANT_ID INTEGER NOT NULL,
UM_USER_STORE_DOMAIN VARCHAR(100),
UM_ACC_LINK_ID INTEGER NOT NULL,
UNIQUE(UM_USER_NAME, UM_TENANT_ID, UM_USER_STORE_DOMAIN, UM_ACC_LINK_ID),
FOREIGN KEY (UM_TENANT_ID) REFERENCES UM_TENANT(UM_ID) ON DELETE CASCADE,
PRIMARY KEY (UM_ID)
);
CREATE TABLE IF NOT EXISTS UM_DIALECT(
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_DIALECT_URI VARCHAR(255) NOT NULL,
UM_TENANT_ID INTEGER DEFAULT 0,
UNIQUE(UM_DIALECT_URI, UM_TENANT_ID),
PRIMARY KEY (UM_ID, UM_TENANT_ID)
);
CREATE TABLE IF NOT EXISTS UM_CLAIM(
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_DIALECT_ID INTEGER NOT NULL,
UM_CLAIM_URI VARCHAR(255) NOT NULL,
UM_DISPLAY_TAG VARCHAR(255),
UM_DESCRIPTION VARCHAR(255),
UM_MAPPED_ATTRIBUTE_DOMAIN VARCHAR(255),
UM_MAPPED_ATTRIBUTE VARCHAR(255),
UM_REG_EX VARCHAR(255),
UM_SUPPORTED SMALLINT,
UM_REQUIRED SMALLINT,
UM_DISPLAY_ORDER INTEGER,
UM_CHECKED_ATTRIBUTE SMALLINT,
UM_READ_ONLY SMALLINT,
UM_TENANT_ID INTEGER DEFAULT 0,
UNIQUE(UM_DIALECT_ID, UM_CLAIM_URI,UM_MAPPED_ATTRIBUTE_DOMAIN, UM_TENANT_ID),
FOREIGN KEY(UM_DIALECT_ID, UM_TENANT_ID) REFERENCES UM_DIALECT(UM_ID, UM_TENANT_ID),
PRIMARY KEY (UM_ID, UM_TENANT_ID)
);
CREATE TABLE IF NOT EXISTS UM_PROFILE_CONFIG(
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_DIALECT_ID INTEGER,
UM_PROFILE_NAME VARCHAR(255),
UM_TENANT_ID INTEGER DEFAULT 0,
FOREIGN KEY(UM_DIALECT_ID, UM_TENANT_ID) REFERENCES UM_DIALECT(UM_ID, UM_TENANT_ID),
PRIMARY KEY (UM_ID, UM_TENANT_ID)
);
CREATE TABLE IF NOT EXISTS UM_HYBRID_ROLE(
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_ROLE_NAME VARCHAR(255),
UM_TENANT_ID INTEGER DEFAULT 0,
PRIMARY KEY (UM_ID, UM_TENANT_ID)
);
CREATE TABLE IF NOT EXISTS UM_HYBRID_USER_ROLE(
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_USER_NAME VARCHAR(255),
UM_ROLE_ID INTEGER NOT NULL,
UM_TENANT_ID INTEGER DEFAULT 0,
UM_DOMAIN_ID INTEGER,
UNIQUE (UM_USER_NAME, UM_ROLE_ID, UM_TENANT_ID,UM_DOMAIN_ID),
FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_HYBRID_ROLE(UM_ID, UM_TENANT_ID) ON DELETE CASCADE,
FOREIGN KEY (UM_DOMAIN_ID, UM_TENANT_ID) REFERENCES UM_DOMAIN(UM_DOMAIN_ID, UM_TENANT_ID) ON DELETE CASCADE,
PRIMARY KEY (UM_ID, UM_TENANT_ID)
);
CREATE TABLE IF NOT EXISTS UM_HYBRID_REMEMBER_ME (
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_USER_NAME VARCHAR(255) NOT NULL,
UM_COOKIE_VALUE VARCHAR(1024),
UM_CREATED_TIME TIMESTAMP,
UM_TENANT_ID INTEGER DEFAULT 0,
PRIMARY KEY (UM_ID, UM_TENANT_ID)
);
CREATE TABLE IF NOT EXISTS UM_SYSTEM_ROLE(
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_ROLE_NAME VARCHAR(255),
UM_TENANT_ID INTEGER DEFAULT 0,
PRIMARY KEY (UM_ID, UM_TENANT_ID)
);
CREATE TABLE IF NOT EXISTS UM_SYSTEM_USER_ROLE(
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
UM_USER_NAME VARCHAR(255),
UM_ROLE_ID INTEGER NOT NULL,
UM_TENANT_ID INTEGER DEFAULT 0,
UNIQUE (UM_USER_NAME, UM_ROLE_ID, UM_TENANT_ID),
FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_SYSTEM_ROLE(UM_ID, UM_TENANT_ID),
PRIMARY KEY (UM_ID, UM_TENANT_ID)
);

@ -54,5 +54,11 @@
<Enable>true</Enable>
<ExpiryTime>300</ExpiryTime>
</DeviceCacheConfiguration>
<PushNotificationConfiguration>
<SchedulerBatchSize>100</SchedulerBatchSize>
<SchedulerBatchDelayMills>2000</SchedulerBatchDelayMills>
<SchedulerTaskInitialDelay>10</SchedulerTaskInitialDelay>
<SchedulerTaskEnabled>false</SchedulerTaskEnabled>
</PushNotificationConfiguration>
</DeviceMgtConfiguration>

@ -28,9 +28,19 @@
<registryRoot>/</registryRoot>
<dbConfig name="wso2registry">
<dataSource>jdbc/WSO2CarbonDB</dataSource>
<url>jdbc:h2:./target/databasetest/CARBON_TEST</url>
<!--userName>sa</userName>
<password>sa</password-->
<driverName>org.h2.Driver</driverName>
<maxActive>80</maxActive>
<maxWait>60000</maxWait>
<minIdle>5</minIdle>
</dbConfig>
<!--<dbConfig name="wso2registry">-->
<!--<dataSource>jdbc/WSO2CarbonDB</dataSource>-->
<!--</dbConfig>-->
<!--<handler class="org.wso2.carbon.registry.extensions.handlers.SynapseRepositoryHandler">
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
<property name="mediaType">application/vnd.apache.synapse</property>

@ -1,3 +1,4 @@
DROP TABLE IF EXISTS DM_DEVICE_TYPE;
CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE (
ID INT AUTO_INCREMENT NOT NULL,
NAME VARCHAR(300) NULL DEFAULT NULL,
@ -8,6 +9,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE (
PRIMARY KEY (ID)
);
DROP TABLE IF EXISTS DM_GROUP;
CREATE TABLE IF NOT EXISTS DM_GROUP (
ID INTEGER AUTO_INCREMENT NOT NULL,
GROUP_NAME VARCHAR(100) DEFAULT NULL,
@ -19,6 +21,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP (
PRIMARY KEY (ID)
);
DROP TABLE IF EXISTS DM_DEVICE_CERTIFICATE;
CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE (
ID INTEGER auto_increment NOT NULL,
SERIAL_NUMBER VARCHAR(500) DEFAULT NULL,
@ -28,6 +31,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE (
PRIMARY KEY (ID)
);
DROP TABLE IF EXISTS DM_DEVICE;
CREATE TABLE IF NOT EXISTS DM_DEVICE (
ID INTEGER auto_increment NOT NULL,
DESCRIPTION TEXT DEFAULT NULL,
@ -41,6 +45,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE (
REFERENCES DM_DEVICE_TYPE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_DEVICE_PROPERTIES;
CREATE TABLE IF NOT EXISTS DM_DEVICE_PROPERTIES (
DEVICE_TYPE_NAME VARCHAR(300) NOT NULL,
DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL,
@ -50,6 +55,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_PROPERTIES (
PRIMARY KEY (DEVICE_TYPE_NAME, DEVICE_IDENTIFICATION, PROPERTY_NAME)
);
DROP TABLE IF EXISTS DM_DEVICE_GROUP_MAP;
CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP (
ID INTEGER AUTO_INCREMENT NOT NULL,
DEVICE_ID INTEGER DEFAULT NULL,
@ -62,6 +68,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP (
REFERENCES DM_GROUP (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_OPERATION;
CREATE TABLE IF NOT EXISTS DM_OPERATION (
ID INTEGER AUTO_INCREMENT NOT NULL,
TYPE VARCHAR(50) NOT NULL,
@ -71,6 +78,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION (
PRIMARY KEY (ID)
);
DROP TABLE IF EXISTS DM_CONFIG_OPERATION;
CREATE TABLE IF NOT EXISTS DM_CONFIG_OPERATION (
OPERATION_ID INTEGER NOT NULL,
OPERATION_CONFIG BLOB DEFAULT NULL,
@ -79,6 +87,7 @@ CREATE TABLE IF NOT EXISTS DM_CONFIG_OPERATION (
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_COMMAND_OPERATION;
CREATE TABLE IF NOT EXISTS DM_COMMAND_OPERATION (
OPERATION_ID INTEGER NOT NULL,
ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
@ -87,6 +96,7 @@ CREATE TABLE IF NOT EXISTS DM_COMMAND_OPERATION (
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_POLICY_OPERATION;
CREATE TABLE IF NOT EXISTS DM_POLICY_OPERATION (
OPERATION_ID INTEGER NOT NULL,
ENABLED INTEGER NOT NULL DEFAULT 0,
@ -96,6 +106,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_OPERATION (
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_PROFILE_OPERATION;
CREATE TABLE IF NOT EXISTS DM_PROFILE_OPERATION (
OPERATION_ID INTEGER NOT NULL,
ENABLED INTEGER NOT NULL DEFAULT 0,
@ -105,6 +116,7 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_OPERATION (
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_ENROLMENT;
CREATE TABLE IF NOT EXISTS DM_ENROLMENT (
ID INTEGER AUTO_INCREMENT NOT NULL,
DEVICE_ID INTEGER NOT NULL,
@ -119,6 +131,7 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT (
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_ENROLMENT_OP_MAPPING;
CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING (
ID INTEGER AUTO_INCREMENT NOT NULL,
ENROLMENT_ID INTEGER NOT NULL,
@ -126,6 +139,7 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING (
STATUS VARCHAR(50) NULL,
CREATED_TIMESTAMP INT NOT NULL,
UPDATED_TIMESTAMP INT NOT NULL,
PUSH_NOTIFICATION_STATUS VARCHAR(50),
PRIMARY KEY (ID),
CONSTRAINT fk_dm_device_operation_mapping_device FOREIGN KEY (ENROLMENT_ID) REFERENCES
DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
@ -133,6 +147,7 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING (
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE;
CREATE TABLE IF NOT EXISTS DM_DEVICE_OPERATION_RESPONSE (
ID INTEGER AUTO_INCREMENT NOT NULL,
ENROLMENT_ID INTEGER NOT NULL,
@ -148,6 +163,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_OPERATION_RESPONSE (
-- POLICY RELATED TABLES --
DROP TABLE IF EXISTS DM_PROFILE;
CREATE TABLE IF NOT EXISTS DM_PROFILE (
ID INT NOT NULL AUTO_INCREMENT ,
PROFILE_NAME VARCHAR(45) NOT NULL ,
@ -163,10 +179,7 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE (
ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_POLICY;
CREATE TABLE IF NOT EXISTS DM_POLICY (
ID INT(11) NOT NULL AUTO_INCREMENT ,
NAME VARCHAR(45) DEFAULT NULL ,
@ -186,9 +199,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY (
ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_DEVICE_POLICY;
CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY (
ID INT(11) NOT NULL AUTO_INCREMENT ,
DEVICE_ID INT(11) NOT NULL ,
@ -208,9 +219,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY (
ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_DEVICE_TYPE_POLICY;
CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY (
ID INT(11) NOT NULL ,
DEVICE_TYPE VARCHAR(20) NOT NULL ,
@ -228,10 +237,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY (
ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_PROFILE_FEATURES;
CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
ID INT(11) NOT NULL AUTO_INCREMENT,
PROFILE_ID INT(11) NOT NULL,
@ -247,9 +253,7 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_ROLE_POLICY;
CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY (
ID INT(11) NOT NULL AUTO_INCREMENT ,
ROLE_NAME VARCHAR(45) NOT NULL ,
@ -262,9 +266,7 @@ CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY (
ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_USER_POLICY;
CREATE TABLE IF NOT EXISTS DM_USER_POLICY (
ID INT NOT NULL AUTO_INCREMENT ,
POLICY_ID INT NOT NULL ,
@ -277,7 +279,7 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY (
ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_DEVICE_POLICY_APPLIED;
CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED (
ID INT NOT NULL AUTO_INCREMENT ,
DEVICE_ID INT NOT NULL ,
@ -298,7 +300,7 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY (
);
DROP TABLE IF EXISTS DM_CRITERIA;
CREATE TABLE IF NOT EXISTS DM_CRITERIA (
ID INT NOT NULL AUTO_INCREMENT,
TENANT_ID INT NOT NULL,
@ -307,7 +309,7 @@ CREATE TABLE IF NOT EXISTS DM_CRITERIA (
);
DROP TABLE IF EXISTS DM_POLICY_CRITERIA;
CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA (
ID INT NOT NULL AUTO_INCREMENT,
CRITERIA_ID INT NOT NULL,
@ -339,6 +341,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES (
ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_POLICY_COMPLIANCE_STATUS;
CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS (
ID INT NOT NULL AUTO_INCREMENT,
DEVICE_ID INT NOT NULL,
@ -353,7 +356,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS (
PRIMARY KEY (ID)
);
DROP TABLE IF EXISTS DM_POLICY_CHANGE_MGT;
CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT (
ID INT NOT NULL AUTO_INCREMENT,
POLICY_ID INT NOT NULL,
@ -362,7 +365,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT (
PRIMARY KEY (ID)
);
DROP TABLE IF EXISTS DM_POLICY_COMPLIANCE_FEATURES;
CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_FEATURES (
ID INT NOT NULL AUTO_INCREMENT,
COMPLIANCE_STATUS_ID INT NOT NULL,
@ -377,6 +380,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_FEATURES (
ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_ENROLMENT;
CREATE TABLE IF NOT EXISTS DM_ENROLMENT (
ID INTEGER AUTO_INCREMENT NOT NULL,
DEVICE_ID INTEGER NOT NULL,
@ -391,6 +395,7 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT (
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_APPLICATION;
CREATE TABLE IF NOT EXISTS DM_APPLICATION (
ID INTEGER AUTO_INCREMENT NOT NULL,
NAME VARCHAR(150) NOT NULL,
@ -408,6 +413,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
PRIMARY KEY (ID)
);
DROP TABLE IF EXISTS DM_DEVICE_APPLICATION_MAPPING;
CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
ID INTEGER AUTO_INCREMENT NOT NULL,
DEVICE_ID INTEGER NOT NULL,
@ -423,6 +429,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
-- POLICY RELATED TABLES FINISHED --
-- NOTIFICATION TABLE --
DROP TABLE IF EXISTS DM_NOTIFICATION;
CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL,
DEVICE_ID INTEGER NOT NULL,
@ -439,7 +446,6 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
-- NOTIFICATION TABLE END --
DROP TABLE IF EXISTS DM_DEVICE_INFO;
CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
ID INTEGER AUTO_INCREMENT NOT NULL,
DEVICE_ID INT NULL,
@ -454,9 +460,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
);
DROP TABLE IF EXISTS DM_DEVICE_LOCATION;
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
ID INTEGER AUTO_INCREMENT NOT NULL,
DEVICE_ID INT NULL,
@ -477,7 +481,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
ON UPDATE NO ACTION
);
DROP TABLE IF EXISTS DM_DEVICE_DETAIL;
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
ID INT NOT NULL AUTO_INCREMENT,
DEVICE_ID INT NOT NULL,
@ -507,7 +511,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
-- POLICY AND DEVICE GROUP MAPPING --
DROP TABLE IF EXISTS DM_DEVICE_GROUP_POLICY;
CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY (
ID INT NOT NULL AUTO_INCREMENT,
DEVICE_GROUP_ID INT NOT NULL,
@ -529,7 +533,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY (
-- END OF POLICY AND DEVICE GROUP MAPPING --
-- DASHBOARD RELATED VIEWS --
DROP VIEW IF EXISTS POLICY_COMPLIANCE_INFO;
CREATE VIEW POLICY_COMPLIANCE_INFO AS
SELECT
DEVICE_INFO.DEVICE_ID,
@ -559,6 +563,7 @@ FROM DM_POLICY_COMPLIANCE_STATUS) DEVICE_WITH_POLICY_INFO
ON DEVICE_INFO.DEVICE_ID = DEVICE_WITH_POLICY_INFO.DEVICE_ID
ORDER BY DEVICE_INFO.DEVICE_ID;
DROP VIEW IF EXISTS FEATURE_NON_COMPLIANCE_INFO;
CREATE VIEW FEATURE_NON_COMPLIANCE_INFO AS
SELECT
DM_DEVICE.ID AS DEVICE_ID,

@ -37,4 +37,10 @@
<class name="org.wso2.carbon.policy.mgt.core.task.TaskSchedulerServiceImplTest" />
</classes>
</test>
<test name="Service Unit Tests" preserve-order="true">
<parameter name="dbType" value="H2"/>
<classes>
<class name="org.wso2.carbon.policy.mgt.core.PolicyManagerServiceImplTest"/>
</classes>
</test>
</suite>

@ -0,0 +1,101 @@
<!--
~ Copyright (c) 2005-2011, 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.
-->
<UserManager>
<Realm>
<Configuration>
<AddAdmin>true</AddAdmin>
<AdminRole>admin</AdminRole>
<AdminUser>
<UserName>admin</UserName>
<Password>admin</Password>
</AdminUser>
<EveryOneRoleName>everyone</EveryOneRoleName>
<ReadOnly>false</ReadOnly>
<MaxUserNameListLength>500</MaxUserNameListLength>
<Property name="url">jdbc:h2:target/databasetest/CARBON_TEST</Property>
<Property name="driverName">org.h2.Driver</Property>
<Property name="maxActive">50</Property>
<Property name="maxWait">60000</Property>
<Property name="minIdle">5</Property>
</Configuration>
<UserStoreManager
class="org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager">
<Property name="PasswordJavaRegEx">[\S]{5,30}$</Property>
<Property name="PasswordJavaScriptRegEx">[\\S]{5,30}</Property>
<Property name="SelectUserSQL">SELECT * FROM UM_USER WHERE UM_USER_NAME=? AND UM_TENANT_ID=?</Property>
<!--<Property name="GetRoleListSQL">SELECT UM_ROLE_NAME FROM UM_ROLE WHERE UM_TENANT_ID=?</Property>-->
<!--<Property name="UserFilterSQL">SELECT UM_USER_NAME FROM UM_USER WHERE UM_USER_NAME LIKE ? AND UM_TENANT_ID=? ORDER BY UM_USER_NAME</Property>-->
<!--<Property name="UserRoleSQL">SELECT UM_ROLE_NAME FROM UM_USER_ROLE, UM_ROLE, UM_USER WHERE UM_USER.UM_USER_NAME=? AND UM_USER.UM_ID=UM_USER_ROLE.UM_USER_ID AND UM_ROLE.UM_ID=UM_USER_ROLE.UM_ROLE_ID AND UM_USER_ROLE.UM_TENANT_ID=? AND UM_ROLE.UM_TENANT_ID=? AND UM_USER.UM_TENANT_ID=?</Property>-->
<!--<Property name="IsRoleExistingSQL">SELECT UM_ID FROM UM_ROLE WHERE UM_ROLE_NAME=? AND UM_TENANT_ID=?</Property>-->
<!--<Property name="IsUserExistingSQL">SELECT UM_ID FROM UM_USER WHERE UM_USER_NAME=? AND UM_TENANT_ID=?</Property>-->
<!--<Property name="GetUserListOfRoleSQL">SELECT UM_USER_NAME FROM UM_USER_ROLE, UM_ROLE, UM_USER WHERE UM_ROLE.UM_ROLE_NAME=? AND UM_USER.UM_ID=UM_USER_ROLE.UM_USER_ID AND UM_ROLE.UM_ID=UM_USER_ROLE.UM_ROLE_ID AND UM_USER_ROLE.UM_TENANT_ID=? AND UM_ROLE.UM_TENANT_ID=? AND UM_USER.UM_TENANT_ID=?</Property>-->
<!--<Property name="GetUserPropertyForProfileSQL">SELECT UM_ATTR_VALUE FROM UM_USER_ATTRIBUTE, UM_USER WHERE UM_USER.UM_ID = UM_USER_ATTRIBUTE.UM_USER_ID AND UM_USER.UM_USER_NAME=? AND UM_ATTR_NAME=? AND UM_PROFILE_ID=? AND UM_USER_ATTRIBUTE.UM_TENANT_ID=? AND UM_USER.UM_TENANT_ID=?</Property>-->
<!--<Property name="GetUserPropertiesForProfileSQL">SELECT UM_ATTR_NAME, UM_ATTR_VALUE FROM UM_USER_ATTRIBUTE, UM_USER WHERE UM_USER.UM_ID = UM_USER_ATTRIBUTE.UM_USER_ID AND UM_USER.UM_USER_NAME=? AND UM_PROFILE_ID=? AND UM_USER_ATTRIBUTE.UM_TENANT_ID=? AND UM_USER.UM_TENANT_ID=?</Property>-->
<!--<Property name="GetProfileNamesSQL">SELECT DISTINCT UM_PROFILE_ID FROM UM_USER_ATTRIBUTE WHERE UM_TENANT_ID=?</Property>-->
<!--<Property name="GetUserProfileNamesSQL">SELECT DISTINCT UM_PROFILE_ID FROM UM_USER_ATTRIBUTE WHERE UM_USER_ID=(SELECT UM_ID FROM UM_USER WHERE UM_USER_NAME=? AND UM_TENANT_ID=?) AND UM_TENANT_ID=?</Property>-->
<!--<Property name="GetUsersWithDefaultPasswordsSQL">SELECT UM_USER_NAME FROM UM_USER WHERE WHERE UM_USER_NAME=? AND UM_TENANT_ID=?</Property>-->
<!--<Property name="UserNameUniqueAcrossTenantsSQL">SELECT UM_ID FROM UM_USER WHERE UM_USER_NAME=?</Property>-->
<!--<Property name="GetUserIDFromUserNameSQL">SELECT UM_ID FROM UM_USER WHERE UM_USER_NAME=? AND UM_TENANT_ID=?</Property>-->
<!--<Property name="GetUserNameFromTenantIDSQL">SELECT UM_USER_NAME FROM UM_USER WHERE UM_TENANT_ID=?</Property>-->
<!--<Property name="GetTenantIDFromUserNameSQL">SELECT UM_TENANT_ID FROM UM_USER WHERE UM_USER_NAME=?</Property>-->
<Property name="PasswordDigest">SHA-256</Property>
<Property name="StoreSaltedPassword">true</Property>
<Property name="UserNameUniqueAcrossTenants">false</Property>
<Property name="IsEmailUserName">false</Property>
<Property name="SuperDomain">wso2.com</Property>
<Property name="IsUsersOfRoleListing">true</Property>
<Property name="MaxUserNameListLength">100</Property>
<!-- writing sqls follow-->
<!--<Property name="AddUserSQL">INSERT INTO UM_USER (UM_USER_NAME, UM_USER_PASSWORD, UM_SALT_VALUE, UM_REQUIRE_CHANGE, UM_CHANGED_TIME, UM_TENANT_ID) VALUES (?, ?, ?, ?, ?, ?)</Property>-->
<Property name="AddRoleSQL">INSERT INTO UM_ROLE (UM_ROLE_NAME, UM_TENANT_ID) VALUES (?, ?)</Property>
<!--<Property name="AddUserToRoleSQL">INSERT INTO UM_USER_ROLE (UM_USER_ID, UM_ROLE_ID, UM_TENANT_ID) VALUES ((SELECT UM_ID FROM UM_USER WHERE UM_USER_NAME=? AND UM_TENANT_ID=?),(SELECT UM_ID FROM UM_ROLE WHERE UM_ROLE_NAME=? AND UM_TENANT_ID=?), ?)</Property>-->
<!--<Property name="AddUserToRoleSQL-mssql">INSERT INTO UM_USER_ROLE (UM_USER_ID, UM_ROLE_ID, UM_TENANT_ID) SELECT (SELECT UM_ID FROM UM_USER WHERE UM_USER_NAME=? AND UM_TENANT_ID=?),(SELECT UM_ID FROM UM_ROLE WHERE UM_ROLE_NAME=? AND UM_TENANT_ID=?),(?)</Property>-->
<!--<Property name="RemoveUserFromRoleSQL">DELETE FROM UM_USER_ROLE WHERE UM_USER_ID=(SELECT UM_ID FROM UM_USER WHERE UM_USER_NAME=? AND UM_TENANT_ID=?) AND UM_ROLE_ID=(SELECT UM_ID FROM UM_ROLE WHERE UM_ROLE_NAME=? AND UM_TENANT_ID=?) AND UM_TENANT_ID=?</Property>-->
<!--<Property name="AddRoleToUserSQL">INSERT INTO UM_USER_ROLE (UM_ROLE_ID, UM_USER_ID, UM_TENANT_ID) VALUES ((SELECT UM_ID FROM UM_ROLE WHERE UM_ROLE_NAME=? AND UM_TENANT_ID=?),(SELECT UM_ID FROM UM_USER WHERE UM_USER_NAME=? AND UM_TENANT_ID=?), ?)</Property>-->
<!--<Property name="AddRoleToUserSQL-mssql">INSERT INTO UM_USER_ROLE (UM_ROLE_ID, UM_USER_ID, UM_TENANT_ID) SELECT (SELECT UM_ID FROM UM_ROLE WHERE UM_ROLE_NAME=? AND UM_TENANT_ID=?),(SELECT UM_ID FROM UM_USER WHERE UM_USER_NAME=? AND UM_TENANT_ID=?), (?)</Property>-->
<!--<Property name="RemoveRoleFromUserSQL">DELETE FROM UM_USER_ROLE WHERE UM_ROLE_ID=(SELECT UM_ID FROM UM_ROLE WHERE UM_ROLE_NAME=? AND UM_TENANT_ID=?) AND UM_USER_ID=(SELECT UM_ID FROM UM_USER WHERE UM_USER_NAME=? AND UM_TENANT_ID=?) AND UM_TENANT_ID=?</Property>-->
<!--<Property name="DeleteRoleSQL">DELETE FROM UM_ROLE WHERE UM_ROLE_NAME = ? AND UM_TENANT_ID=?</Property>-->
<!--<Property name="OnDeleteRoleRemoveUserRoleMappingSQL">DELETE FROM UM_USER_ROLE WHERE UM_ROLE_ID=(SELECT UM_ID FROM UM_ROLE WHERE UM_ROLE_NAME=? AND UM_TENANT_ID=?) AND UM_TENANT_ID=?</Property>-->
<!--<Property name="OnDeleteUserRemoveUserRoleMappingSQL">DELETE FROM UM_USER_ROLE WHERE UM_USER_ID=(SELECT UM_ID FROM UM_USER WHERE UM_USER_NAME=? AND UM_TENANT_ID=?) AND UM_TENANT_ID=?</Property>-->
<!--<Property name="OnDeleteUserRemoveUserAttributeSQL">DELETE FROM UM_USER_ATTRIBUTE WHERE UM_USER_ID=(SELECT UM_ID FROM UM_USER WHERE UM_USER_NAME=? AND UM_TENANT_ID=?) AND UM_TENANT_ID=?</Property>-->
<!--<Property name="DeleteUserSQL">DELETE FROM UM_USER WHERE UM_USER_NAME = ? AND UM_TENANT_ID=?</Property>-->
<!--<Property name="UpdateUserPasswordSQL">UPDATE UM_USER SET UM_USER_PASSWORD= ?, UM_SALT_VALUE=?, UM_REQUIRE_CHANGE=?, UM_CHANGED_TIME=? WHERE UM_USER_NAME= ? AND UM_TENANT_ID=?</Property>-->
<!--<Property name="AddUserPropertySQL">INSERT INTO UM_USER_ATTRIBUTE (UM_USER_ID, UM_ATTR_NAME, UM_ATTR_VALUE, UM_PROFILE_ID, UM_TENANT_ID) VALUES ((SELECT UM_ID FROM UM_USER WHERE UM_USER_NAME=? AND UM_TENANT_ID=?), ?, ?, ?, ?)</Property>-->
<!--<Property name="AddUserPropertySQL-mssql">INSERT INTO UM_USER_ATTRIBUTE (UM_USER_ID, UM_ATTR_NAME, UM_ATTR_VALUE, UM_PROFILE_ID, UM_TENANT_ID) SELECT (SELECT UM_ID FROM UM_USER WHERE UM_USER_NAME=? AND UM_TENANT_ID=?), (?), (?), (?), (?)</Property>-->
<!--<Property name="UpdateUserPropertySQL">UPDATE UM_USER_ATTRIBUTE SET UM_ATTR_VALUE=? WHERE UM_USER_ID=(SELECT UM_ID FROM UM_USER WHERE UM_USER_NAME=? AND UM_TENANT_ID=?) AND UM_ATTR_NAME=? AND UM_PROFILE_ID=? AND UM_TENANT_ID=?</Property>-->
<!--<Property name="DeleteUserPropertySQL">DELETE FROM UM_USER_ATTRIBUTE WHERE UM_USER_ID=(SELECT UM_ID FROM UM_USER WHERE UM_USER_NAME=? AND UM_TENANT_ID=?) AND UM_ATTR_NAME=? AND UM_PROFILE_ID=? AND UM_TENANT_ID=?</Property>-->
<Property name="TenantManager">org.wso2.carbon.user.core.tenant.JDBCTenantManager</Property>
</UserStoreManager>
<AuthorizationManager
class="org.wso2.carbon.user.core.authorization.JDBCAuthorizationManager">
<Property name="AuthorizationCacheEnabled">true</Property>
</AuthorizationManager>
</Realm>
<SystemPermission>
<Permission>login</Permission>
<Permission>manage-configuration</Permission>
<Permission>manage-security</Permission>
<Permission>upload-services</Permission>
<Permission>manage-services</Permission>
<Permission>manage-lc-configuration</Permission>
<Permission>manage-mediation</Permission>
<Permission>monitor-system</Permission>
<Permission>delegate-identity</Permission>
</SystemPermission>
</UserManager>
Loading…
Cancel
Save