From 3032b1c55f0afc36c5fd3d34180838a120f4044f Mon Sep 17 00:00:00 2001 From: Geeth Munasinghe Date: Thu, 12 Feb 2015 20:04:48 +0530 Subject: [PATCH 1/2] Adding policy components, renamed the evaluator as the complex policy decision point, added the PIP component and simple policy decision point, Add the interfaces related to policies --- .../pom.xml | 8 +- .../policy/evaluator/FeatureFilter.java | 0 .../policy/evaluator/FeatureFilterImpl.java | 0 .../carbon/policy/evaluator/FeatureRules.java | 0 .../carbon/policy/evaluator/PDPException.java | 0 .../policy/evaluator/PDPServiceImpl.java | 0 .../carbon/policy/evaluator/PolicyFilter.java | 0 .../policy/evaluator/PolicyFilterImpl.java | 0 .../policy/evaluator/spi/PDPService.java | 0 .../policy/evaluator/utils/Constants.java | 0 .../pom.xml | 67 ++++++++ .../point/PolicyInformationServiceImpl.java | 43 ++++++ .../java/org/wso2/carbon/policy/AppTest.java | 38 +++++ .../policy/mgt/common/PIPDeviceData.java | 39 +++++ .../wso2/carbon/policy/mgt/common/Policy.java | 146 +++++++++++++++--- ...e.java => PolicyAdministratorService.java} | 23 ++- .../mgt/common/PolicyEvaluationService.java | 44 ++++++ .../mgt/common/PolicyInformationService.java | 50 ++++++ .../mgt/common/impl/PolicyManagement.java | 4 +- .../pom.xml | 64 ++++++++ .../point/PolicyEvaluationServiceImpl.java | 38 +++++ .../java/org/wso2/carbon/policy/AppTest.java | 38 +++++ components/policy-mgt/pom.xml | 4 +- 23 files changed, 574 insertions(+), 32 deletions(-) rename components/policy-mgt/{org.wso2.carbon.policy.evalutor => org.wso2.carbon.complex.policy.decision.point}/pom.xml (89%) rename components/policy-mgt/{org.wso2.carbon.policy.evalutor => org.wso2.carbon.complex.policy.decision.point}/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilter.java (100%) rename components/policy-mgt/{org.wso2.carbon.policy.evalutor => org.wso2.carbon.complex.policy.decision.point}/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java (100%) rename components/policy-mgt/{org.wso2.carbon.policy.evalutor => org.wso2.carbon.complex.policy.decision.point}/src/main/java/org/wso2/carbon/policy/evaluator/FeatureRules.java (100%) rename components/policy-mgt/{org.wso2.carbon.policy.evalutor => org.wso2.carbon.complex.policy.decision.point}/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java (100%) rename components/policy-mgt/{org.wso2.carbon.policy.evalutor => org.wso2.carbon.complex.policy.decision.point}/src/main/java/org/wso2/carbon/policy/evaluator/PDPServiceImpl.java (100%) rename components/policy-mgt/{org.wso2.carbon.policy.evalutor => org.wso2.carbon.complex.policy.decision.point}/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilter.java (100%) rename components/policy-mgt/{org.wso2.carbon.policy.evalutor => org.wso2.carbon.complex.policy.decision.point}/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilterImpl.java (100%) rename components/policy-mgt/{org.wso2.carbon.policy.evalutor => org.wso2.carbon.complex.policy.decision.point}/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java (100%) rename components/policy-mgt/{org.wso2.carbon.policy.evalutor => org.wso2.carbon.complex.policy.decision.point}/src/main/java/org/wso2/carbon/policy/evaluator/utils/Constants.java (100%) create mode 100644 components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml create mode 100644 components/policy-mgt/org.wso2.carbon.policy.information.point/src/main/java/org/wso2/carbon/policy/information/point/PolicyInformationServiceImpl.java create mode 100644 components/policy-mgt/org.wso2.carbon.policy.information.point/src/test/java/org/wso2/carbon/policy/AppTest.java create mode 100644 components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PIPDeviceData.java rename components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/{PolicyManagerService.java => PolicyAdministratorService.java} (84%) create mode 100644 components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyEvaluationService.java create mode 100644 components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyInformationService.java create mode 100644 components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/pom.xml create mode 100644 components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/src/main/java/org/wso2/carbon/simple/policy/decision/point/PolicyEvaluationServiceImpl.java create mode 100644 components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/src/test/java/org/wso2/carbon/policy/AppTest.java diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/pom.xml b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml similarity index 89% rename from components/policy-mgt/org.wso2.carbon.policy.evalutor/pom.xml rename to components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml index f0e929c46f..6777e348ba 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml @@ -28,7 +28,7 @@ 4.0.0 org.wso2.carbon.devicemgt - org.wso2.carbon.policy.evaluator + org.wso2.carbon.complex.policy.decision.point 0.9.1-SNAPSHOT bundle WSO2 Carbon - Policy Decision Point @@ -51,10 +51,10 @@ ${project.artifactId} ${project.artifactId} ${carbon.device.mgt.version} - Policy Management Common Bundle - org.wso2.carbon.policy.evaluator + Complex Policy Decision Point Bundle + org.wso2.carbon.complex.policy.decision.point.internal - org.wso2.carbon.policy.evaluator.* + org.wso2.carbon.complex.policy.decision.point.* diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilter.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilter.java similarity index 100% rename from components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilter.java rename to components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilter.java diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java similarity index 100% rename from components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java rename to components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/FeatureRules.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureRules.java similarity index 100% rename from components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/FeatureRules.java rename to components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureRules.java diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java similarity index 100% rename from components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java rename to components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPServiceImpl.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PDPServiceImpl.java similarity index 100% rename from components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPServiceImpl.java rename to components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PDPServiceImpl.java diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilter.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilter.java similarity index 100% rename from components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilter.java rename to components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilter.java diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilterImpl.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilterImpl.java similarity index 100% rename from components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilterImpl.java rename to components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilterImpl.java diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java similarity index 100% rename from components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java rename to components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/utils/Constants.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/utils/Constants.java similarity index 100% rename from components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/utils/Constants.java rename to components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/utils/Constants.java diff --git a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml new file mode 100644 index 0000000000..79cb29e195 --- /dev/null +++ b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml @@ -0,0 +1,67 @@ + + + + org.wso2.carbon.devicemgt + policy-mgt + 0.9.1-SNAPSHOT + ../pom.xml + + + + 4.0.0 + org.wso2.carbon.devicemgt + org.wso2.carbon.policy.information.point + 0.9.1-SNAPSHOT + bundle + WSO2 Carbon - Policy Information Point + WSO2 Carbon - Policy Information Point + http://wso2.org + + + + + + org.apache.felix + maven-scr-plugin + + + org.apache.felix + maven-bundle-plugin + 1.4.0 + true + + + ${project.artifactId} + ${project.artifactId} + ${carbon.device.mgt.version} + Policy Information Point Bundle + org.wso2.carbon.policy.information.point.internal + + org.wso2.carbon.policy.information.point.* + + + + + + + + + org.eclipse.osgi + org.eclipse.osgi + + + org.eclipse.equinox + org.eclipse.equinox.common + + + org.wso2.carbon + org.wso2.carbon.logging + + + org.wso2.carbon.devicemgt + org.wso2.carbon.policy.mgt.common + + + + diff --git a/components/policy-mgt/org.wso2.carbon.policy.information.point/src/main/java/org/wso2/carbon/policy/information/point/PolicyInformationServiceImpl.java b/components/policy-mgt/org.wso2.carbon.policy.information.point/src/main/java/org/wso2/carbon/policy/information/point/PolicyInformationServiceImpl.java new file mode 100644 index 0000000000..5ce43efddf --- /dev/null +++ b/components/policy-mgt/org.wso2.carbon.policy.information.point/src/main/java/org/wso2/carbon/policy/information/point/PolicyInformationServiceImpl.java @@ -0,0 +1,43 @@ +/* +* 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.information.point; + +import org.wso2.carbon.policy.mgt.common.Feature; +import org.wso2.carbon.policy.mgt.common.PIPDeviceData; +import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.policy.mgt.common.PolicyInformationService; + +import java.util.List; + +public class PolicyInformationServiceImpl implements PolicyInformationService{ + @Override + public void getDeviceData(PIPDeviceData pipDeviceData) { + + } + + @Override + public List getRelatedPolicies(PIPDeviceData pipDeviceData) { + return null; + } + + @Override + public List getRelatedFeatures(String deviceType) { + return null; + } +} diff --git a/components/policy-mgt/org.wso2.carbon.policy.information.point/src/test/java/org/wso2/carbon/policy/AppTest.java b/components/policy-mgt/org.wso2.carbon.policy.information.point/src/test/java/org/wso2/carbon/policy/AppTest.java new file mode 100644 index 0000000000..64bc008ddd --- /dev/null +++ b/components/policy-mgt/org.wso2.carbon.policy.information.point/src/test/java/org/wso2/carbon/policy/AppTest.java @@ -0,0 +1,38 @@ +package org.wso2.carbon.policy; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PIPDeviceData.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PIPDeviceData.java new file mode 100644 index 0000000000..caf5c81e2c --- /dev/null +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PIPDeviceData.java @@ -0,0 +1,39 @@ +/* +* 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; + +import java.sql.Timestamp; +import java.util.List; +import java.util.Map; + +public class PIPDeviceData { + + String deviceId; + String deviceType; + String ownershipType; + List userIds; + List roles; + String altitude; + String longitude; + Timestamp timestamp; + + /*This will be used to record attributes to which would come from other PDPs*/ + Map attributes; + +} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java index 0a253421ba..f0f930f57f 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java @@ -18,16 +18,82 @@ package org.wso2.carbon.policy.mgt.common; +import java.sql.Date; import java.util.List; +import java.util.Map; +/** + * This class will be the used to create policy object with relevant information for evaluating. + */ public class Policy { - private int id; - private String policyName; - private List featuresList; - private boolean generic; - private List roleList; - private List DeviceList; - private String deviceType; + private int id; // Identifier of the policy. + private int priorityId; // Priority of the policies. This will be used only for simple evaluation. + private String policyName; // Name of the policy. + private List featuresList; // Features included in the policies. + private boolean generic; // If true, this should be applied to all related device. + private List roleList; // Roles which this policy should be applied. + private String ownershipType; // Ownership type (COPE, BYOD, CPE) + private List DeviceList; // Individual devices this policy should be applied + private String deviceType; // Device type to apply the policy. + + /*Dynamic policy attributes*/ + + /*These are related to time based policies*/ + + private int startTime; // Start time to apply the policy. + private int endTime; // After this time policy will not be applied + private Date startDate; // Start date to apply the policy + private Date endDate; // After this date policy will not be applied. + + + /*These are related to location based policies*/ + + private String altitude; // Altitude + private String longitude; // Longitude + + /*This will be used to record attributes which will be used by customer extended PDPs and PIPs*/ + + private Map attributes; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getPriorityId() { + return priorityId; + } + + public void setPriorityId(int priorityId) { + this.priorityId = priorityId; + } + + public String getPolicyName() { + return policyName; + } + + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + public List getFeaturesList() { + return featuresList; + } + + public void setFeaturesList(List featuresList) { + this.featuresList = featuresList; + } + + public boolean isGeneric() { + return generic; + } + + public void setGeneric(boolean generic) { + this.generic = generic; + } public List getRoleList() { return roleList; @@ -37,6 +103,14 @@ public class Policy { this.roleList = roleList; } + public String getOwnershipType() { + return ownershipType; + } + + public void setOwnershipType(String ownershipType) { + this.ownershipType = ownershipType; + } + public List getDeviceList() { return DeviceList; } @@ -53,35 +127,59 @@ public class Policy { this.deviceType = deviceType; } - public boolean isGeneric() { - return generic; + public int getStartTime() { + return startTime; } - public void setGeneric(boolean generic) { - this.generic = generic; + public void setStartTime(int startTime) { + this.startTime = startTime; } - public int getId() { - return id; + public int getEndTime() { + return endTime; } - public void setId(int id) { - this.id = id; + public void setEndTime(int endTime) { + this.endTime = endTime; } - public String getPolicyName() { - return policyName; + public Date getStartDate() { + return startDate; } - public void setPolicyName(String policyName) { - this.policyName = policyName; + public void setStartDate(Date startDate) { + this.startDate = startDate; } - public List getFeaturesList() { - return featuresList; + public Date getEndDate() { + return endDate; } - public void setFeaturesList(List featuresList) { - this.featuresList = featuresList; + public void setEndDate(Date endDate) { + this.endDate = endDate; + } + + public String getAltitude() { + return altitude; + } + + public void setAltitude(String altitude) { + this.altitude = altitude; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + public Map getAttributes() { + return attributes; + } + + public void setAttributes(Map attributes) { + this.attributes = attributes; } -} +} \ No newline at end of file diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagerService.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyAdministratorService.java similarity index 84% rename from components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagerService.java rename to components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyAdministratorService.java index 1fff4e79fb..4534254ad9 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagerService.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyAdministratorService.java @@ -22,7 +22,7 @@ package org.wso2.carbon.policy.mgt.common; * This interface defines the policy management which should be implemented by the plugins */ -public interface PolicyManagerService { +public interface PolicyAdministratorService { /** * This method adds a policy to the platform @@ -100,11 +100,32 @@ public interface PolicyManagerService { Policy getPolicyOfRole(String roleName) throws FeatureManagementException, PolicyManagementException; + /** + * This method checks weather a policy is available for a device. + * @param deviceId + * @param deviceType + * @return + * @throws PolicyManagementException + */ boolean isPolicyAvailableForDevice(String deviceId, String deviceType) throws PolicyManagementException; + /** + * This method checks weather a policy is used by a particular device. + * @param deviceId + * @param deviceType + * @return + * @throws PolicyManagementException + */ boolean isPolicyUsed(String deviceId, String deviceType) throws PolicyManagementException; + /** + * + * @param deviceId + * @param deviceType + * @param policy + * @throws PolicyManagementException + */ void setPolicyUsed(String deviceId, String deviceType, Policy policy) throws PolicyManagementException; } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyEvaluationService.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyEvaluationService.java new file mode 100644 index 0000000000..b5082c578d --- /dev/null +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyEvaluationService.java @@ -0,0 +1,44 @@ +/* +* 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; + +import java.util.List; + +/** + * This is the interface which will be used to create plug-able policy decision points. + */ +public interface PolicyEvaluationService { + + + /** + * This method returns the effective policy from the list. + * @param pipDeviceData device information. + * @return returns the effective policy. + */ + Policy getEffectivePolicy(PIPDeviceData pipDeviceData); + + + /** + * This class will return the effective feature set from the list. + * @param pipDeviceData device information. + * @return returns the effective feature set. + */ + List getEffectiveFeatures(PIPDeviceData pipDeviceData); +} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyInformationService.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyInformationService.java new file mode 100644 index 0000000000..ea9509506a --- /dev/null +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyInformationService.java @@ -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.common; + +import java.util.List; + +/** + * This will be used retrieve data database. This interface has to be implemented by PIP. PIP will be plug-able. + */ +public interface PolicyInformationService { + + /** + * This method will return the data related Device, Some of the device data will provided in the initial pipDeviceData object such as + * device id, device time and location, Other data such as roles, owned users and ownership type will be filled by this method. + * @param pipDeviceData device data. + */ + void getDeviceData(PIPDeviceData pipDeviceData); + + /** + * This method will retrieve the policies related given device Data. + * @param pipDeviceData + * @return + */ + List getRelatedPolicies(PIPDeviceData pipDeviceData); + + /** + * This is will retrieve the features related to device type. This feature list will be used for dynamically + * merging the policies. + * @param deviceType + * @return + */ + List getRelatedFeatures(String deviceType); +} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/impl/PolicyManagement.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/impl/PolicyManagement.java index de830e596b..3ec34a90f2 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/impl/PolicyManagement.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/impl/PolicyManagement.java @@ -20,10 +20,10 @@ package org.wso2.carbon.policy.mgt.common.impl; import org.wso2.carbon.policy.mgt.common.FeatureManagementException; import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.policy.mgt.common.PolicyAdministratorService; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; -import org.wso2.carbon.policy.mgt.common.PolicyManagerService; -public class PolicyManagement implements PolicyManagerService { +public class PolicyManagement implements PolicyAdministratorService { @Override public int addPolicy(Policy policy) { return 0; diff --git a/components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/pom.xml b/components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/pom.xml new file mode 100644 index 0000000000..8363e939da --- /dev/null +++ b/components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/pom.xml @@ -0,0 +1,64 @@ + + + + org.wso2.carbon.devicemgt + policy-mgt + 0.9.1-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.devicemgt + org.wso2.carbon.simple.policy.decision.point + 0.9.1-SNAPSHOT + bundle + WSO2 Carbon - Simple Policy Decision Point + WSO2 Carbon - Simple Policy Decision Point + http://wso2.org + + + + + org.apache.felix + maven-scr-plugin + + + org.apache.felix + maven-bundle-plugin + 1.4.0 + true + + + ${project.artifactId} + ${project.artifactId} + ${carbon.device.mgt.version} + Simple Policy Decision Point Bundle + org.wso2.carbon.simple.policy.decision.point.internal + + org.wso2.carbon.simple.policy.decision.point.* + + + + + + + + + org.eclipse.osgi + org.eclipse.osgi + + + org.eclipse.equinox + org.eclipse.equinox.common + + + org.wso2.carbon + org.wso2.carbon.logging + + + org.wso2.carbon.devicemgt + org.wso2.carbon.policy.mgt.common + + + diff --git a/components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/src/main/java/org/wso2/carbon/simple/policy/decision/point/PolicyEvaluationServiceImpl.java b/components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/src/main/java/org/wso2/carbon/simple/policy/decision/point/PolicyEvaluationServiceImpl.java new file mode 100644 index 0000000000..fbeb04c7a4 --- /dev/null +++ b/components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/src/main/java/org/wso2/carbon/simple/policy/decision/point/PolicyEvaluationServiceImpl.java @@ -0,0 +1,38 @@ +/* +* 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.simple.policy.decision.point; + +import org.wso2.carbon.policy.mgt.common.Feature; +import org.wso2.carbon.policy.mgt.common.PIPDeviceData; +import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.policy.mgt.common.PolicyEvaluationService; + +import java.util.List; + +public class PolicyEvaluationServiceImpl implements PolicyEvaluationService { + @Override + public Policy getEffectivePolicy(PIPDeviceData pipDeviceData) { + return null; + } + + @Override + public List getEffectiveFeatures(PIPDeviceData pipDeviceData) { + return null; + } +} diff --git a/components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/src/test/java/org/wso2/carbon/policy/AppTest.java b/components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/src/test/java/org/wso2/carbon/policy/AppTest.java new file mode 100644 index 0000000000..64bc008ddd --- /dev/null +++ b/components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/src/test/java/org/wso2/carbon/policy/AppTest.java @@ -0,0 +1,38 @@ +package org.wso2.carbon.policy; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index fb3a917c2f..8dc5b9f79b 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -38,7 +38,9 @@ org.wso2.carbon.policy.mgt.core org.wso2.carbon.policy.mgt.common - org.wso2.carbon.policy.evalutor + org.wso2.carbon.policy.information.point + org.wso2.carbon.simple.policy.decision.point + org.wso2.carbon.complex.policy.decision.point From db5b8b1e1e8997d1867540fd5bb458062f5c9072 Mon Sep 17 00:00:00 2001 From: harshanL Date: Fri, 13 Feb 2015 10:19:02 +0530 Subject: [PATCH 2/2] Fixed build issue --- .../java/org/wso2/carbon/policy/AppTest.java | 38 ------------------- .../java/org/wso2/carbon/policy/AppTest.java | 38 ------------------- 2 files changed, 76 deletions(-) delete mode 100644 components/policy-mgt/org.wso2.carbon.policy.information.point/src/test/java/org/wso2/carbon/policy/AppTest.java delete mode 100644 components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/src/test/java/org/wso2/carbon/policy/AppTest.java diff --git a/components/policy-mgt/org.wso2.carbon.policy.information.point/src/test/java/org/wso2/carbon/policy/AppTest.java b/components/policy-mgt/org.wso2.carbon.policy.information.point/src/test/java/org/wso2/carbon/policy/AppTest.java deleted file mode 100644 index 64bc008ddd..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.information.point/src/test/java/org/wso2/carbon/policy/AppTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.wso2.carbon.policy; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -} diff --git a/components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/src/test/java/org/wso2/carbon/policy/AppTest.java b/components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/src/test/java/org/wso2/carbon/policy/AppTest.java deleted file mode 100644 index 64bc008ddd..0000000000 --- a/components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/src/test/java/org/wso2/carbon/policy/AppTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.wso2.carbon.policy; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -}