|
|
@ -37,24 +37,16 @@ public class MergedEvaluationPoint implements PolicyEvaluationPoint {
|
|
|
|
PIPDevice pipDevice;
|
|
|
|
PIPDevice pipDevice;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<ProfileFeature> getEffectiveFeatures(DeviceIdentifier deviceIdentifier) throws PolicyEvaluationException {
|
|
|
|
public List<ProfileFeature> getEffectiveFeatures(List<Policy> policyList, DeviceIdentifier deviceIdentifier) throws PolicyEvaluationException {
|
|
|
|
PolicyAdministratorPoint policyAdministratorPoint;
|
|
|
|
PolicyAdministratorPoint policyAdministratorPoint;
|
|
|
|
PolicyInformationPoint policyInformationPoint;
|
|
|
|
|
|
|
|
policyManagerService = getPolicyManagerService();
|
|
|
|
policyManagerService = getPolicyManagerService();
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (policyManagerService != null) {
|
|
|
|
if (policyManagerService != null) {
|
|
|
|
|
|
|
|
|
|
|
|
policyInformationPoint = policyManagerService.getPIP();
|
|
|
|
|
|
|
|
PIPDevice pipDevice = policyInformationPoint.getDeviceData(deviceIdentifier);
|
|
|
|
|
|
|
|
policyList = policyInformationPoint.getRelatedPolicies(pipDevice);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!policyList.isEmpty()) {
|
|
|
|
if (!policyList.isEmpty()) {
|
|
|
|
//policy = policyList.get(0);
|
|
|
|
|
|
|
|
//policyList = new ArrayList<Policy>();
|
|
|
|
|
|
|
|
Policy effectivePolicy = policyResolve(policyList);
|
|
|
|
Policy effectivePolicy = policyResolve(policyList);
|
|
|
|
effectivePolicy.setActive(true);
|
|
|
|
effectivePolicy.setActive(true);
|
|
|
|
//TODO : UNCOMMENT THE FOLLOWING CASE
|
|
|
|
|
|
|
|
policyAdministratorPoint = policyManagerService.getPAP();
|
|
|
|
policyAdministratorPoint = policyManagerService.getPAP();
|
|
|
|
policyAdministratorPoint.setPolicyUsed(deviceIdentifier, effectivePolicy);
|
|
|
|
policyAdministratorPoint.setPolicyUsed(deviceIdentifier, effectivePolicy);
|
|
|
|
return effectivePolicy.getProfile().getProfileFeaturesList();
|
|
|
|
return effectivePolicy.getProfile().getProfileFeaturesList();
|
|
|
@ -83,7 +75,7 @@ public class MergedEvaluationPoint implements PolicyEvaluationPoint {
|
|
|
|
|
|
|
|
|
|
|
|
Policy policy = new Policy();
|
|
|
|
Policy policy = new Policy();
|
|
|
|
Profile profile = new Profile();
|
|
|
|
Profile profile = new Profile();
|
|
|
|
profile.setProfileFeaturesList(getEffectiveFeatures(deviceIdentifier));
|
|
|
|
profile.setProfileFeaturesList(getEffectiveFeatures(policyList, deviceIdentifier));
|
|
|
|
policy.setProfile(profile);
|
|
|
|
policy.setProfile(profile);
|
|
|
|
Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
|
|
|
|
Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
|
|
|
|
profile.setCreatedDate(currentTimestamp);
|
|
|
|
profile.setCreatedDate(currentTimestamp);
|
|
|
@ -113,6 +105,8 @@ public class MergedEvaluationPoint implements PolicyEvaluationPoint {
|
|
|
|
|
|
|
|
|
|
|
|
// Iterate through all policies
|
|
|
|
// Iterate through all policies
|
|
|
|
Map<String, ProfileFeature> featureMap = new HashMap<>();
|
|
|
|
Map<String, ProfileFeature> featureMap = new HashMap<>();
|
|
|
|
|
|
|
|
// Merge roles of policies
|
|
|
|
|
|
|
|
//Map<String, java.lang.Integer> rolesMap = new HashMap<>();
|
|
|
|
Iterator<Policy> policyIterator = policyList.iterator();
|
|
|
|
Iterator<Policy> policyIterator = policyList.iterator();
|
|
|
|
while (policyIterator.hasNext()) {
|
|
|
|
while (policyIterator.hasNext()) {
|
|
|
|
Policy policy = policyIterator.next();
|
|
|
|
Policy policy = policyIterator.next();
|
|
|
@ -124,6 +118,16 @@ public class MergedEvaluationPoint implements PolicyEvaluationPoint {
|
|
|
|
featureMap.put(feature.getFeatureCode(), feature);
|
|
|
|
featureMap.put(feature.getFeatureCode(), feature);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// List<String> policyRolesList = policy.getRoles();
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (policyRolesList != null) {
|
|
|
|
|
|
|
|
// Iterator<String> roleIterator = policyRolesList.iterator();
|
|
|
|
|
|
|
|
// while (roleIterator.hasNext()) {
|
|
|
|
|
|
|
|
// String role = roleIterator.next();
|
|
|
|
|
|
|
|
// rolesMap.put(role,policy.getId());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Get prioritized features list
|
|
|
|
// Get prioritized features list
|
|
|
@ -133,6 +137,7 @@ public class MergedEvaluationPoint implements PolicyEvaluationPoint {
|
|
|
|
|
|
|
|
|
|
|
|
Policy effectivePolicy = new Policy();
|
|
|
|
Policy effectivePolicy = new Policy();
|
|
|
|
effectivePolicy.setProfile(profile);
|
|
|
|
effectivePolicy.setProfile(profile);
|
|
|
|
|
|
|
|
//effectivePolicy.setRoles(rolesList);
|
|
|
|
|
|
|
|
|
|
|
|
return effectivePolicy;
|
|
|
|
return effectivePolicy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|