325N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 325N/A * This code is free software; you can redistribute it and/or modify it 325N/A * under the terms of the GNU General Public License version 2 only, as 325N/A * published by the Free Software Foundation. Oracle designates this 325N/A * particular file as subject to the "Classpath" exception as provided 325N/A * by Oracle in the LICENSE file that accompanied this code. 325N/A * This code is distributed in the hope that it will be useful, but WITHOUT 325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 325N/A * version 2 for more details (a copy is included in the LICENSE file that 325N/A * accompanied this code). 325N/A * You should have received a copy of the GNU General Public License version 325N/A * 2 along with this work; if not, write to the Free Software Foundation, 325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 325N/A * or visit www.oracle.com if you need additional information or have any 325N/A * A list of {@link Header}s on a {@link Message}. 325N/A * This list can be modified to add headers 325N/A * from outside a {@link Message}, this is necessary 325N/A * since intermediate processing layers often need to 325N/A * put additional headers. 325N/A * Following the SOAP convention, the order among headers 325N/A * are not significant. However, {@link Codec}s are 325N/A * expected to preserve the order of headers in the input 325N/A * message as much as possible. 325N/A * <h3>MustUnderstand Processing</h3> 325N/A * To perform SOAP mustUnderstang processing correctly, we need to keep 325N/A * track of headers that are understood and headers that are not. 325N/A * This is a collaborative process among {@link Pipe}s, thus it's something 325N/A * a {@link Pipe} author needs to keep in mind. 325N/A * Specifically, when a {@link Pipe} sees a header and processes it 325N/A * (that is, if it did enough computing with the header to claim that 325N/A * the header is understood), then it should mark the corresponding 325N/A * header as "understood". For example, when a pipe that handles JAX-WSA 325N/A * examins the <wsa:To> header, it can claim that it understood the header. 325N/A * But for example, if a pipe that does the signature verification checks 325N/A * <wsa:To> for a signature, that would not be considered as "understood". 325N/A * There are two ways to mark a header as understood: 325N/A * <li>Use one of the <tt>getXXX</tt> methods that take a 325N/A * boolean <tt>markAsUnderstood</tt> parameter. 325N/A * Most often, a {@link Pipe} knows it's going to understand a header 325N/A * as long as it's present, so this is the easiest and thus the preferred way. 325N/A * For example, if JAX-WSA looks for <wsa:To>, then it can set 325N/A * <tt>markAsUnderstand</tt> to true, to do the obtaining of a header 325N/A * and marking at the same time. 325N/A * <li>Call {@link #understood(int)}. 325N/A * If under a rare circumstance, a pipe cannot determine whether 325N/A * it can understand it or not when you are fetching a header, then 325N/A * you can use this method afterward to mark it as understood. 325N/A * Intuitively speaking, at the end of the day, if a header is not 325N/A * understood but {@link Header#isIgnorable(SOAPVersion, java.util.Set)} is false, a bad thing 325N/A * will happen. The actual implementation of the checking is more complicated, 325N/A * for that see {@link ClientMUTube}/{@link ServerMUTube}. 325N/A * @see Message#getHeaders() 325N/A * Bit set to keep track of which headers are understood. 325N/A * The first 32 headers use this field, and the rest will use 325N/A * {@link #moreUnderstoodBits}. The expectation is that 325N/A * most of the time a SOAP message will only have up to 32 headers, 325N/A * so we can avoid allocating separate objects for {@link BitSet}. 325N/A * If there are more than 32 headers, we use this {@link BitSet} 325N/A * to keep track of whether those headers are understood. 325N/A * Creates an empty {@link HeaderList}. 325N/A * The total number of headers. 325N/A * Adds all the headers. 325N/A * Gets the {@link Header} at the specified index. 325N/A * This method does not mark the returned {@link Header} as understood. 325N/A * @see #understood(int) 325N/A * Marks the {@link Header} at the specified index as 325N/A * <a href="#MU">"understood"</a>. 325N/A // check that index is in range 325N/A * Returns true if a {@link Header} at the given index 325N/A * was <a href="#MU">"understood"</a>. 325N/A // check that index is in range 325N/A * Marks the specified {@link Header} as <a href="#MU">"understood"</a>. 325N/A * By the definition of {@link ArrayList}, this operation requires 325N/A * O(n) search of the array, and thus inherently inefficient. 325N/A * Because of this, if you are developing a {@link Pipe} for 325N/A * a performance sensitive environment, do not use this method. 325N/A * @throws IllegalArgumentException 325N/A * if the given header is not {@link #contains(Object) contained} 325N/A * Gets the first {@link Header} of the specified name. 325N/A * @param markAsUnderstood 325N/A * If this parameter is true, the returned header will 325N/A * be marked as <a href="#MU">"understood"</a>. 325N/A * @return null if not found. 325N/A * Use {@link #get(String, String, boolean)} 325N/A * Gets the first {@link Header} of the specified name. 325N/A * @param markAsUnderstood 325N/A * If this parameter is true, the returned header will 325N/A * be marked as <a href="#MU">"understood"</a>. 325N/A * Use {@link #get(QName)} 325N/A * Use {@link #getHeaders(String, String, boolean)} 325N/A * Gets all the {@link Header}s of the specified name, 325N/A * including duplicates (if any.) 325N/A * @param markAsUnderstood 325N/A * If this parameter is true, the returned headers will 325N/A * be marked as <a href="#MU">"understood"</a> when they are returned 325N/A * from {@link Iterator#next()}. 325N/A * @return empty iterator if not found. 325N/A * @see #getHeaders(String, String, boolean) 325N/A * use {@link #getHeaders(String, boolean)}. 325N/A * Gets an iteration of headers {@link Header} in the specified namespace, 325N/A * including duplicates (if any.) 325N/A * @param markAsUnderstood 325N/A * If this parameter is true, the returned headers will 325N/A * be marked as <a href="#MU">"understood"</a> when they are returned 325N/A * from {@link Iterator#next()}. 325N/A * empty iterator if not found. 325N/A * Gets the first {@link Header} of the specified name targeted at the 325N/A * current implicit role. 325N/A * @param name name of the header 325N/A * @param markUnderstood 325N/A * If this parameter is true, the returned headers will 325N/A * be marked as <a href="#MU">"understood"</a> when they are returned 325N/A * from {@link Iterator#next()}. 325N/A * @return null if header not found 325N/A * Returns the value of WS-Addressing <code>To</code> header. The <code>version</code> 325N/A * identifies the WS-Addressing version and the header returned is targeted at 325N/A * the current implicit role. Caches the value for subsequent invocation. 325N/A * Duplicate <code>To</code> headers are detected earlier. 325N/A * @param av WS-Addressing version 325N/A * @param sv SOAP version 325N/A * @throws IllegalArgumentException if either <code>av</code> or <code>sv</code> is null. 325N/A * @return Value of WS-Addressing To header, anonymous URI if no header is present 325N/A * Returns the value of WS-Addressing <code>Action</code> header. The <code>version</code> 325N/A * identifies the WS-Addressing version and the header returned is targeted at 325N/A * the current implicit role. Caches the value for subsequent invocation. 325N/A * Duplicate <code>Action</code> headers are detected earlier. 325N/A * @param av WS-Addressing version 325N/A * @param sv SOAP version 325N/A * @throws IllegalArgumentException if either <code>av</code> or <code>sv</code> is null. 325N/A * @return Value of WS-Addressing Action header, null if no header is present 325N/A * Returns the value of WS-Addressing <code>ReplyTo</code> header. The <code>version</code> 325N/A * identifies the WS-Addressing version and the header returned is targeted at 325N/A * the current implicit role. Caches the value for subsequent invocation. 325N/A * Duplicate <code>ReplyTo</code> headers are detected earlier. 325N/A * @param av WS-Addressing version 325N/A * @param sv SOAP version 325N/A * @throws IllegalArgumentException if either <code>av</code> or <code>sv</code> is null. 325N/A * @return Value of WS-Addressing ReplyTo header, null if no header is present 325N/A * Returns the value of WS-Addressing <code>FaultTo</code> header. The <code>version</code> 325N/A * identifies the WS-Addressing version and the header returned is targeted at 325N/A * the current implicit role. Caches the value for subsequent invocation. 325N/A * Duplicate <code>FaultTo</code> headers are detected earlier. 325N/A * @param av WS-Addressing version 325N/A * @param sv SOAP version 325N/A * @throws IllegalArgumentException if either <code>av</code> or <code>sv</code> is null. 325N/A * @return Value of WS-Addressing FaultTo header, null if no header is present 325N/A * Returns the value of WS-Addressing <code>MessageID</code> header. The <code>version</code> 325N/A * identifies the WS-Addressing version and the header returned is targeted at 325N/A * the current implicit role. Caches the value for subsequent invocation. 325N/A * Duplicate <code>MessageID</code> headers are detected earlier. 325N/A * @param av WS-Addressing version 325N/A * @param sv SOAP version 325N/A * @throws WebServiceException if either <code>av</code> or <code>sv</code> is null. 325N/A * @return Value of WS-Addressing MessageID header, null if no header is present 325N/A * Returns the value of WS-Addressing <code>RelatesTo</code> header. The <code>version</code> 325N/A * identifies the WS-Addressing version and the header returned is targeted at 325N/A * the current implicit role. Caches the value for subsequent invocation. 325N/A * Duplicate <code>RelatesTo</code> headers are detected earlier. 325N/A * @param av WS-Addressing version 325N/A * @param sv SOAP version 325N/A * @throws WebServiceException if either <code>av</code> or <code>sv</code> is null. 325N/A * @return Value of WS-Addressing RelatesTo header, null if no header is present 325N/A * Creates a set of outbound WS-Addressing headers on the client with the 325N/A * specified Action Message Addressing Property value. 325N/A * This method needs to be invoked right after such a Message is 325N/A * created which is error prone but so far only MEX, RM and JAX-WS 325N/A * creates a request so this ugliness is acceptable. This method is also used 325N/A * to create protocol messages that are not associated with any {@link WSBinding} 325N/A * and {@link WSDLPort}. 325N/A * @param packet request packet 325N/A * @param av WS-Addressing version 325N/A * @param sv SOAP version 325N/A * @param oneway Indicates if the message exchange pattern is oneway 325N/A * @param action Action Message Addressing Property value 325N/A * @param mustUnderstand to indicate if the addressing headers are set with mustUnderstand attribute 325N/A * Creates a set of outbound WS-Addressing headers on the client with the 325N/A * default Action Message Addressing Property value. 325N/A * This method needs to be invoked right after such a Message is 325N/A * created which is error prone but so far only MEX, RM and JAX-WS 325N/A * creates a request so this ugliness is acceptable. If more components 325N/A * are identified using this, then we may revisit this. 325N/A * This method is used if default Action Message Addressing Property is to 325N/A * {@link #fillRequestAddressingHeaders(Packet, com.sun.xml.internal.ws.api.addressing.AddressingVersion, com.sun.xml.internal.ws.api.SOAPVersion, boolean, String)} 325N/A * if non-default Action is to be used, for example when creating a protocol message not 325N/A * associated with {@link WSBinding} and {@link WSDLPort}. 325N/A * This method uses SOAPAction as the Action unless set expplicitly in the wsdl. 325N/A * @param wsdlPort request WSDL port 325N/A * @param binding request WSBinding 325N/A * @param packet request packet 325N/A //See if WSA headers are already set by the user. 325N/A //assume that all the WSA headers are set by the user 325N/A //seiModel is passed as null as it is not needed. 325N/A // if WSDL has <wsaw:Anonymous>prohibited</wsaw:Anonymous>, then throw an error 325N/A // as anonymous ReplyTo MUST NOT be added in that case. BindingProvider need to 325N/A // disable AddressingFeature and MemberSubmissionAddressingFeature and hand-craft 325N/A // add wsa:MessageID only for non-null ReplyTo 325N/A * Creates wsa:To, wsa:Action and wsa:MessageID header on the client 325N/A * @param packet request packet 325N/A * @param av WS-Addressing version 325N/A * @param sv SOAP version 325N/A * @param action Action Message Addressing Property value 325N/A * @throws IllegalArgumentException if any of the parameters is null. 325N/A //As per WS-I BP 1.2/2.0, if one of the WSA headers is MU, then all WSA headers should be treated as MU., 325N/A // so just set MU on action header 325N/A * Adds a new {@link Header}. 325N/A * Order doesn't matter in headers, so this method 325N/A * does not make any guarantee as to where the new header 325N/A * always true. Don't use the return value. 325N/A * Removes the first {@link Header} of the specified name. 325N/A * @param nsUri namespace URI of the header to remove 325N/A * @param localName local part of the FQN of the header to remove 325N/A * @return null if not found. 325N/A * Removes the first {@link Header} of the specified name. 325N/A * @param name fully qualified name of the header to remove 325N/A * @return null if not found. 325N/A * Removes the first {@link Header} of the specified name. 325N/A * @param index index of the header to remove 325N/A * @return removed header 325N/A * Removes the "understood" bit for header on the position specified by {@code index} parameter 325N/A * from the set of understood header bits. 325N/A * @param index position of the bit to remove 325N/A * R be the bit to be removed 325N/A * M be a more significant "upper" bit than bit R 325N/A * L be a less significant "lower" bit than bit R 325N/A * Then following 3 lines of code produce these results: 325N/A * old understoodBits = MMMMMMMMMMMMRLLLLLLLLLLLLLLLLLLL 325N/A * shiftedUpperBits = 0MMMMMMMMMMMM0000000000000000000 325N/A * lowerBits = 0000000000000LLLLLLLLLLLLLLLLLLL 325N/A * new understoodBits = 0MMMMMMMMMMMMLLLLLLLLLLLLLLLLLLL 325N/A * The R bit is removed and all the upper bits are shifted right (unsigned) 325N/A // remove bit set if the new size will be < 33 => we fit all bits into int 325N/A * Removes a single instance of the specified element from this 325N/A * header list, if it is present. More formally, 325N/A * removes a header <tt>h</tt> such that <tt>(o==null ? h==null : 325N/A * o.equals(h))</tt>, if the header list contains one or more such 325N/A * headers. Returns <tt>true</tt> if the list contained the 325N/A * specified element (or equivalently, if the list changed as a 325N/A * result of the call).<p> 325N/A * @param o element to be removed from this list, if present. 325N/A * @return <tt>true</tt> if the list contained the specified element. 325N/A * This handles null {@link HeaderList} correctly. 325N/A * Can be null, in which case null will be returned. 325N/A // TODO: validate client-inbound Action