JBossWS SVN: r19042 - in stack/cxf/branches/jbossws-cxf-4.3.x: modules/server/src/main/java/org/jboss/wsf/stack/cxf and 3 other directories.
by jbossws-commits@lists.jboss.org
Author: asoldano
Date: 2014-10-30 12:12:20 -0400 (Thu, 30 Oct 2014)
New Revision: 19042
Added:
stack/cxf/branches/jbossws-cxf-4.3.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationDigestEjbTestCase.java
stack/cxf/branches/jbossws-cxf-4.3.x/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/ejb-digest/
Modified:
stack/cxf/branches/jbossws-cxf-4.3.x/
stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/JBossWSInvoker.java
stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/AutenticationMgrSubjectCreatingInterceptor.java
stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreatingInterceptor.java
stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreatingPolicyInterceptor.java
stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreator.java
Log:
Merged revisions 19030,19032-19033,19040-19041 via svnmerge from
https://svn.jboss.org/repos/jbossws/stack/cxf/trunk
.......
r19030 | jim.ma | 2014-10-24 16:14:55 +0200 (Fri, 24 Oct 2014) | 1 line
[JBWS-3843]:EJB3 Web Service returns Invalid User on parallel invocations
.......
r19032 | jim.ma | 2014-10-27 09:01:58 +0100 (Mon, 27 Oct 2014) | 1 line
[JBWS-3843]:Add org.jboss.as.webservices.server.integration dependency to load UsernameTokenCallback
.......
r19033 | asoldano | 2014-10-27 19:26:59 +0100 (Mon, 27 Oct 2014) | 2 lines
[JBWS-3843] Making the test more robust... ;)
.......
r19040 | asoldano | 2014-10-30 16:15:39 +0100 (Thu, 30 Oct 2014) | 2 lines
[JBWS-3843] Adding comment explaining the workaround; proper fix will come in PicketBox
.......
r19041 | asoldano | 2014-10-30 16:21:54 +0100 (Thu, 30 Oct 2014) | 2 lines
[JBWS-3843] More workaround comments
.......
Property changes on: stack/cxf/branches/jbossws-cxf-4.3.x
___________________________________________________________________
Modified: svnmerge-integrated
- /stack/cxf/trunk:1-18594,18609-18612,18616-18619,18621,18625-18652,18656-18658,18661,18663,18665-18668,18671-18683,18685-18687,18689-18693,18695,18698,18701,18703-18704,18706-18710,18712-18713,18715,18717-18721,18726-18730,18732,18735-18737,18742,18745-18746,18750-18752,18755-18759,18762,18770,18777-18779,18781-18787,18796,18798,18805-18808,18811-18814,18816,18822-18824,18832-18835,18837,18839-18840,18842-18843,18845,18847-18848,18852,18856-18857,18859-18864,18866,18883-18884,18933,18947,19024-19026,19028,19034-19037
+ /stack/cxf/trunk:1-18594,18609-18612,18616-18619,18621,18625-18652,18656-18658,18661,18663,18665-18668,18671-18683,18685-18687,18689-18693,18695,18698,18701,18703-18704,18706-18710,18712-18713,18715,18717-18721,18726-18730,18732,18735-18737,18742,18745-18746,18750-18752,18755-18759,18762,18770,18777-18779,18781-18787,18796,18798,18805-18808,18811-18814,18816,18822-18824,18832-18835,18837,18839-18840,18842-18843,18845,18847-18848,18852,18856-18857,18859-18864,18866,18883-18884,18933,18947,19024-19026,19028,19030,19032-19041
Modified: svn:mergeinfo
- /stack/cxf/branches/asoldano:14032-14050,14068
/stack/cxf/branches/jaspi:18054-18409
/stack/cxf/branches/ropalka:16301-16305,16966-17008
/stack/cxf/branches/ropalka_JBWS-3550:16747-16757
/stack/cxf/trunk:18609,18616-18619,18629,18695,18710,18715,18798,18814,18816,18847,18852,18856,18860-18864,18866,18883-18884,18933,18947,19024-19025,19028,19036-19037
+ /stack/cxf/branches/asoldano:14032-14050,14068
/stack/cxf/branches/jaspi:18054-18409
/stack/cxf/branches/ropalka:16301-16305,16966-17008
/stack/cxf/branches/ropalka_JBWS-3550:16747-16757
/stack/cxf/trunk:18609,18616-18619,18629,18695,18710,18715,18798,18814,18816,18847,18852,18856,18860-18864,18866,18883-18884,18933,18947,19024-19025,19028,19030,19032-19033,19036-19037,19040-19041
Modified: stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/JBossWSInvoker.java
===================================================================
--- stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/JBossWSInvoker.java 2014-10-30 15:21:54 UTC (rev 19041)
+++ stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/JBossWSInvoker.java 2014-10-30 16:12:20 UTC (rev 19042)
@@ -42,6 +42,7 @@
import java.lang.reflect.Method;
import java.util.List;
+import javax.security.auth.callback.CallbackHandler;
import javax.xml.ws.WebServiceContext;
import org.apache.cxf.Bus;
@@ -56,6 +57,7 @@
import org.apache.cxf.service.invoker.Invoker;
import org.apache.cxf.service.invoker.MethodDispatcher;
import org.apache.cxf.service.model.BindingOperationInfo;
+import org.jboss.security.auth.callback.CallbackHandlerPolicyContextHandler;
import org.jboss.ws.api.util.ServiceLoader;
import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
import org.jboss.wsf.spi.deployment.Endpoint;
@@ -126,7 +128,31 @@
} else if (o != null) {
params = new MessageContentsList(o);
}
- return invoke(exchange, targetBean, adjustMethodAndParams(md.getMethod(bop), exchange, params), params);
+ if (factory != null)
+ {
+ targetBean = this.getServiceObject(exchange);
+ }
+
+ //[JBWS-3843] workaround: set the CallbackHandler threadlocal again; as a matter of fact, if that's in the Exchange,
+ //DIGEST auth is being used and that will cause the EJB layer to re-do authentication because of the bug
+ CallbackHandler cbHandler = exchange.getInMessage().get(CallbackHandler.class);
+ Object obj = null;
+ try
+ {
+ if (cbHandler != null)
+ {
+ CallbackHandlerPolicyContextHandler.setCallbackHandler(cbHandler);
+ }
+ obj = invoke(exchange, targetBean, adjustMethodAndParams(md.getMethod(bop), exchange, params), params);
+ }
+ finally
+ {
+ if (cbHandler != null)
+ {
+ CallbackHandlerPolicyContextHandler.setCallbackHandler(null);
+ }
+ }
+ return obj;
}
/**
Modified: stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/AutenticationMgrSubjectCreatingInterceptor.java
===================================================================
--- stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/AutenticationMgrSubjectCreatingInterceptor.java 2014-10-30 15:21:54 UTC (rev 19041)
+++ stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/AutenticationMgrSubjectCreatingInterceptor.java 2014-10-30 16:12:20 UTC (rev 19042)
@@ -72,7 +72,7 @@
throw Messages.MESSAGES.unsupportedTokenType(token.getTokenType());
}
UsernameToken ut = (UsernameToken) token;
- subject = helper.createSubject(authenticationManger, ut.getName(), ut.getPassword(), ut.isHashed(), ut.getNonce(), ut.getCreatedTime());
+ subject = helper.createSubject(authenticationManger, ut.getName(), ut.getPassword(), ut.isHashed(), ut.getNonce(), ut.getCreatedTime(), message);
}
else
@@ -83,7 +83,7 @@
throw Messages.MESSAGES.couldNotGetSubjectInfo();
}
WSUsernameTokenPrincipal up = (WSUsernameTokenPrincipal) p;
- subject = helper.createSubject(authenticationManger, up.getName(), up.getPassword(), up.isPasswordDigest(), up.getNonce(), up.getCreatedTime());
+ subject = helper.createSubject(authenticationManger, up.getName(), up.getPassword(), up.isPasswordDigest(), up.getNonce(), up.getCreatedTime(), message);
}
Principal principal = getPrincipal(context.getUserPrincipal(), subject);
Modified: stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreatingInterceptor.java
===================================================================
--- stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreatingInterceptor.java 2014-10-30 15:21:54 UTC (rev 19041)
+++ stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreatingInterceptor.java 2014-10-30 16:12:20 UTC (rev 19042)
@@ -104,7 +104,7 @@
UsernameToken ut = (UsernameToken)token;
Subject subject = createSubject(ut.getName(), ut.getPassword(), ut.isHashed(),
- ut.getNonce(), ut.getCreatedTime());
+ ut.getNonce(), ut.getCreatedTime(), msg);
SecurityContext sc = doCreateSecurityContext(context.getUserPrincipal(), subject);
msg.put(SecurityContext.class, sc);
@@ -152,7 +152,7 @@
Subject subject = null;
try
{
- subject = createSubject(name, password, isDigest, nonce, created);
+ subject = createSubject(name, password, isDigest, nonce, created, msg);
}
catch (Exception ex)
{
@@ -240,9 +240,9 @@
}
- public Subject createSubject(String name, String password, boolean isDigest, String nonce, String created)
+ public Subject createSubject(String name, String password, boolean isDigest, String nonce, String created, Message msg)
{
- return helper.createSubject(sdc.get(), name, password, isDigest, nonce, created);
+ return helper.createSubject(sdc.get(), name, password, isDigest, nonce, created, msg);
}
public void setPropagateContext(boolean propagateContext)
Modified: stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreatingPolicyInterceptor.java
===================================================================
--- stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreatingPolicyInterceptor.java 2014-10-30 15:21:54 UTC (rev 19041)
+++ stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreatingPolicyInterceptor.java 2014-10-30 16:12:20 UTC (rev 19042)
@@ -81,7 +81,7 @@
throw Messages.MESSAGES.unsupportedTokenType(token.getTokenType());
}
UsernameToken ut = (UsernameToken) token;
- subject = createSubject(sdc, ut.getName(), ut.getPassword(), ut.isHashed(), ut.getNonce(), ut.getCreatedTime());
+ subject = createSubject(sdc, ut.getName(), ut.getPassword(), ut.isHashed(), ut.getNonce(), ut.getCreatedTime(), message);
}
else
@@ -92,19 +92,19 @@
throw Messages.MESSAGES.couldNotGetSubjectInfo();
}
WSUsernameTokenPrincipal up = (WSUsernameTokenPrincipal) p;
- subject = createSubject(sdc, up.getName(), up.getPassword(), up.isPasswordDigest(), up.getNonce(), up.getCreatedTime());
+ subject = createSubject(sdc, up.getName(), up.getPassword(), up.isPasswordDigest(), up.getNonce(), up.getCreatedTime(), message);
}
Principal principal = getPrincipal(context.getUserPrincipal(), subject);
message.put(SecurityContext.class, createSecurityContext(principal, subject));
}
- protected Subject createSubject(SecurityDomainContext sdc, String name, String password, boolean isDigest, String nonce, String creationTime)
+ protected Subject createSubject(SecurityDomainContext sdc, String name, String password, boolean isDigest, String nonce, String creationTime, Message msg)
{
Subject subject = null;
try
{
- subject = helper.createSubject(sdc, name, password, isDigest, nonce, creationTime);
+ subject = helper.createSubject(sdc, name, password, isDigest, nonce, creationTime, msg);
}
catch (Exception ex)
{
Modified: stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreator.java
===================================================================
--- stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreator.java 2014-10-30 15:21:54 UTC (rev 19041)
+++ stack/cxf/branches/jbossws-cxf-4.3.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreator.java 2014-10-30 16:12:20 UTC (rev 19042)
@@ -34,6 +34,7 @@
import javax.security.auth.callback.CallbackHandler;
import org.apache.cxf.common.security.SimplePrincipal;
+import org.apache.cxf.message.Message;
import org.jboss.security.auth.callback.CallbackHandlerPolicyContextHandler;
import org.jboss.security.plugins.JBossAuthenticationManager;
import org.jboss.ws.common.utils.DelegateClassLoader;
@@ -62,7 +63,7 @@
private boolean decodeNonce = true;
- public Subject createSubject(SecurityDomainContext ctx, String name, String password, boolean isDigest, String nonce, String created)
+ public Subject createSubject(SecurityDomainContext ctx, String name, String password, boolean isDigest, String nonce, String created, Message msg)
{
if (isDigest)
{
@@ -75,6 +76,7 @@
CallbackHandler handler = new UsernameTokenCallbackHandler(nonce, created, decodeNonce);
CallbackHandlerPolicyContextHandler.setCallbackHandler(handler);
+ msg.put(CallbackHandler.class, handler);
}
// authenticate and populate Subject
@@ -126,7 +128,7 @@
return subject;
}
//TODO:refactor this
- public Subject createSubject(JBossAuthenticationManager manager, String name, String password, boolean isDigest, String nonce, String created)
+ public Subject createSubject(JBossAuthenticationManager manager, String name, String password, boolean isDigest, String nonce, String created, Message msg)
{
if (isDigest)
{
@@ -139,6 +141,7 @@
CallbackHandler handler = new UsernameTokenCallbackHandler(nonce, created, decodeNonce);
CallbackHandlerPolicyContextHandler.setCallbackHandler(handler);
+ msg.put(CallbackHandler.class, handler);
}
// authenticate and populate Subject
Copied: stack/cxf/branches/jbossws-cxf-4.3.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationDigestEjbTestCase.java (from rev 19030, stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationDigestEjbTestCase.java)
===================================================================
--- stack/cxf/branches/jbossws-cxf-4.3.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationDigestEjbTestCase.java (rev 0)
+++ stack/cxf/branches/jbossws-cxf-4.3.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationDigestEjbTestCase.java 2014-10-30 16:12:20 UTC (rev 19042)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.wsse.policy.jaas;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+
+import junit.framework.Test;
+
+import org.apache.cxf.ws.security.SecurityConstants;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.wsf.stack.cxf.security.authentication.callback.UsernameTokenCallback;
+import org.jboss.wsf.test.JBossWSCXFTestSetup;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestHelper;
+import org.jboss.wsf.test.JBossWSTestHelper.BaseDeployment;
+
+/**
+ * WS-Security Policy username ejb endpoint test case leveraging JAAS container integration and using digest passwords.
+ * WS-SecurityPolicy 1.2 used for policies in the included wsdl contract.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @author <a href="mailto:ema@redhat.com"/>Jim Ma<a>
+ * @since 26-May-2011
+ */
+public final class UsernameAuthorizationDigestEjbTestCase extends JBossWSTest
+{
+ private final String serviceURL = "http://" + getServerHost() + ":8080/jaxws-samples-wsse-policy-username-jaas-ejb-digest/SecurityService/EJBServiceImpl";
+ private QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "SecurityService");
+
+ public static BaseDeployment<?>[] createDeployments()
+ {
+ List<BaseDeployment<?>> list = new LinkedList<BaseDeployment<?>>();
+ list.add(new JBossWSTestHelper.JarDeployment("jaxws-samples-wsse-policy-username-jaas-ejb-digest.jar") {
+ { //[JBWS-3843] workaround: add org.jboss.as.webservices.server.integration dependency to load UsernameTokenCallback for UsernamePasswordLoginModule
+ // This dependency should actually never be set for a user deployment, being it an internal server thing. To be properly replaced after changes in PicketBox.
+ archive
+ .setManifest(new StringAsset("Manifest-Version: 1.0\n" + "Dependencies: org.jboss.ws.cxf.jbossws-cxf-client,org.jboss.as.webservices.server.integration\n"))
+ .addClass(org.jboss.test.ws.jaxws.samples.wsse.policy.jaas.EJBServiceImpl.class)
+ .addClass(org.jboss.test.ws.jaxws.samples.wsse.policy.jaas.ServiceIface.class)
+ .addClass(org.jboss.test.ws.jaxws.samples.wsse.policy.jaxws.GreetMe.class)
+ .addClass(org.jboss.test.ws.jaxws.samples.wsse.policy.jaxws.GreetMeResponse.class)
+ .addClass(org.jboss.test.ws.jaxws.samples.wsse.policy.jaxws.SayHello.class)
+ .addClass(org.jboss.test.ws.jaxws.samples.wsse.policy.jaxws.SayHelloResponse.class)
+ .addAsManifestResource(
+ new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/samples/wsse/policy/jaas/ejb-digest/META-INF/jaxws-endpoint-config.xml"),
+ "jaxws-endpoint-config.xml")
+ .addAsManifestResource(
+ new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/samples/wsse/policy/jaas/ejb-digest/META-INF/wsdl/SecurityService.wsdl"),
+ "wsdl/SecurityService.wsdl")
+ .addAsManifestResource(
+ new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/samples/wsse/policy/jaas/ejb-digest/META-INF/wsdl/SecurityService_schema1.xsd"),
+ "wsdl/SecurityService_schema1.xsd");
+ }
+ });
+ return list.toArray(new BaseDeployment<?>[list.size()]);
+ }
+
+ public static Test suite()
+ {
+ JBossWSCXFTestSetup testSetup;
+ testSetup = new JBossWSCXFTestSetup(UsernameAuthorizationDigestEjbTestCase.class, JBossWSTestHelper.writeToFile(createDeployments()));
+ Map<String, String> authenticationOptions = new HashMap<String, String>();
+ authenticationOptions.put("usersProperties", getResourceFile("jaxws/samples/wsse/policy/jaas/digest/WEB-INF/jbossws-users.properties").getAbsolutePath());
+ authenticationOptions.put("rolesProperties", getResourceFile("jaxws/samples/wsse/policy/jaas/digest/WEB-INF/jbossws-roles.properties").getAbsolutePath());
+ authenticationOptions.put("hashAlgorithm", "SHA");
+ authenticationOptions.put("hashEncoding", "BASE64");
+ authenticationOptions.put("hashCharset", "UTF-8");
+ authenticationOptions.put("hashUserPassword", "false");
+ authenticationOptions.put("hashStorePassword", "true");
+ authenticationOptions.put("storeDigestCallback", UsernameTokenCallback.class.getName());
+ authenticationOptions.put("unauthenticatedIdentity", "anonymous");
+ testSetup.addSecurityDomainRequirement("JBossWS", authenticationOptions);
+ return testSetup;
+ }
+
+ public void test() throws Exception
+ {
+ URL wsdlURL = new URL(serviceURL + "?wsdl");
+ Service service = Service.create(wsdlURL, serviceName);
+ ServiceIface proxy = (ServiceIface)service.getPort(ServiceIface.class);
+ setupWsse(proxy, "kermit");
+ assertEquals("Secure Hello World!", proxy.sayHello());
+ }
+
+ //JBWS-3843
+ public void testConcurrent() throws Exception
+ {
+ ExecutorService executor = Executors.newFixedThreadPool(20);
+
+ List<Callable<String>> taskList = new ArrayList<Callable<String>>();
+ for (int i = 0; i < 20; i++)
+ {
+ taskList.add(new TestRunner());
+ }
+ List<Future<String>> resultList = executor.invokeAll(taskList);
+ boolean passed = true;
+ for (Future<String> future : resultList)
+ {
+ passed = passed && future.get().equals("Secure Hello World!");
+ }
+ assertTrue("Unexpected response from concurrent invocation", passed);
+
+ }
+
+ public class TestRunner implements Callable<String>
+ {
+ public String call() throws Exception
+ {
+ URL wsdlURL = new URL(serviceURL + "?wsdl");
+ Service service = Service.create(wsdlURL, serviceName);
+ ServiceIface proxy = (ServiceIface)service.getPort(ServiceIface.class);
+ setupWsse(proxy, "kermit");
+ return proxy.sayHello();
+
+ }
+
+ }
+
+ public void testUnauthenticated() throws Exception
+ {
+ URL wsdlURL = new URL(serviceURL + "?wsdl");
+ Service service = Service.create(wsdlURL, serviceName);
+ ServiceIface proxy = (ServiceIface)service.getPort(ServiceIface.class);
+ setupWsse(proxy, "kermit");
+ try
+ {
+ proxy.greetMe();
+ fail("User kermit shouldn't be authenticated.");
+ }
+ catch (Exception e)
+ {
+ //OK
+ }
+ }
+
+ private void setupWsse(ServiceIface proxy, String username)
+ {
+ ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.USERNAME, username);
+ ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER,
+ "org.jboss.test.ws.jaxws.samples.wsse.policy.jaas.UsernameDigestPasswordCallback");
+ }
+}
10 years, 1 month
JBossWS SVN: r19041 - stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas.
by jbossws-commits@lists.jboss.org
Author: asoldano
Date: 2014-10-30 11:21:54 -0400 (Thu, 30 Oct 2014)
New Revision: 19041
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationDigestEjbTestCase.java
Log:
[JBWS-3843] More workaround comments
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationDigestEjbTestCase.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationDigestEjbTestCase.java 2014-10-30 15:15:39 UTC (rev 19040)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationDigestEjbTestCase.java 2014-10-30 15:21:54 UTC (rev 19041)
@@ -64,7 +64,8 @@
{
List<BaseDeployment<?>> list = new LinkedList<BaseDeployment<?>>();
list.add(new JBossWSTestHelper.JarDeployment("jaxws-samples-wsse-policy-username-jaas-ejb-digest.jar") {
- { //add org.jboss.as.webservices.server.integration dependency to load UsernameTokenCallback for UsernamePasswordLoginModule
+ { //[JBWS-3843] workaround: add org.jboss.as.webservices.server.integration dependency to load UsernameTokenCallback for UsernamePasswordLoginModule
+ // This dependency should actually never be set for a user deployment, being it an internal server thing. To be properly replaced after changes in PicketBox.
archive
.setManifest(new StringAsset("Manifest-Version: 1.0\n" + "Dependencies: org.jboss.ws.cxf.jbossws-cxf-client,org.jboss.as.webservices.server.integration\n"))
.addClass(org.jboss.test.ws.jaxws.samples.wsse.policy.jaas.EJBServiceImpl.class)
10 years, 1 month
JBossWS SVN: r19040 - stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf.
by jbossws-commits@lists.jboss.org
Author: asoldano
Date: 2014-10-30 11:15:39 -0400 (Thu, 30 Oct 2014)
New Revision: 19040
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/JBossWSInvoker.java
Log:
[JBWS-3843] Adding comment explaining the workaround; proper fix will come in PicketBox
Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/JBossWSInvoker.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/JBossWSInvoker.java 2014-10-30 11:39:52 UTC (rev 19039)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/JBossWSInvoker.java 2014-10-30 15:15:39 UTC (rev 19040)
@@ -133,6 +133,8 @@
targetBean = this.getServiceObject(exchange);
}
+ //[JBWS-3843] workaround: set the CallbackHandler threadlocal again; as a matter of fact, if that's in the Exchange,
+ //DIGEST auth is being used and that will cause the EJB layer to re-do authentication because of the bug
CallbackHandler cbHandler = exchange.getInMessage().get(CallbackHandler.class);
Object obj = null;
try
10 years, 1 month
JBossWS SVN: r19039 - stack/cxf/branches.
by jbossws-commits@lists.jboss.org
Author: mmusaji
Date: 2014-10-30 07:39:52 -0400 (Thu, 30 Oct 2014)
New Revision: 19039
Added:
stack/cxf/branches/jbossws-cxf-4.3.0.Final-BZ1157539/
Log:
[BZ-1157539] Creating one off patch branch for JBWS-3843 backport
10 years, 1 month
JBossWS SVN: r19038 - in stack/cxf/branches/jbossws-cxf-4.3.x: modules/client/src/main/java/org/jboss/wsf/stack/cxf/client and 1 other directories.
by jbossws-commits@lists.jboss.org
Author: asoldano
Date: 2014-10-29 12:44:02 -0400 (Wed, 29 Oct 2014)
New Revision: 19038
Modified:
stack/cxf/branches/jbossws-cxf-4.3.x/
stack/cxf/branches/jbossws-cxf-4.3.x/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java
stack/cxf/branches/jbossws-cxf-4.3.x/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/HandlerChainSortInterceptor.java
Log:
Merged revisions 19024-19025,19028,19036-19037 via svnmerge from
https://svn.jboss.org/repos/jbossws/stack/cxf/trunk
.......
r19024 | asoldano | 2014-10-22 16:06:04 +0200 (Wed, 22 Oct 2014) | 2 lines
[JBWS-3848] Optimize HandlerChainSortInterceptor
.......
r19025 | asoldano | 2014-10-22 16:18:29 +0200 (Wed, 22 Oct 2014) | 2 lines
[JBWS-3848] Always cleanup the sorter
.......
r19028 | asoldano | 2014-10-23 19:04:54 +0200 (Thu, 23 Oct 2014) | 2 lines
[JBWS-3848] Use array lists
.......
r19036 | asoldano | 2014-10-29 15:05:50 +0100 (Wed, 29 Oct 2014) | 2 lines
[JBWS-3848] Avoid resetting the handler-chain in the Binding; instead sort the chain copy that's used to build the handler chain invoker; this hides the process from the user and adds no processing overhead as the chain is already copied to build an invoker; sort the chain upfront when building the client (after pre-defined config setup), to speed up sorting in the best and most common scenario (no manual user change to the chain).
.......
r19037 | asoldano | 2014-10-29 17:09:21 +0100 (Wed, 29 Oct 2014) | 2 lines
Multiple test invocations, to verify the config is not lost after first invocation (no bug expected, I just used this for debugging JBWS-3848 and thought it might be usefull in future)
.......
Property changes on: stack/cxf/branches/jbossws-cxf-4.3.x
___________________________________________________________________
Modified: svnmerge-integrated
- /stack/cxf/trunk:1-18594,18609-18612,18616-18619,18621,18625-18652,18656-18658,18661,18663,18665-18668,18671-18683,18685-18687,18689-18693,18695,18698,18701,18703-18704,18706-18710,18712-18713,18715,18717-18721,18726-18730,18732,18735-18737,18742,18745-18746,18750-18752,18755-18759,18762,18770,18777-18779,18781-18787,18796,18798,18805-18808,18811-18814,18816,18822-18824,18832-18835,18837,18839-18840,18842-18843,18845,18847-18848,18852,18856-18857,18859-18864,18866,18883-18884,18933,18947
+ /stack/cxf/trunk:1-18594,18609-18612,18616-18619,18621,18625-18652,18656-18658,18661,18663,18665-18668,18671-18683,18685-18687,18689-18693,18695,18698,18701,18703-18704,18706-18710,18712-18713,18715,18717-18721,18726-18730,18732,18735-18737,18742,18745-18746,18750-18752,18755-18759,18762,18770,18777-18779,18781-18787,18796,18798,18805-18808,18811-18814,18816,18822-18824,18832-18835,18837,18839-18840,18842-18843,18845,18847-18848,18852,18856-18857,18859-18864,18866,18883-18884,18933,18947,19024-19026,19028,19034-19037
Modified: svn:mergeinfo
- /stack/cxf/branches/asoldano:14032-14050,14068
/stack/cxf/branches/jaspi:18054-18409
/stack/cxf/branches/ropalka:16301-16305,16966-17008
/stack/cxf/branches/ropalka_JBWS-3550:16747-16757
/stack/cxf/trunk:18609,18616-18619,18629,18695,18710,18715,18798,18814,18816,18847,18852,18856,18860-18864,18866,18883-18884,18933,18947
+ /stack/cxf/branches/asoldano:14032-14050,14068
/stack/cxf/branches/jaspi:18054-18409
/stack/cxf/branches/ropalka:16301-16305,16966-17008
/stack/cxf/branches/ropalka_JBWS-3550:16747-16757
/stack/cxf/trunk:18609,18616-18619,18629,18695,18710,18715,18798,18814,18816,18847,18852,18856,18860-18864,18866,18883-18884,18933,18947,19024-19025,19028,19036-19037
Modified: stack/cxf/branches/jbossws-cxf-4.3.x/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java
===================================================================
--- stack/cxf/branches/jbossws-cxf-4.3.x/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java 2014-10-29 16:09:21 UTC (rev 19037)
+++ stack/cxf/branches/jbossws-cxf-4.3.x/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java 2014-10-29 16:44:02 UTC (rev 19038)
@@ -574,7 +574,6 @@
protected void setupClient(Object obj, WebServiceFeature... features) {
Binding binding = ((BindingProvider)obj).getBinding();
Client client = obj instanceof DispatchImpl<?> ? ((DispatchImpl<?>)obj).getClient() : ClientProxy.getClient(obj);
- client.getOutInterceptors().add(new HandlerChainSortInterceptor(binding));
if (ClassLoaderProvider.isSet()) { //optimization for avoiding checking for a server config when we know for sure we're out-of-container
ServerConfig sc = getServerConfig();
if (sc != null) {
@@ -586,6 +585,7 @@
}
}
}
+ client.getOutInterceptors().add(new HandlerChainSortInterceptor(binding)); //add this *after* the config has been set (if any)!
if (features != null) {
for (WebServiceFeature f : features) {
if (f instanceof AbstractClientFeature) {
Modified: stack/cxf/branches/jbossws-cxf-4.3.x/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/HandlerChainSortInterceptor.java
===================================================================
--- stack/cxf/branches/jbossws-cxf-4.3.x/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/HandlerChainSortInterceptor.java 2014-10-29 16:09:21 UTC (rev 19037)
+++ stack/cxf/branches/jbossws-cxf-4.3.x/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/HandlerChainSortInterceptor.java 2014-10-29 16:44:02 UTC (rev 19038)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2014, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -29,6 +29,8 @@
import javax.xml.ws.handler.Handler;
import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.jaxws.handler.HandlerChainInvoker;
+import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
@@ -46,25 +48,45 @@
{
private Binding binding;
@SuppressWarnings("rawtypes")
- private static Comparator<Handler> comparator = new ConfigDelegateHandlerComparator<Handler>();
+ private static final Comparator<Handler> comparator = new ConfigDelegateHandlerComparator<Handler>();
public HandlerChainSortInterceptor(Binding b)
{
- super(Phase.SETUP);
+ super(Phase.PRE_PROTOCOL);
binding = b;
+ //initially sort and reset the handler chain; if the chain is not modified later, the sort process
+ //in handleMessage() deals with an already ordered list and is very efficient (~ O(n) according to
+ //Collections.sort(..) javadoc.
+ @SuppressWarnings("rawtypes")
+ List<Handler> hc = binding.getHandlerChain();
+ if (hc.size() > 1) { //no need to sort etc if the chain is empty or has one handler only
+ Collections.sort(hc, comparator);
+ binding.setHandlerChain(hc);
+ }
}
@Override
+ @SuppressWarnings("rawtypes")
public void handleMessage(Message message) throws Fault
{
if (binding != null) {
- @SuppressWarnings("rawtypes")
- List<Handler> list = binding.getHandlerChain();
- if (list != null && !list.isEmpty()) {
- Collections.sort(list, comparator);
- binding.setHandlerChain(list);
+ Exchange ex = message.getExchange();
+ if (ex.get(HandlerChainInvoker.class) == null) {
+ List<Handler> hc = binding.getHandlerChain();
+ if (hc.size() > 1) { //no need to sort etc if the chain is empty or has one handler only
+ Collections.sort(hc, comparator);
+ //install a new HandlerChainInvoker using the sorted handler chain;
+ //the AbstractJAXWSHandlerInterceptor will be using this invoker
+ //instead of creating a new one
+ ex.put(HandlerChainInvoker.class, new HandlerChainInvoker(hc, isOutbound(message, ex)));
+ }
}
}
}
-
+
+ private boolean isOutbound(Message message, Exchange ex) {
+ return message == ex.getOutMessage()
+ || message == ex.getOutFaultMessage();
+ }
+
}
10 years, 1 month
JBossWS SVN: r19037 - stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig.
by jbossws-commits@lists.jboss.org
Author: asoldano
Date: 2014-10-29 12:09:21 -0400 (Wed, 29 Oct 2014)
New Revision: 19037
Modified:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/Helper.java
Log:
Multiple test invocations, to verify the config is not lost after first invocation (no bug expected, I just used this for debugging JBWS-3848 and thought it might be usefull in future)
Modified: stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/Helper.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/Helper.java 2014-10-29 14:05:50 UTC (rev 19036)
+++ stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/Helper.java 2014-10-29 16:09:21 UTC (rev 19037)
@@ -76,6 +76,8 @@
ClientConfigUtil.setConfigHandlers(bp, "META-INF/jaxws-client-config.xml", "Custom Client Config");
String resStr = port.echo("Kermit");
+ resStr = port.echo("Kermit");
+ resStr = port.echo("Kermit");
return ("Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr));
}
@@ -98,6 +100,8 @@
ClientConfigUtil.setConfigHandlers(bp, "META-INF/jaxws-client-config.xml", "Custom Client Config");
Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+ resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+ resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
return ("Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr));
}
@@ -117,6 +121,8 @@
bp.getBinding().setHandlerChain(hc);
String resStr = port.echo("Kermit");
+ resStr = port.echo("Kermit");
+ resStr = port.echo("Kermit");
if (!"Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr)) {
return false;
}
@@ -129,6 +135,8 @@
bp.getBinding().setHandlerChain(hc);
resStr = port3.echo("Kermit");
+ resStr = port3.echo("Kermit");
+ resStr = port3.echo("Kermit");
if (!"Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr)) {
return false;
}
@@ -141,6 +149,8 @@
bp.getBinding().setHandlerChain(hc);
resStr = port2.echo("Kermit");
+ resStr = port2.echo("Kermit");
+ resStr = port2.echo("Kermit");
return ("Kermit|CustomOut|UserOut|endpoint|UserIn|CustomIn".equals(resStr));
}
@@ -162,6 +172,7 @@
bp.getBinding().setHandlerChain(hc);
Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+ resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
return ("Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr));
}
@@ -184,6 +195,8 @@
configurer.setConfigHandlers(bp, "META-INF/jaxws-client-config.xml", "Custom Client Config");
String resStr = port.echo("Kermit");
+ resStr = port.echo("Kermit");
+ resStr = port.echo("Kermit");
if (!"Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr)) {
return false;
}
@@ -191,6 +204,8 @@
configurer.setConfigHandlers(bp, "META-INF/jaxws-client-config.xml", "Another Client Config");
resStr = port.echo("Kermit");
+ resStr = port.echo("Kermit");
+ resStr = port.echo("Kermit");
return ("Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr));
}
@@ -214,6 +229,8 @@
configurer.setConfigHandlers(bp, "META-INF/jaxws-client-config.xml", "Custom Client Config");
Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+ resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+ resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
if (!"Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr)) {
return false;
@@ -222,6 +239,8 @@
configurer.setConfigHandlers(bp, "META-INF/jaxws-client-config.xml", "Another Client Config");
resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+ resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+ resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
return ("Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr));
}
@@ -256,6 +275,8 @@
bp.getBinding().setHandlerChain(hc);
String resStr = port.echo("Kermit");
+ resStr = port.echo("Kermit");
+ resStr = port.echo("Kermit");
return ("Kermit|UserOut|LogOut|endpoint|LogIn|UserIn".equals(resStr));
}
finally
@@ -290,6 +311,8 @@
bp.getBinding().setHandlerChain(hc);
Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+ resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+ resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
return ("Kermit|UserOut|LogOut|endpoint|LogIn|UserIn".equals(resStr));
}
@@ -332,6 +355,8 @@
ClientConfigUtil.setConfigHandlers(bp, null, testConfigName);
String resStr = port.echo("Kermit");
+ resStr = port.echo("Kermit");
+ resStr = port.echo("Kermit");
return ("Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr));
}
finally
@@ -368,6 +393,8 @@
ClientConfigUtil.setConfigHandlers(bp, null, testConfigName);
Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+ resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+ resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
return ("Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr));
}
@@ -401,6 +428,8 @@
bp.getBinding().setHandlerChain(hc);
String resStr = port.echo("Kermit");
+ resStr = port.echo("Kermit");
+ resStr = port.echo("Kermit");
return ("Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr));
}
finally
@@ -435,6 +464,8 @@
bp.getBinding().setHandlerChain(hc);
Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+ resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+ resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
return ("Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr));
}
@@ -476,6 +507,8 @@
bp.getBinding().setHandlerChain(hc);
String resStr = port.echo("Kermit");
+ resStr = port.echo("Kermit");
+ resStr = port.echo("Kermit");
return ("Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr));
}
finally
@@ -519,6 +552,8 @@
bp.getBinding().setHandlerChain(hc);
String resStr = port.echo("Kermit");
+ resStr = port.echo("Kermit");
+ resStr = port.echo("Kermit");
if (!"Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr)) {
return false;
}
@@ -531,6 +566,8 @@
bp.getBinding().setHandlerChain(hc);
resStr = port2.echo("Kermit");
+ resStr = port2.echo("Kermit");
+ resStr = port2.echo("Kermit");
return ("Kermit|RoutOut|UserOut|LogOut|endpoint|LogIn|UserIn|RoutIn".equals(resStr));
}
10 years, 1 month
JBossWS SVN: r19036 - in stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client: configuration and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: asoldano
Date: 2014-10-29 10:05:50 -0400 (Wed, 29 Oct 2014)
New Revision: 19036
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/HandlerChainSortInterceptor.java
Log:
[JBWS-3848] Avoid resetting the handler-chain in the Binding; instead sort the chain copy that's used to build the handler chain invoker; this hides the process from the user and adds no processing overhead as the chain is already copied to build an invoker; sort the chain upfront when building the client (after pre-defined config setup), to speed up sorting in the best and most common scenario (no manual user change to the chain).
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java 2014-10-29 14:02:39 UTC (rev 19035)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java 2014-10-29 14:05:50 UTC (rev 19036)
@@ -579,13 +579,13 @@
protected void setupClient(Object obj, Class<?> seiClass, WebServiceFeature... features) {
Binding binding = ((BindingProvider)obj).getBinding();
Client client = obj instanceof DispatchImpl<?> ? ((DispatchImpl<?>)obj).getClient() : ClientProxy.getClient(obj);
- client.getOutInterceptors().add(new HandlerChainSortInterceptor(binding));
ClientConfig config = readConfig(seiClass);
if (config != null) {
CXFClientConfigurer helper = new CXFClientConfigurer();
helper.setupConfigHandlers(binding, config);
helper.setConfigProperties(client, config.getProperties());
}
+ client.getOutInterceptors().add(new HandlerChainSortInterceptor(binding)); //add this *after* the config has been set (if any)!
if (features != null) {
for (WebServiceFeature f : features) {
if (f instanceof AbstractClientFeature) {
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/HandlerChainSortInterceptor.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/HandlerChainSortInterceptor.java 2014-10-29 14:02:39 UTC (rev 19035)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/HandlerChainSortInterceptor.java 2014-10-29 14:05:50 UTC (rev 19036)
@@ -21,18 +21,20 @@
*/
package org.jboss.wsf.stack.cxf.client.configuration;
-import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
import javax.xml.ws.Binding;
import javax.xml.ws.handler.Handler;
import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.jaxws.handler.HandlerChainInvoker;
+import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
-import org.jboss.ws.common.configuration.ConfigDelegateHandler;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData.HandlerType;
+import org.jboss.ws.common.configuration.ConfigDelegateHandlerComparator;
/**
@@ -45,137 +47,46 @@
public class HandlerChainSortInterceptor extends AbstractPhaseInterceptor<Message>
{
private final Binding binding;
+ @SuppressWarnings("rawtypes")
+ private static final Comparator<Handler> comparator = new ConfigDelegateHandlerComparator<Handler>();
public HandlerChainSortInterceptor(Binding b)
{
- super(Phase.SETUP);
+ super(Phase.PRE_PROTOCOL);
binding = b;
+ //initially sort and reset the handler chain; if the chain is not modified later, the sort process
+ //in handleMessage() deals with an already ordered list and is very efficient (~ O(n) according to
+ //Collections.sort(..) javadoc.
+ @SuppressWarnings("rawtypes")
+ List<Handler> hc = binding.getHandlerChain();
+ if (hc.size() > 1) { //no need to sort etc if the chain is empty or has one handler only
+ Collections.sort(hc, comparator);
+ binding.setHandlerChain(hc);
+ }
}
@Override
+ @SuppressWarnings("rawtypes")
public void handleMessage(Message message) throws Fault
{
if (binding != null) {
- @SuppressWarnings("rawtypes")
- List<Handler> list = binding.getHandlerChain();
- if (list != null && !list.isEmpty()) {
- HandlerSorter hs = new HandlerSorter();
- if (hs.split(list)) {
- binding.setHandlerChain(hs.merge());
+ Exchange ex = message.getExchange();
+ if (ex.get(HandlerChainInvoker.class) == null) {
+ List<Handler> hc = binding.getHandlerChain();
+ if (hc.size() > 1) { //no need to sort etc if the chain is empty or has one handler only
+ Collections.sort(hc, comparator);
+ //install a new HandlerChainInvoker using the sorted handler chain;
+ //the AbstractJAXWSHandlerInterceptor will be using this invoker
+ //instead of creating a new one
+ ex.put(HandlerChainInvoker.class, new HandlerChainInvoker(hc, isOutbound(message, ex)));
}
- hs.cleanup();
}
}
}
-
- /**
- * Utility class for efficiently sorting handlers so that PRE handlers always
- * come before user handlers and POST handlers always come after user handlers.
- *
- * We need to know if the sorted list is actually different from the original
- * list, as if they are the same we don't want to spend time on setting a new
- * handler chain, which can be expensive. Moreover we're not really interested
- * in sorting the whole chain, we only care about the PRE/user/POST requirement
- * and are fine with the relative order of handlers of the same type.
- *
- * So we process the list in two phases:
- *
- * 1) split phase: the handler list is scanned (O(n)) to split it into PRE, user
- * and POST handler sublists. The relative order of handlers of
- * the same type is not changed.
- * While splitting, the procedure also figures out if the list
- * actually requires sorting, that is whether the PRE-user-POST
- * order requirement is not satisfied; this allows avoiding
- * useless ordering if the list is already fine (which is the
- * most common scenario).
- * 2) merge phase: the sublists are merged together (O(n)) into an ordered
- * handlers list
- *
- * The overall time complexity is O(2n).
- *
- */
- @SuppressWarnings("rawtypes")
- private class HandlerSorter {
- private List<Handler> pre;
- private List<Handler> ep;
- private List<Handler> post;
-
- /**
- * Read the handlers list and figures out if it requires sorting.
- *
- * @param handlers
- * @return
- */
- public boolean split(List<Handler> handlers) {
- boolean requiresSort = false;
- HandlerType lastHandlerType = null;
- for (Handler h : handlers) {
- if (h instanceof ConfigDelegateHandler) {
- if (((ConfigDelegateHandler)h).isPre()) {
- add(h, HandlerType.PRE);
- if (lastHandlerType != null && lastHandlerType != HandlerType.PRE) {
- requiresSort = true;
- }
- lastHandlerType = HandlerType.PRE;
- } else {
- add(h, HandlerType.POST);
- lastHandlerType = HandlerType.POST;
- }
- } else {
- add(h, HandlerType.ENDPOINT);
- if (lastHandlerType != null && lastHandlerType == HandlerType.POST) {
- requiresSort = true;
- }
- lastHandlerType = HandlerType.ENDPOINT;
- }
- }
- return requiresSort;
- }
-
-
-
- public List<Handler> merge() {
- List<Handler> l = new ArrayList<Handler>();
- if (pre != null) {
- l.addAll(pre);
- }
- l.addAll(ep);
- if (post != null) {
- l.addAll(post);
- }
- return l;
- }
-
- public void cleanup() {
- this.pre = null;
- this.post = null;
- this.ep = null;
- }
-
- private void add(Handler h, HandlerType t) {
- switch (t)
- {
- case PRE :
- if (pre == null) {
- pre = new ArrayList<Handler>(4);
- }
- pre.add(h);
- break;
-
- case POST :
- if (post == null) {
- post = new ArrayList<Handler>(4);
- }
- post.add(h);
- break;
-
- default :
- if (ep == null) {
- ep = new ArrayList<Handler>();
- }
- ep.add(h);
- break;
- }
- }
+
+ private boolean isOutbound(Message message, Exchange ex) {
+ return message == ex.getOutMessage()
+ || message == ex.getOutFaultMessage();
}
+
}
10 years, 1 month
JBossWS SVN: r19035 - in common/trunk/src: test/java/org/jboss/test/ws/common/configuration and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: asoldano
Date: 2014-10-29 10:02:39 -0400 (Wed, 29 Oct 2014)
New Revision: 19035
Added:
common/trunk/src/main/java/org/jboss/ws/common/configuration/ConfigDelegateHandlerComparator.java
common/trunk/src/test/java/org/jboss/test/ws/common/configuration/ConfigDelegateHandlerComparatorTestCase.java
Log:
[JBWS-3848] Restore ConfigDelegateHandlerComparator
Copied: common/trunk/src/main/java/org/jboss/ws/common/configuration/ConfigDelegateHandlerComparator.java (from rev 19025, common/trunk/src/main/java/org/jboss/ws/common/configuration/ConfigDelegateHandlerComparator.java)
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/common/configuration/ConfigDelegateHandlerComparator.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/ws/common/configuration/ConfigDelegateHandlerComparator.java 2014-10-29 14:02:39 UTC (rev 19035)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.common.configuration;
+
+import java.io.Serializable;
+import java.util.Comparator;
+
+import javax.xml.ws.handler.Handler;
+
+/**
+ * A Handler comparator properly dealing with PRE/POST ConfigDelegateHandler instances
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 06-Jun-2012
+ *
+ */
+@SuppressWarnings("rawtypes")
+public final class ConfigDelegateHandlerComparator<T extends Handler> implements Comparator<T>, Serializable
+{
+ static final long serialVersionUID = 5045492270035185007L;
+
+ @Override
+ public int compare(Handler o1, Handler o2)
+ {
+ int i1 = 0;
+ int i2 = 0;
+ if (o1 instanceof ConfigDelegateHandler)
+ {
+ i1 = ((ConfigDelegateHandler) o1).isPre() ? -1 : 1;
+ }
+ if (o2 instanceof ConfigDelegateHandler)
+ {
+ i2 = ((ConfigDelegateHandler) o2).isPre() ? -1 : 1;
+ }
+ return i1 - i2;
+ }
+}
\ No newline at end of file
Copied: common/trunk/src/test/java/org/jboss/test/ws/common/configuration/ConfigDelegateHandlerComparatorTestCase.java (from rev 19025, common/trunk/src/test/java/org/jboss/test/ws/common/configuration/ConfigDelegateHandlerComparatorTestCase.java)
===================================================================
--- common/trunk/src/test/java/org/jboss/test/ws/common/configuration/ConfigDelegateHandlerComparatorTestCase.java (rev 0)
+++ common/trunk/src/test/java/org/jboss/test/ws/common/configuration/ConfigDelegateHandlerComparatorTestCase.java 2014-10-29 14:02:39 UTC (rev 19035)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.common.configuration;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.MessageContext;
+
+import junit.framework.TestCase;
+
+import org.jboss.ws.common.configuration.ConfigDelegateHandler;
+import org.jboss.ws.common.configuration.ConfigDelegateHandlerComparator;
+
+/**
+ * Test the ConfigDelegateHandlerComparator
+ *
+ * @author alessio.soldano(a)jboss.org
+ * @since 07-Jun-2012
+ */
+public class ConfigDelegateHandlerComparatorTestCase extends TestCase
+{
+ public void testComparator() throws Exception
+ {
+ List<NamedHandler> list = new LinkedList<NamedHandler>();
+ list.add(new TestConfigDelegateHandler(new TestHandler("post1"), false));
+ list.add(new TestHandler("h1"));
+ list.add(new TestConfigDelegateHandler(new TestHandler("post2"), false));
+ list.add(new TestConfigDelegateHandler(new TestHandler("pre1"), true));
+ list.add(new TestConfigDelegateHandler(new TestHandler("pre2"), true));
+ list.add(new TestHandler("h2"));
+ list.add(new TestHandler("h3"));
+ list.add(new TestHandler("h4"));
+ list.add(new TestHandler("h5"));
+ list.add(new TestConfigDelegateHandler(new TestHandler("post3"), false));
+ list.add(new TestConfigDelegateHandler(new TestHandler("pre3"), true));
+ list.add(new TestConfigDelegateHandler(new TestHandler("pre4"), true));
+ list.add(new TestHandler("h6"));
+ list.add(new TestConfigDelegateHandler(new TestHandler("post4"), false));
+
+ Collections.sort(list, new ConfigDelegateHandlerComparator<Handler<MessageContext>>());
+
+ StringBuilder sb = new StringBuilder();
+ for (NamedHandler h : list)
+ {
+ sb.append(h.getName());
+ sb.append(" ");
+ }
+ assertEquals("pre1 pre2 pre3 pre4 h1 h2 h3 h4 h5 h6 post1 post2 post3 post4", sb.toString().trim());
+ }
+
+ private static interface NamedHandler extends Handler<MessageContext>
+ {
+
+ public String getName();
+
+ }
+
+ private static class TestConfigDelegateHandler extends ConfigDelegateHandler<MessageContext> implements NamedHandler
+ {
+
+ public TestConfigDelegateHandler(Handler<MessageContext> delegate, boolean isPre)
+ {
+ super(delegate, isPre);
+ }
+
+ @Override
+ public String getName()
+ {
+ return delegate instanceof NamedHandler ? ((NamedHandler) delegate).getName() : null;
+ }
+
+ }
+
+ private static class TestHandler implements NamedHandler
+ {
+
+ private String name;
+
+ public TestHandler(String name)
+ {
+ this.name = name;
+ }
+
+ @Override
+ public String getName()
+ {
+ return name;
+ }
+
+ @Override
+ public boolean handleMessage(MessageContext context)
+ {
+ return false;
+ }
+
+ @Override
+ public boolean handleFault(MessageContext context)
+ {
+ return false;
+ }
+
+ @Override
+ public void close(MessageContext context)
+ {
+ }
+ }
+}
10 years, 1 month
JBossWS SVN: r19034 - common/trunk/src/main/java/org/jboss/ws/common/utils.
by jbossws-commits@lists.jboss.org
Author: rsearls
Date: 2014-10-28 10:54:33 -0400 (Tue, 28 Oct 2014)
New Revision: 19034
Modified:
common/trunk/src/main/java/org/jboss/ws/common/utils/AbstractWSDLFilePublisher.java
Log:
[JBWS-3851] checking for https for schema imports
Modified: common/trunk/src/main/java/org/jboss/ws/common/utils/AbstractWSDLFilePublisher.java
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/common/utils/AbstractWSDLFilePublisher.java 2014-10-27 18:26:59 UTC (rev 19033)
+++ common/trunk/src/main/java/org/jboss/ws/common/utils/AbstractWSDLFilePublisher.java 2014-10-28 14:54:33 UTC (rev 19034)
@@ -207,7 +207,7 @@
final String ln = childElement.getLocalName();
if ("import".equals(ln) || "include".equals(ln)) {
String schemaLocation = childElement.getAttribute("schemaLocation");
- if (schemaLocation.length() > 0 && schemaLocation.startsWith("http://") == false)
+ if (schemaLocation.length() > 0 && schemaLocation.startsWith("http://") == false && schemaLocation.startsWith("https://") == false)
{
// infinity loops prevention
if (!published.contains(schemaLocation))
10 years, 1 month
JBossWS SVN: r19033 - stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas.
by jbossws-commits@lists.jboss.org
Author: asoldano
Date: 2014-10-27 14:26:59 -0400 (Mon, 27 Oct 2014)
New Revision: 19033
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationDigestEjbTestCase.java
Log:
[JBWS-3843] Making the test more robust... ;)
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationDigestEjbTestCase.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationDigestEjbTestCase.java 2014-10-27 08:01:58 UTC (rev 19032)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationDigestEjbTestCase.java 2014-10-27 18:26:59 UTC (rev 19033)
@@ -128,7 +128,7 @@
boolean passed = true;
for (Future<String> future : resultList)
{
- passed = future.get().equals("Secure Hello World!");
+ passed = passed && future.get().equals("Secure Hello World!");
}
assertTrue("Unexpected response from concurrent invocation", passed);
10 years, 1 month