001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036: package com.sun.xml.ws.security.impl.policy;
037:
038: import com.sun.xml.ws.policy.AssertionSet;
039: import com.sun.xml.ws.policy.NestedPolicy;
040: import com.sun.xml.ws.policy.PolicyAssertion;
041: import com.sun.xml.ws.policy.sourcemodel.AssertionData;
042: import com.sun.xml.ws.security.policy.AlgorithmSuite;
043: import com.sun.xml.ws.security.policy.HttpsToken;
044: import com.sun.xml.ws.security.policy.MessageLayout;
045: import com.sun.xml.ws.security.policy.Token;
046: import com.sun.xml.ws.security.policy.SecurityAssertionValidator;
047: import java.util.Collection;
048: import java.util.logging.Level;
049: import static com.sun.xml.ws.security.impl.policy.Constants.*;
050:
051: /**
052: *
053: * @author K.Venugopal@sun.com
054: */
055: public class TransportBinding extends PolicyAssertion implements
056: com.sun.xml.ws.security.policy.TransportBinding,
057: SecurityAssertionValidator {
058:
059: HttpsToken transportToken;
060: private AlgorithmSuite algSuite;
061: boolean includeTimeStamp = false;
062: MessageLayout layout = MessageLayout.Lax;
063: boolean populated = false;
064: private AssertionFitness fitness = AssertionFitness.IS_VALID;
065:
066: /**
067: * Creates a new instance of TransportBinding
068: */
069: public TransportBinding() {
070: }
071:
072: public TransportBinding(AssertionData name,
073: Collection<PolicyAssertion> nestedAssertions,
074: AssertionSet nestedAlternative) {
075: super (name, nestedAssertions, nestedAlternative);
076: }
077:
078: public void addTransportToken(Token token) {
079: transportToken = (HttpsToken) token;
080: }
081:
082: public Token getTransportToken() {
083: populate();
084: return transportToken;
085: }
086:
087: public void setAlgorithmSuite(AlgorithmSuite algSuite) {
088: this .algSuite = algSuite;
089: }
090:
091: public AlgorithmSuite getAlgorithmSuite() {
092: populate();
093: return algSuite;
094: }
095:
096: public void includeTimeStamp(boolean value) {
097: includeTimeStamp = value;
098: }
099:
100: public boolean isIncludeTimeStamp() {
101: populate();
102: return includeTimeStamp;
103: }
104:
105: public void setLayout(MessageLayout layout) {
106: this .layout = layout;
107: }
108:
109: public MessageLayout getLayout() {
110: populate();
111: return layout;
112: }
113:
114: public boolean isSignContent() {
115: throw new UnsupportedOperationException("Not supported");
116: }
117:
118: public void setSignContent(boolean contentOnly) {
119: throw new UnsupportedOperationException("Not supported");
120: }
121:
122: public void setProtectionOrder(String order) {
123: throw new UnsupportedOperationException("Not supported");
124: }
125:
126: public String getProtectionOrder() {
127: throw new UnsupportedOperationException("Not supported");
128: }
129:
130: public void setTokenProtection(boolean token) {
131: throw new UnsupportedOperationException("Not supported");
132: }
133:
134: public void setSignatureProtection(boolean token) {
135: throw new UnsupportedOperationException("Not supported");
136: }
137:
138: public boolean getTokenProtection() {
139: throw new UnsupportedOperationException("Not supported");
140: }
141:
142: public boolean getSignatureProtection() {
143: throw new UnsupportedOperationException("Not supported");
144: }
145:
146: public AssertionFitness validate(boolean isServer) {
147: return populate(isServer);
148: }
149:
150: private void populate() {
151: populate(false);
152: }
153:
154: private synchronized AssertionFitness populate(boolean isServer) {
155: if (!populated) {
156: NestedPolicy policy = this .getNestedPolicy();
157: AssertionSet assertions = policy.getAssertionSet();
158: if (assertions == null) {
159: if (logger.getLevel() == Level.FINE) {
160: logger.log(Level.FINE, "NestedPolicy is null");
161: }
162: populated = true;
163: return fitness;
164: }
165: for (PolicyAssertion assertion : assertions) {
166: if (PolicyUtil.isAlgorithmAssertion(assertion)) {
167: this .algSuite = (AlgorithmSuite) assertion;
168: } else if (PolicyUtil.isToken(assertion)) {
169: transportToken = (HttpsToken) ((com.sun.xml.ws.security.impl.policy.Token) assertion)
170: .getToken();
171: } else if (PolicyUtil.isMessageLayout(assertion)) {
172: layout = ((Layout) assertion).getMessageLayout();
173: } else if (PolicyUtil.isIncludeTimestamp(assertion)) {
174: includeTimeStamp = true;
175: } else {
176: if (!assertion.isOptional()) {
177: log_invalid_assertion(assertion, isServer,
178: TransportBinding);
179: fitness = AssertionFitness.HAS_UNKNOWN_ASSERTION;
180: }
181: }
182: }
183: populated = true;
184: }
185: return fitness;
186: }
187:
188: public boolean isDisableTimestampSigning() {
189: throw new UnsupportedOperationException();
190: }
191: }
|