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:
037: package com.sun.xml.ws.policy.spi;
038:
039: import com.sun.xml.ws.policy.PolicyAssertion;
040:
041: /**
042: *
043: *
044: * @author Marek Potociar (marek.potociar at sun.com)
045: */
046: public interface PolicyAssertionValidator {
047:
048: public static enum Fitness {
049: UNKNOWN, INVALID, UNSUPPORTED, SUPPORTED;
050:
051: public Fitness combine(Fitness other) {
052: if (this .compareTo(other) < 0) {
053: return other;
054: } else {
055: return this ;
056: }
057: }
058: }
059:
060: /**
061: * An implementation of this method must return:
062: * <ul>
063: * <li>
064: * {@code Fitness.UNKNOWN} if the policy assertion type is not recognized
065: * </li>
066: * <li>
067: * {@code Fitness.SUPPORTED} if the policy assertion is supported in the
068: * client-side context
069: * </li>
070: * <li>
071: * {@code Fitness.UNSUPPORTED} if the policy assertion is recognized however
072: * it's content is not supported. For each assetion that will be eventually marked with
073: * this validation value, the policy processor will log a WARNING message however
074: * an attempt to call the web service will be made.
075: * </li>
076: * <li>
077: * {@code Fitness.INVALID} if the policy assertion is recognized however
078: * its content (value, parameters, nested assertions) is invalid. For each assetion
079: * that will be eventually marked with this validation value, the policy processor
080: * will log a SEVERE error and throw an exception. No further attempts to call
081: * the web service will be made.
082: * </li>
083: * </ul>
084: *
085: * @param assertion A policy asssertion (See {@link com.sun.xml.ws.policy.PolicyAssertion PolicyAssertion}).
086: * May contain nested policies and assertions.
087: * @return fitness of the {@code assertion} on in the client-side context. Must not be {@code null}.
088: */
089: public Fitness validateClientSide(PolicyAssertion assertion);
090:
091: /**
092: * An implementation of this method must return:
093: * <ul>
094: * <li>
095: * {@code Fitness.UNKNOWN} if the policy assertion type is not recognized
096: * </li>
097: * <li>
098: * {@code Fitness.SUPPORTED} if the policy assertion is supported in the
099: * server-side context
100: * </li>
101: * <li>
102: * {@code Fitness.UNSUPPORTED} if the policy assertion is recognized however
103: * it's content is not supported.
104: * </li>
105: * <li>
106: * {@code Fitness.INVALID} if the policy assertion is recognized however
107: * its content (value, parameters, nested assertions) is invalid.
108: * </li>
109: * </ul>
110: *
111: * For each assetion that will be eventually marked with validation value of
112: * UNKNOWN, UNSUPPORTED or INVALID, the policy processor will log a SEVERE error
113: * and throw an exception.
114: *
115: * @param assertion A policy asssertion (See {@link com.sun.xml.ws.policy.PolicyAssertion PolicyAssertion}).
116: * May contain nested policies and assertions.
117: * @return fitness of the {@code assertion} on in the server-side context. Must not be {@code null}.
118: */
119: public Fitness validateServerSide(PolicyAssertion assertion);
120:
121: /**
122: * Each service provider that implements this SPI must make sure to identify all possible domains it supports.
123: * This operation must be implemented as idempotent (must return same values on multiple calls).
124: * <p/>
125: * It is legal for two or more {@code PolicyAssertionValidator}s to support the same domain. In such case,
126: * the most significant result returned from validation methods will be eventually assigned to the assertion.
127: * The significance of validation results is as follows (from most to least significant):
128: * <ol>
129: * <li>SUPPORTED</li>
130: * <li>UNSUPPORTED</li>
131: * <li>INVALID</li>
132: * <li>UNKNOWN</li>
133: * </ol>
134: *
135: *
136: * @return {@code String} array holding {@code String} representations of identifiers of all supported domains.
137: * Usually a domain identifier is represented by a namespace.
138: */
139: public String[] declareSupportedDomains();
140: }
|