Package org.opensaml.xacml.policy

Examples of org.opensaml.xacml.policy.PolicySetType


        }

        int position = -1;

        if (pivotId != null) {
            PolicySetType rootPolicySet = xacmlPolicyMgmtClient.getRootPolicySet(null);
            position = PolicySetHelper.getPolicySetIdReferenceIndex(rootPolicySet, pivotId);
            if (position == -1) {
                System.out.println("id \"" + pivotId + "\" not found (or it's not a resource id).");
                return false;
            }
            if (moveAfter) {
                position++;
            }
        }

        boolean result = true;

        for (XACMLWizard xacmlWizard : xacmlWizardList) {

            PolicySetWizard policySetWizard = (PolicySetWizard) xacmlWizard;

            PolicySetType policySet = policySetWizard.getXACML();

            policySet.getPolicyIdReferences().clear();

            policySetWizard.releaseDOM();

            String policySetId = xacmlPolicyMgmtClient.addPolicySet(alias, position, policySet);
View Full Code Here


        if (resourceId == null) {
            System.out.println("Error \"resourceId\" is needed to insert action elements");
            return false;
        }

        PolicySetType targetPolicySet = xacmlPolicyMgmtClient.getPolicySet(alias, resourceId);

        int position = -1;

        if (pivotId != null) {
            position = PolicySetHelper.getPolicyIdReferenceIndex(targetPolicySet, pivotId);
View Full Code Here

        log.debug("Executing PDP query...");

        List<XACMLObject> resultList = new LinkedList<XACMLObject>();

        PolicySetType rootPolicySet = ServicesUtils.makeRootPolicySet();

        resultList.add(rootPolicySet);

        List<PapContainer> papContainerList = PapContainer.getContainers(PapManager.getInstance()
                                                                                   .getAllPaps());

        // Add references to the remote PAPs
        for (PapContainer papContainer : papContainerList) {

            if (!papContainer.getPap().isEnabled()) {
                continue;
            }

            log.info("Adding PAP: " + papContainer.getPap().getAlias());

            try {
                PolicySetType papPolicySetNoReferences;

                if (papContainer.getPap().isLocal()) {
                    synchronized (ServicesUtils.highLevelOperationLock) {
                        papPolicySetNoReferences = getPolicySetNoReferences(papContainer,
                                                                            papContainer.getRootPolicySetId());
View Full Code Here

        return resultList;
    }

    private PolicySetType getPolicySetNoReferences(PapContainer papContainer, String policySetId) {

        PolicySetType policySetNoRef = papContainer.getPolicySet(policySetId);

        // replace policy set references with policy sets
        List<String> idReferenceList = PolicySetHelper.getPolicySetIdReferencesValues(policySetNoRef);
        for (String childPolicySetId : idReferenceList) {

            try {
                PolicySetType childPolicySetNoRef = getPolicySetNoReferences(papContainer, childPolicySetId);

                PolicySetHelper.addPolicySet(policySetNoRef, childPolicySetNoRef);

                TypeStringUtils.releaseUnneededMemory(childPolicySetNoRef);
            } catch (NotFoundException e) {
View Full Code Here

        List<XACMLObject> resultList = new LinkedList<XACMLObject>();

        List<PapContainer> papContainerList = new ArrayList<PapContainer>(PapContainer.getContainers(PapManager.getInstance()
                                                                                                               .getPublicPaps()));

        PolicySetType rootPolicySet = ServicesUtils.makeRootPolicySet();
        resultList.add(rootPolicySet);

        for (PapContainer papContainer : papContainerList) {

            List<XACMLObject> papXACMLObjectList = getPublic(papContainer);

            if (papXACMLObjectList.size() > 0) {
                PolicySetType papRootPolicySet = (PolicySetType) papXACMLObjectList.get(0);

                List<String> policySetIdList = PolicySetHelper.getPolicySetIdReferencesValues(papRootPolicySet);
                List<String> policyIdList = PolicySetHelper.getPolicyIdReferencesValues(papRootPolicySet);

                TypeStringUtils.releaseUnneededMemory(papRootPolicySet);
View Full Code Here

        if (bottom) {
            index = -1;
        }
       
        PolicySetType resource = papContainer.getPolicySet(resourceId);
       
        PolicySetHelper.addPolicyReference(resource, index, actionId);
       
        String version = resource.getVersion();
        PolicySetWizard.increaseVersion(resource);
       
        papContainer.updatePolicySet(version, resource);
       
        return actionId;
View Full Code Here

      policyWizard.releaseDOM();
    }

    policyArray = null;

    PolicySetType localRootPolicySet = policySetArray[0];

    for (String policySetId : PolicySetHelper
        .getPolicySetIdReferencesValues(localRootPolicySet)) {

      PolicySetType policySet = null;

      for (PolicySetType policySetElem : policySetArray) {
        if (policySetId.equals(policySetElem.getPolicySetId())) {
          policySet = policySetElem;
          break;
View Full Code Here

            throw new XACMLPolicyManagementServiceException("Forbidden operation for a remote PAP");
        }

        PapContainer papContainer = new PapContainer(pap);

        PolicySetType targetPolicySet = getTargetPolicySet(papContainer);

        if (targetPolicySet == null) {
            targetPolicySet = (new PolicySetWizard(resourceAttributeWizard)).getXACML();
        } else {
            updateOperationForPolicySet = true;
        }

        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);

        // Store the ban policy and the policy set in which it is contained
        // (only if needed)
        if (policySetNeedToBeSaved) {
            if (updateOperationForPolicySet) {
                String oldVersion = targetPolicySet.getVersion();
                PolicySetWizard.increaseVersion(targetPolicySet);
                papContainer.updatePolicySet(oldVersion, targetPolicySet);
            } else {
                papContainer.addPolicySet(0, targetPolicySet);
            }
View Full Code Here

    }

    private PolicySetType getTargetPolicySet(PapContainer papContainer) {

        // get the target policy set, it must be the very first policy set (if it exists)
        PolicySetType targetPolicySet = null;
        TargetWizard policySetTargetWizard = new TargetWizard(resourceAttributeWizard);

        PolicySetType papRootPolicySet = papContainer.getRootPolicySet();

        List<String> policySetIdList = PolicySetHelper.getPolicySetIdReferencesValues(papRootPolicySet);

        TypeStringUtils.releaseUnneededMemory(papRootPolicySet);

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

        PolicySetType candidatePolicySet = papContainer.getPolicySet(policySetIdList.get(0));

        if (policySetTargetWizard.isEquivalent(candidatePolicySet.getTarget())) {
            targetPolicySet = candidatePolicySet;
        }

        return targetPolicySet;
    }
View Full Code Here

    private void movePolicySet(PapContainer papContainer) {

        // now we have only two levels so... all the policy sets (resource <id>) are referenced by
        // the PAP
        // root policy set
        PolicySetType rootPAPPolicySet = papContainer.getRootPolicySet();

        if (!(PolicySetHelper.hasPolicySetReferenceId(rootPAPPolicySet, pivotId))) {
            throw new RepositoryException("Id not found or not a resource-id: " + pivotId);
        }

        if (!(PolicySetHelper.deletePolicySetReference(rootPAPPolicySet, id))) {
            throw new RepositoryException(String.format("Id \"%s\" not found into resource \"%s\"",
                                                        id,
                                                        rootPAPPolicySet.getPolicySetId()));
        }

        int pivotIndex = PolicySetHelper.getPolicySetIdReferenceIndex(rootPAPPolicySet, pivotId);

        if (moveAfter) {
            pivotIndex++;
        }
        log.debug("New position for PolicySet is: " + pivotIndex);

        PolicySetHelper.addPolicySetReference(rootPAPPolicySet, pivotIndex, id);

        String version = rootPAPPolicySet.getVersion();

        PolicySetWizard.increaseVersion(rootPAPPolicySet);

        papContainer.updatePolicySet(version, rootPAPPolicySet);
    }
View Full Code Here

TOP

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

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.