|
|
@ -24,6 +24,8 @@ import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
|
|
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
|
|
|
|
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
|
|
|
|
import org.wso2.carbon.device.mgt.common.policy.mgt.Profile;
|
|
|
|
import org.wso2.carbon.device.mgt.common.policy.mgt.Profile;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration;
|
|
|
|
import org.wso2.carbon.ntask.common.TaskException;
|
|
|
|
import org.wso2.carbon.ntask.common.TaskException;
|
|
|
|
import org.wso2.carbon.ntask.core.TaskInfo;
|
|
|
|
import org.wso2.carbon.ntask.core.TaskInfo;
|
|
|
|
import org.wso2.carbon.ntask.core.TaskManager;
|
|
|
|
import org.wso2.carbon.ntask.core.TaskManager;
|
|
|
@ -53,6 +55,7 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|
|
|
private ProfileManager profileManager;
|
|
|
|
private ProfileManager profileManager;
|
|
|
|
private FeatureManager featureManager;
|
|
|
|
private FeatureManager featureManager;
|
|
|
|
private PolicyCacheManager cacheManager;
|
|
|
|
private PolicyCacheManager cacheManager;
|
|
|
|
|
|
|
|
private PolicyConfiguration policyConfiguration;
|
|
|
|
// private PolicyEnforcementDelegator delegator;
|
|
|
|
// private PolicyEnforcementDelegator delegator;
|
|
|
|
|
|
|
|
|
|
|
|
public PolicyAdministratorPointImpl() {
|
|
|
|
public PolicyAdministratorPointImpl() {
|
|
|
@ -60,6 +63,7 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|
|
|
this.profileManager = new ProfileManagerImpl();
|
|
|
|
this.profileManager = new ProfileManagerImpl();
|
|
|
|
this.featureManager = new FeatureManagerImpl();
|
|
|
|
this.featureManager = new FeatureManagerImpl();
|
|
|
|
this.cacheManager = PolicyCacheManagerImpl.getInstance();
|
|
|
|
this.cacheManager = PolicyCacheManagerImpl.getInstance();
|
|
|
|
|
|
|
|
this.policyConfiguration = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getPolicyConfiguration();
|
|
|
|
// this.delegator = new PolicyEnforcementDelegatorImpl();
|
|
|
|
// this.delegator = new PolicyEnforcementDelegatorImpl();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -71,7 +75,9 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|
|
|
// } catch (PolicyDelegationException e) {
|
|
|
|
// } catch (PolicyDelegationException e) {
|
|
|
|
// throw new PolicyManagementException("Error occurred while delegating policy operation to the devices", e);
|
|
|
|
// throw new PolicyManagementException("Error occurred while delegating policy operation to the devices", e);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
|
|
|
|
}
|
|
|
|
return resultantPolicy;
|
|
|
|
return resultantPolicy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -83,42 +89,54 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|
|
|
// } catch (PolicyDelegationException e) {
|
|
|
|
// } catch (PolicyDelegationException e) {
|
|
|
|
// throw new PolicyManagementException("Error occurred while delegating policy operation to the devices", e);
|
|
|
|
// throw new PolicyManagementException("Error occurred while delegating policy operation to the devices", e);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
|
|
|
|
}
|
|
|
|
return resultantPolicy;
|
|
|
|
return resultantPolicy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean updatePolicyPriorities(List<Policy> policies) throws PolicyManagementException {
|
|
|
|
public boolean updatePolicyPriorities(List<Policy> policies) throws PolicyManagementException {
|
|
|
|
boolean bool = policyManager.updatePolicyPriorities(policies);
|
|
|
|
boolean bool = policyManager.updatePolicyPriorities(policies);
|
|
|
|
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
|
|
|
|
}
|
|
|
|
return bool;
|
|
|
|
return bool;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void activatePolicy(int policyId) throws PolicyManagementException {
|
|
|
|
public void activatePolicy(int policyId) throws PolicyManagementException {
|
|
|
|
policyManager.activatePolicy(policyId);
|
|
|
|
policyManager.activatePolicy(policyId);
|
|
|
|
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void inactivatePolicy(int policyId) throws PolicyManagementException {
|
|
|
|
public void inactivatePolicy(int policyId) throws PolicyManagementException {
|
|
|
|
policyManager.inactivatePolicy(policyId);
|
|
|
|
policyManager.inactivatePolicy(policyId);
|
|
|
|
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean deletePolicy(Policy policy) throws PolicyManagementException {
|
|
|
|
public boolean deletePolicy(Policy policy) throws PolicyManagementException {
|
|
|
|
boolean bool = policyManager.deletePolicy(policy);
|
|
|
|
boolean bool = policyManager.deletePolicy(policy);
|
|
|
|
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
PolicyCacheManager policyCacheManager = PolicyCacheManagerImpl.getInstance();
|
|
|
|
PolicyCacheManager policyCacheManager = PolicyCacheManagerImpl.getInstance();
|
|
|
|
policyCacheManager.rePopulateCache();
|
|
|
|
policyCacheManager.rePopulateCache();
|
|
|
|
|
|
|
|
}
|
|
|
|
return bool;
|
|
|
|
return bool;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean deletePolicy(int policyId) throws PolicyManagementException {
|
|
|
|
public boolean deletePolicy(int policyId) throws PolicyManagementException {
|
|
|
|
boolean bool = policyManager.deletePolicy(policyId);
|
|
|
|
boolean bool = policyManager.deletePolicy(policyId);
|
|
|
|
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
PolicyCacheManager policyCacheManager = PolicyCacheManagerImpl.getInstance();
|
|
|
|
PolicyCacheManager policyCacheManager = PolicyCacheManagerImpl.getInstance();
|
|
|
|
policyCacheManager.rePopulateCache();
|
|
|
|
policyCacheManager.rePopulateCache();
|
|
|
|
|
|
|
|
}
|
|
|
|
return bool;
|
|
|
|
return bool;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -222,25 +240,37 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|
|
|
public Policy addPolicyToDevice(List<DeviceIdentifier> deviceIdentifierList, Policy policy) throws
|
|
|
|
public Policy addPolicyToDevice(List<DeviceIdentifier> deviceIdentifierList, Policy policy) throws
|
|
|
|
PolicyManagementException {
|
|
|
|
PolicyManagementException {
|
|
|
|
policy = policyManager.addPolicyToDevice(deviceIdentifierList, policy);
|
|
|
|
policy = policyManager.addPolicyToDevice(deviceIdentifierList, policy);
|
|
|
|
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
|
|
|
|
}
|
|
|
|
return policy;
|
|
|
|
return policy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Policy addPolicyToRole(List<String> roleNames, Policy policy) throws PolicyManagementException {
|
|
|
|
public Policy addPolicyToRole(List<String> roleNames, Policy policy) throws PolicyManagementException {
|
|
|
|
policy = policyManager.addPolicyToRole(roleNames, policy);
|
|
|
|
policy = policyManager.addPolicyToRole(roleNames, policy);
|
|
|
|
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
|
|
|
|
}
|
|
|
|
return policy;
|
|
|
|
return policy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<Policy> getPolicies() throws PolicyManagementException {
|
|
|
|
public List<Policy> getPolicies() throws PolicyManagementException {
|
|
|
|
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
return PolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
return PolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return policyManager.getPolicies();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Policy getPolicy(int policyId) throws PolicyManagementException {
|
|
|
|
public Policy getPolicy(int policyId) throws PolicyManagementException {
|
|
|
|
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
return PolicyCacheManagerImpl.getInstance().getPolicy(policyId);
|
|
|
|
return PolicyCacheManagerImpl.getInstance().getPolicy(policyId);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return policyManager.getPolicy(policyId);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -340,7 +370,11 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int getPolicyCount() throws PolicyManagementException {
|
|
|
|
public int getPolicyCount() throws PolicyManagementException {
|
|
|
|
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
return PolicyCacheManagerImpl.getInstance().getAllPolicies().size();
|
|
|
|
return PolicyCacheManagerImpl.getInstance().getAllPolicies().size();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return policyManager.getPolicyCount();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|