diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml index 86e3b3e3a0..2fa5370241 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml @@ -52,12 +52,9 @@ ${project.artifactId} ${carbon.device.mgt.version} Policy Management Common Bundle - org.wso2.carbon.policy.mgt.common.internal - org.apache.commons.logging, org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.core.dto.*, - org.wso2.carbon.device.mgt.core.operation.*, javax.xml.bind.*, diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceData.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceData.java index 85234fff61..ea64f96417 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceData.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceData.java @@ -17,7 +17,7 @@ */ -package org.wso2.carbon.policy.mgt.common.Monitor; +package org.wso2.carbon.policy.mgt.common.monitor; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceDecisionPoint.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceDecisionPoint.java new file mode 100644 index 0000000000..fa751528ab --- /dev/null +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceDecisionPoint.java @@ -0,0 +1,48 @@ +/* + * 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.common.monitor; + + +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.policy.mgt.common.Policy; + +public interface ComplianceDecisionPoint { + + String getNoneComplianceRule(Policy policy) throws PolicyComplianceException; + + void setDeviceAsUnreachable(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; + + void setDeviceAsReachable(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; + + void reEnforcePolicy(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; + + void markDeviceAsNoneCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; + + void markDeviceAsCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; + + void deactivateDevice(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; + + void activateDevice(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; + + void validateDevicePolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy) throws + PolicyComplianceException; + + +} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceFeature.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceFeature.java index 7c4589a8ab..0e3e9a9536 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceFeature.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceFeature.java @@ -17,7 +17,7 @@ */ -package org.wso2.carbon.policy.mgt.common.Monitor; +package org.wso2.carbon.policy.mgt.common.monitor; import org.wso2.carbon.policy.mgt.common.ProfileFeature; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/PolicyComplianceException.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/PolicyComplianceException.java index d579546dd9..8d846eb49c 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/PolicyComplianceException.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/PolicyComplianceException.java @@ -17,7 +17,7 @@ */ -package org.wso2.carbon.policy.mgt.common.Monitor; +package org.wso2.carbon.policy.mgt.common.monitor; public class PolicyComplianceException extends Exception { diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/spi/PolicyMonitoringService.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/spi/PolicyMonitoringService.java index 4d5e34b368..86af5a0693 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/spi/PolicyMonitoringService.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/spi/PolicyMonitoringService.java @@ -20,8 +20,8 @@ package org.wso2.carbon.policy.mgt.common.spi; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.Monitor.PolicyComplianceException; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; +import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.common.Policy; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml index bd87dba8f4..d66c087ac2 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml @@ -71,7 +71,8 @@ org.wso2.carbon.context.*, org.wso2.carbon.user.api.*, org.wso2.carbon.device.mgt.core.*, - org.wso2.carbon.device.mgt.common.* + org.wso2.carbon.device.mgt.common.*, + org.wso2.carbon.ntask.* !org.wso2.carbon.policy.mgt.core.internal, @@ -132,6 +133,12 @@ org.wso2.carbon.ndatasource.rdbms + + + org.wso2.carbon.commons + org.wso2.carbon.ntask.core + + org.wso2.carbon.devicemgt diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerService.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerService.java index 3a5a48ab52..59e0c7a30d 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerService.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerService.java @@ -22,9 +22,9 @@ package org.wso2.carbon.policy.mgt.core; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.policy.mgt.common.FeatureManagementException; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.Monitor.PolicyComplianceException; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; +import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.common.Policy; import org.wso2.carbon.policy.mgt.common.PolicyAdministratorPoint; import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint; @@ -77,4 +77,6 @@ public interface PolicyManagerService { boolean checkCompliance(DeviceIdentifier deviceIdentifier, Object response) throws PolicyComplianceException; ComplianceData getDeviceCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; + + boolean isCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerServiceImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerServiceImpl.java index c4fcd2a4e8..70e76eb1f2 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerServiceImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerServiceImpl.java @@ -27,18 +27,16 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementExcept import org.wso2.carbon.device.mgt.core.operation.mgt.PolicyOperation; import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; import org.wso2.carbon.policy.mgt.common.*; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.Monitor.PolicyComplianceException; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; +import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.core.impl.PolicyAdministratorPointImpl; import org.wso2.carbon.policy.mgt.core.impl.PolicyInformationPointImpl; import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder; import org.wso2.carbon.policy.mgt.core.mgt.MonitoringManager; import org.wso2.carbon.policy.mgt.core.mgt.impl.MonitoringManagerImpl; -import org.wso2.carbon.policy.mgt.core.util.PolicyManagementConstants; import java.util.ArrayList; -import java.util.Date; import java.util.List; public class PolicyManagerServiceImpl implements PolicyManagerService { @@ -232,4 +230,9 @@ public class PolicyManagerServiceImpl implements PolicyManagerService { public ComplianceData getDeviceCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { return monitoringManager.getDevicePolicyCompliance(deviceIdentifier); } + + @Override + public boolean isCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + return monitoringManager.isCompliance(deviceIdentifier); + } } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/MonitoringDAO.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/MonitoringDAO.java index e97501dc05..a29928f8c4 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/MonitoringDAO.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/MonitoringDAO.java @@ -19,11 +19,10 @@ package org.wso2.carbon.policy.mgt.core.dao; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceFeature; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; import java.util.List; -import java.util.Map; public interface MonitoringDAO { diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/ComplianceDecisionPointImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/ComplianceDecisionPointImpl.java index 8efd5fc203..e089f03204 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/ComplianceDecisionPointImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/ComplianceDecisionPointImpl.java @@ -19,5 +19,54 @@ package org.wso2.carbon.policy.mgt.core.impl; -public class ComplianceDecisionPointImpl { +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceDecisionPoint; +import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; + +public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint { + @Override + public String getNoneComplianceRule(Policy policy) throws PolicyComplianceException { + return null; + } + + @Override + public void setDeviceAsUnreachable(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + + } + + @Override + public void setDeviceAsReachable(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + + } + + @Override + public void reEnforcePolicy(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + + } + + @Override + public void markDeviceAsNoneCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + + } + + @Override + public void markDeviceAsCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + + } + + @Override + public void deactivateDevice(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + + } + + @Override + public void activateDevice(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + + } + + @Override + public void validateDevicePolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy) throws PolicyComplianceException { + + } } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/MonitoringManager.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/MonitoringManager.java index f0ca764d8c..8ad323f2eb 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/MonitoringManager.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/MonitoringManager.java @@ -20,9 +20,9 @@ package org.wso2.carbon.policy.mgt.core.mgt; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.Monitor.PolicyComplianceException; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; +import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java index 56c4f593b8..d5143122a3 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java @@ -26,9 +26,9 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.core.dao.DeviceDAO; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.Monitor.PolicyComplianceException; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; +import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.common.Policy; import org.wso2.carbon.policy.mgt.common.ProfileFeature; import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/service/PolicyManagementService.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/service/PolicyManagementService.java index a6cebdd59c..5c73fcedea 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/service/PolicyManagementService.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/service/PolicyManagementService.java @@ -21,9 +21,9 @@ package org.wso2.carbon.policy.mgt.core.service; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.policy.mgt.common.FeatureManagementException; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.Monitor.PolicyComplianceException; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; +import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.common.Policy; import org.wso2.carbon.policy.mgt.common.PolicyAdministratorPoint; import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint; @@ -132,4 +132,9 @@ public class PolicyManagementService implements PolicyManagerService { public ComplianceData getDeviceCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { return policyManagerService.getDeviceCompliance(deviceIdentifier); } + + @Override + public boolean isCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + return policyManagerService.isCompliance(deviceIdentifier); + } } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java new file mode 100644 index 0000000000..e68c55e921 --- /dev/null +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java @@ -0,0 +1,42 @@ +/* + * 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.task; + +import org.wso2.carbon.ntask.core.Task; + +import java.util.Map; + +public class MonitoringTask implements Task { + + @Override + public void setProperties(Map map) { + + } + + @Override + public void init() { + + } + + @Override + public void execute() { + + } +}