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.rm.jaxws.util;
037:
038: import com.sun.xml.ws.policy.PolicyAssertion;
039: import com.sun.xml.ws.policy.spi.PolicyAssertionValidator;
040: import com.sun.xml.ws.policy.spi.PolicyAssertionValidator.Fitness;
041: import static com.sun.xml.ws.rm.Constants.*;
042:
043: import javax.xml.namespace.QName;
044: import java.util.ArrayList;
045: import java.util.Iterator;
046:
047: /*
048: * RMPolicyValidator.java
049: *
050: * @author Mike Grogan
051: * Created on April 13, 2006, 11:40 AM
052: *
053: */
054: public class RMPolicyValidator implements PolicyAssertionValidator {
055:
056: private static final ArrayList<QName> serverSideSupportedAssertions = new ArrayList<QName>(
057: 7);
058: private static final ArrayList<QName> clientSideSupportedAssertions = new ArrayList<QName>(
059: 6);
060:
061: static {
062: serverSideSupportedAssertions.add(new QName(version10,
063: "RMAssertion"));
064: serverSideSupportedAssertions.add(new QName(version11,
065: "RMAssertion"));
066: serverSideSupportedAssertions.add(new QName(version11,
067: "SequenceSTR"));
068: serverSideSupportedAssertions.add(new QName(version11,
069: "SequenceTransportSecurity"));
070: serverSideSupportedAssertions.add(new QName(sunVersion,
071: "Ordered"));
072: serverSideSupportedAssertions.add(new QName(sunVersion,
073: "AllowDuplicates"));
074: serverSideSupportedAssertions.add(new QName(microsoftVersion,
075: "RmFlowControl"));
076:
077: clientSideSupportedAssertions.add(new QName(sunClientVersion,
078: "AckRequestInterval"));
079: clientSideSupportedAssertions.add(new QName(sunClientVersion,
080: "ResendInterval"));
081: clientSideSupportedAssertions.add(new QName(sunClientVersion,
082: "CloseTimeout"));
083: clientSideSupportedAssertions
084: .addAll(serverSideSupportedAssertions);
085: }
086:
087: public RMPolicyValidator() {
088: }
089:
090: public Fitness validateClientSide(PolicyAssertion assertion) {
091: return clientSideSupportedAssertions.contains(assertion
092: .getName()) ? Fitness.SUPPORTED : Fitness.UNKNOWN;
093: }
094:
095: public Fitness validateServerSide(PolicyAssertion assertion) {
096: QName assertionName = assertion.getName();
097: if (serverSideSupportedAssertions.contains(assertionName)) {
098: return Fitness.SUPPORTED;
099: } else if (clientSideSupportedAssertions
100: .contains(assertionName)) {
101: return Fitness.UNSUPPORTED;
102: } else {
103: return Fitness.UNKNOWN;
104: }
105: }
106:
107: public String[] declareSupportedDomains() {
108: return new String[] { version10, version11, microsoftVersion,
109: sunVersion, sunClientVersion };
110: }
111: }
|