Thu, 31 Aug 2017 15:18:52 +0800
merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. Oracle designates this |
aoqi@0 | 8 | * particular file as subject to the "Classpath" exception as provided |
aoqi@0 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
aoqi@0 | 10 | * |
aoqi@0 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 15 | * accompanied this code). |
aoqi@0 | 16 | * |
aoqi@0 | 17 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 20 | * |
aoqi@0 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 22 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 23 | * questions. |
aoqi@0 | 24 | */ |
aoqi@0 | 25 | |
aoqi@0 | 26 | package com.sun.xml.internal.ws.addressing; |
aoqi@0 | 27 | |
aoqi@0 | 28 | import com.sun.istack.internal.NotNull; |
aoqi@0 | 29 | import com.sun.xml.internal.ws.addressing.model.InvalidAddressingHeaderException; |
aoqi@0 | 30 | import com.sun.xml.internal.ws.addressing.model.MissingAddressingHeaderException; |
aoqi@0 | 31 | import com.sun.xml.internal.ws.api.SOAPVersion; |
aoqi@0 | 32 | import com.sun.xml.internal.ws.api.WSBinding; |
aoqi@0 | 33 | import com.sun.xml.internal.ws.api.addressing.AddressingVersion; |
aoqi@0 | 34 | import com.sun.xml.internal.ws.api.message.AddressingUtils; |
aoqi@0 | 35 | import com.sun.xml.internal.ws.api.message.Header; |
aoqi@0 | 36 | import com.sun.xml.internal.ws.api.message.Message; |
aoqi@0 | 37 | import com.sun.xml.internal.ws.api.message.Messages; |
aoqi@0 | 38 | import com.sun.xml.internal.ws.api.message.Packet; |
aoqi@0 | 39 | import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation; |
aoqi@0 | 40 | import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; |
aoqi@0 | 41 | import com.sun.xml.internal.ws.api.pipe.NextAction; |
aoqi@0 | 42 | import com.sun.xml.internal.ws.api.pipe.Tube; |
aoqi@0 | 43 | import com.sun.xml.internal.ws.api.pipe.TubeCloner; |
aoqi@0 | 44 | import com.sun.xml.internal.ws.api.pipe.helper.AbstractFilterTubeImpl; |
aoqi@0 | 45 | import com.sun.xml.internal.ws.developer.MemberSubmissionAddressingFeature; |
aoqi@0 | 46 | import com.sun.xml.internal.ws.message.FaultDetailHeader; |
aoqi@0 | 47 | import com.sun.xml.internal.ws.resources.AddressingMessages; |
aoqi@0 | 48 | |
aoqi@0 | 49 | import javax.xml.namespace.QName; |
aoqi@0 | 50 | import javax.xml.soap.SOAPFault; |
aoqi@0 | 51 | import javax.xml.stream.XMLStreamException; |
aoqi@0 | 52 | import javax.xml.ws.WebServiceException; |
aoqi@0 | 53 | import javax.xml.ws.soap.AddressingFeature; |
aoqi@0 | 54 | import javax.xml.ws.soap.SOAPBinding; |
aoqi@0 | 55 | import java.util.Iterator; |
aoqi@0 | 56 | import java.util.logging.Logger; |
aoqi@0 | 57 | import java.util.logging.Level; |
aoqi@0 | 58 | |
aoqi@0 | 59 | /** |
aoqi@0 | 60 | * WS-Addressing processing code shared between client and server. |
aoqi@0 | 61 | * |
aoqi@0 | 62 | * <p> |
aoqi@0 | 63 | * This tube is used only when WS-Addressing is enabled. |
aoqi@0 | 64 | * |
aoqi@0 | 65 | * @author Rama Pulavarthi |
aoqi@0 | 66 | * @author Arun Gupta |
aoqi@0 | 67 | */ |
aoqi@0 | 68 | abstract class WsaTube extends AbstractFilterTubeImpl { |
aoqi@0 | 69 | /** |
aoqi@0 | 70 | * Port that we are processing. |
aoqi@0 | 71 | */ |
aoqi@0 | 72 | protected final @NotNull WSDLPort wsdlPort; |
aoqi@0 | 73 | protected final WSBinding binding; |
aoqi@0 | 74 | final WsaTubeHelper helper; |
aoqi@0 | 75 | protected final @NotNull AddressingVersion addressingVersion; |
aoqi@0 | 76 | protected final SOAPVersion soapVersion; |
aoqi@0 | 77 | |
aoqi@0 | 78 | /** |
aoqi@0 | 79 | * True if the addressing headers are mandatory. |
aoqi@0 | 80 | */ |
aoqi@0 | 81 | private final boolean addressingRequired; |
aoqi@0 | 82 | |
aoqi@0 | 83 | public WsaTube(WSDLPort wsdlPort, WSBinding binding, Tube next) { |
aoqi@0 | 84 | super(next); |
aoqi@0 | 85 | this.wsdlPort = wsdlPort; |
aoqi@0 | 86 | this.binding = binding; |
aoqi@0 | 87 | addKnownHeadersToBinding(binding); |
aoqi@0 | 88 | addressingVersion = binding.getAddressingVersion(); |
aoqi@0 | 89 | soapVersion = binding.getSOAPVersion(); |
aoqi@0 | 90 | helper = getTubeHelper(); |
aoqi@0 | 91 | addressingRequired = AddressingVersion.isRequired(binding); |
aoqi@0 | 92 | } |
aoqi@0 | 93 | |
aoqi@0 | 94 | public WsaTube(WsaTube that, TubeCloner cloner) { |
aoqi@0 | 95 | super(that, cloner); |
aoqi@0 | 96 | this.wsdlPort = that.wsdlPort; |
aoqi@0 | 97 | this.binding = that.binding; |
aoqi@0 | 98 | this.helper = that.helper; |
aoqi@0 | 99 | addressingVersion = that.addressingVersion; |
aoqi@0 | 100 | soapVersion = that.soapVersion; |
aoqi@0 | 101 | addressingRequired = that.addressingRequired; |
aoqi@0 | 102 | } |
aoqi@0 | 103 | |
aoqi@0 | 104 | private void addKnownHeadersToBinding(WSBinding binding) { |
aoqi@0 | 105 | for (AddressingVersion addrVersion: AddressingVersion.values()) { |
aoqi@0 | 106 | binding.addKnownHeader(addrVersion.actionTag); |
aoqi@0 | 107 | binding.addKnownHeader(addrVersion.faultDetailTag); |
aoqi@0 | 108 | binding.addKnownHeader(addrVersion.faultToTag); |
aoqi@0 | 109 | binding.addKnownHeader(addrVersion.fromTag); |
aoqi@0 | 110 | binding.addKnownHeader(addrVersion.messageIDTag); |
aoqi@0 | 111 | binding.addKnownHeader(addrVersion.relatesToTag); |
aoqi@0 | 112 | binding.addKnownHeader(addrVersion.replyToTag); |
aoqi@0 | 113 | binding.addKnownHeader(addrVersion.toTag); |
aoqi@0 | 114 | } |
aoqi@0 | 115 | } |
aoqi@0 | 116 | |
aoqi@0 | 117 | @Override |
aoqi@0 | 118 | public @NotNull NextAction processException(Throwable t) { |
aoqi@0 | 119 | return super.processException(t); |
aoqi@0 | 120 | } |
aoqi@0 | 121 | |
aoqi@0 | 122 | protected WsaTubeHelper getTubeHelper() { |
aoqi@0 | 123 | if(binding.isFeatureEnabled(AddressingFeature.class)) { |
aoqi@0 | 124 | return new WsaTubeHelperImpl(wsdlPort, null, binding); |
aoqi@0 | 125 | } else if(binding.isFeatureEnabled(MemberSubmissionAddressingFeature.class)) { |
aoqi@0 | 126 | //seiModel is null as it is not needed. |
aoqi@0 | 127 | return new com.sun.xml.internal.ws.addressing.v200408.WsaTubeHelperImpl(wsdlPort, null, binding); |
aoqi@0 | 128 | } else { |
aoqi@0 | 129 | // Addressing is not enabled, WsaTube should not be included in the pipeline |
aoqi@0 | 130 | throw new WebServiceException(AddressingMessages.ADDRESSING_NOT_ENABLED(this.getClass().getSimpleName())); |
aoqi@0 | 131 | } |
aoqi@0 | 132 | } |
aoqi@0 | 133 | |
aoqi@0 | 134 | /** |
aoqi@0 | 135 | * Validates the inbound message. If an error is found, create |
aoqi@0 | 136 | * a fault message and returns that. Otherwise |
aoqi@0 | 137 | * it will pass through the parameter 'packet' object to the return value. |
aoqi@0 | 138 | */ |
aoqi@0 | 139 | protected Packet validateInboundHeaders(Packet packet) { |
aoqi@0 | 140 | SOAPFault soapFault; |
aoqi@0 | 141 | FaultDetailHeader s11FaultDetailHeader; |
aoqi@0 | 142 | |
aoqi@0 | 143 | try { |
aoqi@0 | 144 | checkMessageAddressingProperties(packet); |
aoqi@0 | 145 | return packet; |
aoqi@0 | 146 | } catch (InvalidAddressingHeaderException e) { |
aoqi@0 | 147 | LOGGER.log(Level.WARNING, |
aoqi@0 | 148 | addressingVersion.getInvalidMapText()+", Problem header:" + e.getProblemHeader()+ ", Reason: "+ e.getSubsubcode(),e); |
aoqi@0 | 149 | soapFault = helper.createInvalidAddressingHeaderFault(e, addressingVersion); |
aoqi@0 | 150 | s11FaultDetailHeader = new FaultDetailHeader(addressingVersion, addressingVersion.problemHeaderQNameTag.getLocalPart(), e.getProblemHeader()); |
aoqi@0 | 151 | } catch (MissingAddressingHeaderException e) { |
aoqi@0 | 152 | LOGGER.log(Level.WARNING,addressingVersion.getMapRequiredText()+", Problem header:"+ e.getMissingHeaderQName(),e); |
aoqi@0 | 153 | soapFault = helper.newMapRequiredFault(e); |
aoqi@0 | 154 | s11FaultDetailHeader = new FaultDetailHeader(addressingVersion, addressingVersion.problemHeaderQNameTag.getLocalPart(), e.getMissingHeaderQName()); |
aoqi@0 | 155 | } |
aoqi@0 | 156 | |
aoqi@0 | 157 | if (soapFault != null) { |
aoqi@0 | 158 | // WS-A fault processing for one-way methods |
aoqi@0 | 159 | if ((wsdlPort !=null) && packet.getMessage().isOneWay(wsdlPort)) { |
aoqi@0 | 160 | return packet.createServerResponse(null, wsdlPort, null, binding); |
aoqi@0 | 161 | } |
aoqi@0 | 162 | |
aoqi@0 | 163 | Message m = Messages.create(soapFault); |
aoqi@0 | 164 | if (soapVersion == SOAPVersion.SOAP_11) { |
aoqi@0 | 165 | m.getHeaders().add(s11FaultDetailHeader); |
aoqi@0 | 166 | } |
aoqi@0 | 167 | |
aoqi@0 | 168 | return packet.createServerResponse(m, wsdlPort, null, binding); |
aoqi@0 | 169 | } |
aoqi@0 | 170 | |
aoqi@0 | 171 | return packet; |
aoqi@0 | 172 | } |
aoqi@0 | 173 | |
aoqi@0 | 174 | /** |
aoqi@0 | 175 | * This method checks all the WS-Addressing headers are valid and as per the spec definded rules. |
aoqi@0 | 176 | * Mainly it checks the cardinality of the WSA headers and checks that mandatory headers exist. |
aoqi@0 | 177 | * It also checks if the SOAPAction is equal to wsa:Action value when non-empty. |
aoqi@0 | 178 | * |
aoqi@0 | 179 | * Override this method if you need to additional checking of headers other than just existence of the headers. |
aoqi@0 | 180 | * For ex: On server-side, check Anonymous and Non-Anonymous semantics in addition to checking cardinality. |
aoqi@0 | 181 | * |
aoqi@0 | 182 | * Override checkMandatoryHeaders(Packet p) to have different validation rules for different versions |
aoqi@0 | 183 | * |
aoqi@0 | 184 | * @param packet |
aoqi@0 | 185 | */ |
aoqi@0 | 186 | protected void checkMessageAddressingProperties(Packet packet) { |
aoqi@0 | 187 | checkCardinality(packet); |
aoqi@0 | 188 | } |
aoqi@0 | 189 | |
aoqi@0 | 190 | final boolean isAddressingEngagedOrRequired(Packet packet, WSBinding binding) { |
aoqi@0 | 191 | if (AddressingVersion.isRequired(binding)) |
aoqi@0 | 192 | return true; |
aoqi@0 | 193 | |
aoqi@0 | 194 | if (packet == null) |
aoqi@0 | 195 | return false; |
aoqi@0 | 196 | |
aoqi@0 | 197 | if (packet.getMessage() == null) |
aoqi@0 | 198 | return false; |
aoqi@0 | 199 | |
aoqi@0 | 200 | if (packet.getMessage().getHeaders() != null) |
aoqi@0 | 201 | return false; |
aoqi@0 | 202 | |
aoqi@0 | 203 | String action = AddressingUtils.getAction( |
aoqi@0 | 204 | packet.getMessage().getHeaders(), |
aoqi@0 | 205 | addressingVersion, soapVersion); |
aoqi@0 | 206 | if (action == null) |
aoqi@0 | 207 | return true; |
aoqi@0 | 208 | |
aoqi@0 | 209 | return true; |
aoqi@0 | 210 | } |
aoqi@0 | 211 | |
aoqi@0 | 212 | /** |
aoqi@0 | 213 | * Checks the cardinality of WS-Addressing headers on an inbound {@link Packet}. This method |
aoqi@0 | 214 | * checks for the cardinality if WS-Addressing is engaged (detected by the presence of wsa:Action |
aoqi@0 | 215 | * header) or wsdl:required=true. |
aoqi@0 | 216 | * |
aoqi@0 | 217 | * @param packet The inbound packet. |
aoqi@0 | 218 | * @throws WebServiceException if: |
aoqi@0 | 219 | * <ul> |
aoqi@0 | 220 | * <li>there is an error reading ReplyTo or FaultTo</li> |
aoqi@0 | 221 | * <li>WS-Addressing is required and {@link Message} within <code>packet</code> is null</li> |
aoqi@0 | 222 | * <li>WS-Addressing is required and no headers are found in the {@link Message}</li> |
aoqi@0 | 223 | * <li>an uknown WS-Addressing header is present</li> |
aoqi@0 | 224 | * </ul> |
aoqi@0 | 225 | */ |
aoqi@0 | 226 | protected void checkCardinality(Packet packet) { |
aoqi@0 | 227 | Message message = packet.getMessage(); |
aoqi@0 | 228 | if (message == null) { |
aoqi@0 | 229 | if (addressingRequired) |
aoqi@0 | 230 | throw new WebServiceException(AddressingMessages.NULL_MESSAGE()); |
aoqi@0 | 231 | else |
aoqi@0 | 232 | return; |
aoqi@0 | 233 | } |
aoqi@0 | 234 | |
aoqi@0 | 235 | Iterator<Header> hIter = message.getHeaders().getHeaders(addressingVersion.nsUri, true); |
aoqi@0 | 236 | |
aoqi@0 | 237 | if (!hIter.hasNext()) { |
aoqi@0 | 238 | // no WS-A headers are found |
aoqi@0 | 239 | if (addressingRequired) |
aoqi@0 | 240 | // if WS-A is required, then throw an exception looking for wsa:Action header |
aoqi@0 | 241 | throw new MissingAddressingHeaderException(addressingVersion.actionTag,packet); |
aoqi@0 | 242 | else |
aoqi@0 | 243 | // else no need to process |
aoqi@0 | 244 | return; |
aoqi@0 | 245 | } |
aoqi@0 | 246 | |
aoqi@0 | 247 | boolean foundFrom = false; |
aoqi@0 | 248 | boolean foundTo = false; |
aoqi@0 | 249 | boolean foundReplyTo = false; |
aoqi@0 | 250 | boolean foundFaultTo = false; |
aoqi@0 | 251 | boolean foundAction = false; |
aoqi@0 | 252 | boolean foundMessageId = false; |
aoqi@0 | 253 | boolean foundRelatesTo = false; |
aoqi@0 | 254 | QName duplicateHeader = null; |
aoqi@0 | 255 | |
aoqi@0 | 256 | while (hIter.hasNext()) { |
aoqi@0 | 257 | Header h = hIter.next(); |
aoqi@0 | 258 | |
aoqi@0 | 259 | // check if the Header is in current role |
aoqi@0 | 260 | if (!isInCurrentRole(h, binding)) { |
aoqi@0 | 261 | continue; |
aoqi@0 | 262 | } |
aoqi@0 | 263 | |
aoqi@0 | 264 | String local = h.getLocalPart(); |
aoqi@0 | 265 | if (local.equals(addressingVersion.fromTag.getLocalPart())) { |
aoqi@0 | 266 | if (foundFrom) { |
aoqi@0 | 267 | duplicateHeader = addressingVersion.fromTag; |
aoqi@0 | 268 | break; |
aoqi@0 | 269 | } |
aoqi@0 | 270 | foundFrom = true; |
aoqi@0 | 271 | } else if (local.equals(addressingVersion.toTag.getLocalPart())) { |
aoqi@0 | 272 | if (foundTo) { |
aoqi@0 | 273 | duplicateHeader = addressingVersion.toTag; |
aoqi@0 | 274 | break; |
aoqi@0 | 275 | } |
aoqi@0 | 276 | foundTo = true; |
aoqi@0 | 277 | } else if (local.equals(addressingVersion.replyToTag.getLocalPart())) { |
aoqi@0 | 278 | if (foundReplyTo) { |
aoqi@0 | 279 | duplicateHeader = addressingVersion.replyToTag; |
aoqi@0 | 280 | break; |
aoqi@0 | 281 | } |
aoqi@0 | 282 | foundReplyTo = true; |
aoqi@0 | 283 | try { // verify that the header is in a good shape |
aoqi@0 | 284 | h.readAsEPR(addressingVersion); |
aoqi@0 | 285 | } catch (XMLStreamException e) { |
aoqi@0 | 286 | throw new WebServiceException(AddressingMessages.REPLY_TO_CANNOT_PARSE(), e); |
aoqi@0 | 287 | } |
aoqi@0 | 288 | } else if (local.equals(addressingVersion.faultToTag.getLocalPart())) { |
aoqi@0 | 289 | if (foundFaultTo) { |
aoqi@0 | 290 | duplicateHeader = addressingVersion.faultToTag; |
aoqi@0 | 291 | break; |
aoqi@0 | 292 | } |
aoqi@0 | 293 | foundFaultTo = true; |
aoqi@0 | 294 | try { // verify that the header is in a good shape |
aoqi@0 | 295 | h.readAsEPR(addressingVersion); |
aoqi@0 | 296 | } catch (XMLStreamException e) { |
aoqi@0 | 297 | throw new WebServiceException(AddressingMessages.FAULT_TO_CANNOT_PARSE(), e); |
aoqi@0 | 298 | } |
aoqi@0 | 299 | } else if (local.equals(addressingVersion.actionTag.getLocalPart())) { |
aoqi@0 | 300 | if (foundAction) { |
aoqi@0 | 301 | duplicateHeader = addressingVersion.actionTag; |
aoqi@0 | 302 | break; |
aoqi@0 | 303 | } |
aoqi@0 | 304 | foundAction = true; |
aoqi@0 | 305 | } else if (local.equals(addressingVersion.messageIDTag.getLocalPart())) { |
aoqi@0 | 306 | if (foundMessageId) { |
aoqi@0 | 307 | duplicateHeader = addressingVersion.messageIDTag; |
aoqi@0 | 308 | break; |
aoqi@0 | 309 | } |
aoqi@0 | 310 | foundMessageId = true; |
aoqi@0 | 311 | } else if (local.equals(addressingVersion.relatesToTag.getLocalPart())) { |
aoqi@0 | 312 | foundRelatesTo = true; |
aoqi@0 | 313 | } else if (local.equals(addressingVersion.faultDetailTag.getLocalPart())) { |
aoqi@0 | 314 | // TODO: should anything be done here ? |
aoqi@0 | 315 | // TODO: fault detail element - only for SOAP 1.1 |
aoqi@0 | 316 | } else { |
aoqi@0 | 317 | System.err.println(AddressingMessages.UNKNOWN_WSA_HEADER()); |
aoqi@0 | 318 | } |
aoqi@0 | 319 | } |
aoqi@0 | 320 | |
aoqi@0 | 321 | // check for invalid cardinality first before checking for mandatory headers |
aoqi@0 | 322 | if (duplicateHeader != null) { |
aoqi@0 | 323 | throw new InvalidAddressingHeaderException(duplicateHeader, addressingVersion.invalidCardinalityTag); |
aoqi@0 | 324 | } |
aoqi@0 | 325 | |
aoqi@0 | 326 | // WS-A is engaged if wsa:Action header is found |
aoqi@0 | 327 | boolean engaged = foundAction; |
aoqi@0 | 328 | |
aoqi@0 | 329 | // check for mandatory set of headers only if: |
aoqi@0 | 330 | // 1. WS-A is engaged or |
aoqi@0 | 331 | // 2. wsdl:required=true |
aoqi@0 | 332 | // Both wsa:Action and wsa:To MUST be present on request (for oneway MEP) and |
aoqi@0 | 333 | // response messages (for oneway and request/response MEP only) |
aoqi@0 | 334 | if (engaged || addressingRequired) { |
aoqi@0 | 335 | // Check for mandatory headers always (even for Protocol messages). |
aoqi@0 | 336 | // If it breaks any interop scenarios, Remove the comments. |
aoqi@0 | 337 | /* |
aoqi@0 | 338 | WSDLBoundOperation wbo = getWSDLBoundOperation(packet); |
aoqi@0 | 339 | // no need to check for for non-application messages |
aoqi@0 | 340 | if (wbo == null) |
aoqi@0 | 341 | return; |
aoqi@0 | 342 | */ |
aoqi@0 | 343 | checkMandatoryHeaders(packet, foundAction, foundTo, foundReplyTo, |
aoqi@0 | 344 | foundFaultTo, foundMessageId, foundRelatesTo); |
aoqi@0 | 345 | } |
aoqi@0 | 346 | } |
aoqi@0 | 347 | |
aoqi@0 | 348 | final boolean isInCurrentRole(Header header, WSBinding binding) { |
aoqi@0 | 349 | // TODO: binding will be null for protocol messages |
aoqi@0 | 350 | // TODO: returning true assumes that protocol messages are |
aoqi@0 | 351 | // TODO: always in current role, this may not to be fixed. |
aoqi@0 | 352 | if (binding == null) |
aoqi@0 | 353 | return true; |
aoqi@0 | 354 | return ((SOAPBinding)binding).getRoles().contains(header.getRole(soapVersion)); |
aoqi@0 | 355 | |
aoqi@0 | 356 | } |
aoqi@0 | 357 | |
aoqi@0 | 358 | protected final WSDLBoundOperation getWSDLBoundOperation(Packet packet) { |
aoqi@0 | 359 | //we can find Req/Response or Oneway only with WSDLModel |
aoqi@0 | 360 | if(wsdlPort == null) |
aoqi@0 | 361 | return null; |
aoqi@0 | 362 | QName opName = packet.getWSDLOperation(); |
aoqi@0 | 363 | if(opName != null) |
aoqi@0 | 364 | return wsdlPort.getBinding().get(opName); |
aoqi@0 | 365 | return null; |
aoqi@0 | 366 | } |
aoqi@0 | 367 | |
aoqi@0 | 368 | protected void validateSOAPAction(Packet packet) { |
aoqi@0 | 369 | String gotA = AddressingUtils.getAction( |
aoqi@0 | 370 | packet.getMessage().getHeaders(), |
aoqi@0 | 371 | addressingVersion, soapVersion); |
aoqi@0 | 372 | if (gotA == null) |
aoqi@0 | 373 | throw new WebServiceException(AddressingMessages.VALIDATION_SERVER_NULL_ACTION()); |
aoqi@0 | 374 | if(packet.soapAction != null && !packet.soapAction.equals("\"\"") && !packet.soapAction.equals("\""+gotA+"\"")) { |
aoqi@0 | 375 | throw new InvalidAddressingHeaderException(addressingVersion.actionTag, addressingVersion.actionMismatchTag); |
aoqi@0 | 376 | } |
aoqi@0 | 377 | } |
aoqi@0 | 378 | |
aoqi@0 | 379 | protected abstract void validateAction(Packet packet); |
aoqi@0 | 380 | |
aoqi@0 | 381 | /** |
aoqi@0 | 382 | * This should be called only when Addressing is engaged. |
aoqi@0 | 383 | * |
aoqi@0 | 384 | * Checks only for presence of wsa:Action and validates that wsa:Action |
aoqi@0 | 385 | * equals SOAPAction header when non-empty |
aoqi@0 | 386 | * Should be overridden if other wsa headers need to be checked based on version. |
aoqi@0 | 387 | * |
aoqi@0 | 388 | * @param packet |
aoqi@0 | 389 | * @param foundAction |
aoqi@0 | 390 | * @param foundTo |
aoqi@0 | 391 | * @param foundReplyTo |
aoqi@0 | 392 | * @param foundFaultTo |
aoqi@0 | 393 | * @param foundMessageId |
aoqi@0 | 394 | * @param foundRelatesTo |
aoqi@0 | 395 | */ |
aoqi@0 | 396 | protected void checkMandatoryHeaders( |
aoqi@0 | 397 | Packet packet, boolean foundAction, boolean foundTo, boolean foundReplyTo, |
aoqi@0 | 398 | boolean foundFaultTo, boolean foundMessageId, boolean foundRelatesTo) { |
aoqi@0 | 399 | // if no wsa:Action header is found |
aoqi@0 | 400 | if (!foundAction) |
aoqi@0 | 401 | throw new MissingAddressingHeaderException(addressingVersion.actionTag,packet); |
aoqi@0 | 402 | validateSOAPAction(packet); |
aoqi@0 | 403 | } |
aoqi@0 | 404 | private static final Logger LOGGER = Logger.getLogger(WsaTube.class.getName()); |
aoqi@0 | 405 | } |