001: /*
002: * $Id: WSSPolicy.java,v 1.4 2007/01/08 09:28:46 ashutoshshahi Exp $
003: */
004:
005: /*
006: * The contents of this file are subject to the terms
007: * of the Common Development and Distribution License
008: * (the License). You may not use this file except in
009: * compliance with the License.
010: *
011: * You can obtain a copy of the license at
012: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
013: * See the License for the specific language governing
014: * permissions and limitations under the License.
015: *
016: * When distributing Covered Code, include this CDDL
017: * Header Notice in each file and include the License file
018: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
019: * If applicable, add the following below the CDDL Header,
020: * with the fields enclosed by brackets [] replaced by
021: * you own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
025: */
026:
027: package com.sun.xml.wss.impl.policy.mls;
028:
029: import com.sun.xml.wss.impl.policy.MLSPolicy;
030:
031: /**
032: * Represents a base class for SOAP Message Security Policies.
033: * Any WSSPolicy can be epxressed as being composed of one or both of
034: * two SecurityPolicy components called FeatureBinding and KeyBinding.
035: * This generic structure for a WSSPolicy allows for representing complex,
036: * concrete WSS Policy Instances.
037: *
038: * For example, A SignaturePolicy can have a SAMLAssertion as its KeyBinding.
039: * The SAMLAssertionBinding can in turn have a KeyBinding which is a PrivateKeyBinding.
040: * The PrivateKeyBinding would contain a PrivateKey corresponding to the PublicKey
041: * contained in the SAML Assertion of the SAMLAssertionBinding. Such a SignaturePolicy
042: * instance can then be used by the XWS-Runtime to sign Message parts of an outgoing
043: * SOAP Message. The MessageParts to be signed are inturn identified by the FeatureBinding
044: * component of the SignaturePolicy.
045: *
046: */
047: public abstract class WSSPolicy extends MLSPolicy implements Cloneable {
048: protected String UUID;
049: protected String _policyIdentifier;
050:
051: protected MLSPolicy _keyBinding = null;
052: protected MLSPolicy _featureBinding = null;
053:
054: protected boolean _isOptional = false;
055:
056: protected boolean bsp = false;
057:
058: /**
059: *Default constructor
060: */
061: public WSSPolicy() {
062: }
063:
064: /**
065: * @return MLSPolicy the FeatureBinding associated with this WSSPolicy, null otherwise
066: * @see SignaturePolicy
067: * @see EncryptionPolicy
068: * @see AuthenticationTokenPolicy
069: */
070: public MLSPolicy getFeatureBinding() {
071: return _featureBinding;
072: }
073:
074: /**
075: * @return MLSPolicy the KeyBinding associated with this WSSPolicy, null otherwise
076: *
077: * @see SignaturePolicy
078: * @see EncryptionPolicy
079: * @see AuthenticationTokenPolicy
080: */
081: public MLSPolicy getKeyBinding() {
082: return _keyBinding;
083: }
084:
085: /**
086: * set the FeatureBinding for this WSSPolicy
087: * @param policy the FeatureBinding to be set for this WSSPolicy
088: */
089: public void setFeatureBinding(MLSPolicy policy) {
090: if (isReadOnly()) {
091: throw new RuntimeException(
092: "Can not set FeatureBinding : Policy is Readonly");
093: }
094:
095: this ._featureBinding = policy;
096: }
097:
098: /**
099: * set the KeyBinding for this WSSPolicy
100: * @param policy the KeyBinding to be set for this WSSPolicy
101: */
102: public void setKeyBinding(MLSPolicy policy) {
103: if (isReadOnly()) {
104: throw new RuntimeException(
105: "Can not set KeyBinding : Policy is Readonly");
106: }
107:
108: this ._keyBinding = policy;
109: }
110:
111: /*
112: *@param pi the policy identifier
113: */
114: public void setPolicyIdentifier(String pi) {
115: if (isReadOnly()) {
116: throw new RuntimeException(
117: "Can not set PolicyIdentifier : Policy is Readonly");
118: }
119:
120: this ._policyIdentifier = pi;
121: }
122:
123: /*
124: *@return policy identifier
125: */
126: public String getPolicyIdentifier() {
127: return _policyIdentifier;
128: }
129:
130: /**
131: *@return unique policy identifier associated with this policy
132: */
133: public String getUUID() {
134: return UUID;
135: }
136:
137: /**
138: * set a unique policy identifier for this WSSPolicy
139: * @param uuid
140: */
141: public void setUUID(String uuid) {
142: if (isReadOnly()) {
143: throw new RuntimeException(
144: "Can not set UUID : Policy is Readonly");
145: }
146:
147: this .UUID = uuid;
148: }
149:
150: /*
151: * @return true if-requirement-is-optional
152: */
153: public boolean isOptional() {
154: return this ._isOptional;
155: }
156:
157: /*
158: * @param isOptional parameter to indicate if this requirement is optional
159: */
160: public void isOptional(boolean isOptional) {
161: if (isReadOnly()) {
162: throw new RuntimeException(
163: "Can not set Optional Requirement flag : Policy is Readonly");
164: }
165:
166: this ._isOptional = isOptional;
167: }
168:
169: //TODO: we are not making any validity checks before creating KeyBindings.
170:
171: /**
172: * clone operatror
173: * @return a clone of this WSSPolicy
174: *
175: * @see SignaturePolicy
176: * @see EncryptionPolicy
177: * @see AuthenticationTokenPolicy
178: */
179: public abstract Object clone();
180:
181: /**
182: * equals operator
183: *
184: * @return true if the argument policy is the same as this WSSPolicy
185: * @see SignaturePolicy
186: * @see EncryptionPolicy
187: * @see AuthenticationTokenPolicy
188: * @see PrivateKeyBinding
189: * @see SymmetricKeyBinding
190: */
191: public abstract boolean equals(WSSPolicy policy);
192:
193: /*
194: * @return true if the argument policy is the same as this WSSPolicy ignoring Target bindings.
195: *
196: * @see SignaturePolicy
197: * @see EncryptionPolicy
198: * @see AuthenticationTokenPolicy
199: * @see PrivateKeyBinding
200: * @see SymmetricKeyBinding
201: */
202: public abstract boolean equalsIgnoreTargets(WSSPolicy policy);
203:
204: /*
205: * Sets whether Basic Security Profile restrictions should be enforced as part
206: * of this policy.
207: */
208: public void isBSP(boolean flag) {
209: bsp = flag;
210: }
211:
212: /*
213: * @return true if BSP restrictions will be enforced.
214: */
215: public boolean isBSP() {
216: return bsp;
217: }
218:
219: }
|