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

revert-70aa11f8
Geeth Munasinghe 10 years ago
parent 98ac04479d
commit 3032b1c55f

@ -28,7 +28,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.evaluator</artifactId>
<artifactId>org.wso2.carbon.complex.policy.decision.point</artifactId>
<version>0.9.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Decision Point</name>
@ -51,10 +51,10 @@
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
<Bundle-Description>Policy Management Common Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.policy.evaluator</Private-Package>
<Bundle-Description>Complex Policy Decision Point Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.complex.policy.decision.point.internal</Private-Package>
<Export-Package>
org.wso2.carbon.policy.evaluator.*
org.wso2.carbon.complex.policy.decision.point.*
</Export-Package>
</instructions>
</configuration>

@ -0,0 +1,67 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId>
<version>0.9.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.information.point</artifactId>
<version>0.9.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Information Point</name>
<description>WSO2 Carbon - Policy Information Point</description>
<url>http://wso2.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
<Bundle-Description>Policy Information Point Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.policy.information.point.internal</Private-Package>
<Export-Package>
org.wso2.carbon.policy.information.point.*
</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
</dependency>
</dependencies>
</project>

@ -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<Policy> getRelatedPolicies(PIPDeviceData pipDeviceData) {
return null;
}
@Override
public List<Feature> getRelatedFeatures(String deviceType) {
return null;
}
}

@ -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 );
}
}

@ -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<String> userIds;
List<String> roles;
String altitude;
String longitude;
Timestamp timestamp;
/*This will be used to record attributes to which would come from other PDPs*/
Map<String, Object> attributes;
}

@ -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<Feature> featuresList;
private boolean generic;
private List<String> roleList;
private List<String> 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<Feature> featuresList; // Features included in the policies.
private boolean generic; // If true, this should be applied to all related device.
private List<String> roleList; // Roles which this policy should be applied.
private String ownershipType; // Ownership type (COPE, BYOD, CPE)
private List<String> 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<String, Object> 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<Feature> getFeaturesList() {
return featuresList;
}
public void setFeaturesList(List<Feature> featuresList) {
this.featuresList = featuresList;
}
public boolean isGeneric() {
return generic;
}
public void setGeneric(boolean generic) {
this.generic = generic;
}
public List<String> 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<String> 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<Feature> getFeaturesList() {
return featuresList;
public Date getEndDate() {
return endDate;
}
public void setFeaturesList(List<Feature> 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<String, Object> getAttributes() {
return attributes;
}
public void setAttributes(Map<String, Object> attributes) {
this.attributes = attributes;
}
}
}

@ -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;
}

@ -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<Feature> getEffectiveFeatures(PIPDeviceData pipDeviceData);
}

@ -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<Policy> 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<Feature> getRelatedFeatures(String deviceType);
}

@ -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;

@ -0,0 +1,64 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId>
<version>0.9.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.simple.policy.decision.point</artifactId>
<version>0.9.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Simple Policy Decision Point</name>
<description>WSO2 Carbon - Simple Policy Decision Point</description>
<url>http://wso2.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
<Bundle-Description>Simple Policy Decision Point Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.simple.policy.decision.point.internal</Private-Package>
<Export-Package>
org.wso2.carbon.simple.policy.decision.point.*
</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
</dependency>
</dependencies>
</project>

@ -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<Feature> getEffectiveFeatures(PIPDeviceData pipDeviceData) {
return null;
}
}

@ -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 );
}
}

@ -38,7 +38,9 @@
<modules>
<module>org.wso2.carbon.policy.mgt.core</module>
<module>org.wso2.carbon.policy.mgt.common</module>
<module>org.wso2.carbon.policy.evalutor</module>
<module>org.wso2.carbon.policy.information.point</module>
<module>org.wso2.carbon.simple.policy.decision.point</module>
<module>org.wso2.carbon.complex.policy.decision.point</module>
</modules>

Loading…
Cancel
Save