From 9a3aaf380a66f79286f4e56e143d02ddd0a3d60b Mon Sep 17 00:00:00 2001 From: David BRASSELY Date: Thu, 5 Sep 2013 19:39:24 +0200 Subject: [PATCH 1/7] Bumped version number to 2.3.1 --- global-common/ojc-versions/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/global-common/ojc-versions/pom.xml b/global-common/ojc-versions/pom.xml index 2bebbc7bf..b28165574 100755 --- a/global-common/ojc-versions/pom.xml +++ b/global-common/ojc-versions/pom.xml @@ -64,8 +64,8 @@ - 2.4.0-SNAPSHOT - 2.4.0-SNAPSHOT + 2.3.1-SNAPSHOT + 2.3.1-SNAPSHOT 2.3.0 From ae48a63fadce6b0a0e8434f571d36263c5189088 Mon Sep 17 00:00:00 2001 From: David BRASSELY Date: Fri, 18 Oct 2013 10:26:06 +0200 Subject: [PATCH 2/7] Nexus URL has changed --- global-common/ojc-versions/pom.xml | 2 +- global-common/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/global-common/ojc-versions/pom.xml b/global-common/ojc-versions/pom.xml index b28165574..dca102bec 100755 --- a/global-common/ojc-versions/pom.xml +++ b/global-common/ojc-versions/pom.xml @@ -972,7 +972,7 @@ openesb-release OpenESB repo release - http://openesb-dev.org:8081/nexus/content/repositories/openesb-release/ + http://nexus.openesb-dev.org:8081/nexus/content/repositories/openesb-release/ openesb-snapshot diff --git a/global-common/pom.xml b/global-common/pom.xml index 5c1e7128c..43683e305 100644 --- a/global-common/pom.xml +++ b/global-common/pom.xml @@ -181,7 +181,7 @@ openesb-release OpenESB repo release - http://openesb-dev.org:8081/nexus/content/repositories/openesb-release/ + http://nexus.openesb-dev.org:8081/nexus/content/repositories/openesb-release/ openesb-snapshot From 16d4356f9ffd33b472042ce6f9f2ca36b78bff08 Mon Sep 17 00:00:00 2001 From: David BRASSELY Date: Mon, 21 Oct 2013 11:26:43 +0200 Subject: [PATCH 3/7] Add support for MTOM Optimized Protocol --- .../sun/jbi/httpsoapbc/AbstractEndpoint.java | 16 + .../src/com/sun/jbi/httpsoapbc/Endpoint.java | 2 + .../embedded/JAXWSGrizzlyHttpConnection.java | 261 +++++++-------- .../OptimizedMimeSerialization.java | 60 ++++ .../sun/jbi/httpsoapbc/extensions/Policy.java | 13 +- .../extensions/SOAPExtSerializer.java | 300 ++++++++++-------- .../jaxwssupport/JAXWSEndpointFactory.java | 26 +- 7 files changed, 391 insertions(+), 287 deletions(-) create mode 100644 ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/extensions/OptimizedMimeSerialization.java diff --git a/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/AbstractEndpoint.java b/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/AbstractEndpoint.java index 12f55d0cb..7dc81648b 100755 --- a/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/AbstractEndpoint.java +++ b/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/AbstractEndpoint.java @@ -571,6 +571,22 @@ public abstract class AbstractEndpoint } return false; } + + public boolean isMTOMEnabled() { + PolicyReference reference = getPolicyReference(); + if(reference != null) { + String policyReferenceURI = reference.getURI(); + if(policyReferenceURI == null) { + return false; + } else { + Policy pol = getPolicy(reference); + if(pol != null) { + return (pol.getOptimizedMimeSerialization() != null); + } + } + } + return false; + } public Policy getPolicy(PolicyReference pr) { Policy p = null; diff --git a/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/Endpoint.java b/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/Endpoint.java index 919448495..60a8d9c19 100755 --- a/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/Endpoint.java +++ b/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/Endpoint.java @@ -179,6 +179,8 @@ public interface Endpoint { boolean isBasicAuthenticationEnabled(); + boolean isMTOMEnabled(); + EndpointSecurityManager getEndpointSecurityManager(); QName createOperationAddress(OperationMetaData opMetaData); diff --git a/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/embedded/JAXWSGrizzlyHttpConnection.java b/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/embedded/JAXWSGrizzlyHttpConnection.java index 2e30bb2a5..dba51ca6b 100755 --- a/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/embedded/JAXWSGrizzlyHttpConnection.java +++ b/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/embedded/JAXWSGrizzlyHttpConnection.java @@ -27,7 +27,6 @@ * * END_HEADER - DO NOT EDIT */ - package com.sun.jbi.httpsoapbc.embedded; import com.sun.jbi.internationalization.Messages; @@ -37,6 +36,7 @@ import com.sun.xml.ws.api.message.Packet; import com.sun.xml.ws.api.server.WSEndpoint; import com.sun.xml.ws.api.server.WebServiceContextDelegate; import com.sun.xml.ws.transport.http.WSHTTPConnection; +import org.jvnet.ws.message.PropertySet.Property; import java.io.IOException; import java.io.InputStream; @@ -49,6 +49,7 @@ import java.util.List; import java.util.StringTokenizer; import java.util.logging.Logger; import java.util.Map; +import java.util.Set; import javax.security.auth.Subject; import javax.servlet.http.HttpServletRequest; @@ -62,16 +63,15 @@ import org.apache.coyote.tomcat5.CoyoteResponse; import org.apache.tomcat.util.http.MimeHeaders; /** - * Based on JAX-WS WSHTTPConnection used with Java SE endpoints. It provides connection - * implementation using Grizzly. + * Based on JAX-WS WSHTTPConnection used with Java SE endpoints. It provides + * connection implementation using Grizzly. */ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implements WebServiceContextDelegate { private static final Messages mMessages = - Messages.getMessages(JAXWSGrizzlyHttpConnection.class); + Messages.getMessages(JAXWSGrizzlyHttpConnection.class); private final static Logger mLogger = - Messages.getLogger(JAXWSGrizzlyHttpConnection.class); - + Messages.getLogger(JAXWSGrizzlyHttpConnection.class); //private final HttpExchange httpExchange; private Request req; private Response res; @@ -80,14 +80,14 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement private int status; private int responseContentLength = 0; private Subject basicAuthSubject; - private boolean outputWritten; private boolean isSecure; - private AsyncTask grizzlyAsyncTask; + private Map> requestHeaders; + private Map> responseHeaders; - public JAXWSGrizzlyHttpConnection(@NotNull Request request, @NotNull Response response, @NotNull CoyoteRequest coyoteRequest, - @NotNull CoyoteResponse coyoteResponse, AsyncTask grizzlyAsyncTask, boolean isSecure) { + public JAXWSGrizzlyHttpConnection(@NotNull Request request, @NotNull Response response, @NotNull CoyoteRequest coyoteRequest, + @NotNull CoyoteResponse coyoteResponse, AsyncTask grizzlyAsyncTask, boolean isSecure) { this.req = request; this.res = response; this.coyoteRequest = coyoteRequest; @@ -97,11 +97,14 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement } @Override - @Property({MessageContext.HTTP_REQUEST_HEADERS, Packet.INBOUND_TRANSPORT_HEADERS}) - public @NotNull Map> getRequestHeaders() { - MimeHeaders mimeHeaders = req.getMimeHeaders(); - Map> jaxWSHeaders = convertHeaders(mimeHeaders); - return jaxWSHeaders; + @org.jvnet.ws.message.PropertySet.Property({MessageContext.HTTP_REQUEST_HEADERS, Packet.INBOUND_TRANSPORT_HEADERS}) + public @NotNull + Map> getRequestHeaders() { + if (requestHeaders == null) { + requestHeaders = initializeRequestHeaders(); + } + + return requestHeaders; } @Override @@ -109,70 +112,41 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement return req.getHeader(headerName); } - - /** - * there seems to issue with metro implementation while creating soap 1.2 - * mime headers, for the content-type mime header it does not propagate - * the exact value for the content-type mime header, specially in this case - * though the http-request contents the value of the action in the content - * type , the same value is not propagated from the http transport layer to - * the soap message layer - * - * this is a work around which is used to pass on the action value if - * present in the content-type , this code needs to removed once we have the - * metro fix - * - * @param headerName - * @return - */ - private String soapActionHeader(String value) { - - StringTokenizer tk = new StringTokenizer(value,";"); - String soapAction=null; - while(tk.hasMoreTokens()){ - String t = tk.nextToken(); - if(t.startsWith("action=")){ - soapAction= t.substring("action=".length()); - } - } - return soapAction; - } - - - @Override - public void setResponseHeaders(Map> headers) { - if (headers != null) { - for (Map.Entry> entry : headers.entrySet()) { - String key = entry.getKey(); - List values = entry.getValue(); - if (values.size() == 1) { - res.setHeader(key, values.get(1)); - } else { - // If the header has multiple values, comma separte them - StringBuffer concat = new StringBuffer(); - boolean firstTime = true; - for (String aValue : values) { - if (!firstTime) { - concat.append(','); - } - concat.append(aValue); - firstTime = false; - } - res.setHeader(key, concat.toString()); - } - } + public void setResponseHeaders(Map> headers) { + this.responseHeaders = headers; + if (headers == null) { + return; + + } + if (status != 0) { + res.setStatus(status); + } + + res.reset(); // clear all the headers + + for (Map.Entry> entry : headers.entrySet()) { + String name = entry.getKey(); + if (name.equalsIgnoreCase("Content-Type") || name.equalsIgnoreCase("Content-Length")) { + continue; // ignore headers that interfere with the operation + } + for (String value : entry.getValue()) { + res.addHeader(name, value); + } } } - @Override - @Property(MessageContext.HTTP_RESPONSE_HEADERS) - public Map> getResponseHeaders() { - MimeHeaders mimeHeaders = res.getMimeHeaders(); - Map> jaxWSHeaders = convertHeaders(mimeHeaders); - return jaxWSHeaders; + //@Override + public void setResponseHeader(String headerName, List values) { + responseHeaders.put(headerName, values); } - + + @Override + @org.jvnet.ws.message.PropertySet.Property(MessageContext.HTTP_RESPONSE_HEADERS) + public Map> getResponseHeaders() { + return responseHeaders; + } + @Override public void setContentTypeResponseHeader(@NotNull String value) { res.setHeader("Content-Type", value); @@ -184,27 +158,29 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement } @Override - @Property(MessageContext.HTTP_RESPONSE_CODE) + @org.jvnet.ws.message.PropertySet.Property(MessageContext.HTTP_RESPONSE_CODE) public int getStatus() { return status; } - - @Property(MessageContext.SERVLET_REQUEST) + + @org.jvnet.ws.message.PropertySet.Property(MessageContext.SERVLET_REQUEST) public HttpServletRequest getRequest() { return coyoteRequest; } - - @Property(MessageContext.SERVLET_RESPONSE) + + @org.jvnet.ws.message.PropertySet.Property(MessageContext.SERVLET_RESPONSE) public HttpServletResponse getResponse() { return coyoteResponse; - } + } - public @NotNull InputStream getInput() throws IOException{ + public @NotNull + InputStream getInput() throws IOException { return coyoteRequest.getInputStream(); //return httpExchange.getRequestBody(); } - public @NotNull OutputStream getOutput() throws IOException { + public @NotNull + OutputStream getOutput() throws IOException { assert !outputWritten; outputWritten = true; @@ -212,7 +188,8 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement return coyoteResponse.getOutputStream(); } - public @NotNull WebServiceContextDelegate getWebServiceContextDelegate() { + public @NotNull + WebServiceContextDelegate getWebServiceContextDelegate() { return this; } @@ -224,36 +201,38 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement return false; } - public @NotNull String getEPRAddress(Packet request, WSEndpoint endpoint) { + public @NotNull + String getEPRAddress(Packet request, WSEndpoint endpoint) { // TODO: verify the kind of address it wants here return coyoteRequest.getRequestURL().toString(); } - - public String getWSDLAddress(@NotNull Packet request, @NotNull WSEndpoint endpoint) { - String eprAddress = getEPRAddress(request,endpoint); + + public String getWSDLAddress(@NotNull Packet request, @NotNull WSEndpoint endpoint) { + String eprAddress = getEPRAddress(request, endpoint); String wsdlAddress = eprAddress + "?wsdl"; - return wsdlAddress; - } + return wsdlAddress; + } //@Override - public boolean isSecure() { + public boolean isSecure() { return this.isSecure; } - + @Override - @Property(MessageContext.HTTP_REQUEST_METHOD) - public @NotNull String getRequestMethod() { + @org.jvnet.ws.message.PropertySet.Property(MessageContext.HTTP_REQUEST_METHOD) + public @NotNull + String getRequestMethod() { return coyoteRequest.getMethod(); } @Override - @Property(MessageContext.QUERY_STRING) + @org.jvnet.ws.message.PropertySet.Property(MessageContext.QUERY_STRING) public String getQueryString() { return coyoteRequest.getQueryString(); } @Override - @Property(MessageContext.PATH_INFO) + @org.jvnet.ws.message.PropertySet.Property(MessageContext.PATH_INFO) public String getPathInfo() { return coyoteRequest.getRequestURI(); } @@ -266,11 +245,11 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement finishGrizzlyResponse(); super.close(); } - + protected PropertyMap getPropertyMap() { return model; } - + void finishGrizzlyResponse() { if (grizzlyAsyncTask != null) { JBIGrizzlyAsyncFilter.finishResponse(grizzlyAsyncTask); @@ -280,57 +259,33 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement } } - /** - * Convert from MimeHeaders to the format JAX-WS uses - * with the header name as the map key pointing to a list of values - * for that header - * - * This conversion might be expesive, if this is frequently used it may - * be worth changing Grizzly or JAX-WS to remove the need for the conversion - */ - Map> convertHeaders(MimeHeaders mimeHeaders) { - Map> jaxWSHeaders = new HashMap(); - Enumeration names = mimeHeaders.names(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - List jaxWSHeaderValues = new ArrayList(); - Enumeration values = mimeHeaders.values(name); + private Map> initializeRequestHeaders() { + final Map> headers = new HashMap>(); + MimeHeaders mimeHeaders = req.getMimeHeaders(); + Enumeration names = mimeHeaders.names(); + while (names.hasMoreElements()) { + String name = (String) names.nextElement(); + List jaxWsValues = new ArrayList(); + Enumeration values = mimeHeaders.values(name); + while (values.hasMoreElements()) { + String aValue = (String) values.nextElement(); + jaxWsValues.add(aValue); + } + headers.put(name, jaxWsValues); + } - if (name.equalsIgnoreCase("Content-Type")) { - while (values.hasMoreElements()) { - String aValue = (String) values.nextElement(); - jaxWSHeaderValues.add(aValue); - if(aValue.indexOf("action=") > 0){ - List soapActions = new ArrayList(); - soapActions.add(soapActionHeader(aValue)); - jaxWSHeaders.put("SOAPAction", soapActions); - } - } - } else { - - while (values.hasMoreElements()) { - String aValue = (String) values.nextElement(); - jaxWSHeaderValues.add(aValue); - } - } - jaxWSHeaders.put(name, jaxWSHeaderValues); - } - - return jaxWSHeaders; + return headers; } - - private static final PropertyMap model; static { - model = parse(JAXWSGrizzlyHttpConnection.class); + model = parse(JAXWSGrizzlyHttpConnection.class); } /** * @return the basicAuthSubject */ - - @Property("basicAuthSubject") + @org.jvnet.ws.message.PropertySet.Property("basicAuthSubject") public Subject getBasicAuthSubject() { return basicAuthSubject; } @@ -341,4 +296,34 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement public void setBasicAuthSubject(Subject basicAuthSubject) { this.basicAuthSubject = basicAuthSubject; } + + //@Override + public Set getRequestHeaderNames() { + return requestHeaders.keySet(); + } + + //@Override + public List getRequestHeaderValues(String headerName) { + return requestHeaders.get(headerName); + } + + //@Override + public String getRequestURI() { + return req.requestURI().getString(); + } + + //@Override + public String getRequestScheme() { + return req.scheme().getString(); + } + + //@Override + public String getServerName() { + return req.serverName().getString(); + } + + //@Override + public int getServerPort() { + return req.getServerPort(); + } } diff --git a/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/extensions/OptimizedMimeSerialization.java b/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/extensions/OptimizedMimeSerialization.java new file mode 100644 index 000000000..45f523019 --- /dev/null +++ b/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/extensions/OptimizedMimeSerialization.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * The contents of this file are subject to the terms of the Common Development and + * Distribution License(theLicense).You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the License at http://opensource.org/licenses/CDDL-1.0or + * http://opensource.org/licenses/cddl1.txt + * + * When distributing Covered Code,include this CDDL Header Notice in each file and + * include the License file at http://opensource.org/licenses/cddl1.txt. If applicable, add + * the following below the CDDL Header, with the fields enclosed by brackets [] + * replaced by your own identifying information: + * + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * Portions Copyrighted 2013 OpenESB Community + ******************************************************************************/ + +package com.sun.jbi.httpsoapbc.extensions; + +import java.io.Serializable; +import javax.wsdl.extensions.ExtensibilityElement; +import javax.xml.namespace.QName; + +/** + * + * @author David BRASSELY (brasseld at gmail.com) + * @author OpenESB Community + */ +public class OptimizedMimeSerialization implements ExtensibilityElement, Serializable { + + public static String NS_URI_HTTPBC_MTOM_EXTENSION = "http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization"; + + // Local element name + public static final String ELEM_OptimizedMimeSerialization = "OptimizedMimeSerialization"; + + // QName representing this Extensibility Element + private QName QNAME_OptimizedMimeSerialization = + new QName(NS_URI_HTTPBC_MTOM_EXTENSION, ELEM_OptimizedMimeSerialization); + + private Boolean mFieldRequired = false; + + public void setElementType(QName elementType) { + QNAME_OptimizedMimeSerialization = elementType; + } + + public QName getElementType() { + return QNAME_OptimizedMimeSerialization; + } + + public void setRequired(Boolean arg0) { + mFieldRequired = arg0; + } + + public Boolean getRequired() { + return mFieldRequired; + } +} diff --git a/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/extensions/Policy.java b/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/extensions/Policy.java index aaad217a5..3a8806d30 100755 --- a/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/extensions/Policy.java +++ b/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/extensions/Policy.java @@ -58,7 +58,9 @@ public class Policy implements ExtensibilityElement, Serializable { private MustSupportBasicAuthentication msba; private BasicAuthenticationDetail bad; - + + private OptimizedMimeSerialization oms; + public Policy() { } @@ -101,7 +103,6 @@ public class Policy implements ExtensibilityElement, Serializable { return this.password; } - public MustSupportBasicAuthentication getMustSupportBasicAuthentication() { return msba; } @@ -110,6 +111,14 @@ public class Policy implements ExtensibilityElement, Serializable { msba = val; } + public OptimizedMimeSerialization getOptimizedMimeSerialization() { + return oms; + } + + public void setOptimizedMimeSerialization (OptimizedMimeSerialization val) { + oms = val; + } + public BasicAuthenticationDetail getBasicAuthenticationDetail() { return bad; } diff --git a/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/extensions/SOAPExtSerializer.java b/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/extensions/SOAPExtSerializer.java index b3fd24446..bb4ba92e0 100755 --- a/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/extensions/SOAPExtSerializer.java +++ b/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/extensions/SOAPExtSerializer.java @@ -27,7 +27,6 @@ * * END_HEADER - DO NOT EDIT */ - package com.sun.jbi.httpsoapbc.extensions; import com.ibm.wsdl.util.xml.DOMUtils; @@ -38,6 +37,7 @@ import com.sun.jbi.internationalization.Messages; import java.io.Serializable; import java.io.PrintWriter; import java.util.Map; +import javax.wsdl.Binding; import javax.wsdl.Definition; import javax.wsdl.Port; @@ -56,14 +56,14 @@ import org.w3c.dom.NamedNodeMap; /** * * - * @version + * @version * */ public class SOAPExtSerializer - implements ExtensionSerializer, ExtensionDeserializer, Serializable { + implements ExtensionSerializer, ExtensionDeserializer, Serializable { + private static final long serialVersionUID = 1L; private static final Messages mMessages = Messages.getMessages(SOAPExtSerializer.class); - // Policy element constants // No I18N private static final String WSP_NAMESPACE = "http://schemas.xmlsoap.org/ws/2004/09/policy"; @@ -71,54 +71,67 @@ public class SOAPExtSerializer private static final String MY_SP_NAMESPACE = "http://sun.com/ws/httpbc/security/BasicauthSecurityPolicy"; private static final String WSU_NAMESPACE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"; private static final String USER_TOKEN_NAME_SPACE = "http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"; + private static final String WSOMA_SP_NAMESPACE = "http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization"; private RuntimeConfigurationMBean mRuntimeConfig = null; private Map mApplicationVariablesMap = null; private boolean mResolveTokens = false; - + public SOAPExtSerializer(RuntimeConfigurationMBean runtimeConfig, boolean resolveTokens) { - mRuntimeConfig = runtimeConfig; + mRuntimeConfig = runtimeConfig; mApplicationVariablesMap = runtimeConfig.retrieveApplicationVariablesMap(); mResolveTokens = resolveTokens; } public void registerSerializer(ExtensionRegistry registry) { - registry.registerSerializer(Port.class, - PolicyReference.QNAME_ADDRESS, - this); + registry.registerSerializer(Port.class, + PolicyReference.QNAME_ADDRESS, + this); registry.registerDeserializer(Port.class, - PolicyReference.QNAME_ADDRESS, - this); + PolicyReference.QNAME_ADDRESS, + this); registry.mapExtensionTypes(Port.class, - PolicyReference.QNAME_ADDRESS, - PolicyReference.class); - - registry.registerSerializer(Definition.class, - Policy.QNAME_ADDRESS, - this); + PolicyReference.QNAME_ADDRESS, + PolicyReference.class); + + registry.registerSerializer(Binding.class, + Policy.QNAME_ADDRESS, + this); + registry.registerDeserializer(Binding.class, + Policy.QNAME_ADDRESS, + this); + registry.mapExtensionTypes(Binding.class, + Policy.QNAME_ADDRESS, + Policy.class); + + registry.registerSerializer(Definition.class, + Policy.QNAME_ADDRESS, + this); registry.registerDeserializer(Definition.class, - Policy.QNAME_ADDRESS, - this); + Policy.QNAME_ADDRESS, + this); registry.mapExtensionTypes(Definition.class, - Policy.QNAME_ADDRESS, - Policy.class); - + Policy.QNAME_ADDRESS, + Policy.class); + } public void marshall(Class parentType, QName elementType, - ExtensibilityElement extension, PrintWriter pw, - Definition def, ExtensionRegistry extReg) - throws WSDLException { + ExtensibilityElement extension, PrintWriter pw, + Definition def, ExtensionRegistry extReg) + throws WSDLException { // NOTE: no I18N String wspNs = (def.getPrefix(WSP_NAMESPACE) != null && !def.getPrefix(WSP_NAMESPACE).equals("")) ? def.getPrefix(WSP_NAMESPACE) : "wsp"; - String myspNs = (def.getPrefix(MY_SP_NAMESPACE) != null && !def.getPrefix(MY_SP_NAMESPACE).equals(""))? def.getPrefix(MY_SP_NAMESPACE) : "mysp"; - String wsuNs = (def.getPrefix(WSU_NAMESPACE) != null && !def.getPrefix(WSU_NAMESPACE).equals(""))? def.getPrefix(WSU_NAMESPACE) : "wsu"; - String spNs = (def.getPrefix(SP_NAMESPACE) != null && !def.getPrefix(SP_NAMESPACE).equals(""))? def.getPrefix(SP_NAMESPACE) : "sp"; + String myspNs = (def.getPrefix(MY_SP_NAMESPACE) != null && !def.getPrefix(MY_SP_NAMESPACE).equals("")) ? def.getPrefix(MY_SP_NAMESPACE) : "mysp"; + String wsuNs = (def.getPrefix(WSU_NAMESPACE) != null && !def.getPrefix(WSU_NAMESPACE).equals("")) ? def.getPrefix(WSU_NAMESPACE) : "wsu"; + String spNs = (def.getPrefix(SP_NAMESPACE) != null && !def.getPrefix(SP_NAMESPACE).equals("")) ? def.getPrefix(SP_NAMESPACE) : "sp"; + String wsomaNs = (def.getPrefix(WSOMA_SP_NAMESPACE) != null && !def.getPrefix(WSOMA_SP_NAMESPACE).equals("")) ? def.getPrefix(WSOMA_SP_NAMESPACE) : "wsoma"; + if (extension instanceof Policy) { Policy policy = (Policy) extension; - - pw.print("<" + wspNs+":Policy"); + + pw.print("<" + wspNs + ":Policy"); String policyId = policy.getID(); if (policyId != null && !policyId.equals("")) { DOMUtils.printAttribute(wsuNs + ":Id", policyId, pw); @@ -127,8 +140,8 @@ public class SOAPExtSerializer if (policy.getMustSupportBasicAuthentication() != null) { MustSupportBasicAuthentication msba = policy.getMustSupportBasicAuthentication(); pw.print("<" + myspNs + ":MustSupportBasicAuthentication"); - String authEnabled = msba.getAuthEnabled() == Boolean.TRUE? "true" : "false"; - DOMUtils.printAttribute("on",authEnabled, pw); + String authEnabled = msba.getAuthEnabled() == Boolean.TRUE ? "true" : "false"; + DOMUtils.printAttribute("on", authEnabled, pw); pw.print(">"); if (policy.getBasicAuthenticationDetail() != null) { boolean useUserNameToken = false; @@ -155,20 +168,23 @@ public class SOAPExtSerializer pw.print("<" + myspNs + ":UsernameToken>"); DOMUtils.printAttribute(myspNs + ":IncludeToken", USER_TOKEN_NAME_SPACE, pw); pw.println(">"); - pw.print("<" + wspNs +":Policy>"); - pw.print("<" + spNs +":WssUsernameToken10>"); + pw.print("<" + wspNs + ":Policy>"); + pw.print("<" + spNs + ":WssUsernameToken10>"); StringCompareValidation stringCompare = (StringCompareValidation) policy.getBasicAuthenticationDetail().getCredentialValidation(); if (stringCompare.getUsername() != null) { pw.print(stringCompare.getUsername()); } - pw.print(""); + pw.print(""); if (stringCompare.getPassword() != null) { - pw.print("<" + spNs +":WssPassword>******"); + pw.print("<" + spNs + ":WssPassword>******"); } pw.print(""); pw.print(""); } - } + } + } else if(policy.getOptimizedMimeSerialization() != null) { + OptimizedMimeSerialization oms = policy.getOptimizedMimeSerialization(); + pw.print("<" + wsomaNs + ":OptimizedMimeSerialization/>"); } pw.print(""); } else if (extension instanceof PolicyReference) { @@ -186,136 +202,147 @@ public class SOAPExtSerializer } public ExtensibilityElement unmarshall(Class parentType, QName elementType, - Element el, Definition def, - ExtensionRegistry extReg) - throws WSDLException { + Element el, Definition def, + ExtensionRegistry extReg) + throws WSDLException { - if(Policy.QNAME_ADDRESS.equals(elementType)) { - String wsuNs = (def.getPrefix(WSU_NAMESPACE) != null && !def.getPrefix(WSU_NAMESPACE).equals(""))? def.getPrefix(WSU_NAMESPACE) : "wsu"; + if (Policy.QNAME_ADDRESS.equals(elementType)) { + String wsuNs = (def.getPrefix(WSU_NAMESPACE) != null && !def.getPrefix(WSU_NAMESPACE).equals("")) ? def.getPrefix(WSU_NAMESPACE) : "wsu"; String id = DOMUtils.getAttribute(el, wsuNs + ":Id"); Policy pol = null; - if(id != null) { + if (id != null) { NodeList list = el.getElementsByTagNameNS(Policy.NS_URI_BASIC_AUTHENTICATION_SECURITY_POLICY, "MustSupportBasicAuthentication"); - if(list != null && list.getLength() > 0) { + if (list != null && list.getLength() > 0) { Node msbaNode = list.item(0); MustSupportBasicAuthentication msba = new MustSupportBasicAuthentication(); NamedNodeMap attrs = msbaNode.getAttributes(); Node onNode = attrs.getNamedItem(MustSupportBasicAuthentication.ATTR_ON); if (onNode != null) { String on = onNode.getNodeValue(); - msba.setAuthEnabled(Boolean.valueOf(on.equalsIgnoreCase("true") || - on.equalsIgnoreCase("yes") || - on.equalsIgnoreCase("1"))); + msba.setAuthEnabled(Boolean.valueOf(on.equalsIgnoreCase("true") + || on.equalsIgnoreCase("yes") + || on.equalsIgnoreCase("1"))); } - + BasicAuthenticationDetail bad = new BasicAuthenticationDetail(); try { getAuthenticationDetail(msbaNode, bad); } catch (Exception e) { - throw new WSDLException("INVALID_WSDL", e.getMessage(), e); + throw new WSDLException("INVALID_WSDL", e.getMessage(), e); } - + pol = new Policy(); pol.setID(id); pol.setMustSupportBasicAuthentication(msba); pol.setBasicAuthenticationDetail(bad); - - NodeList userNameList = el.getElementsByTagNameNS(Policy.NS_URI_SECURITY_POLICY, "WssUsernameToken10"); - if(userNameList != null) { - Element userElem = (Element)userNameList.item(0); - if(userElem != null && userElem.getChildNodes().getLength() > 0) { + + NodeList userNameList = el.getElementsByTagNameNS(Policy.NS_URI_SECURITY_POLICY, "WssUsernameToken10"); + if (userNameList != null) { + Element userElem = (Element) userNameList.item(0); + if (userElem != null && userElem.getChildNodes().getLength() > 0) { String username = userElem.getChildNodes().item(0).getNodeValue(); try { if (isAToken(username)) { - String token = username; - String appVariableName = getApplicationVariableName(token); - - if (!mResolveTokens) { - if (!mApplicationVariablesMap.containsKey(appVariableName)) { - String[] metadata = new String[] {null, "STRING"}; - mApplicationVariablesMap.put(appVariableName, metadata); - } - } else { - String[] metadata = (String[]) mApplicationVariablesMap.get(appVariableName); - - if (metadata == null || metadata[0] == null) { - throw new Exception(mMessages.getString("HTTPBC-E00252.Application_variable_not_defined", token)); - } - + String token = username; + String appVariableName = getApplicationVariableName(token); + + if (!mResolveTokens) { + if (!mApplicationVariablesMap.containsKey(appVariableName)) { + String[] metadata = new String[]{null, "STRING"}; + mApplicationVariablesMap.put(appVariableName, metadata); + } + } else { + String[] metadata = (String[]) mApplicationVariablesMap.get(appVariableName); + + if (metadata == null || metadata[0] == null) { + throw new Exception(mMessages.getString("HTTPBC-E00252.Application_variable_not_defined", token)); + } + pol.setUserName(metadata[0]); - - if (bad.getCredentialValidation() instanceof StringCompareValidation) { - StringCompareValidation scv = (StringCompareValidation)bad.getCredentialValidation(); + + if (bad.getCredentialValidation() instanceof StringCompareValidation) { + StringCompareValidation scv = (StringCompareValidation) bad.getCredentialValidation(); scv.setUsername(metadata[0]); } - } - } else { - pol.setUserName(username); - - if (bad.getCredentialValidation() instanceof StringCompareValidation) { - StringCompareValidation scv = (StringCompareValidation)bad.getCredentialValidation(); + } + } else { + pol.setUserName(username); + + if (bad.getCredentialValidation() instanceof StringCompareValidation) { + StringCompareValidation scv = (StringCompareValidation) bad.getCredentialValidation(); scv.setUsername(username); } - } + } } catch (Exception e) { throw new WSDLException("INVALID_WSDL", e.getMessage(), e); } } } NodeList passwordList = el.getElementsByTagNameNS(Policy.NS_URI_SECURITY_POLICY, "WssPassword"); - if(passwordList != null) { - Element passwordElem = (Element)passwordList.item(0); - if(passwordElem != null && passwordElem.getChildNodes().getLength() > 0) { + if (passwordList != null) { + Element passwordElem = (Element) passwordList.item(0); + if (passwordElem != null && passwordElem.getChildNodes().getLength() > 0) { String password = passwordElem.getChildNodes().item(0).getNodeValue(); try { if (isAToken(password)) { - String token = password; - String appVariableName = getApplicationVariableName(token); - - if (!mResolveTokens) { - if (!mApplicationVariablesMap.containsKey(appVariableName)) { - String[] metadata = new String[] {null, "PASSWORD"}; - mApplicationVariablesMap.put(appVariableName, metadata); - } - } else { - String[] metadata = (String[]) mApplicationVariablesMap.get(appVariableName); - if (metadata == null || metadata[0] == null) { - throw new Exception(mMessages.getString("HTTPBC-E00252.Application_variable_not_defined", token)); - } - + String token = password; + String appVariableName = getApplicationVariableName(token); + + if (!mResolveTokens) { + if (!mApplicationVariablesMap.containsKey(appVariableName)) { + String[] metadata = new String[]{null, "PASSWORD"}; + mApplicationVariablesMap.put(appVariableName, metadata); + } + } else { + String[] metadata = (String[]) mApplicationVariablesMap.get(appVariableName); + if (metadata == null || metadata[0] == null) { + throw new Exception(mMessages.getString("HTTPBC-E00252.Application_variable_not_defined", token)); + } + pol.setPassword(metadata[0]); - - if (bad.getCredentialValidation() instanceof StringCompareValidation) { - StringCompareValidation scv = (StringCompareValidation)bad.getCredentialValidation(); + + if (bad.getCredentialValidation() instanceof StringCompareValidation) { + StringCompareValidation scv = (StringCompareValidation) bad.getCredentialValidation(); scv.setPassword(metadata[0].toCharArray()); } - } + } } else { - pol.setPassword(password); - - if (bad.getCredentialValidation() instanceof StringCompareValidation) { - StringCompareValidation scv = (StringCompareValidation)bad.getCredentialValidation(); + pol.setPassword(password); + + if (bad.getCredentialValidation() instanceof StringCompareValidation) { + StringCompareValidation scv = (StringCompareValidation) bad.getCredentialValidation(); scv.setPassword(password.toCharArray()); } - } + } } catch (Exception e) { throw new WSDLException("INVALID_WSDL", e.getMessage(), e); } } } - if ((bad.getCredentialValidationType() == BasicAuthenticationDetail.CredentialValidationType.StringCompare) && - (userNameList == null || passwordList == null)) { + if ((bad.getCredentialValidationType() == BasicAuthenticationDetail.CredentialValidationType.StringCompare) + && (userNameList == null || passwordList == null)) { throw new WSDLException("INVALID_WSDL", mMessages.getString("HTTPBC-E00256.WssTokenCompare_authentication_no_username_or_password")); } + + return pol; + } + list = el.getElementsByTagNameNS(WSOMA_SP_NAMESPACE, "OptimizedMimeSerialization"); + if (list != null && list.getLength() > 0) { + OptimizedMimeSerialization msba = new OptimizedMimeSerialization(); + + pol = new Policy(); + pol.setID(id); + pol.setOptimizedMimeSerialization(msba); + return pol; } } } - if(PolicyReference.QNAME_ADDRESS.equals(elementType)) { + if (PolicyReference.QNAME_ADDRESS.equals(elementType)) { String URI = DOMUtils.getAttribute(el, "URI"); - if(URI != null) { + if (URI != null) { PolicyReference pref = new PolicyReference(); pref.setURI(URI); return pref; @@ -332,10 +359,9 @@ public class SOAPExtSerializer return extDeserializer.unmarshall(parentType, elementType, el, def, extReg); } - protected boolean isAToken(String name) throws Exception { - boolean isToken = false; - + boolean isToken = false; + if (name.startsWith("${")) { if (name.endsWith("}")) { isToken = true; @@ -343,52 +369,52 @@ public class SOAPExtSerializer throw new Exception(mMessages.getString("HTTPBC-E00253.Token_name_invalid", name)); } } - + return isToken; } - + protected String getApplicationVariableName(String aToken) throws Exception { String tokenName = null; - + if (aToken == null || "".equals(aToken)) { throw new Exception(mMessages.getString("HTTPBC-E00253.Token_name_invalid", aToken)); // fixme! } - + tokenName = aToken.substring(2, aToken.length() - 1); if ("".equals(tokenName)) { throw new Exception(mMessages.getString("HTTPBC-E00253.Token_name_invalid", aToken)); // fixme! - } - + } + return tokenName; - + } - private void getAuthenticationDetail (Node mustSupportAuthNode, BasicAuthenticationDetail detail) throws Exception { + private void getAuthenticationDetail(Node mustSupportAuthNode, BasicAuthenticationDetail detail) throws Exception { if (mustSupportAuthNode != null) { NodeList list = mustSupportAuthNode.getChildNodes(); if (list == null) { // fall back to string compare detail.setCredentialValidationType(BasicAuthenticationDetail.CredentialValidationType.StringCompare); - detail.setCredentialValidation(new StringCompareValidation()); + detail.setCredentialValidation(new StringCompareValidation()); } else { - for (int i=0; i < list.getLength(); i++) { + for (int i = 0; i < list.getLength(); i++) { Node cNode = list.item(i); if (cNode.getNodeType() == Node.ELEMENT_NODE) { - Element elem = (Element)cNode; + Element elem = (Element) cNode; String elemLN = elem.getLocalName(); if (elemLN.equals(BasicAuthenticationDetail.ELEM_BasicAuthenticationDetail)) { NodeList detailChildren = cNode.getChildNodes(); if (detailChildren == null) { // fall back to string compare detail.setCredentialValidationType(BasicAuthenticationDetail.CredentialValidationType.StringCompare); - detail.setCredentialValidation(new StringCompareValidation()); + detail.setCredentialValidation(new StringCompareValidation()); } else { - for (int ii=0; ii < detailChildren.getLength(); ii++) { + for (int ii = 0; ii < detailChildren.getLength(); ii++) { Node detailChild = detailChildren.item(ii); if (detailChild.getNodeType() == Node.ELEMENT_NODE) { - Element dcelem = (Element)detailChild; + Element dcelem = (Element) detailChild; String dcelemLN = dcelem.getLocalName(); if (dcelemLN.equals(StringCompareValidation.ELEM_StringCompare)) { detail.setCredentialValidationType(BasicAuthenticationDetail.CredentialValidationType.StringCompare); - detail.setCredentialValidation(new StringCompareValidation()); + detail.setCredentialValidation(new StringCompareValidation()); break; } else if (dcelemLN.equals(AccessManagerValidation.ELEM_AccessManager)) { AccessManagerValidation am = new AccessManagerValidation(); @@ -396,9 +422,9 @@ public class SOAPExtSerializer detail.setCredentialValidation(am); NamedNodeMap attrs = detailChild.getAttributes(); Node authNode = attrs.getNamedItem(AccessManagerValidation.ATTR_AUTHORIZATION); - if(authNode != null){ - String authValue = authNode.getNodeValue(); - am.setAuthorization(authValue); + if (authNode != null) { + String authValue = authNode.getNodeValue(); + am.setAuthorization(authValue); } break; } else if (dcelemLN.equals(RealmValidation.ELEM_Realm)) { @@ -412,7 +438,7 @@ public class SOAPExtSerializer String appVariableName = getApplicationVariableName(token); if (!mResolveTokens) { if (!mApplicationVariablesMap.containsKey(appVariableName)) { - String[] metadata = new String[] {null, "STRING"}; + String[] metadata = new String[]{null, "STRING"}; mApplicationVariablesMap.put(appVariableName, metadata); } } else { @@ -420,16 +446,16 @@ public class SOAPExtSerializer if (metadata == null || metadata[0] == null) { throw new Exception(mMessages.getString("HTTPBC-E00252.Application_variable_not_defined", token)); } - rv.setRealmName(metadata[0]); + rv.setRealmName(metadata[0]); } } else { rv.setRealmName(realmName); - } + } } else { - throw new Exception (mMessages.getString("HTTPBC-E00255.Realm_authentication_no_realm_name")); + throw new Exception(mMessages.getString("HTTPBC-E00255.Realm_authentication_no_realm_name")); } detail.setCredentialValidationType(BasicAuthenticationDetail.CredentialValidationType.Realm); - detail.setCredentialValidation(rv); + detail.setCredentialValidation(rv); break; } } @@ -438,7 +464,7 @@ public class SOAPExtSerializer } } } - } + } } } } diff --git a/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/jaxwssupport/JAXWSEndpointFactory.java b/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/jaxwssupport/JAXWSEndpointFactory.java index 6c1cb415f..2cad46261 100755 --- a/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/jaxwssupport/JAXWSEndpointFactory.java +++ b/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/jaxwssupport/JAXWSEndpointFactory.java @@ -112,21 +112,27 @@ public class JAXWSEndpointFactory { QName portName = new QName(endpoint.getServiceName().getNamespaceURI(), endpoint.getEndpointName()); Container container = null; // This counter can contain info on security/monitoring pipe - WSBinding binding = null; + String lexicalBindingType = null; + if (endpoint instanceof com.sun.jbi.httpsoapbc.HttpSoap12Endpoint) { - String lexicalBindingType = javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING;; - BindingID bindingID = BindingID.parse(lexicalBindingType); - binding = bindingID.createBinding(); + if (endpoint.isMTOMEnabled()) { + lexicalBindingType = javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_MTOM_BINDING; + } else { + lexicalBindingType = javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING; + } }else if (endpoint instanceof HttpSoapEndpoint) { - String lexicalBindingType = javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING;; - BindingID bindingID = BindingID.parse(lexicalBindingType); - binding = bindingID.createBinding(); + if (endpoint.isMTOMEnabled()) { + lexicalBindingType = javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_MTOM_BINDING; + } else { + lexicalBindingType = javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING; + } } else if (endpoint instanceof HttpEndpoint) { - String lexicalBindingType = javax.xml.ws.http.HTTPBinding.HTTP_BINDING;; - BindingID bindingID = BindingID.parse(lexicalBindingType); - binding = bindingID.createBinding(); + lexicalBindingType = javax.xml.ws.http.HTTPBinding.HTTP_BINDING; } + BindingID bindingID = BindingID.parse(lexicalBindingType); + WSBinding binding = bindingID.createBinding(); + if (mLogger.isLoggable(Level.FINE)) { mLogger.log(Level.FINE, "Creating WSEndpoint with primary WSDL URL: " + endpoint.getOriginalWSDL().toURL()); } From bcdb13abe80e55de4c191a79db34a11ed5892896 Mon Sep 17 00:00:00 2001 From: David BRASSELY Date: Fri, 15 Nov 2013 14:40:26 +0100 Subject: [PATCH 4/7] Check headers before setting charset --- .../jbiadapter/inbound/CharsetResponseFilter.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ojc-core/restbc/jbiadapter/src/com/sun/jbi/restbc/jbiadapter/inbound/CharsetResponseFilter.java b/ojc-core/restbc/jbiadapter/src/com/sun/jbi/restbc/jbiadapter/inbound/CharsetResponseFilter.java index 75739e784..e0d511560 100644 --- a/ojc-core/restbc/jbiadapter/src/com/sun/jbi/restbc/jbiadapter/inbound/CharsetResponseFilter.java +++ b/ojc-core/restbc/jbiadapter/src/com/sun/jbi/restbc/jbiadapter/inbound/CharsetResponseFilter.java @@ -3,6 +3,7 @@ package com.sun.jbi.restbc.jbiadapter.inbound; import com.sun.jersey.spi.container.ContainerRequest; import com.sun.jersey.spi.container.ContainerResponse; import com.sun.jersey.spi.container.ContainerResponseFilter; +import java.util.List; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; @@ -14,10 +15,12 @@ import javax.ws.rs.core.MediaType; public class CharsetResponseFilter implements ContainerResponseFilter { public ContainerResponse filter(ContainerRequest request, ContainerResponse response) { - - MediaType contentType = (MediaType) response.getHttpHeaders().get(HttpHeaders.CONTENT_TYPE).iterator().next(); - response.getHttpHeaders().putSingle("Content-Type", contentType.toString() + ";charset=UTF-8"); - + List headers = response.getHttpHeaders().get(HttpHeaders.CONTENT_TYPE); + + if (headers != null) { + MediaType contentType = (MediaType) headers.iterator().next(); + response.getHttpHeaders().putSingle("Content-Type", contentType.toString() + ";charset=UTF-8"); + } return response; } } From 1fd80258e6896c316b9c1eca9d73b7b9ba7f01f4 Mon Sep 17 00:00:00 2001 From: David BRASSELY Date: Fri, 15 Nov 2013 14:59:16 +0100 Subject: [PATCH 5/7] Prepare release 2.3.1 --- global-common/ojc-versions/pom.xml | 6 +++--- ojc-core/build-common/ojc-common/pom.xml | 2 +- ojc-core/build-common/pom.xml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/global-common/ojc-versions/pom.xml b/global-common/ojc-versions/pom.xml index dca102bec..12afa7be2 100755 --- a/global-common/ojc-versions/pom.xml +++ b/global-common/ojc-versions/pom.xml @@ -64,11 +64,11 @@ - 2.3.1-SNAPSHOT - 2.3.1-SNAPSHOT + 2.3.1 + 2.3.1 - 2.3.0 + 2.3.1 1.0 diff --git a/ojc-core/build-common/ojc-common/pom.xml b/ojc-core/build-common/ojc-common/pom.xml index d13d450f9..9fbfe891d 100755 --- a/ojc-core/build-common/ojc-common/pom.xml +++ b/ojc-core/build-common/ojc-common/pom.xml @@ -594,7 +594,7 @@ java.lang.NoSuchMethodError: org.codehaus.plexus.util.cli.Commandline.createArg( ${env.JV_SRCROOT}/ojc-core ${env.JV_SRCROOT}/ojc-core/component-common ${env.JV_SRCROOT}/ojc-core - 2.3.0 + 2.3.1 net.java.hulp.i18n.buildtools.I18NTask diff --git a/ojc-core/build-common/pom.xml b/ojc-core/build-common/pom.xml index 81fd2d29f..f2503def5 100755 --- a/ojc-core/build-common/pom.xml +++ b/ojc-core/build-common/pom.xml @@ -252,6 +252,6 @@ ${env.JV_SRCROOT}/ojc-core ${env.JV_SRCROOT}/ojc-core/component-common ${env.JV_SRCROOT}/ojc-core - 1.1 + 2.3.1 From 23e068829a4a09f29b74251b82599ae3776da9b2 Mon Sep 17 00:00:00 2001 From: David BRASSELY Date: Fri, 15 Nov 2013 15:31:19 +0100 Subject: [PATCH 6/7] Version error --- ojc-core/build-common/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ojc-core/build-common/pom.xml b/ojc-core/build-common/pom.xml index f2503def5..81fd2d29f 100755 --- a/ojc-core/build-common/pom.xml +++ b/ojc-core/build-common/pom.xml @@ -252,6 +252,6 @@ ${env.JV_SRCROOT}/ojc-core ${env.JV_SRCROOT}/ojc-core/component-common ${env.JV_SRCROOT}/ojc-core - 2.3.1 + 1.1 From 4d0d8e3f4752a48187e89a394700c7af053a64b5 Mon Sep 17 00:00:00 2001 From: David BRASSELY Date: Fri, 15 Nov 2013 16:02:11 +0100 Subject: [PATCH 7/7] Let's go back to Metro 2.1.x --- .../embedded/JAXWSGrizzlyHttpConnection.java | 263 +++++++++--------- 1 file changed, 139 insertions(+), 124 deletions(-) diff --git a/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/embedded/JAXWSGrizzlyHttpConnection.java b/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/embedded/JAXWSGrizzlyHttpConnection.java index dba51ca6b..e8bdbea39 100755 --- a/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/embedded/JAXWSGrizzlyHttpConnection.java +++ b/ojc-core/httpsoapbc/httpsoapbcimpl/src/com/sun/jbi/httpsoapbc/embedded/JAXWSGrizzlyHttpConnection.java @@ -27,6 +27,7 @@ * * END_HEADER - DO NOT EDIT */ + package com.sun.jbi.httpsoapbc.embedded; import com.sun.jbi.internationalization.Messages; @@ -36,7 +37,6 @@ import com.sun.xml.ws.api.message.Packet; import com.sun.xml.ws.api.server.WSEndpoint; import com.sun.xml.ws.api.server.WebServiceContextDelegate; import com.sun.xml.ws.transport.http.WSHTTPConnection; -import org.jvnet.ws.message.PropertySet.Property; import java.io.IOException; import java.io.InputStream; @@ -49,7 +49,6 @@ import java.util.List; import java.util.StringTokenizer; import java.util.logging.Logger; import java.util.Map; -import java.util.Set; import javax.security.auth.Subject; import javax.servlet.http.HttpServletRequest; @@ -63,15 +62,16 @@ import org.apache.coyote.tomcat5.CoyoteResponse; import org.apache.tomcat.util.http.MimeHeaders; /** - * Based on JAX-WS WSHTTPConnection used with Java SE endpoints. It provides - * connection implementation using Grizzly. + * Based on JAX-WS WSHTTPConnection used with Java SE endpoints. It provides connection + * implementation using Grizzly. */ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implements WebServiceContextDelegate { private static final Messages mMessages = - Messages.getMessages(JAXWSGrizzlyHttpConnection.class); + Messages.getMessages(JAXWSGrizzlyHttpConnection.class); private final static Logger mLogger = - Messages.getLogger(JAXWSGrizzlyHttpConnection.class); + Messages.getLogger(JAXWSGrizzlyHttpConnection.class); + //private final HttpExchange httpExchange; private Request req; private Response res; @@ -80,14 +80,14 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement private int status; private int responseContentLength = 0; private Subject basicAuthSubject; + private boolean outputWritten; private boolean isSecure; - private AsyncTask grizzlyAsyncTask; - private Map> requestHeaders; - private Map> responseHeaders; - public JAXWSGrizzlyHttpConnection(@NotNull Request request, @NotNull Response response, @NotNull CoyoteRequest coyoteRequest, - @NotNull CoyoteResponse coyoteResponse, AsyncTask grizzlyAsyncTask, boolean isSecure) { + private AsyncTask grizzlyAsyncTask; + + public JAXWSGrizzlyHttpConnection(@NotNull Request request, @NotNull Response response, @NotNull CoyoteRequest coyoteRequest, + @NotNull CoyoteResponse coyoteResponse, AsyncTask grizzlyAsyncTask, boolean isSecure) { this.req = request; this.res = response; this.coyoteRequest = coyoteRequest; @@ -97,14 +97,11 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement } @Override - @org.jvnet.ws.message.PropertySet.Property({MessageContext.HTTP_REQUEST_HEADERS, Packet.INBOUND_TRANSPORT_HEADERS}) - public @NotNull - Map> getRequestHeaders() { - if (requestHeaders == null) { - requestHeaders = initializeRequestHeaders(); - } - - return requestHeaders; + @Property({MessageContext.HTTP_REQUEST_HEADERS, Packet.INBOUND_TRANSPORT_HEADERS}) + public @NotNull Map> getRequestHeaders() { + MimeHeaders mimeHeaders = req.getMimeHeaders(); + Map> jaxWSHeaders = convertHeaders(mimeHeaders); + return jaxWSHeaders; } @Override @@ -112,41 +109,70 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement return req.getHeader(headerName); } - @Override - public void setResponseHeaders(Map> headers) { - this.responseHeaders = headers; - if (headers == null) { - return; - - } - if (status != 0) { - res.setStatus(status); - } - - res.reset(); // clear all the headers - - for (Map.Entry> entry : headers.entrySet()) { - String name = entry.getKey(); - if (name.equalsIgnoreCase("Content-Type") || name.equalsIgnoreCase("Content-Length")) { - continue; // ignore headers that interfere with the operation - } - for (String value : entry.getValue()) { - res.addHeader(name, value); - } - } + + /** + * there seems to issue with metro implementation while creating soap 1.2 + * mime headers, for the content-type mime header it does not propagate + * the exact value for the content-type mime header, specially in this case + * though the http-request contents the value of the action in the content + * type , the same value is not propagated from the http transport layer to + * the soap message layer + * + * this is a work around which is used to pass on the action value if + * present in the content-type , this code needs to removed once we have the + * metro fix + * + * @param headerName + * @return + */ + private String soapActionHeader(String value) { + + StringTokenizer tk = new StringTokenizer(value,";"); + String soapAction=null; + while(tk.hasMoreTokens()){ + String t = tk.nextToken(); + if(t.startsWith("action=")){ + soapAction= t.substring("action=".length()); + } + } + return soapAction; } + + - //@Override - public void setResponseHeader(String headerName, List values) { - responseHeaders.put(headerName, values); + @Override + public void setResponseHeaders(Map> headers) { + if (headers != null) { + for (Map.Entry> entry : headers.entrySet()) { + String key = entry.getKey(); + List values = entry.getValue(); + if (values.size() == 1) { + res.setHeader(key, values.get(1)); + } else { + // If the header has multiple values, comma separte them + StringBuffer concat = new StringBuffer(); + boolean firstTime = true; + for (String aValue : values) { + if (!firstTime) { + concat.append(','); + } + concat.append(aValue); + firstTime = false; + } + res.setHeader(key, concat.toString()); + } + } + } } @Override - @org.jvnet.ws.message.PropertySet.Property(MessageContext.HTTP_RESPONSE_HEADERS) - public Map> getResponseHeaders() { - return responseHeaders; + @Property(MessageContext.HTTP_RESPONSE_HEADERS) + public Map> getResponseHeaders() { + MimeHeaders mimeHeaders = res.getMimeHeaders(); + Map> jaxWSHeaders = convertHeaders(mimeHeaders); + return jaxWSHeaders; } - + @Override public void setContentTypeResponseHeader(@NotNull String value) { res.setHeader("Content-Type", value); @@ -158,29 +184,27 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement } @Override - @org.jvnet.ws.message.PropertySet.Property(MessageContext.HTTP_RESPONSE_CODE) + @Property(MessageContext.HTTP_RESPONSE_CODE) public int getStatus() { return status; } - - @org.jvnet.ws.message.PropertySet.Property(MessageContext.SERVLET_REQUEST) + + @Property(MessageContext.SERVLET_REQUEST) public HttpServletRequest getRequest() { return coyoteRequest; } - - @org.jvnet.ws.message.PropertySet.Property(MessageContext.SERVLET_RESPONSE) + + @Property(MessageContext.SERVLET_RESPONSE) public HttpServletResponse getResponse() { return coyoteResponse; - } + } - public @NotNull - InputStream getInput() throws IOException { + public @NotNull InputStream getInput() throws IOException{ return coyoteRequest.getInputStream(); //return httpExchange.getRequestBody(); } - public @NotNull - OutputStream getOutput() throws IOException { + public @NotNull OutputStream getOutput() throws IOException { assert !outputWritten; outputWritten = true; @@ -188,8 +212,7 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement return coyoteResponse.getOutputStream(); } - public @NotNull - WebServiceContextDelegate getWebServiceContextDelegate() { + public @NotNull WebServiceContextDelegate getWebServiceContextDelegate() { return this; } @@ -201,38 +224,36 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement return false; } - public @NotNull - String getEPRAddress(Packet request, WSEndpoint endpoint) { + public @NotNull String getEPRAddress(Packet request, WSEndpoint endpoint) { // TODO: verify the kind of address it wants here return coyoteRequest.getRequestURL().toString(); } - - public String getWSDLAddress(@NotNull Packet request, @NotNull WSEndpoint endpoint) { - String eprAddress = getEPRAddress(request, endpoint); + + public String getWSDLAddress(@NotNull Packet request, @NotNull WSEndpoint endpoint) { + String eprAddress = getEPRAddress(request,endpoint); String wsdlAddress = eprAddress + "?wsdl"; - return wsdlAddress; - } + return wsdlAddress; + } //@Override - public boolean isSecure() { + public boolean isSecure() { return this.isSecure; } - + @Override - @org.jvnet.ws.message.PropertySet.Property(MessageContext.HTTP_REQUEST_METHOD) - public @NotNull - String getRequestMethod() { + @Property(MessageContext.HTTP_REQUEST_METHOD) + public @NotNull String getRequestMethod() { return coyoteRequest.getMethod(); } @Override - @org.jvnet.ws.message.PropertySet.Property(MessageContext.QUERY_STRING) + @Property(MessageContext.QUERY_STRING) public String getQueryString() { return coyoteRequest.getQueryString(); } @Override - @org.jvnet.ws.message.PropertySet.Property(MessageContext.PATH_INFO) + @Property(MessageContext.PATH_INFO) public String getPathInfo() { return coyoteRequest.getRequestURI(); } @@ -245,11 +266,11 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement finishGrizzlyResponse(); super.close(); } - + protected PropertyMap getPropertyMap() { return model; } - + void finishGrizzlyResponse() { if (grizzlyAsyncTask != null) { JBIGrizzlyAsyncFilter.finishResponse(grizzlyAsyncTask); @@ -259,33 +280,57 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement } } - private Map> initializeRequestHeaders() { - final Map> headers = new HashMap>(); - MimeHeaders mimeHeaders = req.getMimeHeaders(); - Enumeration names = mimeHeaders.names(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - List jaxWsValues = new ArrayList(); - Enumeration values = mimeHeaders.values(name); - while (values.hasMoreElements()) { - String aValue = (String) values.nextElement(); - jaxWsValues.add(aValue); - } - headers.put(name, jaxWsValues); - } + /** + * Convert from MimeHeaders to the format JAX-WS uses + * with the header name as the map key pointing to a list of values + * for that header + * + * This conversion might be expesive, if this is frequently used it may + * be worth changing Grizzly or JAX-WS to remove the need for the conversion + */ + Map> convertHeaders(MimeHeaders mimeHeaders) { + Map> jaxWSHeaders = new HashMap(); + Enumeration names = mimeHeaders.names(); + while (names.hasMoreElements()) { + String name = (String) names.nextElement(); + List jaxWSHeaderValues = new ArrayList(); + Enumeration values = mimeHeaders.values(name); - return headers; + if (name.equalsIgnoreCase("Content-Type")) { + while (values.hasMoreElements()) { + String aValue = (String) values.nextElement(); + jaxWSHeaderValues.add(aValue); + if(aValue.indexOf("action=") > 0){ + List soapActions = new ArrayList(); + soapActions.add(soapActionHeader(aValue)); + jaxWSHeaders.put("SOAPAction", soapActions); + } + } + } else { + + while (values.hasMoreElements()) { + String aValue = (String) values.nextElement(); + jaxWSHeaderValues.add(aValue); + } + } + jaxWSHeaders.put(name, jaxWSHeaderValues); + } + + return jaxWSHeaders; } + + private static final PropertyMap model; static { - model = parse(JAXWSGrizzlyHttpConnection.class); + model = parse(JAXWSGrizzlyHttpConnection.class); } /** * @return the basicAuthSubject */ - @org.jvnet.ws.message.PropertySet.Property("basicAuthSubject") + + @Property("basicAuthSubject") public Subject getBasicAuthSubject() { return basicAuthSubject; } @@ -296,34 +341,4 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement public void setBasicAuthSubject(Subject basicAuthSubject) { this.basicAuthSubject = basicAuthSubject; } - - //@Override - public Set getRequestHeaderNames() { - return requestHeaders.keySet(); - } - - //@Override - public List getRequestHeaderValues(String headerName) { - return requestHeaders.get(headerName); - } - - //@Override - public String getRequestURI() { - return req.requestURI().getString(); - } - - //@Override - public String getRequestScheme() { - return req.scheme().getString(); - } - - //@Override - public String getServerName() { - return req.serverName().getString(); - } - - //@Override - public int getServerPort() { - return req.getServerPort(); - } -} +} \ No newline at end of file