com.sun.xml.wss.impl.policy.mls.WSSPolicy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xws-security Show documentation
Show all versions of xws-security Show documentation
sun xml wss xws-security library
The newest version!
/*
* $Id: WSSPolicy.java,v 1.4 2007/01/08 09:28:46 ashutoshshahi Exp $
*/
/*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the license at
* https://glassfish.dev.java.net/public/CDDLv1.0.html.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at https://glassfish.dev.java.net/public/CDDLv1.0.html.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* you own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* Copyright 2006 Sun Microsystems Inc. All Rights Reserved
*/
package com.sun.xml.wss.impl.policy.mls;
import com.sun.xml.wss.impl.policy.MLSPolicy;
/**
* Represents a base class for SOAP Message Security Policies.
* Any WSSPolicy can be epxressed as being composed of one or both of
* two SecurityPolicy components called FeatureBinding and KeyBinding.
* This generic structure for a WSSPolicy allows for representing complex,
* concrete WSS Policy Instances.
*
* For example, A SignaturePolicy can have a SAMLAssertion as its KeyBinding.
* The SAMLAssertionBinding can in turn have a KeyBinding which is a PrivateKeyBinding.
* The PrivateKeyBinding would contain a PrivateKey corresponding to the PublicKey
* contained in the SAML Assertion of the SAMLAssertionBinding. Such a SignaturePolicy
* instance can then be used by the XWS-Runtime to sign Message parts of an outgoing
* SOAP Message. The MessageParts to be signed are inturn identified by the FeatureBinding
* component of the SignaturePolicy.
*
*/
public abstract class WSSPolicy extends MLSPolicy implements Cloneable {
protected String UUID;
protected String _policyIdentifier;
protected MLSPolicy _keyBinding= null;
protected MLSPolicy _featureBinding= null;
protected boolean _isOptional = false;
protected boolean bsp = false;
/**
*Default constructor
*/
public WSSPolicy () {}
/**
* @return MLSPolicy the FeatureBinding associated with this WSSPolicy, null otherwise
* @see SignaturePolicy
* @see EncryptionPolicy
* @see AuthenticationTokenPolicy
*/
public MLSPolicy getFeatureBinding () {
return _featureBinding;
}
/**
* @return MLSPolicy the KeyBinding associated with this WSSPolicy, null otherwise
*
* @see SignaturePolicy
* @see EncryptionPolicy
* @see AuthenticationTokenPolicy
*/
public MLSPolicy getKeyBinding () {
return _keyBinding;
}
/**
* set the FeatureBinding for this WSSPolicy
* @param policy the FeatureBinding to be set for this WSSPolicy
*/
public void setFeatureBinding (MLSPolicy policy) {
if ( isReadOnly () ) {
throw new RuntimeException ("Can not set FeatureBinding : Policy is Readonly");
}
this._featureBinding = policy;
}
/**
* set the KeyBinding for this WSSPolicy
* @param policy the KeyBinding to be set for this WSSPolicy
*/
public void setKeyBinding (MLSPolicy policy) {
if ( isReadOnly () ) {
throw new RuntimeException ("Can not set KeyBinding : Policy is Readonly");
}
this._keyBinding = policy;
}
/*
*@param pi the policy identifier
*/
public void setPolicyIdentifier (String pi) {
if ( isReadOnly () ) {
throw new RuntimeException ("Can not set PolicyIdentifier : Policy is Readonly");
}
this._policyIdentifier = pi;
}
/*
*@return policy identifier
*/
public String getPolicyIdentifier () {
return _policyIdentifier;
}
/**
*@return unique policy identifier associated with this policy
*/
public String getUUID () {
return UUID;
}
/**
* set a unique policy identifier for this WSSPolicy
* @param uuid
*/
public void setUUID (String uuid) {
if ( isReadOnly () ) {
throw new RuntimeException ("Can not set UUID : Policy is Readonly");
}
this.UUID = uuid;
}
/*
* @return true if-requirement-is-optional
*/
public boolean isOptional () {
return this._isOptional;
}
/*
* @param isOptional parameter to indicate if this requirement is optional
*/
public void isOptional (boolean isOptional) {
if ( isReadOnly () ) {
throw new RuntimeException ("Can not set Optional Requirement flag : Policy is Readonly");
}
this._isOptional = isOptional;
}
//TODO: we are not making any validity checks before creating KeyBindings.
/**
* clone operatror
* @return a clone of this WSSPolicy
*
* @see SignaturePolicy
* @see EncryptionPolicy
* @see AuthenticationTokenPolicy
*/
public abstract Object clone ();
/**
* equals operator
*
* @return true if the argument policy is the same as this WSSPolicy
* @see SignaturePolicy
* @see EncryptionPolicy
* @see AuthenticationTokenPolicy
* @see PrivateKeyBinding
* @see SymmetricKeyBinding
*/
public abstract boolean equals (WSSPolicy policy);
/*
* @return true if the argument policy is the same as this WSSPolicy ignoring Target bindings.
*
* @see SignaturePolicy
* @see EncryptionPolicy
* @see AuthenticationTokenPolicy
* @see PrivateKeyBinding
* @see SymmetricKeyBinding
*/
public abstract boolean equalsIgnoreTargets (WSSPolicy policy);
/*
* Sets whether Basic Security Profile restrictions should be enforced as part
* of this policy.
*/
public void isBSP (boolean flag) {
bsp = flag;
}
/*
* @return true if BSP restrictions will be enforced.
*/
public boolean isBSP () {
return bsp;
}
}