Class Policy

java.lang.Object
com.sun.xml.ws.policy.Policy
All Implemented Interfaces:
Iterable<AssertionSet>
Direct Known Subclasses:
NestedPolicy

public class Policy extends Object implements Iterable<AssertionSet>
A policy represents normalized policy as a wrapper of available policy alternatives represented by child AssertionSets.
Author:
Fabian Ritzmann, Marek Potociar
  • Method Details

    • createNullPolicy

      public static Policy createNullPolicy()
      The factory method creates an immutable policy instance which represents a 'nothing allowed' policy expression. The policy is created using the latest namespace version supported.
      Returns:
      policy instance which represents a 'nothing allowed' (no policy alternatives).
    • createEmptyPolicy

      public static Policy createEmptyPolicy()
      The factory method creates an immutable policy instance which represents a 'anything allowed' policy expression. The policy is created using the latest namespace version supported.
      Returns:
      policy instance which represents a 'anything allowed' (empty policy alternative with no plicy assertions prescribed).
    • createNullPolicy

      public static Policy createNullPolicy(String name, String policyId)
      The factory method creates an immutable policy instance which represents a 'nothing allowed' policy expression. The policy is created using the latest namespace version supported.
      Parameters:
      name - global URI of the policy. May be null.
      policyId - local URI of the policy. May be null.
      Returns:
      policy instance which represents a 'nothing allowed' (no policy alternatives).
    • createNullPolicy

      public static Policy createNullPolicy(NamespaceVersion nsVersion, String name, String policyId)
      The factory method creates an immutable policy instance which represents a 'nothing allowed' policy expression. The policy is created using the latest namespace version supported.
      Parameters:
      nsVersion - Policy namespace version to be used when marshalling the policy expression
      name - global URI of the policy. May be null.
      policyId - local URI of the policy. May be null.
      Returns:
      policy instance which represents a 'nothing allowed' (no policy alternatives).
    • createEmptyPolicy

      public static Policy createEmptyPolicy(String name, String policyId)
      The factory method creates an immutable policy instance which represents a 'anything allowed' policy expression. The policy is created using the latest namespace version supported.
      Parameters:
      name - global URI of the policy. May be null.
      policyId - local URI of the policy. May be null.
      Returns:
      policy instance which represents a 'anything allowed' (empty policy alternative with no plicy assertions prescribed).
    • createEmptyPolicy

      public static Policy createEmptyPolicy(NamespaceVersion nsVersion, String name, String policyId)
      The factory method creates an immutable policy instance which represents a 'anything allowed' policy expression. The policy is created using the latest namespace version supported.
      Parameters:
      nsVersion - Policy namespace version to be used when marshalling the policy expression
      name - global URI of the policy. May be null.
      policyId - local URI of the policy. May be null.
      Returns:
      policy instance which represents a 'anything allowed' (empty policy alternative with no plicy assertions prescribed).
    • createPolicy

      public static Policy createPolicy(Collection<AssertionSet> sets)
      The factory method creates an immutable policy instance which represents a policy expression with alternatives specified by sets input parameter. If the collection of policy alternatives is null or empty an object representing a 'NULL' policy expression is returned. However, in such case it is better to use createNullPolicy() factory method directly. The policy is created using the latest namespace version supported.
      Parameters:
      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.
      Returns:
      policy instance which represents the policy with given alternatives.
    • createPolicy

      public static Policy createPolicy(String name, String policyId, Collection<AssertionSet> sets)
      The factory method creates an immutable policy instance which represents a policy expression with alternatives specified by sets input parameter. If the collection of policy alternatives is null or empty an object representing a 'NULL' policy expression is returned. However, in such case it is better to use createNullPolicy(String, String) factory method directly. The policy is created using the latest namespace version supported.
      Parameters:
      name - global URI of the policy. May be null.
      policyId - local URI of the policy. May be null.
      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.
      Returns:
      policy instance which represents the policy with given alternatives.
    • createPolicy

      public static Policy createPolicy(NamespaceVersion nsVersion, String name, String policyId, Collection<AssertionSet> sets)
      The factory method creates an immutable policy instance which represents a policy expression with alternatives specified by sets input parameter. If the collection of policy alternatives is null or empty an object representing a 'NULL' policy expression is returned. However, in such case it is better to use createNullPolicy(String, String) factory method directly. The policy is created using the latest namespace version supported.
      Parameters:
      nsVersion - Policy namespace version to be used when marshalling the policy expression
      name - global URI of the policy. May be null.
      policyId - local URI of the policy. May be null.
      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.
      Returns:
      policy instance which represents the policy with given alternatives.
    • getId

      public String getId()
      Returns the policy identifier that serves as a local relative policy URI.
      Returns:
      policy identifier - a local relative policy URI. If no policy identifier is set, returns null.
    • getName

      public String getName()
      Returns the policy name that serves as a global policy URI.
      Returns:
      policy name - a global policy URI. If no policy name is set, returns null.
    • getNamespaceVersion

      public NamespaceVersion getNamespaceVersion()
    • getIdOrName

      public String getIdOrName()
      Returns the policy ID or if that is null the policy name. May return null if both attributes are null.
      Returns:
      The policy ID if it was set, or the name or null if no attribute was set.
      See Also:
    • getNumberOfAssertionSets

      public int getNumberOfAssertionSets()
      Method returns how many policy alternatives this policy instance contains.
      Returns:
      number of policy alternatives contained in this policy instance
    • iterator

      public Iterator<AssertionSet> iterator()
      A policy usually contains one or more assertion sets. Each assertion set corresponds to a policy alternative as defined by WS-Policy.
      Specified by:
      iterator in interface Iterable<AssertionSet>
      Returns:
      An iterator to iterate through all contained assertion sets
    • isNull

      public boolean isNull()
      Returns true if the policy instance represents "nothing allowed" policy expression
      Returns:
      true if the policy instance represents "nothing allowed" policy expression, false otherwise.
    • isEmpty

      public boolean isEmpty()
      Returns true if the policy instance represents "anything allowed" policy expression
      Returns:
      true if the policy instance represents "anything allowed" policy expression, false otherwise.
    • contains

      public boolean contains(String namespaceUri)
      Returns true if the policy contains the assertion names with specified namespace in its vocabulary
      Parameters:
      namespaceUri - the assertion namespace URI (identifying assertion domain)
      Returns:
      true, if an assertion with the given name could be found in the policy vocabulary false otherwise.
    • getVocabulary

      public Collection<QName> getVocabulary()
      Retrieves the vocabulary of this policy expression. The vocabulary is represented by an immutable collection of unique QName objects. Each of those objects represents single assertion type contained in the policy.
      Returns:
      immutable collection of assertion types contained in the policy (a policy vocabulary).
    • contains

      public boolean contains(QName assertionName)
      Determines if the policy instance contains the assertion with the name specified in its vocabulary.
      Parameters:
      assertionName - the name of the assertion to be tested.
      Returns:
      true if the assertion with the specified name is part of the policy instance's vocabulary, false otherwise.
    • equals

      public boolean equals(Object obj)
      An Object.equals(Object obj) method override.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      An Object.hashCode() method override.
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      An Object.toString() method override.
      Overrides:
      toString in class Object