Merge branch 'release/v2.3.1'

master
David BRASSELY 2013-11-18 10:45:24 +01:00
commit 82c48204e3
10 changed files with 280 additions and 158 deletions

View File

@ -64,11 +64,11 @@
<!-- <!--
! jbicomps.currentVersion sets the default project-wide artifact version. ! jbicomps.currentVersion sets the default project-wide artifact version.
--> -->
<jbicomps.currentVersion>2.4.0-SNAPSHOT</jbicomps.currentVersion> <jbicomps.currentVersion>2.3.1</jbicomps.currentVersion>
<ojc.default.release.version>2.4.0-SNAPSHOT</ojc.default.release.version> <ojc.default.release.version>2.3.1</ojc.default.release.version>
<!-- The version number for OSGi bundles. Has to be triple. Cannot be SNAPSHOT. --> <!-- The version number for OSGi bundles. Has to be triple. Cannot be SNAPSHOT. -->
<OSGI_VERSION>2.3.0</OSGI_VERSION> <OSGI_VERSION>2.3.1</OSGI_VERSION>
<!-- JBI version --> <!-- JBI version -->
<JBI_SPEC_VERSION>1.0</JBI_SPEC_VERSION> <JBI_SPEC_VERSION>1.0</JBI_SPEC_VERSION>

View File

@ -594,7 +594,7 @@ java.lang.NoSuchMethodError: org.codehaus.plexus.util.cli.Commandline.createArg(
<ALASKA_ROOT>${env.JV_SRCROOT}/ojc-core</ALASKA_ROOT> <ALASKA_ROOT>${env.JV_SRCROOT}/ojc-core</ALASKA_ROOT>
<ALASKA_SHAREDLIBRARY>${env.JV_SRCROOT}/ojc-core/component-common</ALASKA_SHAREDLIBRARY> <ALASKA_SHAREDLIBRARY>${env.JV_SRCROOT}/ojc-core/component-common</ALASKA_SHAREDLIBRARY>
<JBICOMPS_HOME>${env.JV_SRCROOT}/ojc-core</JBICOMPS_HOME> <JBICOMPS_HOME>${env.JV_SRCROOT}/ojc-core</JBICOMPS_HOME>
<OPEN_ESB_VERSION>2.3.0</OPEN_ESB_VERSION> <OPEN_ESB_VERSION>2.3.1</OPEN_ESB_VERSION>
<!-- this sets the versions for https://hulp.dev.java.net/i18n ant task: --> <!-- this sets the versions for https://hulp.dev.java.net/i18n ant task: -->
<I18NTASK_CLASS>net.java.hulp.i18n.buildtools.I18NTask</I18NTASK_CLASS> <I18NTASK_CLASS>net.java.hulp.i18n.buildtools.I18NTask</I18NTASK_CLASS>

View File

@ -571,6 +571,22 @@ public abstract class AbstractEndpoint
} }
return false; 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) { public Policy getPolicy(PolicyReference pr) {
Policy p = null; Policy p = null;

View File

@ -179,6 +179,8 @@ public interface Endpoint {
boolean isBasicAuthenticationEnabled(); boolean isBasicAuthenticationEnabled();
boolean isMTOMEnabled();
EndpointSecurityManager getEndpointSecurityManager(); EndpointSecurityManager getEndpointSecurityManager();
QName createOperationAddress(OperationMetaData opMetaData); QName createOperationAddress(OperationMetaData opMetaData);

View File

@ -341,4 +341,4 @@ public final class JAXWSGrizzlyHttpConnection extends WSHTTPConnection implement
public void setBasicAuthSubject(Subject basicAuthSubject) { public void setBasicAuthSubject(Subject basicAuthSubject) {
this.basicAuthSubject = basicAuthSubject; this.basicAuthSubject = basicAuthSubject;
} }
} }

View File

@ -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;
}
}

View File

@ -58,7 +58,9 @@ public class Policy implements ExtensibilityElement, Serializable {
private MustSupportBasicAuthentication msba; private MustSupportBasicAuthentication msba;
private BasicAuthenticationDetail bad; private BasicAuthenticationDetail bad;
private OptimizedMimeSerialization oms;
public Policy() { public Policy() {
} }
@ -101,7 +103,6 @@ public class Policy implements ExtensibilityElement, Serializable {
return this.password; return this.password;
} }
public MustSupportBasicAuthentication getMustSupportBasicAuthentication() { public MustSupportBasicAuthentication getMustSupportBasicAuthentication() {
return msba; return msba;
} }
@ -110,6 +111,14 @@ public class Policy implements ExtensibilityElement, Serializable {
msba = val; msba = val;
} }
public OptimizedMimeSerialization getOptimizedMimeSerialization() {
return oms;
}
public void setOptimizedMimeSerialization (OptimizedMimeSerialization val) {
oms = val;
}
public BasicAuthenticationDetail getBasicAuthenticationDetail() { public BasicAuthenticationDetail getBasicAuthenticationDetail() {
return bad; return bad;
} }

View File

@ -27,7 +27,6 @@
* *
* END_HEADER - DO NOT EDIT * END_HEADER - DO NOT EDIT
*/ */
package com.sun.jbi.httpsoapbc.extensions; package com.sun.jbi.httpsoapbc.extensions;
import com.ibm.wsdl.util.xml.DOMUtils; import com.ibm.wsdl.util.xml.DOMUtils;
@ -38,6 +37,7 @@ import com.sun.jbi.internationalization.Messages;
import java.io.Serializable; import java.io.Serializable;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.Map; import java.util.Map;
import javax.wsdl.Binding;
import javax.wsdl.Definition; import javax.wsdl.Definition;
import javax.wsdl.Port; import javax.wsdl.Port;
@ -56,14 +56,14 @@ import org.w3c.dom.NamedNodeMap;
/** /**
* *
* *
* @version * @version
* *
*/ */
public class SOAPExtSerializer public class SOAPExtSerializer
implements ExtensionSerializer, ExtensionDeserializer, Serializable { implements ExtensionSerializer, ExtensionDeserializer, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final Messages mMessages = Messages.getMessages(SOAPExtSerializer.class); private static final Messages mMessages = Messages.getMessages(SOAPExtSerializer.class);
// Policy element constants // Policy element constants
// No I18N // No I18N
private static final String WSP_NAMESPACE = "http://schemas.xmlsoap.org/ws/2004/09/policy"; 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 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 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 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 RuntimeConfigurationMBean mRuntimeConfig = null;
private Map mApplicationVariablesMap = null; private Map mApplicationVariablesMap = null;
private boolean mResolveTokens = false; private boolean mResolveTokens = false;
public SOAPExtSerializer(RuntimeConfigurationMBean runtimeConfig, boolean resolveTokens) { public SOAPExtSerializer(RuntimeConfigurationMBean runtimeConfig, boolean resolveTokens) {
mRuntimeConfig = runtimeConfig; mRuntimeConfig = runtimeConfig;
mApplicationVariablesMap = runtimeConfig.retrieveApplicationVariablesMap(); mApplicationVariablesMap = runtimeConfig.retrieveApplicationVariablesMap();
mResolveTokens = resolveTokens; mResolveTokens = resolveTokens;
} }
public void registerSerializer(ExtensionRegistry registry) { public void registerSerializer(ExtensionRegistry registry) {
registry.registerSerializer(Port.class, registry.registerSerializer(Port.class,
PolicyReference.QNAME_ADDRESS, PolicyReference.QNAME_ADDRESS,
this); this);
registry.registerDeserializer(Port.class, registry.registerDeserializer(Port.class,
PolicyReference.QNAME_ADDRESS, PolicyReference.QNAME_ADDRESS,
this); this);
registry.mapExtensionTypes(Port.class, registry.mapExtensionTypes(Port.class,
PolicyReference.QNAME_ADDRESS, PolicyReference.QNAME_ADDRESS,
PolicyReference.class); PolicyReference.class);
registry.registerSerializer(Definition.class, registry.registerSerializer(Binding.class,
Policy.QNAME_ADDRESS, Policy.QNAME_ADDRESS,
this); 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, registry.registerDeserializer(Definition.class,
Policy.QNAME_ADDRESS, Policy.QNAME_ADDRESS,
this); this);
registry.mapExtensionTypes(Definition.class, registry.mapExtensionTypes(Definition.class,
Policy.QNAME_ADDRESS, Policy.QNAME_ADDRESS,
Policy.class); Policy.class);
} }
public void marshall(Class parentType, QName elementType, public void marshall(Class parentType, QName elementType,
ExtensibilityElement extension, PrintWriter pw, ExtensibilityElement extension, PrintWriter pw,
Definition def, ExtensionRegistry extReg) Definition def, ExtensionRegistry extReg)
throws WSDLException { throws WSDLException {
// NOTE: no I18N // NOTE: no I18N
String wspNs = (def.getPrefix(WSP_NAMESPACE) != null && !def.getPrefix(WSP_NAMESPACE).equals("")) ? def.getPrefix(WSP_NAMESPACE) : "wsp"; 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 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 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 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) { if (extension instanceof Policy) {
Policy policy = (Policy) extension; Policy policy = (Policy) extension;
pw.print("<" + wspNs+":Policy"); pw.print("<" + wspNs + ":Policy");
String policyId = policy.getID(); String policyId = policy.getID();
if (policyId != null && !policyId.equals("")) { if (policyId != null && !policyId.equals("")) {
DOMUtils.printAttribute(wsuNs + ":Id", policyId, pw); DOMUtils.printAttribute(wsuNs + ":Id", policyId, pw);
@ -127,8 +140,8 @@ public class SOAPExtSerializer
if (policy.getMustSupportBasicAuthentication() != null) { if (policy.getMustSupportBasicAuthentication() != null) {
MustSupportBasicAuthentication msba = policy.getMustSupportBasicAuthentication(); MustSupportBasicAuthentication msba = policy.getMustSupportBasicAuthentication();
pw.print("<" + myspNs + ":MustSupportBasicAuthentication"); pw.print("<" + myspNs + ":MustSupportBasicAuthentication");
String authEnabled = msba.getAuthEnabled() == Boolean.TRUE? "true" : "false"; String authEnabled = msba.getAuthEnabled() == Boolean.TRUE ? "true" : "false";
DOMUtils.printAttribute("on",authEnabled, pw); DOMUtils.printAttribute("on", authEnabled, pw);
pw.print(">"); pw.print(">");
if (policy.getBasicAuthenticationDetail() != null) { if (policy.getBasicAuthenticationDetail() != null) {
boolean useUserNameToken = false; boolean useUserNameToken = false;
@ -155,20 +168,23 @@ public class SOAPExtSerializer
pw.print("<" + myspNs + ":UsernameToken>"); pw.print("<" + myspNs + ":UsernameToken>");
DOMUtils.printAttribute(myspNs + ":IncludeToken", USER_TOKEN_NAME_SPACE, pw); DOMUtils.printAttribute(myspNs + ":IncludeToken", USER_TOKEN_NAME_SPACE, pw);
pw.println(">"); pw.println(">");
pw.print("<" + wspNs +":Policy>"); pw.print("<" + wspNs + ":Policy>");
pw.print("<" + spNs +":WssUsernameToken10>"); pw.print("<" + spNs + ":WssUsernameToken10>");
StringCompareValidation stringCompare = (StringCompareValidation) policy.getBasicAuthenticationDetail().getCredentialValidation(); StringCompareValidation stringCompare = (StringCompareValidation) policy.getBasicAuthenticationDetail().getCredentialValidation();
if (stringCompare.getUsername() != null) { if (stringCompare.getUsername() != null) {
pw.print(stringCompare.getUsername()); pw.print(stringCompare.getUsername());
} }
pw.print("</" + spNs +":WssUsernameToken10>"); pw.print("</" + spNs + ":WssUsernameToken10>");
if (stringCompare.getPassword() != null) { if (stringCompare.getPassword() != null) {
pw.print("<" + spNs +":WssPassword>******</" + spNs + ":WssPassword>"); pw.print("<" + spNs + ":WssPassword>******</" + spNs + ":WssPassword>");
} }
pw.print("</" + wspNs + ":Policy>"); pw.print("</" + wspNs + ":Policy>");
pw.print("</" + myspNs + ":UsernameToken>"); pw.print("</" + myspNs + ":UsernameToken>");
} }
} }
} else if(policy.getOptimizedMimeSerialization() != null) {
OptimizedMimeSerialization oms = policy.getOptimizedMimeSerialization();
pw.print("<" + wsomaNs + ":OptimizedMimeSerialization/>");
} }
pw.print("</" + wspNs + ":Policy>"); pw.print("</" + wspNs + ":Policy>");
} else if (extension instanceof PolicyReference) { } else if (extension instanceof PolicyReference) {
@ -186,136 +202,147 @@ public class SOAPExtSerializer
} }
public ExtensibilityElement unmarshall(Class parentType, QName elementType, public ExtensibilityElement unmarshall(Class parentType, QName elementType,
Element el, Definition def, Element el, Definition def,
ExtensionRegistry extReg) ExtensionRegistry extReg)
throws WSDLException { throws WSDLException {
if(Policy.QNAME_ADDRESS.equals(elementType)) { if (Policy.QNAME_ADDRESS.equals(elementType)) {
String wsuNs = (def.getPrefix(WSU_NAMESPACE) != null && !def.getPrefix(WSU_NAMESPACE).equals(""))? def.getPrefix(WSU_NAMESPACE) : "wsu"; String wsuNs = (def.getPrefix(WSU_NAMESPACE) != null && !def.getPrefix(WSU_NAMESPACE).equals("")) ? def.getPrefix(WSU_NAMESPACE) : "wsu";
String id = DOMUtils.getAttribute(el, wsuNs + ":Id"); String id = DOMUtils.getAttribute(el, wsuNs + ":Id");
Policy pol = null; Policy pol = null;
if(id != null) { if (id != null) {
NodeList list = el.getElementsByTagNameNS(Policy.NS_URI_BASIC_AUTHENTICATION_SECURITY_POLICY, "MustSupportBasicAuthentication"); 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); Node msbaNode = list.item(0);
MustSupportBasicAuthentication msba = new MustSupportBasicAuthentication(); MustSupportBasicAuthentication msba = new MustSupportBasicAuthentication();
NamedNodeMap attrs = msbaNode.getAttributes(); NamedNodeMap attrs = msbaNode.getAttributes();
Node onNode = attrs.getNamedItem(MustSupportBasicAuthentication.ATTR_ON); Node onNode = attrs.getNamedItem(MustSupportBasicAuthentication.ATTR_ON);
if (onNode != null) { if (onNode != null) {
String on = onNode.getNodeValue(); String on = onNode.getNodeValue();
msba.setAuthEnabled(Boolean.valueOf(on.equalsIgnoreCase("true") || msba.setAuthEnabled(Boolean.valueOf(on.equalsIgnoreCase("true")
on.equalsIgnoreCase("yes") || || on.equalsIgnoreCase("yes")
on.equalsIgnoreCase("1"))); || on.equalsIgnoreCase("1")));
} }
BasicAuthenticationDetail bad = new BasicAuthenticationDetail(); BasicAuthenticationDetail bad = new BasicAuthenticationDetail();
try { try {
getAuthenticationDetail(msbaNode, bad); getAuthenticationDetail(msbaNode, bad);
} catch (Exception e) { } catch (Exception e) {
throw new WSDLException("INVALID_WSDL", e.getMessage(), e); throw new WSDLException("INVALID_WSDL", e.getMessage(), e);
} }
pol = new Policy(); pol = new Policy();
pol.setID(id); pol.setID(id);
pol.setMustSupportBasicAuthentication(msba); pol.setMustSupportBasicAuthentication(msba);
pol.setBasicAuthenticationDetail(bad); pol.setBasicAuthenticationDetail(bad);
NodeList userNameList = el.getElementsByTagNameNS(Policy.NS_URI_SECURITY_POLICY, "WssUsernameToken10"); NodeList userNameList = el.getElementsByTagNameNS(Policy.NS_URI_SECURITY_POLICY, "WssUsernameToken10");
if(userNameList != null) { if (userNameList != null) {
Element userElem = (Element)userNameList.item(0); Element userElem = (Element) userNameList.item(0);
if(userElem != null && userElem.getChildNodes().getLength() > 0) { if (userElem != null && userElem.getChildNodes().getLength() > 0) {
String username = userElem.getChildNodes().item(0).getNodeValue(); String username = userElem.getChildNodes().item(0).getNodeValue();
try { try {
if (isAToken(username)) { if (isAToken(username)) {
String token = username; String token = username;
String appVariableName = getApplicationVariableName(token); String appVariableName = getApplicationVariableName(token);
if (!mResolveTokens) { if (!mResolveTokens) {
if (!mApplicationVariablesMap.containsKey(appVariableName)) { if (!mApplicationVariablesMap.containsKey(appVariableName)) {
String[] metadata = new String[] {null, "STRING"}; String[] metadata = new String[]{null, "STRING"};
mApplicationVariablesMap.put(appVariableName, metadata); mApplicationVariablesMap.put(appVariableName, metadata);
} }
} else { } else {
String[] metadata = (String[]) mApplicationVariablesMap.get(appVariableName); String[] metadata = (String[]) mApplicationVariablesMap.get(appVariableName);
if (metadata == null || metadata[0] == null) { if (metadata == null || metadata[0] == null) {
throw new Exception(mMessages.getString("HTTPBC-E00252.Application_variable_not_defined", token)); throw new Exception(mMessages.getString("HTTPBC-E00252.Application_variable_not_defined", token));
} }
pol.setUserName(metadata[0]); pol.setUserName(metadata[0]);
if (bad.getCredentialValidation() instanceof StringCompareValidation) { if (bad.getCredentialValidation() instanceof StringCompareValidation) {
StringCompareValidation scv = (StringCompareValidation)bad.getCredentialValidation(); StringCompareValidation scv = (StringCompareValidation) bad.getCredentialValidation();
scv.setUsername(metadata[0]); scv.setUsername(metadata[0]);
} }
} }
} else { } else {
pol.setUserName(username); pol.setUserName(username);
if (bad.getCredentialValidation() instanceof StringCompareValidation) { if (bad.getCredentialValidation() instanceof StringCompareValidation) {
StringCompareValidation scv = (StringCompareValidation)bad.getCredentialValidation(); StringCompareValidation scv = (StringCompareValidation) bad.getCredentialValidation();
scv.setUsername(username); scv.setUsername(username);
} }
} }
} catch (Exception e) { } catch (Exception e) {
throw new WSDLException("INVALID_WSDL", e.getMessage(), e); throw new WSDLException("INVALID_WSDL", e.getMessage(), e);
} }
} }
} }
NodeList passwordList = el.getElementsByTagNameNS(Policy.NS_URI_SECURITY_POLICY, "WssPassword"); NodeList passwordList = el.getElementsByTagNameNS(Policy.NS_URI_SECURITY_POLICY, "WssPassword");
if(passwordList != null) { if (passwordList != null) {
Element passwordElem = (Element)passwordList.item(0); Element passwordElem = (Element) passwordList.item(0);
if(passwordElem != null && passwordElem.getChildNodes().getLength() > 0) { if (passwordElem != null && passwordElem.getChildNodes().getLength() > 0) {
String password = passwordElem.getChildNodes().item(0).getNodeValue(); String password = passwordElem.getChildNodes().item(0).getNodeValue();
try { try {
if (isAToken(password)) { if (isAToken(password)) {
String token = password; String token = password;
String appVariableName = getApplicationVariableName(token); String appVariableName = getApplicationVariableName(token);
if (!mResolveTokens) { if (!mResolveTokens) {
if (!mApplicationVariablesMap.containsKey(appVariableName)) { if (!mApplicationVariablesMap.containsKey(appVariableName)) {
String[] metadata = new String[] {null, "PASSWORD"}; String[] metadata = new String[]{null, "PASSWORD"};
mApplicationVariablesMap.put(appVariableName, metadata); mApplicationVariablesMap.put(appVariableName, metadata);
} }
} else { } else {
String[] metadata = (String[]) mApplicationVariablesMap.get(appVariableName); String[] metadata = (String[]) mApplicationVariablesMap.get(appVariableName);
if (metadata == null || metadata[0] == null) { if (metadata == null || metadata[0] == null) {
throw new Exception(mMessages.getString("HTTPBC-E00252.Application_variable_not_defined", token)); throw new Exception(mMessages.getString("HTTPBC-E00252.Application_variable_not_defined", token));
} }
pol.setPassword(metadata[0]); pol.setPassword(metadata[0]);
if (bad.getCredentialValidation() instanceof StringCompareValidation) { if (bad.getCredentialValidation() instanceof StringCompareValidation) {
StringCompareValidation scv = (StringCompareValidation)bad.getCredentialValidation(); StringCompareValidation scv = (StringCompareValidation) bad.getCredentialValidation();
scv.setPassword(metadata[0].toCharArray()); scv.setPassword(metadata[0].toCharArray());
} }
} }
} else { } else {
pol.setPassword(password); pol.setPassword(password);
if (bad.getCredentialValidation() instanceof StringCompareValidation) { if (bad.getCredentialValidation() instanceof StringCompareValidation) {
StringCompareValidation scv = (StringCompareValidation)bad.getCredentialValidation(); StringCompareValidation scv = (StringCompareValidation) bad.getCredentialValidation();
scv.setPassword(password.toCharArray()); scv.setPassword(password.toCharArray());
} }
} }
} catch (Exception e) { } catch (Exception e) {
throw new WSDLException("INVALID_WSDL", e.getMessage(), e); throw new WSDLException("INVALID_WSDL", e.getMessage(), e);
} }
} }
} }
if ((bad.getCredentialValidationType() == BasicAuthenticationDetail.CredentialValidationType.StringCompare) && if ((bad.getCredentialValidationType() == BasicAuthenticationDetail.CredentialValidationType.StringCompare)
(userNameList == null || passwordList == null)) { && (userNameList == null || passwordList == null)) {
throw new WSDLException("INVALID_WSDL", mMessages.getString("HTTPBC-E00256.WssTokenCompare_authentication_no_username_or_password")); 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; return pol;
} }
} }
} }
if(PolicyReference.QNAME_ADDRESS.equals(elementType)) { if (PolicyReference.QNAME_ADDRESS.equals(elementType)) {
String URI = DOMUtils.getAttribute(el, "URI"); String URI = DOMUtils.getAttribute(el, "URI");
if(URI != null) { if (URI != null) {
PolicyReference pref = new PolicyReference(); PolicyReference pref = new PolicyReference();
pref.setURI(URI); pref.setURI(URI);
return pref; return pref;
@ -332,10 +359,9 @@ public class SOAPExtSerializer
return extDeserializer.unmarshall(parentType, elementType, el, def, extReg); return extDeserializer.unmarshall(parentType, elementType, el, def, extReg);
} }
protected boolean isAToken(String name) throws Exception { protected boolean isAToken(String name) throws Exception {
boolean isToken = false; boolean isToken = false;
if (name.startsWith("${")) { if (name.startsWith("${")) {
if (name.endsWith("}")) { if (name.endsWith("}")) {
isToken = true; isToken = true;
@ -343,52 +369,52 @@ public class SOAPExtSerializer
throw new Exception(mMessages.getString("HTTPBC-E00253.Token_name_invalid", name)); throw new Exception(mMessages.getString("HTTPBC-E00253.Token_name_invalid", name));
} }
} }
return isToken; return isToken;
} }
protected String getApplicationVariableName(String aToken) throws Exception { protected String getApplicationVariableName(String aToken) throws Exception {
String tokenName = null; String tokenName = null;
if (aToken == null || "".equals(aToken)) { if (aToken == null || "".equals(aToken)) {
throw new Exception(mMessages.getString("HTTPBC-E00253.Token_name_invalid", aToken)); // fixme! throw new Exception(mMessages.getString("HTTPBC-E00253.Token_name_invalid", aToken)); // fixme!
} }
tokenName = aToken.substring(2, aToken.length() - 1); tokenName = aToken.substring(2, aToken.length() - 1);
if ("".equals(tokenName)) { if ("".equals(tokenName)) {
throw new Exception(mMessages.getString("HTTPBC-E00253.Token_name_invalid", aToken)); // fixme! throw new Exception(mMessages.getString("HTTPBC-E00253.Token_name_invalid", aToken)); // fixme!
} }
return tokenName; return tokenName;
} }
private void getAuthenticationDetail (Node mustSupportAuthNode, BasicAuthenticationDetail detail) throws Exception { private void getAuthenticationDetail(Node mustSupportAuthNode, BasicAuthenticationDetail detail) throws Exception {
if (mustSupportAuthNode != null) { if (mustSupportAuthNode != null) {
NodeList list = mustSupportAuthNode.getChildNodes(); NodeList list = mustSupportAuthNode.getChildNodes();
if (list == null) { // fall back to string compare if (list == null) { // fall back to string compare
detail.setCredentialValidationType(BasicAuthenticationDetail.CredentialValidationType.StringCompare); detail.setCredentialValidationType(BasicAuthenticationDetail.CredentialValidationType.StringCompare);
detail.setCredentialValidation(new StringCompareValidation()); detail.setCredentialValidation(new StringCompareValidation());
} else { } else {
for (int i=0; i < list.getLength(); i++) { for (int i = 0; i < list.getLength(); i++) {
Node cNode = list.item(i); Node cNode = list.item(i);
if (cNode.getNodeType() == Node.ELEMENT_NODE) { if (cNode.getNodeType() == Node.ELEMENT_NODE) {
Element elem = (Element)cNode; Element elem = (Element) cNode;
String elemLN = elem.getLocalName(); String elemLN = elem.getLocalName();
if (elemLN.equals(BasicAuthenticationDetail.ELEM_BasicAuthenticationDetail)) { if (elemLN.equals(BasicAuthenticationDetail.ELEM_BasicAuthenticationDetail)) {
NodeList detailChildren = cNode.getChildNodes(); NodeList detailChildren = cNode.getChildNodes();
if (detailChildren == null) { // fall back to string compare if (detailChildren == null) { // fall back to string compare
detail.setCredentialValidationType(BasicAuthenticationDetail.CredentialValidationType.StringCompare); detail.setCredentialValidationType(BasicAuthenticationDetail.CredentialValidationType.StringCompare);
detail.setCredentialValidation(new StringCompareValidation()); detail.setCredentialValidation(new StringCompareValidation());
} else { } else {
for (int ii=0; ii < detailChildren.getLength(); ii++) { for (int ii = 0; ii < detailChildren.getLength(); ii++) {
Node detailChild = detailChildren.item(ii); Node detailChild = detailChildren.item(ii);
if (detailChild.getNodeType() == Node.ELEMENT_NODE) { if (detailChild.getNodeType() == Node.ELEMENT_NODE) {
Element dcelem = (Element)detailChild; Element dcelem = (Element) detailChild;
String dcelemLN = dcelem.getLocalName(); String dcelemLN = dcelem.getLocalName();
if (dcelemLN.equals(StringCompareValidation.ELEM_StringCompare)) { if (dcelemLN.equals(StringCompareValidation.ELEM_StringCompare)) {
detail.setCredentialValidationType(BasicAuthenticationDetail.CredentialValidationType.StringCompare); detail.setCredentialValidationType(BasicAuthenticationDetail.CredentialValidationType.StringCompare);
detail.setCredentialValidation(new StringCompareValidation()); detail.setCredentialValidation(new StringCompareValidation());
break; break;
} else if (dcelemLN.equals(AccessManagerValidation.ELEM_AccessManager)) { } else if (dcelemLN.equals(AccessManagerValidation.ELEM_AccessManager)) {
AccessManagerValidation am = new AccessManagerValidation(); AccessManagerValidation am = new AccessManagerValidation();
@ -396,9 +422,9 @@ public class SOAPExtSerializer
detail.setCredentialValidation(am); detail.setCredentialValidation(am);
NamedNodeMap attrs = detailChild.getAttributes(); NamedNodeMap attrs = detailChild.getAttributes();
Node authNode = attrs.getNamedItem(AccessManagerValidation.ATTR_AUTHORIZATION); Node authNode = attrs.getNamedItem(AccessManagerValidation.ATTR_AUTHORIZATION);
if(authNode != null){ if (authNode != null) {
String authValue = authNode.getNodeValue(); String authValue = authNode.getNodeValue();
am.setAuthorization(authValue); am.setAuthorization(authValue);
} }
break; break;
} else if (dcelemLN.equals(RealmValidation.ELEM_Realm)) { } else if (dcelemLN.equals(RealmValidation.ELEM_Realm)) {
@ -412,7 +438,7 @@ public class SOAPExtSerializer
String appVariableName = getApplicationVariableName(token); String appVariableName = getApplicationVariableName(token);
if (!mResolveTokens) { if (!mResolveTokens) {
if (!mApplicationVariablesMap.containsKey(appVariableName)) { if (!mApplicationVariablesMap.containsKey(appVariableName)) {
String[] metadata = new String[] {null, "STRING"}; String[] metadata = new String[]{null, "STRING"};
mApplicationVariablesMap.put(appVariableName, metadata); mApplicationVariablesMap.put(appVariableName, metadata);
} }
} else { } else {
@ -420,16 +446,16 @@ public class SOAPExtSerializer
if (metadata == null || metadata[0] == null) { if (metadata == null || metadata[0] == null) {
throw new Exception(mMessages.getString("HTTPBC-E00252.Application_variable_not_defined", token)); throw new Exception(mMessages.getString("HTTPBC-E00252.Application_variable_not_defined", token));
} }
rv.setRealmName(metadata[0]); rv.setRealmName(metadata[0]);
} }
} else { } else {
rv.setRealmName(realmName); rv.setRealmName(realmName);
} }
} else { } 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.setCredentialValidationType(BasicAuthenticationDetail.CredentialValidationType.Realm);
detail.setCredentialValidation(rv); detail.setCredentialValidation(rv);
break; break;
} }
} }
@ -438,7 +464,7 @@ public class SOAPExtSerializer
} }
} }
} }
} }
} }
} }
} }

View File

@ -112,21 +112,27 @@ public class JAXWSEndpointFactory {
QName portName = new QName(endpoint.getServiceName().getNamespaceURI(), endpoint.getEndpointName()); QName portName = new QName(endpoint.getServiceName().getNamespaceURI(), endpoint.getEndpointName());
Container container = null; // This counter can contain info on security/monitoring pipe 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) { if (endpoint instanceof com.sun.jbi.httpsoapbc.HttpSoap12Endpoint) {
String lexicalBindingType = javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING;; if (endpoint.isMTOMEnabled()) {
BindingID bindingID = BindingID.parse(lexicalBindingType); lexicalBindingType = javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_MTOM_BINDING;
binding = bindingID.createBinding(); } else {
lexicalBindingType = javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING;
}
}else if (endpoint instanceof HttpSoapEndpoint) { }else if (endpoint instanceof HttpSoapEndpoint) {
String lexicalBindingType = javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING;; if (endpoint.isMTOMEnabled()) {
BindingID bindingID = BindingID.parse(lexicalBindingType); lexicalBindingType = javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_MTOM_BINDING;
binding = bindingID.createBinding(); } else {
lexicalBindingType = javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING;
}
} else if (endpoint instanceof HttpEndpoint) { } else if (endpoint instanceof HttpEndpoint) {
String lexicalBindingType = javax.xml.ws.http.HTTPBinding.HTTP_BINDING;; lexicalBindingType = javax.xml.ws.http.HTTPBinding.HTTP_BINDING;
BindingID bindingID = BindingID.parse(lexicalBindingType);
binding = bindingID.createBinding();
} }
BindingID bindingID = BindingID.parse(lexicalBindingType);
WSBinding binding = bindingID.createBinding();
if (mLogger.isLoggable(Level.FINE)) { if (mLogger.isLoggable(Level.FINE)) {
mLogger.log(Level.FINE, "Creating WSEndpoint with primary WSDL URL: " + endpoint.getOriginalWSDL().toURL()); mLogger.log(Level.FINE, "Creating WSEndpoint with primary WSDL URL: " + endpoint.getOriginalWSDL().toURL());
} }

View File

@ -3,6 +3,7 @@ package com.sun.jbi.restbc.jbiadapter.inbound;
import com.sun.jersey.spi.container.ContainerRequest; import com.sun.jersey.spi.container.ContainerRequest;
import com.sun.jersey.spi.container.ContainerResponse; import com.sun.jersey.spi.container.ContainerResponse;
import com.sun.jersey.spi.container.ContainerResponseFilter; import com.sun.jersey.spi.container.ContainerResponseFilter;
import java.util.List;
import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
@ -14,10 +15,12 @@ import javax.ws.rs.core.MediaType;
public class CharsetResponseFilter implements ContainerResponseFilter { public class CharsetResponseFilter implements ContainerResponseFilter {
public ContainerResponse filter(ContainerRequest request, ContainerResponse response) { public ContainerResponse filter(ContainerRequest request, ContainerResponse response) {
List<Object> headers = response.getHttpHeaders().get(HttpHeaders.CONTENT_TYPE);
MediaType contentType = (MediaType) response.getHttpHeaders().get(HttpHeaders.CONTENT_TYPE).iterator().next();
response.getHttpHeaders().putSingle("Content-Type", contentType.toString() + ";charset=UTF-8"); if (headers != null) {
MediaType contentType = (MediaType) headers.iterator().next();
response.getHttpHeaders().putSingle("Content-Type", contentType.toString() + ";charset=UTF-8");
}
return response; return response;
} }
} }