Author: asoldano
Date: 2013-10-03 04:48:06 -0400 (Thu, 03 Oct 2013)
New Revision: 17974
Added:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/LogicalSimpleHandler.java
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/SecureEndpointImpl2.java
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/handlers2.xml
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/HandlerAuthInterceptor.java
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/ant-import/build-jars-jaxws.xml
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/HandlerAuthTestCase.java
Log:
[WFLY-308][JBWS-3378] Also deal with logical handlers
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/HandlerAuthInterceptor.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/HandlerAuthInterceptor.java 2013-10-02
11:12:29 UTC (rev 17973)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/HandlerAuthInterceptor.java 2013-10-03
08:48:06 UTC (rev 17974)
@@ -24,7 +24,6 @@
import static org.jboss.wsf.stack.cxf.Messages.MESSAGES;
import java.lang.reflect.Method;
-import java.util.LinkedList;
import java.util.List;
import javax.xml.ws.handler.Handler;
@@ -34,6 +33,7 @@
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.jaxws.context.WrappedMessageContext;
import org.apache.cxf.jaxws.handler.HandlerChainInvoker;
+import org.apache.cxf.jaxws.handler.logical.LogicalHandlerInInterceptor;
import org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor;
import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
import org.apache.cxf.message.Exchange;
@@ -61,20 +61,25 @@
{
super(Phase.PRE_PROTOCOL_FRONTEND);
addBefore(SOAPHandlerInterceptor.class.getName());
+ addBefore(LogicalHandlerInInterceptor.class.getName());
}
@Override
public void handleMessage(Message message) throws Fault
{
- Exchange ex = message.getExchange();
+ final Exchange ex = message.getExchange();
HandlerChainInvoker invoker = ex.get(HandlerChainInvoker.class);
if (null == invoker)
{
- org.apache.cxf.endpoint.Endpoint endpoint = ex.getEndpoint();
- if (endpoint instanceof JaxWsEndpointImpl) {
- JaxWsEndpointImpl ep = (JaxWsEndpointImpl)endpoint;
- invoker = new
JBossWSHandlerChainInvoker(ep.getJaxwsBinding().getHandlerChain(), isOutbound(message,
ex));
- ex.put(HandlerChainInvoker.class, invoker);
+ final org.apache.cxf.endpoint.Endpoint endpoint = ex.getEndpoint();
+ if (endpoint instanceof JaxWsEndpointImpl) { // JAXWS handlers are not assigned
to different endpoint types
+ final JaxWsEndpointImpl ep = (JaxWsEndpointImpl)endpoint;
+ @SuppressWarnings("rawtypes")
+ final List<Handler> handlerChain =
ep.getJaxwsBinding().getHandlerChain();
+ if (handlerChain != null && !handlerChain.isEmpty()) { //save
+ invoker = new JBossWSHandlerChainInvoker(handlerChain, isOutbound(message,
ex));
+ ex.put(HandlerChainInvoker.class, invoker);
+ }
}
}
}
@@ -117,7 +122,7 @@
Endpoint ep = exchange.get(Endpoint.class);
EJBMethodSecurityAttributeProvider attributeProvider = ep
.getAttachment(EJBMethodSecurityAttributeProvider.class);
- if (attributeProvider != null) //ejb endpoints only can associated with this...
+ if (attributeProvider != null) //ejb endpoints only can be associated with
this...
{
SecurityContext secCtx = message.get(SecurityContext.class);
BindingOperationInfo bop = exchange.get(BindingOperationInfo.class);
Modified:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/ant-import/build-jars-jaxws.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/ant-import/build-jars-jaxws.xml 2013-10-02
11:12:29 UTC (rev 17973)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/ant-import/build-jars-jaxws.xml 2013-10-03
08:48:06 UTC (rev 17974)
@@ -176,12 +176,23 @@
<!-- jaxws-handlerauth -->
<jar destfile="${tests.output.dir}/test-libs/jaxws-handlerauth.jar">
<fileset dir="${tests.output.dir}/test-classes">
- <include
name="org/jboss/test/ws/jaxws/handlerauth/SecureEndpoint*.class" />
+ <include name="org/jboss/test/ws/jaxws/handlerauth/SecureEndpoint.class"
/>
+ <include
name="org/jboss/test/ws/jaxws/handlerauth/SecureEndpointImpl.class" />
<include name="org/jboss/test/ws/jaxws/handlerauth/SimpleHandler.class"
/>
<include name="org/jboss/test/ws/jaxws/handlerauth/handlers.xml" />
</fileset>
</jar>
+ <!-- jaxws-handlerauth2 -->
+ <jar destfile="${tests.output.dir}/test-libs/jaxws-handlerauth2.jar">
+ <fileset dir="${tests.output.dir}/test-classes">
+ <include name="org/jboss/test/ws/jaxws/handlerauth/SecureEndpoint.class"
/>
+ <include
name="org/jboss/test/ws/jaxws/handlerauth/SecureEndpointImpl2.class" />
+ <include
name="org/jboss/test/ws/jaxws/handlerauth/LogicalSimpleHandler.class" />
+ <include name="org/jboss/test/ws/jaxws/handlerauth/handlers2.xml" />
+ </fileset>
+ </jar>
+
<!-- jaxws-handlerscope -->
<war warfile="${tests.output.dir}/test-libs/jaxws-handlerscope.war"
webxml="${tests.output.dir}/test-resources/jaxws/handlerscope/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/test-classes">
Modified:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/HandlerAuthTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/HandlerAuthTestCase.java 2013-10-02
11:12:29 UTC (rev 17973)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/HandlerAuthTestCase.java 2013-10-03
08:48:06 UTC (rev 17974)
@@ -44,7 +44,7 @@
{
public static Test suite()
{
- JBossWSTestSetup testSetup = new JBossWSTestSetup(HandlerAuthTestCase.class,
"jaxws-handlerauth.jar");
+ JBossWSTestSetup testSetup = new JBossWSTestSetup(HandlerAuthTestCase.class,
"jaxws-handlerauth.jar,jaxws-handlerauth2.jar");
Map<String, String> authenticationOptions = new HashMap<String,
String>();
authenticationOptions.put("usersProperties",
getResourceFile("jaxws/handlerauth/jbossws-users.properties").getAbsolutePath());
@@ -53,13 +53,23 @@
testSetup.addSecurityDomainRequirement("handlerauth-security-domain",
authenticationOptions);
return testSetup;
}
-
- public void testAuth() throws Exception
- {
+
+ public void testAuthSOAPHandler() throws Exception {
URL wsdlURL = new URL("http://" + getServerHost() +
":8080/handlerauth?wsdl");
Service service = Service.create(wsdlURL, new QName("http://ws/",
"SecureEndpointImplService"));
SecureEndpoint port = service.getPort(new QName("http://ws/",
"SecureEndpointPort"), SecureEndpoint.class);
-
+ testAuth(port);
+ }
+
+ public void testAuthLogicalHandler() throws Exception {
+ URL wsdlURL = new URL("http://" + getServerHost() +
":8080/handlerauth2?wsdl");
+ Service service = Service.create(wsdlURL, new QName("http://ws/",
"SecureEndpointImpl2Service"));
+ SecureEndpoint port = service.getPort(new QName("http://ws/",
"SecureEndpoint2Port"), SecureEndpoint.class);
+ testAuth(port);
+ }
+
+ private void testAuth(final SecureEndpoint port) throws Exception
+ {
setUser((BindingProvider)port, "John", "foo");
int count = port.getHandlerCounter();
int newCount;
Added:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/LogicalSimpleHandler.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/LogicalSimpleHandler.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/LogicalSimpleHandler.java 2013-10-03
08:48:06 UTC (rev 17974)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, 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.handlerauth;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.handler.LogicalHandler;
+import javax.xml.ws.handler.LogicalMessageContext;
+import javax.xml.ws.handler.MessageContext;
+
+public class LogicalSimpleHandler implements LogicalHandler<LogicalMessageContext>
+{
+ public static volatile int counter = 0;
+
+ @Override
+ public boolean handleMessage(LogicalMessageContext context)
+ {
+ Boolean isOutbound = (Boolean)
context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+ String operation = ((QName)
context.get(MessageContext.WSDL_OPERATION)).getLocalPart();
+ if (!isOutbound && !operation.equals("getHandlerCounter")) {
+ counter++;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean handleFault(LogicalMessageContext context)
+ {
+ return true;
+ }
+
+ @Override
+ public void close(MessageContext context)
+ {
+ //NOOP
+ }
+}
Property changes on:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/LogicalSimpleHandler.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/SecureEndpointImpl2.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/SecureEndpointImpl2.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/SecureEndpointImpl2.java 2013-10-03
08:48:06 UTC (rev 17974)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, 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.handlerauth;
+
+import javax.jws.Oneway;
+import javax.jws.WebService;
+import javax.ejb.Stateless;
+import javax.annotation.security.DeclareRoles;
+import javax.annotation.security.DenyAll;
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+
+import javax.jws.WebMethod;
+
+import java.util.Enumeration;
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.jws.HandlerChain;
+import javax.xml.soap.SOAPMessage;
+import javax.annotation.PostConstruct;
+
+import java.io.PrintStream;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.ws.api.annotation.WebContext;
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.logging.Logger;
+
+@WebService(name = "SecureEndpoint2", targetNamespace =
"http://ws/")
+@HandlerChain(file = "handlers2.xml")
+@WebContext(contextRoot = "/handlerauth2", urlPattern = "/*",
authMethod = "BASIC", transportGuarantee = "NONE", secureWSDLAccess =
false)
+@Stateless
+@SecurityDomain("handlerauth-security-domain")
+@RolesAllowed({"user", "friend"})
+@DeclareRoles({"user", "friend"})
+public class SecureEndpointImpl2 implements SecureEndpoint
+{
+ private Logger log = Logger.getLogger(this.getClass());
+
+ @Resource
+ WebServiceContext context;
+
+ @RolesAllowed("user")
+ public String sayHello(String name)
+ {
+ String principalName = context.getUserPrincipal().getName();
+ if (principalName.equals(name)) {
+ log.info("sayHello() invoked : Hello, Mr. " + name);
+ return "Hello, Mr. " + name;
+ } else {
+ return "Mr. " + name + ", you authenticated as \'" +
principalName + "\'";
+ }
+ }
+
+ @RolesAllowed("friend")
+ public String sayBye(String name)
+ {
+ String principalName = context.getUserPrincipal().getName();
+ if (principalName.equals(name)) {
+ log.info("sayBye() invoked : Bye, Mr. " + name);
+ return "Bye, Mr. " + name;
+ } else {
+ return "Mr. " + name + ", you authenticated as \'" +
principalName + "\'";
+ }
+ }
+
+ public int getHandlerCounter() {
+ return LogicalSimpleHandler.counter;
+ }
+
+
+ @Oneway
+ @RolesAllowed("friend")
+ public void ping() {
+ //NOOP
+ }
+
+ @DenyAll
+ public void deniedMethod() {
+ //NOOP
+ }
+
+ @PermitAll
+ public String echo(String s) {
+ return s;
+ }
+}
Property changes on:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/SecureEndpointImpl2.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/handlers2.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/handlers2.xml
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/handlers2.xml 2013-10-03
08:48:06 UTC (rev 17974)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<handler-chains
xmlns="http://java.sun.com/xml/ns/javaee">
+ <handler-chain>
+ <handler>
+ <handler-name>LogicalSimpleHandler</handler-name>
+
<handler-class>org.jboss.test.ws.jaxws.handlerauth.LogicalSimpleHandler</handler-class>
+ </handler>
+ </handler-chain>
+</handler-chains>
\ No newline at end of file
Property changes on:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/handlerauth/handlers2.xml
___________________________________________________________________
Added: svn:mime-type
+ text/xml
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native