Examples of PolicyAdmin


Examples of org.wso2.carbon.identity.entitlement.policy.PolicyAdmin

     *            PolicyDTO object
     * @throws org.wso2.carbon.identity.base.IdentityException
     *             throws if invalid policy or if policy with same id is exist
     */
    public void addPolicy(PolicyDTO policy) throws IdentityException {
        PolicyAdmin policyAdmin;
        AbstractPolicy policyObj;
        EntitlementEngine entitlementEngine = EntitlementEngine
                .getInstance(getGovernanceUserRegistry(), CarbonContext.getCurrentContext().getTenantId());
        policyObj = PolicyReader.getInstance(null, null).getPolicy(policy.getPolicy());
        if (policyObj != null) {
            policyAdmin = new PolicyAdmin(new PolicyStore(getGovernanceUserRegistry()));
            policy.setPolicyId(policyObj.getId().toASCIIString());
            // All the policies wont be active at the time been added.
            policy.setActive(policy.isActive());
            if (getPolicy(policy.getPolicyId()) != null) {
                throw new IdentityException(
                        "An Entitlement Policy with the given ID already exists");
            }
            policyAdmin.addOrUpdatePolicy(policy);
            entitlementEngine.getRegistryModule().init(null);
        } else {
            throw new IdentityException("Invalid Entitlement Policy");
        }
    }
View Full Code Here

Examples of org.wso2.carbon.identity.entitlement.policy.PolicyAdmin

     *            policy object
     * @throws org.wso2.carbon.identity.base.IdentityException
     *             throws
     */
    public void removePolicy(PolicyDTO policy) throws IdentityException {
        PolicyAdmin policyAdmin;
        EntitlementEngine entitlementEngine = EntitlementEngine
                .getInstance(getGovernanceUserRegistry(), CarbonContext.getCurrentContext().getTenantId());
        policyAdmin = new PolicyAdmin(new PolicyStore(getGovernanceUserRegistry()));
        policyAdmin.removePolicy(policy);
        // Reload the policies to the memory.
        entitlementEngine.getRegistryModule().init(null);
    }
View Full Code Here

Examples of org.wso2.carbon.identity.entitlement.policy.PolicyAdmin

     *            policy object
     * @throws org.wso2.carbon.identity.base.IdentityException
     *             throws if invalid policy
     */
    public void updatePolicy(PolicyDTO policy) throws IdentityException {
        PolicyAdmin policyAdmin;
        AbstractPolicy policyObj;
        EntitlementEngine entitlementEngine = EntitlementEngine
                .getInstance(getGovernanceUserRegistry(), CarbonContext.getCurrentContext().getTenantId());
        policyObj = PolicyReader.getInstance(null, null).getPolicy(policy.getPolicy());
        if (policyObj != null) {
            policyAdmin = new PolicyAdmin(new PolicyStore(getGovernanceUserRegistry()));
            policy.setPolicyId(policyObj.getId().toASCIIString());
            policyAdmin.addOrUpdatePolicy(policy);
            // Reload the policies to the memory.
            entitlementEngine.getRegistryModule().init(null);
        } else {
            throw new IdentityException("Invalid Policy");
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.