forked from community/device-mgt-core
commit
a9a0ac5899
@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* 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.device.mgt.core.util;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class DateAdapter extends XmlAdapter<String, Date> {
|
|
||||||
|
|
||||||
private SimpleDateFormat dateFormat = new SimpleDateFormat("dd-mm-yyyy");
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Date unmarshal(String strDate) throws ParseException {
|
|
||||||
return dateFormat.parse(strDate);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String marshal(Date date) throws ParseException {
|
|
||||||
return dateFormat.format(date);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,68 @@
|
|||||||
|
<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>
|
||||||
|
<Bundle-Activator>org.wso2.carbon.policy.information.point.internal.PolicyInformationPointBundleActivator</Bundle-Activator>
|
||||||
|
<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,66 @@
|
|||||||
|
/*
|
||||||
|
* 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.internal;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.osgi.framework.BundleActivator;
|
||||||
|
import org.osgi.framework.BundleContext;
|
||||||
|
import org.osgi.framework.ServiceRegistration;
|
||||||
|
import org.wso2.carbon.policy.information.point.PolicyInformationServiceImpl;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.PolicyInformationService;
|
||||||
|
|
||||||
|
public class PolicyInformationPointBundleActivator implements BundleActivator {
|
||||||
|
|
||||||
|
private ServiceRegistration pipServiceRegRef;
|
||||||
|
private static final Log log = LogFactory.getLog(PolicyInformationPointBundleActivator.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(BundleContext bundleContext) throws Exception {
|
||||||
|
try {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Activating Policy information Point bundle.");
|
||||||
|
}
|
||||||
|
|
||||||
|
pipServiceRegRef = bundleContext.registerService(PolicyInformationService.class.getName(),
|
||||||
|
new PolicyInformationServiceImpl(), null);
|
||||||
|
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Policy information Point bundle is activated.");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.error("Error occurred while activating the Policy Information Point bundle.", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop(BundleContext bundleContext) throws Exception {
|
||||||
|
try {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Policy information Point bundle is deactivated.");
|
||||||
|
}
|
||||||
|
pipServiceRegRef.unregister();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.error("Error occurred while de-activating the Policy Information Point bundle.", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue