Package org.opensaml.xacml.policy

Examples of org.opensaml.xacml.policy.PolicyType


    }

    private void removeRule(PapContainer papContainer, String id) {
        List<PolicyType> policyList = papContainer.getAllPolicies();
        PolicyType targetPolicy = null;
        RuleType targetRule = null;

        for (PolicyType policy : policyList) {
            List<RuleType> ruleList = policy.getRules();

            for (RuleType rule : ruleList) {
                if (id.equals(rule.getRuleId())) {
                    targetRule = rule;
                    break;
                }
            }

            if (targetRule != null) {
                ruleList.remove(targetRule);
                targetPolicy = policy;
                break;
            }
        }

        if (targetPolicy == null) {
            throw new NotFoundException("Id not found: " + id);
        }

        if (targetPolicy.getRules().size() == 0) {
           
            papContainer.removePolicyAndReferences(targetPolicy.getPolicyId());
           
        } else {
            String version = targetPolicy.getVersion();

            PolicyWizard.increaseVersion(targetPolicy);

            papContainer.updatePolicy(version, targetPolicy);
        }
View Full Code Here


        if (!papContainer.hasPolicy(policyId)) {
            throw new NotFoundException("Policy '" + policyId + "' not found.");
        }

        PolicyType policy = papContainer.getPolicy(policyId);

        return policy;
    }
View Full Code Here

        }

        String policyId = null;

        PolicyWizard targetPolicyWizard;
        PolicyType candidatePolicy = getTargetPolicy(papContainer, targetPolicySet);

        if (candidatePolicy == null) {
            targetPolicyWizard = new PolicyWizard(actionAttributeWizard);
            targetPolicyWizard.setPrivate(!isPublic);
            policyId = targetPolicyWizard.getPolicyId();
            PolicySetHelper.addPolicyReference(targetPolicySet, 0, policyId);
        } else {
            targetPolicyWizard = new PolicyWizard(candidatePolicy);

            if (targetPolicyWizard.denyRuleForAttributeExists(banAttributeWizard)) {
                // ban policy already exists
                return null;
            }
            policyId = candidatePolicy.getPolicyId();
            updateOperationForPolicy = true;
            policySetNeedToBeSaved = false;
        }

        targetPolicyWizard.addRule(0, banAttributeWizard, EffectType.Deny);
View Full Code Here

        if (policyIdList.size() == 0) {
            return null;
        }

        // get the target policy, it must be the very first policy
        PolicyType candidatePolicy = papContainer.getPolicy(policyIdList.get(0));

        PolicyType policy = null;;
        TargetWizard policyTargetWizard = new TargetWizard(actionAttributeWizard);

        if (policyTargetWizard.isEquivalent(candidatePolicy.getTarget())) {

            policy = candidatePolicy;

            if (PolicyWizard.isPublic(policy.getPolicyId()) != isPublic) {
                return null;
            }
        }
        return policy;
    }
View Full Code Here

        papContainer.updatePolicySet(version, targetPolicySet);
    }

    private void moveRule(PapContainer papContainer) {

        PolicyType targetPolicy = null;

        for (PolicyType policy : papContainer.getAllPolicies()) {
            if (PolicyHelper.hasRuleWithId(policy, pivotId)) {
                targetPolicy = policy;
                break;
            }
        }

        if (targetPolicy == null) {
            throw new RepositoryException("Id not found or not a rule-id: " + pivotId);
        }

        RuleType rule = PolicyHelper.removeRule(targetPolicy, id);

        if (rule == null) {
            throw new RepositoryException(String.format("Id \"%s\" not found into action \"%s\"",
                                                        id,
                                                        targetPolicy.getPolicyId()));
        }

        int pivotIndex = PolicyHelper.indexOfRule(targetPolicy, pivotId);

        if (moveAfter) {
            pivotIndex++;
        }

        PolicyHelper.addRule(targetPolicy, pivotIndex, rule);

        String version = targetPolicy.getVersion();

        PolicyWizard.increaseVersion(targetPolicy);

        papContainer.updatePolicy(version, targetPolicy);
    }
View Full Code Here

     * @return a PolicyType object with the given id, the given rule combining algorithm and the
     *         given target.
     */
    public static PolicyType build(String policyId, String ruleCombinerAlgorithmId, TargetType target) {

        PolicyType policy = (PolicyType) builderFactory.getBuilder(ELEMENT_NAME).buildObject(ELEMENT_NAME);
        policy.setPolicyId(policyId);
        policy.setRuleCombiningAlgoId(ruleCombinerAlgorithmId);

        if (target == null)
            policy.setTarget(TargetHelper.build());
        else
            policy.setTarget(target);

        return policy;
    }
View Full Code Here

            log.debug("targetPolicySet not found");
            unbanResult.setStatusCode(1);
            return unbanResult;
        }

        PolicyType targetPolicy = null;

        for (PolicySetType targetPolicySet : targetPolicySetList) {
            targetPolicy = getTargetPolicy(papContainer, targetPolicySet);
            if (targetPolicy != null) {
                break;
View Full Code Here

        TargetWizard policyTargetWizard = new TargetWizard(actionAttributeWizard);

        for (String policyId : policyIdList) {

            PolicyType repositoryPolicy = papContainer.getPolicy(policyId);

            if (policyTargetWizard.isEquivalent(repositoryPolicy.getTarget())) {
                return repositoryPolicy;
            }
            TypeStringUtils.releaseUnneededMemory(repositoryPolicy);
        }
        return null;
View Full Code Here

    public void deleteAllPolicySets() {
        policySetDAO.deleteAll(papId);
    }

    public void deletePolicy(String id) throws NotFoundException, RepositoryException {
        PolicyType policy = policyDAO.getById(papId, id);

        int numberOfRules = policy.getRules().size();

        policyDAO.delete(papId, id);

        updatePapPolicyLastModificationTime();
        notifyPoliciesDeleted(numberOfRules);
View Full Code Here

       
        if (policyAlreadyRemoved) {
            return;
        }

        PolicyType policy = policyDAO.getById(papId, policyId);

        int numberOfRules = policy.getRules().size();

        policyDAO.delete(papId, policyId);

        updatePapPolicyLastModificationTime();
        notifyPoliciesDeleted(numberOfRules);
View Full Code Here

TOP

Related Classes of org.opensaml.xacml.policy.PolicyType

Copyright © 2018 www.massapicom. 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.