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