forked from community/device-mgt-core
Merge branch 'master' of https://github.com/wso2/carbon-device-mgt
commit
c0b0975929
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.policy.mgt.core.enforcement;
|
||||||
|
|
||||||
|
public class PolicyDelegationException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -3151279311929070297L;
|
||||||
|
|
||||||
|
private String errorMessage;
|
||||||
|
|
||||||
|
public String getErrorMessage() {
|
||||||
|
return errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorMessage(String errorMessage) {
|
||||||
|
this.errorMessage = errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PolicyDelegationException(String msg, Exception nestedEx) {
|
||||||
|
super(msg, nestedEx);
|
||||||
|
setErrorMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PolicyDelegationException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
setErrorMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PolicyDelegationException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
setErrorMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PolicyDelegationException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PolicyDelegationException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.policy.mgt.core.enforcement;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface PolicyEnforcementDelegator {
|
||||||
|
|
||||||
|
void delegate(Policy policy, List<Device> devices) throws PolicyDelegationException;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.policy.mgt.core.enforcement;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
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.core.operation.mgt.OperationManagerImpl;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||||
|
import org.wso2.carbon.policy.mgt.core.util.PolicyManagerUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PolicyEnforcementDelegatorImpl implements PolicyEnforcementDelegator {
|
||||||
|
|
||||||
|
private OperationManager operationManager = new OperationManagerImpl();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delegate(Policy policy, List<Device> devices) throws PolicyDelegationException {
|
||||||
|
try {
|
||||||
|
List<DeviceIdentifier> deviceIds = new ArrayList<>();
|
||||||
|
for (Device device : devices) {
|
||||||
|
deviceIds.add(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
||||||
|
}
|
||||||
|
operationManager.addOperation(PolicyManagerUtil.transformPolicy(policy), deviceIds);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
throw new PolicyDelegationException("Error occurred while delegating policy information to " +
|
||||||
|
"the respective enforcement points", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,78 +0,0 @@
|
|||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE (
|
|
||||||
ID INT auto_increment NOT NULL,
|
|
||||||
NAME VARCHAR(300) NULL DEFAULT NULL,
|
|
||||||
PRIMARY KEY (ID)
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE (
|
|
||||||
ID INTEGER auto_increment NOT NULL,
|
|
||||||
DESCRIPTION TEXT NULL DEFAULT NULL,
|
|
||||||
NAME VARCHAR(100) NULL DEFAULT NULL,
|
|
||||||
DATE_OF_ENROLLMENT BIGINT NULL DEFAULT NULL,
|
|
||||||
DATE_OF_LAST_UPDATE BIGINT NULL DEFAULT NULL,
|
|
||||||
OWNERSHIP VARCHAR(45) NULL DEFAULT NULL,
|
|
||||||
STATUS VARCHAR(15) NULL DEFAULT NULL,
|
|
||||||
DEVICE_TYPE_ID INT(11) NULL DEFAULT NULL,
|
|
||||||
DEVICE_IDENTIFICATION VARCHAR(300) NULL DEFAULT NULL,
|
|
||||||
OWNER VARCHAR(45) NULL DEFAULT NULL,
|
|
||||||
TENANT_ID INTEGER DEFAULT 0,
|
|
||||||
PRIMARY KEY (ID),
|
|
||||||
CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID )
|
|
||||||
REFERENCES DM_DEVICE_TYPE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS DM_OPERATION (
|
|
||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
|
||||||
TYPE VARCHAR(50) NOT NULL,
|
|
||||||
CREATED_TIMESTAMP TIMESTAMP NOT NULL,
|
|
||||||
RECEIVED_TIMESTAMP TIMESTAMP NULL,
|
|
||||||
PRIMARY KEY (ID)
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS DM_CONFIG_OPERATION (
|
|
||||||
OPERATION_ID INTEGER NOT NULL,
|
|
||||||
PRIMARY KEY (OPERATION_ID),
|
|
||||||
CONSTRAINT fk_dm_operation_config FOREIGN KEY (OPERATION_ID) REFERENCES
|
|
||||||
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS DM_COMMAND_OPERATION (
|
|
||||||
OPERATION_ID INTEGER NOT NULL,
|
|
||||||
ENABLED INTEGER NOT NULL DEFAULT 0,
|
|
||||||
PRIMARY KEY (OPERATION_ID),
|
|
||||||
CONSTRAINT fk_dm_operation_command FOREIGN KEY (OPERATION_ID) REFERENCES
|
|
||||||
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS DM_PROFILE_OPERATION (
|
|
||||||
OPERATION_ID INTEGER NOT NULL,
|
|
||||||
ENABLED INTEGER NOT NULL DEFAULT 0,
|
|
||||||
OPERATION_DETAILS BLOB DEFAULT NULL,
|
|
||||||
PRIMARY KEY (OPERATION_ID),
|
|
||||||
CONSTRAINT fk_dm_operation_profile FOREIGN KEY (OPERATION_ID) REFERENCES
|
|
||||||
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS DM_POLICY_OPERATION (
|
|
||||||
OPERATION_ID INTEGER NOT NULL,
|
|
||||||
ENABLED INTEGER NOT NULL DEFAULT 0,
|
|
||||||
OPERATION_DETAILS BLOB DEFAULT NULL,
|
|
||||||
PRIMARY KEY (OPERATION_ID),
|
|
||||||
CONSTRAINT fk_dm_operation_policy FOREIGN KEY (OPERATION_ID) REFERENCES
|
|
||||||
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OPERATION_MAPPING (
|
|
||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
|
||||||
ENROLMENT_ID INTEGER NOT NULL,
|
|
||||||
OPERATION_ID INTEGER NOT NULL,
|
|
||||||
STATUS VARCHAR(50) NULL,
|
|
||||||
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,
|
|
||||||
CONSTRAINT fk_dm_device_operation_mapping_operation FOREIGN KEY (OPERATION_ID) REFERENCES
|
|
||||||
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
||||||
);
|
|
||||||
|
|
||||||
-- TO:DO - Remove this INSERT sql statement.
|
|
||||||
Insert into DM_DEVICE_TYPE (ID,NAME) VALUES (1, 'android');
|
|
@ -1,35 +0,0 @@
|
|||||||
-- -----------------------------------------------------
|
|
||||||
-- Table `DM_DEVICE_TYPE`
|
|
||||||
-- -----------------------------------------------------
|
|
||||||
CREATE TABLE IF NOT EXISTS `DM_DEVICE_TYPE` (
|
|
||||||
`ID` INT(11) NOT NULL ,
|
|
||||||
`NAME` VARCHAR(300) NULL DEFAULT NULL ,
|
|
||||||
PRIMARY KEY (`ID`) )
|
|
||||||
ENGINE = InnoDB
|
|
||||||
DEFAULT CHARACTER SET = latin1;
|
|
||||||
|
|
||||||
|
|
||||||
-- -----------------------------------------------------
|
|
||||||
-- Table `DM_DEVICE`
|
|
||||||
-- -----------------------------------------------------
|
|
||||||
CREATE TABLE IF NOT EXISTS `DM_DEVICE` (
|
|
||||||
`ID` VARCHAR(20) NOT NULL ,
|
|
||||||
`DESCRIPTION` TEXT NULL DEFAULT NULL ,
|
|
||||||
`NAME` VARCHAR(100) NULL DEFAULT NULL ,
|
|
||||||
`DATE_OF_ENROLLMENT` DATETIME NULL DEFAULT NULL ,
|
|
||||||
`DATE_OF_LAST_UPDATE` DATETIME NULL DEFAULT NULL ,
|
|
||||||
`OWNERSHIP` VARCHAR(45) NULL DEFAULT NULL ,
|
|
||||||
`STATUS` VARCHAR(15) NULL DEFAULT NULL ,
|
|
||||||
`DEVICE_TYPE_ID` INT(11) NULL DEFAULT NULL ,
|
|
||||||
`DEVICE_IDENTIFICATION` VARCHAR(300) NULL DEFAULT NULL ,
|
|
||||||
`OWNER` VARCHAR(45) NULL DEFAULT NULL ,
|
|
||||||
TENANT_ID INTEGER DEFAULT 0,
|
|
||||||
PRIMARY KEY (`ID`) ,
|
|
||||||
INDEX `fk_DM_DEVICE_DM_DEVICE_TYPE2_idx` (`DEVICE_TYPE_ID` ASC) ,
|
|
||||||
CONSTRAINT `fk_DM_DEVICE_DM_DEVICE_TYPE2`
|
|
||||||
FOREIGN KEY (`DEVICE_TYPE_ID` )
|
|
||||||
REFERENCES `DM_DEVICE_TYPE` (`ID` )
|
|
||||||
ON DELETE NO ACTION
|
|
||||||
ON UPDATE NO ACTION)
|
|
||||||
ENGINE = InnoDB
|
|
||||||
DEFAULT CHARACTER SET = latin1;
|
|
@ -1,47 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<artifactType type="application/vnd.wso2-license+xml" shortName="license" singularLabel="License" pluralLabel="Licenses"
|
|
||||||
hasNamespace="false" iconSet="10">
|
|
||||||
<storagePath>/device-mgt/license/@{overview_name}/@{overview_language}/@{overview_version}</storagePath>
|
|
||||||
<nameAttribute>overview_name</nameAttribute>
|
|
||||||
<ui>
|
|
||||||
<list>
|
|
||||||
<column name="Device Type">
|
|
||||||
<data type="path" value="overview_provider" href="@{storagePath}"/>
|
|
||||||
</column>
|
|
||||||
<column name="Name">
|
|
||||||
<data type="path" value="overview_name" href="@{storagePath}"/>
|
|
||||||
</column>
|
|
||||||
<column name="Language">
|
|
||||||
<data type="path" value="overview_language" href="@{storagePath}"/>
|
|
||||||
</column>
|
|
||||||
<column name="Version">
|
|
||||||
<data type="path" value="overview_version" href="@{storagePath}"/>
|
|
||||||
</column>
|
|
||||||
</list>
|
|
||||||
</ui>
|
|
||||||
<content>
|
|
||||||
<table name="Overview">
|
|
||||||
<field type="text" required="true">
|
|
||||||
<name>Provider</name>
|
|
||||||
</field>
|
|
||||||
<field type="text" required="true">
|
|
||||||
<name>Name</name>
|
|
||||||
</field>
|
|
||||||
<field type="text" required="true">
|
|
||||||
<name>Language</name>
|
|
||||||
</field>
|
|
||||||
<field type="text" required="true">
|
|
||||||
<name>Version</name>
|
|
||||||
</field>
|
|
||||||
<field type="text">
|
|
||||||
<name>Validity From</name>
|
|
||||||
</field>
|
|
||||||
<field type="text">
|
|
||||||
<name>Validity To</name>
|
|
||||||
</field>
|
|
||||||
<field type="text-area">
|
|
||||||
<name>License</name>
|
|
||||||
</field>
|
|
||||||
</table>
|
|
||||||
</content>
|
|
||||||
</artifactType>
|
|
Loading…
Reference in new issue