aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package com.sun.xml.internal.ws.addressing; aoqi@0: aoqi@0: import com.sun.istack.internal.NotNull; aoqi@0: import com.sun.xml.internal.ws.addressing.model.ActionNotSupportedException; aoqi@0: import com.sun.xml.internal.ws.api.WSBinding; aoqi@0: import com.sun.xml.internal.ws.api.message.AddressingUtils; aoqi@0: import com.sun.xml.internal.ws.api.message.Packet; aoqi@0: import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation; aoqi@0: import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; aoqi@0: import com.sun.xml.internal.ws.api.pipe.NextAction; aoqi@0: import com.sun.xml.internal.ws.api.pipe.Tube; aoqi@0: import com.sun.xml.internal.ws.api.pipe.TubeCloner; aoqi@0: import com.sun.xml.internal.ws.resources.AddressingMessages; aoqi@0: aoqi@0: import javax.xml.ws.WebServiceException; aoqi@0: aoqi@0: /** aoqi@0: * WsaClientTube appears in the Tubeline only if addressing is enabled. aoqi@0: * This tube checks the validity of addressing headers in the incoming messages aoqi@0: * based on the WSDL model. aoqi@0: * @author Rama Pulavarthi aoqi@0: * @author Arun Gupta aoqi@0: */ aoqi@0: public class WsaClientTube extends WsaTube { aoqi@0: // capture if the request expects a reply so that it can be used to aoqi@0: // determine if its oneway for response validation. aoqi@0: protected boolean expectReply = true; aoqi@0: public WsaClientTube(WSDLPort wsdlPort, WSBinding binding, Tube next) { aoqi@0: super(wsdlPort, binding, next); aoqi@0: } aoqi@0: aoqi@0: public WsaClientTube(WsaClientTube that, TubeCloner cloner) { aoqi@0: super(that, cloner); aoqi@0: } aoqi@0: aoqi@0: public WsaClientTube copy(TubeCloner cloner) { aoqi@0: return new WsaClientTube(this, cloner); aoqi@0: } aoqi@0: aoqi@0: @Override aoqi@0: public @NotNull NextAction processRequest(Packet request) { aoqi@0: expectReply = request.expectReply; aoqi@0: return doInvoke(next,request); aoqi@0: } aoqi@0: aoqi@0: @Override aoqi@0: public @NotNull NextAction processResponse(Packet response) { aoqi@0: // if one-way then, no validation aoqi@0: if (response.getMessage() != null) { aoqi@0: response = validateInboundHeaders(response); aoqi@0: response.addSatellite(new WsaPropertyBag(addressingVersion,soapVersion,response)); aoqi@0: String msgId = AddressingUtils. aoqi@0: getMessageID(response.getMessage().getHeaders(), aoqi@0: addressingVersion, soapVersion); aoqi@0: response.put(WsaPropertyBag.WSA_MSGID_FROM_REQUEST, msgId); aoqi@0: } aoqi@0: aoqi@0: return doReturnWith(response); aoqi@0: } aoqi@0: aoqi@0: aoqi@0: @Override aoqi@0: protected void validateAction(Packet packet) { aoqi@0: //There may not be a WSDL operation. There may not even be a WSDL. aoqi@0: //For instance this may be a RM CreateSequence message. aoqi@0: WSDLBoundOperation wbo = getWSDLBoundOperation(packet); aoqi@0: aoqi@0: if (wbo == null) return; aoqi@0: aoqi@0: String gotA = AddressingUtils.getAction( aoqi@0: packet.getMessage().getHeaders(), aoqi@0: addressingVersion, soapVersion); aoqi@0: if (gotA == null) aoqi@0: throw new WebServiceException(AddressingMessages.VALIDATION_CLIENT_NULL_ACTION()); aoqi@0: aoqi@0: String expected = helper.getOutputAction(packet); aoqi@0: aoqi@0: if (expected != null && !gotA.equals(expected)) aoqi@0: throw new ActionNotSupportedException(gotA); aoqi@0: } aoqi@0: aoqi@0: }