public class Policy extends java.lang.Object implements java.lang.Iterable<AssertionSet>
AssertionSets.| Modifier and Type | Field and Description |
|---|---|
private static Policy |
ANONYMOUS_EMPTY_POLICY
Constant representation of all 'EMPTY' policies returned by createEmptyPolicy() factory method.
|
private static Policy |
ANONYMOUS_NULL_POLICY
Constant representation of all 'NULL' policies returned by createNullPolicy() factory method.
|
private java.util.List<AssertionSet> |
assertionSets
internal collection of policy alternatives
|
private static java.util.List<AssertionSet> |
EMPTY_POLICY_ASSERTION_SETS
Constant represents list of assertion sets with single empty assertion set.
|
private static java.util.Set<javax.xml.namespace.QName> |
EMPTY_VOCABULARY
Constant represents empty vocabulary of a 'NULL' or 'EMPTY' policies.
|
private java.util.Collection<javax.xml.namespace.QName> |
immutableVocabulary
immutable version of policy vocabulary that is made available to clients via getter method
|
private java.lang.String |
name
Policy name holder
|
private NamespaceVersion |
nsVersion
Namespace version holder
|
private static java.util.List<AssertionSet> |
NULL_POLICY_ASSERTION_SETS
Constant represents empty list of assertion sets.
|
private static java.lang.String |
POLICY_TOSTRING_NAME
A string constant used in package private constructor to customize the object's toString() method output.
|
private java.lang.String |
policyId
Policy ID holder
|
private java.lang.String |
toStringName
policy object name used in a toString() method.
|
private java.util.Set<javax.xml.namespace.QName> |
vocabulary
internal collection of policy vocabulary entries (qualified names of all assertion types present in the policy expression)
|
| Modifier | Constructor and Description |
|---|---|
(package private) |
Policy(NamespaceVersion nsVersion,
java.lang.String toStringName,
java.util.Collection<AssertionSet> sets)
Constructor that should be overridden by child implementation.
|
private |
Policy(NamespaceVersion nsVersion,
java.lang.String name,
java.lang.String policyId,
java.util.List<AssertionSet> assertionSets,
java.util.Set<javax.xml.namespace.QName> vocabulary)
A most flexible policy object constructor that allows private creation of policy objects and direct setting
of all its attributes.
|
(package private) |
Policy(NamespaceVersion nsVersion,
java.lang.String toStringName,
java.lang.String name,
java.lang.String policyId,
java.util.Collection<AssertionSet> sets)
Constructor that should be overridden by child implementation.
|
(package private) |
Policy(java.lang.String toStringName,
java.util.Collection<AssertionSet> sets)
Constructor that should be overridden by child implementation.
|
private |
Policy(java.lang.String name,
java.lang.String policyId,
java.util.List<AssertionSet> assertionSets,
java.util.Set<javax.xml.namespace.QName> vocabulary)
A most flexible policy object constructor that allows private creation of policy objects and direct setting
of all its attributes.
|
(package private) |
Policy(java.lang.String toStringName,
java.lang.String name,
java.lang.String policyId,
java.util.Collection<AssertionSet> sets)
Constructor that should be overridden by child implementation.
|
| Modifier and Type | Method and Description |
|---|---|
private boolean |
add(AssertionSet set)
Adds single alternative to the internal alternatives set of the policy object.
|
private boolean |
addAll(java.util.Collection<AssertionSet> sets)
Adds all alternatives from the input collection of assertion sets to the policy object's internal set of alternatives.
|
boolean |
contains(javax.xml.namespace.QName assertionName)
Determines if the policy instance contains the assertion with the name specified in its vocabulary.
|
boolean |
contains(java.lang.String namespaceUri)
Returns true if the policy contains the assertion names with specified namespace in its vocabulary
|
static Policy |
createEmptyPolicy()
The factory method creates an immutable policy instance which represents a
|
static Policy |
createEmptyPolicy(NamespaceVersion nsVersion,
java.lang.String name,
java.lang.String policyId)
The factory method creates an immutable policy instance which represents a
|
static Policy |
createEmptyPolicy(java.lang.String name,
java.lang.String policyId)
The factory method creates an immutable policy instance which represents a
|
static Policy |
createNullPolicy()
The factory method creates an immutable policy instance which represents a
|
static Policy |
createNullPolicy(NamespaceVersion nsVersion,
java.lang.String name,
java.lang.String policyId)
The factory method creates an immutable policy instance which represents a
|
static Policy |
createNullPolicy(java.lang.String name,
java.lang.String policyId)
The factory method creates an immutable policy instance which represents a
|
static Policy |
createPolicy(java.util.Collection<AssertionSet> sets)
The factory method creates an immutable policy instance which represents a policy expression with
alternatives specified by
sets input parameter. |
static Policy |
createPolicy(NamespaceVersion nsVersion,
java.lang.String name,
java.lang.String policyId,
java.util.Collection<AssertionSet> sets)
The factory method creates an immutable policy instance which represents a policy expression with
alternatives specified by
sets input parameter. |
static Policy |
createPolicy(java.lang.String name,
java.lang.String policyId,
java.util.Collection<AssertionSet> sets)
The factory method creates an immutable policy instance which represents a policy expression with
alternatives specified by
sets input parameter. |
boolean |
equals(java.lang.Object obj)
An
Object.equals(Object obj) method override. |
(package private) java.util.Collection<AssertionSet> |
getContent() |
java.lang.String |
getId()
Returns the policy identifier that serves as a local relative policy URI.
|
java.lang.String |
getIdOrName()
Returns the policy ID or if that is null the policy name.
|
java.lang.String |
getName()
Returns the policy name that serves as a global policy URI.
|
NamespaceVersion |
getNamespaceVersion() |
int |
getNumberOfAssertionSets()
Method returns how many policy alternatives this policy instance contains.
|
java.util.Collection<javax.xml.namespace.QName> |
getVocabulary()
Retrieves the vocabulary of this policy expression.
|
int |
hashCode()
An
Object.hashCode() method override. |
boolean |
isEmpty()
Returns
true if the policy instance represents "anything allowed" policy expression |
boolean |
isNull()
Returns
true if the policy instance represents "nothing allowed" policy expression |
java.util.Iterator<AssertionSet> |
iterator()
A policy usually contains one or more assertion sets.
|
java.lang.String |
toString()
An
Object.toString() method override. |
(package private) java.lang.StringBuffer |
toString(int indentLevel,
java.lang.StringBuffer buffer)
A helper method that appends indented string representation of this instance to the input string buffer.
|
private static final java.lang.String POLICY_TOSTRING_NAME
private static final java.util.List<AssertionSet> NULL_POLICY_ASSERTION_SETS
private static final java.util.List<AssertionSet> EMPTY_POLICY_ASSERTION_SETS
private static final java.util.Set<javax.xml.namespace.QName> EMPTY_VOCABULARY
private static final Policy ANONYMOUS_NULL_POLICY
private static final Policy ANONYMOUS_EMPTY_POLICY
private java.lang.String policyId
private java.lang.String name
private NamespaceVersion nsVersion
private final java.util.List<AssertionSet> assertionSets
private final java.util.Set<javax.xml.namespace.QName> vocabulary
private final java.util.Collection<javax.xml.namespace.QName> immutableVocabulary
private final java.lang.String toStringName
private Policy(java.lang.String name,
java.lang.String policyId,
java.util.List<AssertionSet> assertionSets,
java.util.Set<javax.xml.namespace.QName> vocabulary)
name - global URI of the policy. May be null.policyId - local URI of the policy. May be null.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.vocabulary - represents the vocabulary of the policy object. Subsequent manipulations on the collection
must be handled with care.Policy(java.lang.String toStringName,
java.util.Collection<AssertionSet> sets)
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.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 null or empty. In such case a 'NULL' policy object is constructed.Policy(java.lang.String toStringName,
java.lang.String name,
java.lang.String policyId,
java.util.Collection<AssertionSet> sets)
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.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. The
collection may be null or empty. In such case a 'NULL' policy object is constructed.private Policy(NamespaceVersion nsVersion, java.lang.String name, java.lang.String policyId, java.util.List<AssertionSet> assertionSets, java.util.Set<javax.xml.namespace.QName> vocabulary)
nsVersion - Policy namespace version to be used when marshalling the policy expressionname - global URI of the policy. May be null.policyId - local URI of the policy. May be null.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.vocabulary - represents the vocabulary of the policy object. Subsequent manipulations on the collection
must be handled with care.Policy(NamespaceVersion nsVersion, java.lang.String toStringName, java.util.Collection<AssertionSet> sets)
nsVersion - Policy namespace version to be used when marshalling the policy expressiontoStringName - a general name of the object (such as 'policy' or 'nested policy') that will be used in the
toString() method to identify the object.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 null or empty. In such case a 'NULL' policy object is constructed.Policy(NamespaceVersion nsVersion, java.lang.String toStringName, java.lang.String name, java.lang.String policyId, java.util.Collection<AssertionSet> sets)
nsVersion - Policy namespace version to be used when marshalling the policy expressiontoStringName - a general name of the object (such as 'policy' or 'nested policy') that will be used in the
toString() method to identify the object.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. The
collection may be null or empty. In such case a 'NULL' policy object is constructed.public static Policy createNullPolicy()
public static Policy createEmptyPolicy()
public static Policy createNullPolicy(java.lang.String name, java.lang.String policyId)
name - global URI of the policy. May be null.policyId - local URI of the policy. May be null.public static Policy createNullPolicy(NamespaceVersion nsVersion, java.lang.String name, java.lang.String policyId)
nsVersion - Policy namespace version to be used when marshalling the policy expressionname - global URI of the policy. May be null.policyId - local URI of the policy. May be null.public static Policy createEmptyPolicy(java.lang.String name, java.lang.String policyId)
name - global URI of the policy. May be null.policyId - local URI of the policy. May be null.public static Policy createEmptyPolicy(NamespaceVersion nsVersion, java.lang.String name, java.lang.String policyId)
nsVersion - Policy namespace version to be used when marshalling the policy expressionname - global URI of the policy. May be null.policyId - local URI of the policy. May be null.public static Policy createPolicy(java.util.Collection<AssertionSet> sets)
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.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.public static Policy createPolicy(java.lang.String name, java.lang.String policyId, java.util.Collection<AssertionSet> sets)
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.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.public static Policy createPolicy(NamespaceVersion nsVersion, java.lang.String name, java.lang.String policyId, java.util.Collection<AssertionSet> sets)
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.nsVersion - Policy namespace version to be used when marshalling the policy expressionname - 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.private boolean add(AssertionSet set)
set - assertion set (policy alternative) object to be added. May be null; in such case the method
returns false.true or false depending on whether the new alternative was added to the policy object or not.private boolean addAll(java.util.Collection<AssertionSet> sets)
sets - collection of new alternatives. Must NOT be null or empty. The check for null or empty input
parameter is performed with help of assert keyword, thus during the testing and development of this class
-ea switch should be turned on for this class.true if all elements in the input collection were added to internal structure, false otherwise.java.util.Collection<AssertionSet> getContent()
public java.lang.String getId()
null.public java.lang.String getName()
null.public NamespaceVersion getNamespaceVersion()
public java.lang.String getIdOrName()
public int getNumberOfAssertionSets()
public java.util.Iterator<AssertionSet> iterator()
iterator in interface java.lang.Iterable<AssertionSet>public boolean isNull()
true if the policy instance represents "nothing allowed" policy expressiontrue if the policy instance represents "nothing allowed" policy expression, false otherwise.public boolean isEmpty()
true if the policy instance represents "anything allowed" policy expressiontrue if the policy instance represents "anything allowed" policy expression, false otherwise.public boolean contains(java.lang.String namespaceUri)
namespaceUri - the assertion namespace URI (identifying assertion domain)true, if an assertion with the given name could be found in the policy vocabulary false otherwise.public java.util.Collection<javax.xml.namespace.QName> getVocabulary()
public boolean contains(javax.xml.namespace.QName assertionName)
assertionName - the name of the assertion to be tested.true if the assertion with the specified name is part of the policy instance's vocabulary,
false otherwise.public boolean equals(java.lang.Object obj)
Object.equals(Object obj) method override.equals in class java.lang.Objectpublic int hashCode()
Object.hashCode() method override.hashCode in class java.lang.Objectpublic java.lang.String toString()
Object.toString() method override.toString in class java.lang.Objectjava.lang.StringBuffer toString(int indentLevel,
java.lang.StringBuffer buffer)
indentLevel - indentation level to be used.buffer - buffer to be used for appending string representation of this instance