Java Code Examples for com.sun.xml.internal.ws.policy.sourcemodel.wspolicy.NamespaceVersion#getLatestVersion()

The following examples show how to use com.sun.xml.internal.ws.policy.sourcemodel.wspolicy.NamespaceVersion#getLatestVersion() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Policy.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor that should be overridden by child implementation. The constructor allows for easy toString() output
 * customization.
 *
 * @param toStringName a general name of the object (such as 'policy' or 'nested policy') that will be used in the
 * toString() method to identify the object.
 * @param sets represents the collection of policy alternatives of the policy object created. During the creation of
 * the new policy object, the content of the alternatives collection is copied into an internal policy object structure,
 * thus any subsequent operations on the collection will have no impact on the newly constructed policy object. The
 * collection may be {@code null} or empty. In such case a 'NULL' policy object is constructed.
 */
Policy(final String toStringName, final Collection<AssertionSet> sets) {
    this.nsVersion = NamespaceVersion.getLatestVersion();
    this.toStringName = toStringName;

    if (sets == null || sets.isEmpty()) {
        this.assertionSets = NULL_POLICY_ASSERTION_SETS;
        this.vocabulary = EMPTY_VOCABULARY;
        this.immutableVocabulary = EMPTY_VOCABULARY;
    } else {
        this.assertionSets = new LinkedList<AssertionSet>();
        this.vocabulary = new TreeSet<QName>(PolicyUtils.Comparison.QNAME_COMPARATOR);
        this.immutableVocabulary = Collections.unmodifiableCollection(this.vocabulary);

        addAll(sets);
    }
}
 
Example 2
Source File: Policy.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor that should be overridden by child implementation. The constructor allows for easy toString() output
 * customization.
 *
 * @param toStringName a general name of the object (such as 'policy' or 'nested policy') that will be used in the
 * toString() method to identify the object.
 * @param sets represents the collection of policy alternatives of the policy object created. During the creation of
 * the new policy object, the content of the alternatives collection is copied into an internal policy object structure,
 * thus any subsequent operations on the collection will have no impact on the newly constructed policy object. The
 * collection may be {@code null} or empty. In such case a 'NULL' policy object is constructed.
 */
Policy(final String toStringName, final Collection<AssertionSet> sets) {
    this.nsVersion = NamespaceVersion.getLatestVersion();
    this.toStringName = toStringName;

    if (sets == null || sets.isEmpty()) {
        this.assertionSets = NULL_POLICY_ASSERTION_SETS;
        this.vocabulary = EMPTY_VOCABULARY;
        this.immutableVocabulary = EMPTY_VOCABULARY;
    } else {
        this.assertionSets = new LinkedList<AssertionSet>();
        this.vocabulary = new TreeSet<QName>(PolicyUtils.Comparison.QNAME_COMPARATOR);
        this.immutableVocabulary = Collections.unmodifiableCollection(this.vocabulary);

        addAll(sets);
    }
}
 
Example 3
Source File: Policy.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor that should be overridden by child implementation. The constructor allows for easy toString() output
 * customization.
 *
 * @param toStringName a general name of the object (such as 'policy' or 'nested policy') that will be used in the
 * toString() method to identify the object.
 * @param sets represents the collection of policy alternatives of the policy object created. During the creation of
 * the new policy object, the content of the alternatives collection is copied into an internal policy object structure,
 * thus any subsequent operations on the collection will have no impact on the newly constructed policy object. The
 * collection may be {@code null} or empty. In such case a 'NULL' policy object is constructed.
 */
Policy(final String toStringName, final Collection<AssertionSet> sets) {
    this.nsVersion = NamespaceVersion.getLatestVersion();
    this.toStringName = toStringName;

    if (sets == null || sets.isEmpty()) {
        this.assertionSets = NULL_POLICY_ASSERTION_SETS;
        this.vocabulary = EMPTY_VOCABULARY;
        this.immutableVocabulary = EMPTY_VOCABULARY;
    } else {
        this.assertionSets = new LinkedList<AssertionSet>();
        this.vocabulary = new TreeSet<QName>(PolicyUtils.Comparison.QNAME_COMPARATOR);
        this.immutableVocabulary = Collections.unmodifiableCollection(this.vocabulary);

        addAll(sets);
    }
}
 
Example 4
Source File: Policy.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor that should be overridden by child implementation. The constructor allows for easy toString() output
 * customization.
 *
 * @param toStringName a general name of the object (such as 'policy' or 'nested policy') that will be used in the
 * toString() method to identify the object.
 * @param sets represents the collection of policy alternatives of the policy object created. During the creation of
 * the new policy object, the content of the alternatives collection is copied into an internal policy object structure,
 * thus any subsequent operations on the collection will have no impact on the newly constructed policy object. The
 * collection may be {@code null} or empty. In such case a 'NULL' policy object is constructed.
 */
Policy(final String toStringName, final Collection<AssertionSet> sets) {
    this.nsVersion = NamespaceVersion.getLatestVersion();
    this.toStringName = toStringName;

    if (sets == null || sets.isEmpty()) {
        this.assertionSets = NULL_POLICY_ASSERTION_SETS;
        this.vocabulary = EMPTY_VOCABULARY;
        this.immutableVocabulary = EMPTY_VOCABULARY;
    } else {
        this.assertionSets = new LinkedList<AssertionSet>();
        this.vocabulary = new TreeSet<QName>(PolicyUtils.Comparison.QNAME_COMPARATOR);
        this.immutableVocabulary = Collections.unmodifiableCollection(this.vocabulary);

        addAll(sets);
    }
}
 
Example 5
Source File: PolicyIntersector.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Performs intersection on the input collection of policies and returns the resulting (intersected) policy. If input policy
 * collection contains only a single policy instance, no intersection is performed and the instance is directly returned
 * as a method call result.
 *
 * @param policies collection of policies to be intersected. Must not be {@code null} nor empty, otherwise exception is thrown.
 * @return intersected policy as a result of perfromed policy intersection. A {@code null} value is never returned.
 *
 * @throws IllegalArgumentException in case {@code policies} argument is either {@code null} or empty collection.
 */
public Policy intersect(final Policy... policies) {
    if (policies == null || policies.length == 0) {
        throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0056_NEITHER_NULL_NOR_EMPTY_POLICY_COLLECTION_EXPECTED()));
    } else if (policies.length == 1) {
        return policies[0];
    }

    // check for "null" and "empty" policy: if such policy is found return "null" policy,
    // or if all policies are "empty", return "empty" policy
    boolean found = false;
    boolean allPoliciesEmpty = true;
    NamespaceVersion latestVersion = null;
    for (Policy tested : policies) {
        if (tested.isEmpty()) {
            found = true;
        } else {
            if (tested.isNull()) {
                found = true;
            }
            allPoliciesEmpty = false;
        }
        if (latestVersion == null) {
            latestVersion = tested.getNamespaceVersion();
        } else if (latestVersion.compareTo(tested.getNamespaceVersion()) < 0) {
            latestVersion = tested.getNamespaceVersion();
        }

        if (found && !allPoliciesEmpty) {
            return Policy.createNullPolicy(latestVersion, null, null);
        }
    }
    latestVersion = (latestVersion != null) ? latestVersion : NamespaceVersion.getLatestVersion();
    if (allPoliciesEmpty) {
        return Policy.createEmptyPolicy(latestVersion, null, null);
    }

    // simple tests didn't lead to final answer => let's performe some intersecting ;)
    final List<AssertionSet> finalAlternatives = new LinkedList<AssertionSet>(policies[0].getContent());
    final Queue<AssertionSet> testedAlternatives = new LinkedList<AssertionSet>();
    final List<AssertionSet> alternativesToMerge = new ArrayList<AssertionSet>(2);
    for (int i = 1; i < policies.length; i++) {
        final Collection<AssertionSet> currentAlternatives = policies[i].getContent();

        testedAlternatives.clear();
        testedAlternatives.addAll(finalAlternatives);
        finalAlternatives.clear();

        AssertionSet testedAlternative;
        while ((testedAlternative = testedAlternatives.poll()) != null) {
            for (AssertionSet currentAlternative : currentAlternatives) {
                if (testedAlternative.isCompatibleWith(currentAlternative, this.mode)) {
                    alternativesToMerge.add(testedAlternative);
                    alternativesToMerge.add(currentAlternative);
                    finalAlternatives.add(AssertionSet.createMergedAssertionSet(alternativesToMerge));
                    alternativesToMerge.clear();
                }
            }
        }
    }

    return Policy.createPolicy(latestVersion, null, null, finalAlternatives);
}
 
Example 6
Source File: PolicyIntersector.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Performs intersection on the input collection of policies and returns the resulting (intersected) policy. If input policy
 * collection contains only a single policy instance, no intersection is performed and the instance is directly returned
 * as a method call result.
 *
 * @param policies collection of policies to be intersected. Must not be {@code null} nor empty, otherwise exception is thrown.
 * @return intersected policy as a result of perfromed policy intersection. A {@code null} value is never returned.
 *
 * @throws IllegalArgumentException in case {@code policies} argument is either {@code null} or empty collection.
 */
public Policy intersect(final Policy... policies) {
    if (policies == null || policies.length == 0) {
        throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0056_NEITHER_NULL_NOR_EMPTY_POLICY_COLLECTION_EXPECTED()));
    } else if (policies.length == 1) {
        return policies[0];
    }

    // check for "null" and "empty" policy: if such policy is found return "null" policy,
    // or if all policies are "empty", return "empty" policy
    boolean found = false;
    boolean allPoliciesEmpty = true;
    NamespaceVersion latestVersion = null;
    for (Policy tested : policies) {
        if (tested.isEmpty()) {
            found = true;
        } else {
            if (tested.isNull()) {
                found = true;
            }
            allPoliciesEmpty = false;
        }
        if (latestVersion == null) {
            latestVersion = tested.getNamespaceVersion();
        } else if (latestVersion.compareTo(tested.getNamespaceVersion()) < 0) {
            latestVersion = tested.getNamespaceVersion();
        }

        if (found && !allPoliciesEmpty) {
            return Policy.createNullPolicy(latestVersion, null, null);
        }
    }
    latestVersion = (latestVersion != null) ? latestVersion : NamespaceVersion.getLatestVersion();
    if (allPoliciesEmpty) {
        return Policy.createEmptyPolicy(latestVersion, null, null);
    }

    // simple tests didn't lead to final answer => let's performe some intersecting ;)
    final List<AssertionSet> finalAlternatives = new LinkedList<AssertionSet>(policies[0].getContent());
    final Queue<AssertionSet> testedAlternatives = new LinkedList<AssertionSet>();
    final List<AssertionSet> alternativesToMerge = new ArrayList<AssertionSet>(2);
    for (int i = 1; i < policies.length; i++) {
        final Collection<AssertionSet> currentAlternatives = policies[i].getContent();

        testedAlternatives.clear();
        testedAlternatives.addAll(finalAlternatives);
        finalAlternatives.clear();

        AssertionSet testedAlternative;
        while ((testedAlternative = testedAlternatives.poll()) != null) {
            for (AssertionSet currentAlternative : currentAlternatives) {
                if (testedAlternative.isCompatibleWith(currentAlternative, this.mode)) {
                    alternativesToMerge.add(testedAlternative);
                    alternativesToMerge.add(currentAlternative);
                    finalAlternatives.add(AssertionSet.createMergedAssertionSet(alternativesToMerge));
                    alternativesToMerge.clear();
                }
            }
        }
    }

    return Policy.createPolicy(latestVersion, null, null, finalAlternatives);
}
 
Example 7
Source File: PolicyIntersector.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Performs intersection on the input collection of policies and returns the resulting (intersected) policy. If input policy
 * collection contains only a single policy instance, no intersection is performed and the instance is directly returned
 * as a method call result.
 *
 * @param policies collection of policies to be intersected. Must not be {@code null} nor empty, otherwise exception is thrown.
 * @return intersected policy as a result of perfromed policy intersection. A {@code null} value is never returned.
 *
 * @throws IllegalArgumentException in case {@code policies} argument is either {@code null} or empty collection.
 */
public Policy intersect(final Policy... policies) {
    if (policies == null || policies.length == 0) {
        throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0056_NEITHER_NULL_NOR_EMPTY_POLICY_COLLECTION_EXPECTED()));
    } else if (policies.length == 1) {
        return policies[0];
    }

    // check for "null" and "empty" policy: if such policy is found return "null" policy,
    // or if all policies are "empty", return "empty" policy
    boolean found = false;
    boolean allPoliciesEmpty = true;
    NamespaceVersion latestVersion = null;
    for (Policy tested : policies) {
        if (tested.isEmpty()) {
            found = true;
        } else {
            if (tested.isNull()) {
                found = true;
            }
            allPoliciesEmpty = false;
        }
        if (latestVersion == null) {
            latestVersion = tested.getNamespaceVersion();
        } else if (latestVersion.compareTo(tested.getNamespaceVersion()) < 0) {
            latestVersion = tested.getNamespaceVersion();
        }

        if (found && !allPoliciesEmpty) {
            return Policy.createNullPolicy(latestVersion, null, null);
        }
    }
    latestVersion = (latestVersion != null) ? latestVersion : NamespaceVersion.getLatestVersion();
    if (allPoliciesEmpty) {
        return Policy.createEmptyPolicy(latestVersion, null, null);
    }

    // simple tests didn't lead to final answer => let's performe some intersecting ;)
    final List<AssertionSet> finalAlternatives = new LinkedList<AssertionSet>(policies[0].getContent());
    final Queue<AssertionSet> testedAlternatives = new LinkedList<AssertionSet>();
    final List<AssertionSet> alternativesToMerge = new ArrayList<AssertionSet>(2);
    for (int i = 1; i < policies.length; i++) {
        final Collection<AssertionSet> currentAlternatives = policies[i].getContent();

        testedAlternatives.clear();
        testedAlternatives.addAll(finalAlternatives);
        finalAlternatives.clear();

        AssertionSet testedAlternative;
        while ((testedAlternative = testedAlternatives.poll()) != null) {
            for (AssertionSet currentAlternative : currentAlternatives) {
                if (testedAlternative.isCompatibleWith(currentAlternative, this.mode)) {
                    alternativesToMerge.add(testedAlternative);
                    alternativesToMerge.add(currentAlternative);
                    finalAlternatives.add(AssertionSet.createMergedAssertionSet(alternativesToMerge));
                    alternativesToMerge.clear();
                }
            }
        }
    }

    return Policy.createPolicy(latestVersion, null, null, finalAlternatives);
}
 
Example 8
Source File: Policy.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * The factory method creates an <b>immutable</b> policy instance which represents a <emph>'anything allowed'</emph>
 * policy expression. The policy is created using the latest namespace version supported.
 *
 * @param nsVersion Policy namespace version to be used when marshalling the policy expression
 * @param name global URI of the policy. May be {@code null}.
 * @param policyId local URI of the policy. May be {@code null}.
 *
 * @return policy instance which represents a <emph>'anything allowed'</emph> (empty policy alternative with no plicy
 * assertions prescribed).
 */
public static Policy createEmptyPolicy(final NamespaceVersion nsVersion, final String name, final String policyId) {
    if ((nsVersion == null || nsVersion == NamespaceVersion.getLatestVersion()) && name == null && policyId == null) {
        return ANONYMOUS_EMPTY_POLICY;
    } else {
        return new Policy(nsVersion, name, policyId, EMPTY_POLICY_ASSERTION_SETS, EMPTY_VOCABULARY);
    }
}
 
Example 9
Source File: Policy.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * A most flexible policy object constructor that allows private creation of policy objects and direct setting
 * of all its attributes.
 *
 * @param name global URI of the policy. May be {@code null}.
 * @param policyId local URI of the policy. May be {@code null}.
 * @param assertionSets represents the collection of policy alternatives of the policy object created. The list is directly
 * assigned to the policy object internal attribute. Subsequent manipulations on the collection must be handled with
 * care.
 * @param vocabulary represents the vocabulary of the policy object. Subsequent manipulations on the collection
 * must be handled with care.
 */
private Policy(final String name, final String policyId, final List<AssertionSet> assertionSets, final Set<QName> vocabulary) {
    this.nsVersion = NamespaceVersion.getLatestVersion();
    this.toStringName = POLICY_TOSTRING_NAME;
    this.name = name;
    this.policyId = policyId;
    this.assertionSets = assertionSets;
    this.vocabulary = vocabulary;
    this.immutableVocabulary = Collections.unmodifiableCollection(this.vocabulary);
}
 
Example 10
Source File: Policy.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * The factory method creates an <b>immutable</b> policy instance which represents a <emph>'anything allowed'</emph>
 * policy expression. The policy is created using the latest namespace version supported.
 *
 * @param nsVersion Policy namespace version to be used when marshalling the policy expression
 * @param name global URI of the policy. May be {@code null}.
 * @param policyId local URI of the policy. May be {@code null}.
 *
 * @return policy instance which represents a <emph>'anything allowed'</emph> (empty policy alternative with no plicy
 * assertions prescribed).
 */
public static Policy createEmptyPolicy(final NamespaceVersion nsVersion, final String name, final String policyId) {
    if ((nsVersion == null || nsVersion == NamespaceVersion.getLatestVersion()) && name == null && policyId == null) {
        return ANONYMOUS_EMPTY_POLICY;
    } else {
        return new Policy(nsVersion, name, policyId, EMPTY_POLICY_ASSERTION_SETS, EMPTY_VOCABULARY);
    }
}
 
Example 11
Source File: Policy.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * The factory method creates an <b>immutable</b> policy instance which represents a <emph>'anything allowed'</emph>
 * policy expression. The policy is created using the latest namespace version supported.
 *
 * @param nsVersion Policy namespace version to be used when marshalling the policy expression
 * @param name global URI of the policy. May be {@code null}.
 * @param policyId local URI of the policy. May be {@code null}.
 *
 * @return policy instance which represents a <emph>'anything allowed'</emph> (empty policy alternative with no plicy
 * assertions prescribed).
 */
public static Policy createEmptyPolicy(final NamespaceVersion nsVersion, final String name, final String policyId) {
    if ((nsVersion == null || nsVersion == NamespaceVersion.getLatestVersion()) && name == null && policyId == null) {
        return ANONYMOUS_EMPTY_POLICY;
    } else {
        return new Policy(nsVersion, name, policyId, EMPTY_POLICY_ASSERTION_SETS, EMPTY_VOCABULARY);
    }
}
 
Example 12
Source File: Policy.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * A most flexible policy object constructor that allows private creation of policy objects and direct setting
 * of all its attributes.
 *
 * @param name global URI of the policy. May be {@code null}.
 * @param policyId local URI of the policy. May be {@code null}.
 * @param assertionSets represents the collection of policy alternatives of the policy object created. The list is directly
 * assigned to the policy object internal attribute. Subsequent manipulations on the collection must be handled with
 * care.
 * @param vocabulary represents the vocabulary of the policy object. Subsequent manipulations on the collection
 * must be handled with care.
 */
private Policy(final String name, final String policyId, final List<AssertionSet> assertionSets, final Set<QName> vocabulary) {
    this.nsVersion = NamespaceVersion.getLatestVersion();
    this.toStringName = POLICY_TOSTRING_NAME;
    this.name = name;
    this.policyId = policyId;
    this.assertionSets = assertionSets;
    this.vocabulary = vocabulary;
    this.immutableVocabulary = Collections.unmodifiableCollection(this.vocabulary);
}
 
Example 13
Source File: Policy.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * A most flexible policy object constructor that allows private creation of policy objects and direct setting
 * of all its attributes.
 *
 * @param name global URI of the policy. May be {@code null}.
 * @param policyId local URI of the policy. May be {@code null}.
 * @param assertionSets represents the collection of policy alternatives of the policy object created. The list is directly
 * assigned to the policy object internal attribute. Subsequent manipulations on the collection must be handled with
 * care.
 * @param vocabulary represents the vocabulary of the policy object. Subsequent manipulations on the collection
 * must be handled with care.
 */
private Policy(final String name, final String policyId, final List<AssertionSet> assertionSets, final Set<QName> vocabulary) {
    this.nsVersion = NamespaceVersion.getLatestVersion();
    this.toStringName = POLICY_TOSTRING_NAME;
    this.name = name;
    this.policyId = policyId;
    this.assertionSets = assertionSets;
    this.vocabulary = vocabulary;
    this.immutableVocabulary = Collections.unmodifiableCollection(this.vocabulary);
}
 
Example 14
Source File: Policy.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * The factory method creates an <b>immutable</b> policy instance which represents a <emph>'nothing allowed'</emph>
 * policy expression. The policy is created using the latest namespace version supported.
 *
 * @param nsVersion Policy namespace version to be used when marshalling the policy expression
 * @param name global URI of the policy. May be {@code null}.
 * @param policyId local URI of the policy. May be {@code null}.
 * @return policy instance which represents a <emph>'nothing allowed'</emph> (no policy alternatives).
 */
public static Policy createNullPolicy(final NamespaceVersion nsVersion, final String name, final String policyId) {
    if ((nsVersion == null || nsVersion == NamespaceVersion.getLatestVersion()) && name == null && policyId == null) {
        return ANONYMOUS_NULL_POLICY;
    } else {
        return new Policy(nsVersion, name, policyId, NULL_POLICY_ASSERTION_SETS, EMPTY_VOCABULARY);
    }
}
 
Example 15
Source File: Policy.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * A most flexible policy object constructor that allows private creation of policy objects and direct setting
 * of all its attributes.
 *
 * @param name global URI of the policy. May be {@code null}.
 * @param policyId local URI of the policy. May be {@code null}.
 * @param assertionSets represents the collection of policy alternatives of the policy object created. The list is directly
 * assigned to the policy object internal attribute. Subsequent manipulations on the collection must be handled with
 * care.
 * @param vocabulary represents the vocabulary of the policy object. Subsequent manipulations on the collection
 * must be handled with care.
 */
private Policy(final String name, final String policyId, final List<AssertionSet> assertionSets, final Set<QName> vocabulary) {
    this.nsVersion = NamespaceVersion.getLatestVersion();
    this.toStringName = POLICY_TOSTRING_NAME;
    this.name = name;
    this.policyId = policyId;
    this.assertionSets = assertionSets;
    this.vocabulary = vocabulary;
    this.immutableVocabulary = Collections.unmodifiableCollection(this.vocabulary);
}
 
Example 16
Source File: Policy.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * A most flexible policy object constructor that allows private creation of policy objects and direct setting
 * of all its attributes.
 *
 * @param name global URI of the policy. May be {@code null}.
 * @param policyId local URI of the policy. May be {@code null}.
 * @param assertionSets represents the collection of policy alternatives of the policy object created. The list is directly
 * assigned to the policy object internal attribute. Subsequent manipulations on the collection must be handled with
 * care.
 * @param vocabulary represents the vocabulary of the policy object. Subsequent manipulations on the collection
 * must be handled with care.
 */
private Policy(final String name, final String policyId, final List<AssertionSet> assertionSets, final Set<QName> vocabulary) {
    this.nsVersion = NamespaceVersion.getLatestVersion();
    this.toStringName = POLICY_TOSTRING_NAME;
    this.name = name;
    this.policyId = policyId;
    this.assertionSets = assertionSets;
    this.vocabulary = vocabulary;
    this.immutableVocabulary = Collections.unmodifiableCollection(this.vocabulary);
}
 
Example 17
Source File: Policy.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * The factory method creates an <b>immutable</b> policy instance which represents a <emph>'nothing allowed'</emph>
 * policy expression. The policy is created using the latest namespace version supported.
 *
 * @param nsVersion Policy namespace version to be used when marshalling the policy expression
 * @param name global URI of the policy. May be {@code null}.
 * @param policyId local URI of the policy. May be {@code null}.
 * @return policy instance which represents a <emph>'nothing allowed'</emph> (no policy alternatives).
 */
public static Policy createNullPolicy(final NamespaceVersion nsVersion, final String name, final String policyId) {
    if ((nsVersion == null || nsVersion == NamespaceVersion.getLatestVersion()) && name == null && policyId == null) {
        return ANONYMOUS_NULL_POLICY;
    } else {
        return new Policy(nsVersion, name, policyId, NULL_POLICY_ASSERTION_SETS, EMPTY_VOCABULARY);
    }
}
 
Example 18
Source File: Policy.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * The factory method creates an <b>immutable</b> policy instance which represents a <emph>'anything allowed'</emph>
 * policy expression. The policy is created using the latest namespace version supported.
 *
 * @param nsVersion Policy namespace version to be used when marshalling the policy expression
 * @param name global URI of the policy. May be {@code null}.
 * @param policyId local URI of the policy. May be {@code null}.
 *
 * @return policy instance which represents a <emph>'anything allowed'</emph> (empty policy alternative with no plicy
 * assertions prescribed).
 */
public static Policy createEmptyPolicy(final NamespaceVersion nsVersion, final String name, final String policyId) {
    if ((nsVersion == null || nsVersion == NamespaceVersion.getLatestVersion()) && name == null && policyId == null) {
        return ANONYMOUS_EMPTY_POLICY;
    } else {
        return new Policy(nsVersion, name, policyId, EMPTY_POLICY_ASSERTION_SETS, EMPTY_VOCABULARY);
    }
}
 
Example 19
Source File: Policy.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * The factory method creates an <b>immutable</b> policy instance which represents a <emph>'nothing allowed'</emph>
 * policy expression. The policy is created using the latest namespace version supported.
 *
 * @param nsVersion Policy namespace version to be used when marshalling the policy expression
 * @param name global URI of the policy. May be {@code null}.
 * @param policyId local URI of the policy. May be {@code null}.
 * @return policy instance which represents a <emph>'nothing allowed'</emph> (no policy alternatives).
 */
public static Policy createNullPolicy(final NamespaceVersion nsVersion, final String name, final String policyId) {
    if ((nsVersion == null || nsVersion == NamespaceVersion.getLatestVersion()) && name == null && policyId == null) {
        return ANONYMOUS_NULL_POLICY;
    } else {
        return new Policy(nsVersion, name, policyId, NULL_POLICY_ASSERTION_SETS, EMPTY_VOCABULARY);
    }
}
 
Example 20
Source File: Policy.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * The factory method creates an <b>immutable</b> policy instance which represents a <emph>'anything allowed'</emph>
 * policy expression. The policy is created using the latest namespace version supported.
 *
 * @param nsVersion Policy namespace version to be used when marshalling the policy expression
 * @param name global URI of the policy. May be {@code null}.
 * @param policyId local URI of the policy. May be {@code null}.
 *
 * @return policy instance which represents a <emph>'anything allowed'</emph> (empty policy alternative with no plicy
 * assertions prescribed).
 */
public static Policy createEmptyPolicy(final NamespaceVersion nsVersion, final String name, final String policyId) {
    if ((nsVersion == null || nsVersion == NamespaceVersion.getLatestVersion()) && name == null && policyId == null) {
        return ANONYMOUS_EMPTY_POLICY;
    } else {
        return new Policy(nsVersion, name, policyId, EMPTY_POLICY_ASSERTION_SETS, EMPTY_VOCABULARY);
    }
}