Fields Summary |
---|
private static final String | POLICY_TOSTRING_NAMEA string constant used in package private constructor to customize the object's toString() method output. |
private static final List | NULL_POLICY_ASSERTION_SETSConstant represents empty list of assertion sets. This represents the content of a 'NULL' policy - a policy with
no alternatives. The constant supports memory effective creation of 'NULL' policy objects. |
private static final List | EMPTY_POLICY_ASSERTION_SETSConstant represents list of assertion sets with single empty assertion set. This represents the content of
an 'EMPTY' policy - a policy with a single empty alternative. The constant supports memory effective creation
of 'EMPTY' policy objects. |
private static final Set | EMPTY_VOCABULARYConstant represents empty vocabulary of a 'NULL' or 'EMPTY' policies. The constant supports memory effective
creation of 'NULL' and 'EMPTY' policy objects. |
private static final Policy | ANONYMOUS_NULL_POLICYConstant representation of all 'NULL' policies returned by createNullPolicy() factory method. This is to optimize
the memory footprint. |
private static final Policy | ANONYMOUS_EMPTY_POLICYConstant representation of all 'EMPTY' policies returned by createEmptyPolicy() factory method. This constant is
to optimize the memory footprint. |
private String | policyIdPolicy ID holder |
private String | namePolicy name holder |
private final List | assertionSetsinternal collection of policy alternatives |
private final Set | vocabularyinternal collection of policy vocabulary entries (qualified names of all assertion types present in the policy expression) |
private final Collection | immutableVocabularyimmutable version of policy vocabulary that is made available to clients via getter method |
private final String | toStringNamepolicy object name used in a toString() method. This ensures that Policy class children can customize
(via package private Policy constructors) the toString() method without having to override it. |
Methods Summary |
---|
private boolean | add(AssertionSet set)Adds single alternative to the internal alternatives set of the policy object.
if (set == null) {
return false;
}
if (this.assertionSets.contains(set)) {
return false;
} else {
this.assertionSets.add(set);
this.vocabulary.addAll(set.getVocabulary());
return true;
}
|
private boolean | addAll(java.util.Collection sets)Adds all alternatives from the input collection of assertion sets to the policy object's internal set of alternatives.
The policy object's vocabulary structure is updated as well.
assert (sets != null && !sets.isEmpty()) : LocalizationMessages.WSP_0036_PRIVATE_METHOD_DOES_NOT_ACCEPT_NULL_OR_EMPTY_COLLECTION();
boolean result = true;
for (AssertionSet set : sets) {
result &= add(set); // this is here to ensure that vocabulary is built correctly as well
}
Collections.sort(this.assertionSets);
return result;
|
public boolean | contains(java.lang.String namespaceUri)Returns true if the policy contains the assertion names with specified namespace in its vocabulary
for (QName entry : vocabulary) {
if (entry.getNamespaceURI().equals(namespaceUri)) {
return true;
}
}
return false;
|
public boolean | contains(javax.xml.namespace.QName assertionName)Determines if the policy instance contains the assertion with the name specified in its vocabulary.
return vocabulary.contains(assertionName);
|
public static com.sun.xml.ws.policy.Policy | createEmptyPolicy()The factory method creates an immutable policy instance which represents a 'anything allowed'
policy expression.
return ANONYMOUS_EMPTY_POLICY;
|
public static com.sun.xml.ws.policy.Policy | createEmptyPolicy(java.lang.String name, java.lang.String policyId)The factory method creates an immutable policy instance which represents a 'anything allowed'
policy expression.
if (name == null && policyId == null) {
return ANONYMOUS_EMPTY_POLICY;
} else {
return new Policy(name, policyId, EMPTY_POLICY_ASSERTION_SETS, EMPTY_VOCABULARY);
}
|
public static com.sun.xml.ws.policy.Policy | createNullPolicy()The factory method creates an immutable policy instance which represents a 'nothing allowed'
policy expression.
return ANONYMOUS_NULL_POLICY;
|
public static com.sun.xml.ws.policy.Policy | createNullPolicy(java.lang.String name, java.lang.String policyId)The factory method creates an immutable policy instance which represents a 'nothing allowed'
policy expression.
if (name == null && policyId == null) {
return ANONYMOUS_NULL_POLICY;
} else {
return new Policy(name, policyId, NULL_POLICY_ASSERTION_SETS, EMPTY_VOCABULARY);
}
|
public static com.sun.xml.ws.policy.Policy | createPolicy(java.util.Collection sets)The factory method creates an immutable policy instance which represents a policy expression with
alternatives specified by {@code 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
{@link #createNullPolicy()} factory method directly.
if (sets == null || sets.isEmpty()) {
return createNullPolicy();
} else {
return new Policy(POLICY_TOSTRING_NAME, sets);
}
|
public static com.sun.xml.ws.policy.Policy | createPolicy(java.lang.String name, java.lang.String policyId, java.util.Collection sets)The factory method creates an immutable policy instance which represents a policy expression with
alternatives specified by {@code 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
{@link #createNullPolicy(String, String)} factory method directly.
if (sets == null || sets.isEmpty()) {
return createNullPolicy(name, policyId);
} else {
return new Policy(POLICY_TOSTRING_NAME, name, policyId, sets);
}
|
public boolean | equals(java.lang.Object obj)An {@code Object.equals(Object obj)} method override.
if (this == obj) {
return true;
}
if (!(obj instanceof Policy)) {
return false;
}
final Policy that = (Policy) obj;
boolean result = true;
result = result && this.vocabulary.equals(that.vocabulary);
result = result && this.assertionSets.size() == that.assertionSets.size() && this.assertionSets.containsAll(that.assertionSets);
return result;
|
java.util.Collection | getContent()
return assertionSets;
|
public java.lang.String | getId()Returns the policy identifier that serves as a local relative policy URI.
return policyId;
|
public java.lang.String | getIdOrName()Returns the policy ID or if that is null the policy name. May return null
if both attributes are null.
if (policyId != null) {
return policyId;
}
return name;
|
public java.lang.String | getName()Returns the policy name that serves as a global policy URI.
return name;
|
public int | getNumberOfAssertionSets()Method returns how many policy alternatives this policy instance contains.
return assertionSets.size();
|
public java.util.Collection | 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.
return immutableVocabulary;
|
public int | hashCode()An {@code Object.hashCode()} method override.
int result = 17;
result = 37 * result + vocabulary.hashCode();
result = 37 * result + assertionSets.hashCode();
return result;
|
public boolean | isEmpty()Returns {@code true} if the policy instance represents "anything allowed" policy expression
return assertionSets.size() == 1 && assertionSets.get(0).isEmpty();
|
public boolean | isNull()Returns {@code true} if the policy instance represents "nothing allowed" policy expression
return assertionSets.size() == 0;
|
public java.util.Iterator | iterator()A policy usually contains one or more assertion sets. Each assertion set
corresponds to a policy alternative as defined by WS-Policy.
return assertionSets.iterator();
|
public java.lang.String | toString()An {@code Object.toString()} method override.
return toString(0, new StringBuffer()).toString();
|
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.
final String indent = PolicyUtils.Text.createIndent(indentLevel);
final String innerIndent = PolicyUtils.Text.createIndent(indentLevel + 1);
final String innerDoubleIndent = PolicyUtils.Text.createIndent(indentLevel + 2);
buffer.append(indent).append(toStringName).append(" {").append(PolicyUtils.Text.NEW_LINE);
buffer.append(innerIndent).append("id = '").append(policyId).append('\'").append(PolicyUtils.Text.NEW_LINE);
buffer.append(innerIndent).append("name = '").append(name).append('\'").append(PolicyUtils.Text.NEW_LINE);
buffer.append(innerIndent).append("vocabulary {").append(PolicyUtils.Text.NEW_LINE);
if (vocabulary.isEmpty()) {
buffer.append(innerDoubleIndent).append("no entries").append(PolicyUtils.Text.NEW_LINE);
} else {
int index = 1;
for (QName entry : vocabulary) {
buffer.append(innerDoubleIndent).append(index++).append(". entry = '").append(entry.getNamespaceURI()).append(':").append(entry.getLocalPart()).append('\'").append(PolicyUtils.Text.NEW_LINE);
}
}
buffer.append(innerIndent).append('}").append(PolicyUtils.Text.NEW_LINE);
if (assertionSets.isEmpty()) {
buffer.append(innerIndent).append("no assertion sets").append(PolicyUtils.Text.NEW_LINE);
} else {
for (AssertionSet set : assertionSets) {
set.toString(indentLevel + 1, buffer).append(PolicyUtils.Text.NEW_LINE);
}
}
buffer.append(indent).append('}");
return buffer;
|