001: /*
002: * The contents of this file are subject to the terms
003: * of the Common Development and Distribution License
004: * (the License). You may not use this file except in
005: * compliance with the License.
006: *
007: * You can obtain a copy of the license at
008: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
009: * See the License for the specific language governing
010: * permissions and limitations under the License.
011: *
012: * When distributing Covered Code, include this CDDL
013: * Header Notice in each file and include the License file
014: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
015: * If applicable, add the following below the CDDL Header,
016: * with the fields enclosed by brackets [] replaced by
017: * you own identifying information:
018: * "Portions Copyrighted [year] [name of copyright owner]"
019: *
020: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
021: */
022:
023: /*
024: * WSSFeatureBindingExtension.java
025: *
026: * Created on August 31, 2005, 7:11 PM
027: *
028: * To change this template, choose Tools | Options and locate the template under
029: * the Source Creation and Management node. Right-click the template and choose
030: * Open. You can then make changes to the template in the Source Editor.
031: */
032:
033: package com.sun.xml.wss.impl.policy.mls;
034:
035: import com.sun.xml.wss.impl.PolicyTypeUtil;
036: import com.sun.xml.wss.impl.policy.MLSPolicy;
037: import com.sun.xml.wss.impl.policy.PolicyGenerationException;
038:
039: /**
040: *
041: * @author abhijit.das@Sun.COM
042: */
043: public abstract class WSSFeatureBindingExtension extends WSSPolicy {
044:
045: /** Creates a new instance of WSSFeatureBindingExtension */
046: public WSSFeatureBindingExtension() {
047: }
048:
049: /**
050: * Create and set the FeatureBinding for this WSSPolicy to a UsernameTokenBinding
051: * @return a new UsernameTokenBinding as a FeatureBinding for this WSSPolicy
052: * @exception PolicyGenerationException if UsernameTokenBinding is not a valid FeatureBinding for this WSSPolicy
053: * @see SignaturePolicy
054: * @see EncryptionPolicy
055: * @see AuthenticationTokenPolicy
056: */
057: public MLSPolicy newUsernameTokenFeatureBinding()
058: throws PolicyGenerationException {
059: if (isReadOnly()) {
060: throw new RuntimeException(
061: "Can not create a feature binding of UsernameToken type for ReadOnly "
062: + _policyIdentifier);
063: }
064:
065: if ((PolicyTypeUtil.SIGNATURE_POLICY_TYPE == _policyIdentifier)
066: || (PolicyTypeUtil.ENCRYPTION_POLICY_TYPE == _policyIdentifier)) {
067: throw new PolicyGenerationException(
068: "Can not create a feature binding of UsernameToken type for "
069: + _policyIdentifier);
070: }
071:
072: this ._featureBinding = new AuthenticationTokenPolicy.UsernameTokenBinding();
073: return _featureBinding;
074: }
075:
076: /**
077: * Create and set the FeatureBinding for this WSSPolicy to an X509CertificateBinding
078: * @return a new X509CertificateBinding as a FeatureBinding for this WSSPolicy
079: * @exception PolicyGenerationException if X509CertificateBinding is not a valid FeatureBinding for this WSSPolicy
080: * @see SignaturePolicy
081: * @see EncryptionPolicy
082: * @see AuthenticationTokenPolicy
083: */
084: public MLSPolicy newX509CertificateFeatureBinding()
085: throws PolicyGenerationException {
086: if (isReadOnly()) {
087: throw new RuntimeException(
088: "Can not create a feature binding of X509Certificate type for ReadOnly "
089: + _policyIdentifier);
090: }
091:
092: if ((PolicyTypeUtil.SIGNATURE_POLICY_TYPE == _policyIdentifier)
093: || (PolicyTypeUtil.ENCRYPTION_POLICY_TYPE == _policyIdentifier)) {
094: throw new PolicyGenerationException(
095: "Can not create a feature binding of X509Certificate type for "
096: + _policyIdentifier);
097: }
098:
099: this ._featureBinding = new AuthenticationTokenPolicy.X509CertificateBinding();
100: return _featureBinding;
101: }
102:
103: /**
104: * Create and set the FeatureBinding for this WSSPolicy to a SAMLAssertionBinding
105: * @return a new SAMLAssertionBinding as a FeatureBinding for this WSSPolicy
106: * @exception PolicyGenerationException if SAMLAssertionBinding is not a valid FeatureBinding for this WSSPolicy
107: * @see SignaturePolicy
108: * @see EncryptionPolicy
109: * @see AuthenticationTokenPolicy
110: */
111: public MLSPolicy newSAMLAssertionFeatureBinding()
112: throws PolicyGenerationException {
113: if (isReadOnly()) {
114: throw new RuntimeException(
115: "Can not create a feature binding of SAMLAssertion type for ReadOnly "
116: + _policyIdentifier);
117: }
118:
119: if ((PolicyTypeUtil.SIGNATURE_POLICY_TYPE == _policyIdentifier)
120: || (PolicyTypeUtil.ENCRYPTION_POLICY_TYPE == _policyIdentifier)) {
121: throw new PolicyGenerationException(
122: "Can not create a feature binding of SAMLAssertion type for "
123: + _policyIdentifier);
124: }
125:
126: this ._featureBinding = new AuthenticationTokenPolicy.SAMLAssertionBinding();
127: return _featureBinding;
128: }
129:
130: /**
131: * Create and set the FeatureBinding for this WSSPolicy to a TimestampPolicy
132: * @return a new TimestampPolicy as a FeatureBinding for this WSSPolicy
133: * @exception PolicyGenerationException, if TimestampPolicy is not a valid FeatureBinding for this WSSPolicy
134: * @see SignaturePolicy
135: * @see EncryptionPolicy
136: * @see AuthenticationTokenPolicy
137: */
138: /*public MLSPolicy newTimestampFeatureBinding () throws PolicyGenerationException {
139: if ( isReadOnly () ) {
140: throw new RuntimeException (
141: "Can not create a feature binding of Timestamp type for ReadOnly " + _policyIdentifier);
142: }
143:
144: if (!(_policyIdentifier == PolicyTypeUtil.USERNAMETOKEN_TYPE) &&
145: !(_policyIdentifier == PolicyTypeUtil.SIGNATURE_POLICY_FEATUREBINDING_TYPE))
146: throw new PolicyGenerationException (
147: "Can not create a feature binding of Timestamp type for " + _policyIdentifier);
148:
149: this._featureBinding = new TimestampPolicy ();
150: return _featureBinding;
151: }*/
152:
153: }
|