Package com.sun.xml.ws.policy
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 childAssertionSets.- Author:
- Fabian Ritzmann, Marek Potociar
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(String namespaceUri)Returns true if the policy contains the assertion names with specified namespace in its vocabularybooleancontains(QName assertionName)Determines if the policy instance contains the assertion with the name specified in its vocabulary.static PolicycreateEmptyPolicy()The factory method creates an immutable policy instance which represents a 'anything allowed' policy expression.static PolicycreateEmptyPolicy(NamespaceVersion nsVersion, String name, String policyId)The factory method creates an immutable policy instance which represents a 'anything allowed' policy expression.static PolicycreateEmptyPolicy(String name, String policyId)The factory method creates an immutable policy instance which represents a 'anything allowed' policy expression.static PolicycreateNullPolicy()The factory method creates an immutable policy instance which represents a 'nothing allowed' policy expression.static PolicycreateNullPolicy(NamespaceVersion nsVersion, String name, String policyId)The factory method creates an immutable policy instance which represents a 'nothing allowed' policy expression.static PolicycreateNullPolicy(String name, String policyId)The factory method creates an immutable policy instance which represents a 'nothing allowed' policy expression.static PolicycreatePolicy(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 bysetsinput parameter.static PolicycreatePolicy(String name, String policyId, Collection<AssertionSet> sets)The factory method creates an immutable policy instance which represents a policy expression with alternatives specified bysetsinput parameter.static PolicycreatePolicy(Collection<AssertionSet> sets)The factory method creates an immutable policy instance which represents a policy expression with alternatives specified bysetsinput parameter.booleanequals(Object obj)AnObject.equals(Object obj)method override.StringgetId()Returns the policy identifier that serves as a local relative policy URI.StringgetIdOrName()Returns the policy ID or if that is null the policy name.StringgetName()Returns the policy name that serves as a global policy URI.NamespaceVersiongetNamespaceVersion()intgetNumberOfAssertionSets()Method returns how many policy alternatives this policy instance contains.Collection<QName>getVocabulary()Retrieves the vocabulary of this policy expression.inthashCode()AnObject.hashCode()method override.booleanisEmpty()Returnstrueif the policy instance represents "anything allowed" policy expressionbooleanisNull()Returnstrueif the policy instance represents "nothing allowed" policy expressionIterator<AssertionSet>iterator()A policy usually contains one or more assertion sets.StringtoString()AnObject.toString()method override.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
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 benull.policyId- local URI of the policy. May benull.- 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 expressionname- global URI of the policy. May benull.policyId- local URI of the policy. May benull.- 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 benull.policyId- local URI of the policy. May benull.- 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 expressionname- global URI of the policy. May benull.policyId- local URI of the policy. May benull.- 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 bysetsinput 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 usecreateNullPolicy()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 bysetsinput 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 usecreateNullPolicy(String, String)factory method directly. The policy is created using the latest namespace version supported.- Parameters:
name- global URI of the policy. May benull.policyId- local URI of the policy. May benull.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 bysetsinput 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 usecreateNullPolicy(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 expressionname- global URI of the policy. May benull.policyId- local URI of the policy. May benull.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.
-
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:
iteratorin interfaceIterable<AssertionSet>- Returns:
- An iterator to iterate through all contained assertion sets
-
isNull
public boolean isNull()
Returnstrueif the policy instance represents "nothing allowed" policy expression- Returns:
trueif the policy instance represents "nothing allowed" policy expression,falseotherwise.
-
isEmpty
public boolean isEmpty()
Returnstrueif the policy instance represents "anything allowed" policy expression- Returns:
trueif the policy instance represents "anything allowed" policy expression,falseotherwise.
-
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 vocabularyfalseotherwise.
-
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:
trueif the assertion with the specified name is part of the policy instance's vocabulary,falseotherwise.
-
equals
public boolean equals(Object obj)
AnObject.equals(Object obj)method override.
-
hashCode
public int hashCode()
AnObject.hashCode()method override.
-
-