1 /* |
1 /* |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
28 import com.sun.istack.internal.NotNull; |
28 import com.sun.istack.internal.NotNull; |
29 import com.sun.xml.internal.ws.addressing.model.InvalidAddressingHeaderException; |
29 import com.sun.xml.internal.ws.addressing.model.InvalidAddressingHeaderException; |
30 import com.sun.xml.internal.ws.addressing.model.MissingAddressingHeaderException; |
30 import com.sun.xml.internal.ws.addressing.model.MissingAddressingHeaderException; |
31 import com.sun.xml.internal.ws.api.SOAPVersion; |
31 import com.sun.xml.internal.ws.api.SOAPVersion; |
32 import com.sun.xml.internal.ws.api.WSBinding; |
32 import com.sun.xml.internal.ws.api.WSBinding; |
33 import com.sun.xml.internal.ws.api.server.WSEndpoint; |
|
34 import com.sun.xml.internal.ws.api.addressing.AddressingVersion; |
33 import com.sun.xml.internal.ws.api.addressing.AddressingVersion; |
|
34 import com.sun.xml.internal.ws.api.message.AddressingUtils; |
35 import com.sun.xml.internal.ws.api.message.Header; |
35 import com.sun.xml.internal.ws.api.message.Header; |
36 import com.sun.xml.internal.ws.api.message.Message; |
36 import com.sun.xml.internal.ws.api.message.Message; |
37 import com.sun.xml.internal.ws.api.message.Messages; |
37 import com.sun.xml.internal.ws.api.message.Messages; |
38 import com.sun.xml.internal.ws.api.message.Packet; |
38 import com.sun.xml.internal.ws.api.message.Packet; |
39 import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation; |
39 import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation; |
41 import com.sun.xml.internal.ws.api.pipe.NextAction; |
41 import com.sun.xml.internal.ws.api.pipe.NextAction; |
42 import com.sun.xml.internal.ws.api.pipe.Tube; |
42 import com.sun.xml.internal.ws.api.pipe.Tube; |
43 import com.sun.xml.internal.ws.api.pipe.TubeCloner; |
43 import com.sun.xml.internal.ws.api.pipe.TubeCloner; |
44 import com.sun.xml.internal.ws.api.pipe.helper.AbstractFilterTubeImpl; |
44 import com.sun.xml.internal.ws.api.pipe.helper.AbstractFilterTubeImpl; |
45 import com.sun.xml.internal.ws.developer.MemberSubmissionAddressingFeature; |
45 import com.sun.xml.internal.ws.developer.MemberSubmissionAddressingFeature; |
46 import com.sun.xml.internal.ws.developer.WSBindingProvider; |
|
47 import com.sun.xml.internal.ws.message.FaultDetailHeader; |
46 import com.sun.xml.internal.ws.message.FaultDetailHeader; |
48 import com.sun.xml.internal.ws.resources.AddressingMessages; |
47 import com.sun.xml.internal.ws.resources.AddressingMessages; |
49 import com.sun.xml.internal.ws.binding.BindingImpl; |
|
50 |
48 |
51 import javax.xml.namespace.QName; |
49 import javax.xml.namespace.QName; |
52 import javax.xml.soap.SOAPFault; |
50 import javax.xml.soap.SOAPFault; |
53 import javax.xml.stream.XMLStreamException; |
51 import javax.xml.stream.XMLStreamException; |
54 import javax.xml.ws.WebServiceException; |
52 import javax.xml.ws.WebServiceException; |
55 import javax.xml.ws.Binding; |
|
56 import javax.xml.ws.soap.AddressingFeature; |
53 import javax.xml.ws.soap.AddressingFeature; |
57 import javax.xml.ws.soap.SOAPBinding; |
54 import javax.xml.ws.soap.SOAPBinding; |
58 import java.util.Iterator; |
55 import java.util.Iterator; |
59 import java.util.Set; |
|
60 import java.util.Arrays; |
|
61 import java.util.logging.Logger; |
56 import java.util.logging.Logger; |
62 import java.util.logging.Level; |
57 import java.util.logging.Level; |
63 |
58 |
64 /** |
59 /** |
65 * WS-Addressing processing code shared between client and server. |
60 * WS-Addressing processing code shared between client and server. |
105 soapVersion = that.soapVersion; |
100 soapVersion = that.soapVersion; |
106 addressingRequired = that.addressingRequired; |
101 addressingRequired = that.addressingRequired; |
107 } |
102 } |
108 |
103 |
109 private void addKnownHeadersToBinding(WSBinding binding) { |
104 private void addKnownHeadersToBinding(WSBinding binding) { |
110 Set<QName> headerQNames = binding.getKnownHeaders(); |
|
111 for (AddressingVersion addrVersion: AddressingVersion.values()) { |
105 for (AddressingVersion addrVersion: AddressingVersion.values()) { |
112 headerQNames.add(addrVersion.actionTag); |
106 binding.addKnownHeader(addrVersion.actionTag); |
113 headerQNames.add(addrVersion.faultDetailTag); |
107 binding.addKnownHeader(addrVersion.faultDetailTag); |
114 headerQNames.add(addrVersion.faultToTag); |
108 binding.addKnownHeader(addrVersion.faultToTag); |
115 headerQNames.add(addrVersion.fromTag); |
109 binding.addKnownHeader(addrVersion.fromTag); |
116 headerQNames.add(addrVersion.messageIDTag); |
110 binding.addKnownHeader(addrVersion.messageIDTag); |
117 headerQNames.add(addrVersion.relatesToTag); |
111 binding.addKnownHeader(addrVersion.relatesToTag); |
118 headerQNames.add(addrVersion.replyToTag); |
112 binding.addKnownHeader(addrVersion.replyToTag); |
119 headerQNames.add(addrVersion.toTag); |
113 binding.addKnownHeader(addrVersion.toTag); |
120 } |
114 } |
121 } |
115 } |
122 |
116 |
123 @Override |
117 @Override |
124 public @NotNull NextAction processException(Throwable t) { |
118 public @NotNull NextAction processException(Throwable t) { |
368 return wsdlPort.getBinding().get(opName); |
364 return wsdlPort.getBinding().get(opName); |
369 return null; |
365 return null; |
370 } |
366 } |
371 |
367 |
372 protected void validateSOAPAction(Packet packet) { |
368 protected void validateSOAPAction(Packet packet) { |
373 String gotA = packet.getMessage().getHeaders().getAction(addressingVersion, soapVersion); |
369 String gotA = AddressingUtils.getAction( |
|
370 packet.getMessage().getHeaders(), |
|
371 addressingVersion, soapVersion); |
374 if (gotA == null) |
372 if (gotA == null) |
375 throw new WebServiceException(AddressingMessages.VALIDATION_SERVER_NULL_ACTION()); |
373 throw new WebServiceException(AddressingMessages.VALIDATION_SERVER_NULL_ACTION()); |
376 if(packet.soapAction != null && !packet.soapAction.equals("\"\"") && !packet.soapAction.equals("\""+gotA+"\"")) { |
374 if(packet.soapAction != null && !packet.soapAction.equals("\"\"") && !packet.soapAction.equals("\""+gotA+"\"")) { |
377 throw new InvalidAddressingHeaderException(addressingVersion.actionTag, addressingVersion.actionMismatchTag); |
375 throw new InvalidAddressingHeaderException(addressingVersion.actionTag, addressingVersion.actionMismatchTag); |
378 } |
376 } |