You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2011/07/07 21:50:03 UTC
svn commit: r1144006 - in /openejb/trunk/openejb3: ./
examples/webservice-ws-security/src/main/resources/META-INF/
examples/webservice-ws-security/src/test/java/org/superbiz/calculator/
server/openejb-cxf/ server/openejb-cxf/src/main/java/org/apache/op...
Author: rmannibucau
Date: Thu Jul 7 19:50:02 2011
New Revision: 1144006
URL: http://svn.apache.org/viewvc?rev=1144006&view=rev
Log:
OPENEJB-1626 upgrading cxf to version 2.4.1 (in progress)
Added:
openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/OpenEJBLoginValidator.java
Removed:
openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ResourceManager.java
openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ServerPasswordHandler.java
openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/WsdlQueryHandler.java
openejb/trunk/openejb3/server/openejb-cxf/src/main/resources/META-INF/cxf-extension-openejb.xml
openejb/trunk/openejb3/server/openejb-cxf/src/main/resources/META-INF/cxf.extension
Modified:
openejb/trunk/openejb3/examples/webservice-ws-security/src/main/resources/META-INF/openejb-jar.xml
openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CalculatorTest.java
openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CustomPasswordHandler.java
openejb/trunk/openejb3/pom.xml
openejb/trunk/openejb3/server/openejb-cxf/pom.xml
openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ConfigureCxfSecurity.java
openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfEndpoint.java
openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java
openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/HttpDestination.java
openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/HttpTransportFactory.java
openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbEndpoint.java
openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbWsContainer.java
openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoWsContainer.java
Modified: openejb/trunk/openejb3/examples/webservice-ws-security/src/main/resources/META-INF/openejb-jar.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-ws-security/src/main/resources/META-INF/openejb-jar.xml?rev=1144006&r1=1144005&r2=1144006&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-ws-security/src/main/resources/META-INF/openejb-jar.xml (original)
+++ openejb/trunk/openejb3/examples/webservice-ws-security/src/main/resources/META-INF/openejb-jar.xml Thu Jul 7 19:50:02 2011
@@ -25,6 +25,10 @@
webservice.security.authMethod = WS-SECURITY
wss4j.in.action = UsernameToken
wss4j.in.passwordType = PasswordText
+ wss4j.in.passwordCallbackClass = org.superbiz.calculator.CustomPasswordHandler
+
+ # automatically added
+ wss4j.in.validator.{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}UsernameToken = org.apache.openejb.server.cxf.OpenEJBLoginValidator
</properties>
</ejb-deployment>
<ejb-deployment ejb-name="CalculatorImplTimestamp1way">
@@ -45,6 +49,7 @@
webservice.security.authMethod = WS-SECURITY
wss4j.in.action = UsernameToken
wss4j.in.passwordType = PasswordText
+ wss4j.in.passwordCallbackClass=org.superbiz.calculator.CustomPasswordHandler
</properties>
</ejb-deployment>
<ejb-deployment ejb-name="CalculatorImplUsernameTokenHashedPassword">
Modified: openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CalculatorTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CalculatorTest.java?rev=1144006&r1=1144005&r2=1144006&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CalculatorTest.java (original)
+++ openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CalculatorTest.java Thu Jul 7 19:50:02 2011
@@ -24,7 +24,6 @@ import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor;
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
-import org.apache.log4j.BasicConfigurator;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.WSPasswordCallback;
import org.apache.ws.security.handler.WSHandlerConstants;
@@ -46,23 +45,15 @@ import java.util.Properties;
public class CalculatorTest extends TestCase {
//START SNIPPET: setup
- private InitialContext initialContext;
-
protected void setUp() throws Exception {
- BasicConfigurator.configure();
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
properties.setProperty("openejb.embedded.remotable", "true");
- initialContext = new InitialContext(properties);
+ new InitialContext(properties);
}
//END SNIPPET: setup
- /**
- * Create a webservice client using wsdl url
- *
- * @throws Exception
- */
//START SNIPPET: webservice
public void testCalculatorViaWsInterface() throws Exception {
Service calcService = Service.create(new URL("http://127.0.0.1:4204/CalculatorImpl?wsdl"),
Modified: openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CustomPasswordHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CustomPasswordHandler.java?rev=1144006&r1=1144005&r2=1144006&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CustomPasswordHandler.java (original)
+++ openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CustomPasswordHandler.java Thu Jul 7 19:50:02 2011
@@ -16,19 +16,15 @@
*/
package org.superbiz.calculator;
-import org.apache.openejb.loader.SystemInstance;
-import org.apache.openejb.spi.SecurityService;
import org.apache.ws.security.WSPasswordCallback;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.login.LoginException;
import java.io.IOException;
public class CustomPasswordHandler implements CallbackHandler {
-
- public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ @Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN) {
@@ -42,25 +38,5 @@ public class CustomPasswordHandler imple
pc.setPassword("serverPassword");
}
-
- if ((pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN)
- || (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN)) {
-
- SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
- Object token = null;
- try {
- securityService.disassociate();
-
- token = securityService.login(pc.getIdentifer(), pc.getPassword());
- securityService.associate(token);
-
- } catch (LoginException e) {
- e.printStackTrace();
- throw new SecurityException("wrong password");
- } finally {
- }
- }
-
-
}
}
Modified: openejb/trunk/openejb3/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/pom.xml?rev=1144006&r1=1144005&r2=1144006&view=diff
==============================================================================
--- openejb/trunk/openejb3/pom.xml (original)
+++ openejb/trunk/openejb3/pom.xml Thu Jul 7 19:50:02 2011
@@ -119,6 +119,9 @@
<!-- Used in assembly/openejb-tomcat* projects -->
<tomcatVersion>7.0.16</tomcatVersion>
+ <!-- used by cxf -->
+ <jetty.version>7.4.2.v20110526</jetty.version>
+
<!--
- http://docs.codehaus.org/display/MAVENUSER/POM+Element+for+Source+File+Encoding
-->
@@ -572,6 +575,36 @@
<dependencyManagement>
<dependencies>
<dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-continuation</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-io</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-http</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-security</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.bval</groupId>
<artifactId>bval-core</artifactId>
<version>${bval.version}</version>
@@ -966,7 +999,7 @@
<dependency>
<groupId>org.apache.ws.security</groupId>
<artifactId>wss4j</artifactId>
- <version>1.5.8</version>
+ <version>1.6.1</version>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
@@ -1021,7 +1054,7 @@
<dependency>
<groupId>org.apache.neethi</groupId>
<artifactId>neethi</artifactId>
- <version>2.0.4</version>
+ <version>3.0.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.ws.commons.axiom</groupId>
Modified: openejb/trunk/openejb3/server/openejb-cxf/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/pom.xml?rev=1144006&r1=1144005&r2=1144006&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/pom.xml (original)
+++ openejb/trunk/openejb3/server/openejb-cxf/pom.xml Thu Jul 7 19:50:02 2011
@@ -103,167 +103,147 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle</artifactId>
- <version>2.2.10</version>
+ <version>2.4.1</version>
<exclusions>
<exclusion>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
</exclusion>
<exclusion>
- <groupId>aopalliance</groupId>
- <artifactId>aopalliance</artifactId>
- </exclusion>
- <exclusion>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
<exclusion>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-xjc</artifactId>
+ <groupId>aopalliance</groupId>
+ <artifactId>aopalliance</artifactId>
</exclusion>
<exclusion>
- <groupId>com.sun.xml.fastinfoset</groupId>
- <artifactId>FastInfoset</artifactId>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
</exclusion>
<exclusion>
- <groupId>javax.jw.rs</groupId>
- <artifactId>jsr311-api</artifactId>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-continuation</artifactId>
</exclusion>
<exclusion>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-io</artifactId>
</exclusion>
<exclusion>
- <groupId>javax.xml.soap</groupId>
- <artifactId>saaj-api</artifactId>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-http</artifactId>
</exclusion>
<exclusion>
- <groupId>jaxen</groupId>
- <artifactId>jaxen</artifactId>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-security</artifactId>
</exclusion>
<exclusion>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-core</artifactId>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
</exclusion>
<exclusion>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-extensions-json</artifactId>
+ <groupId>org.codehaus.jettison</groupId>
+ <artifactId>jettison</artifactId>
</exclusion>
<exclusion>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-extensions-main</artifactId>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>jsr311-api</artifactId>
</exclusion>
<exclusion>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-i18n</artifactId>
+ <groupId>org.apache.xmlbeans</groupId>
+ <artifactId>xmlbeans</artifactId>
</exclusion>
<exclusion>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-parser</artifactId>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>woodstox-core-asl</artifactId>
</exclusion>
<exclusion>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-activation_1.1_spec</artifactId>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>stax2-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-annotation_1.0_spec</artifactId>
+ <artifactId>geronimo-servlet_3.0_spec</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-javamail_1.4_spec</artifactId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jaxws_2.1_spec</artifactId>
+ <artifactId>geronimo-activation_1.1_spec</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <artifactId>geronimo-annotation_1.0_spec</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-servlet_2.5_spec</artifactId>
+ <artifactId>geronimo-javamail_1.4_spec</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
</exclusion>
<exclusion>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
+ <groupId>org.codehaus.jra</groupId>
+ <artifactId>jra</artifactId>
</exclusion>
<exclusion>
- <groupId>org.apache.neethi</groupId>
- <artifactId>neethi</artifactId>
+ <groupId>rhino</groupId>
+ <artifactId>js</artifactId>
</exclusion>
<exclusion>
- <groupId>org.apache.santuario</groupId>
- <artifactId>xmlsec</artifactId>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
</exclusion>
<exclusion>
- <groupId>org.apache.ws.commons.axiom</groupId>
- <artifactId>axiom-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.ws.commons.axiom</groupId>
- <artifactId>axiom-impl</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.ws.security</groupId>
- <artifactId>wss4j</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.xmlbeans</groupId>
- <artifactId>xmlbeans</artifactId>
+ <groupId>oro</groupId>
+ <artifactId>oro</artifactId>
</exclusion>
<exclusion>
- <groupId>org.bouncycastle</groupId>
- <artifactId>bcprov-jdk15</artifactId>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
</exclusion>
<exclusion>
- <groupId>org.codehaus.jettison</groupId>
- <artifactId>jettison</artifactId>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-xjc</artifactId>
</exclusion>
<exclusion>
- <groupId>org.codehaus.jra</groupId>
- <artifactId>jra</artifactId>
+ <groupId>javax.xml.soap</groupId>
+ <artifactId>saaj-api</artifactId>
</exclusion>
<exclusion>
- <groupId>org.codehaus.woodstox</groupId>
- <artifactId>wstx-asl</artifactId>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
</exclusion>
<exclusion>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jaxws_2.2_spec</artifactId>
</exclusion>
<exclusion>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty-util</artifactId>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
</exclusion>
<exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-expression</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
+ <artifactId>spring-aop</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
+ <artifactId>spring-asm</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
- <artifactId>spring-context-support</artifactId>
+ <artifactId>spring-context</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
@@ -282,28 +262,28 @@
<artifactId>spring-web</artifactId>
</exclusion>
<exclusion>
- <groupId>oro</groupId>
- <artifactId>oro</artifactId>
- </exclusion>
- <exclusion>
- <groupId>rhino</groupId>
- <artifactId>js</artifactId>
+ <groupId>joda-time</groupId>
+ <artifactId>joda-time</artifactId>
</exclusion>
<exclusion>
- <groupId>xalan</groupId>
- <artifactId>serializer</artifactId>
+ <groupId>org.opensaml</groupId>
+ <artifactId>opensaml</artifactId>
</exclusion>
<exclusion>
- <groupId>xalan</groupId>
- <artifactId>xalan</artifactId>
+ <groupId>org.opensaml</groupId>
+ <artifactId>openws</artifactId>
</exclusion>
<exclusion>
- <groupId>xml-resolver</groupId>
- <artifactId>xml-resolver</artifactId>
+ <groupId>org.opensaml</groupId>
+ <artifactId>xmltooling</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ </dependency>
+ <dependency>
<groupId>xml-resolver</groupId>
<artifactId>xml-resolver</artifactId>
<version>1.2</version>
Modified: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ConfigureCxfSecurity.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ConfigureCxfSecurity.java?rev=1144006&r1=1144005&r2=1144006&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ConfigureCxfSecurity.java (original)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ConfigureCxfSecurity.java Thu Jul 7 19:50:02 2011
@@ -16,49 +16,86 @@
*/
package org.apache.openejb.server.cxf;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor;
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
-import org.apache.ws.security.handler.WSHandlerConstants;
+import org.apache.openejb.util.LogCategory;
+import org.apache.openejb.util.Logger;
+
+import javax.xml.namespace.QName;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
/**
* Helper class to extract WSS4J properties from a set of properties. More over,
* it configures In and Out interceptor to manage WS-Security.
*/
public class ConfigureCxfSecurity {
+ private static final Logger LOGGER = Logger.getInstance(LogCategory.CXF, ConfigureCxfSecurity.class);
+ private static final Map<QName, Object> DEFAULT_VALIDATOR_MAP = new HashMap<QName, Object>() {{
+ put(new QName(
+ "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
+ "UsernameToken"),
+ new OpenEJBLoginValidator());
+ }};
public static final void setupWSS4JChain(Endpoint endpoint, Properties inProps) {
- Map<String, Object> in = getPropsFromProperties(inProps, "wss4j.in.");
- Map<String, Object> out = getPropsFromProperties(inProps, "wss4j.out.");
+ final Map<String, Object> in = getPropsFromProperties(inProps, "wss4j.in.");
+ final Map<String, Object> out = getPropsFromProperties(inProps, "wss4j.out.");
+ if (!in.containsKey(WSS4JInInterceptor.VALIDATOR_MAP)) {
+ // default case, if user doesn't want it he should add: wss4j.in.validator.{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}UsernameToken = DummyImpl
+ in.put(WSS4JInInterceptor.VALIDATOR_MAP, DEFAULT_VALIDATOR_MAP);
+ }
setupWSS4JChain(endpoint, in, out);
}
public static Map<String, Object> getPropsFromProperties(Properties inProps, String pattern) {
- String key, val;
+ final String validatorPrefix = pattern + "validator";
+ final String processorPrefix = pattern + "processor";
+ final Map<QName, Object> validatorMap = new HashMap<QName, Object>();
+ final Map<QName, Object> processorMap = new HashMap<QName, Object>();
+ final Map<String, Object> props = new HashMap<String, Object>();
- Map<String, Object> props = new HashMap<String, Object>();
+ String key, val;
for (Map.Entry<Object, Object> entry : inProps.entrySet()) {
- key = String.valueOf(entry.getKey());
+ key = String.valueOf(entry.getKey()).trim();
val = String.valueOf(entry.getValue()).trim();
- if (key.startsWith(pattern)) {
+ if (key.startsWith(validatorPrefix)) {
+ SplitInfo infos = new SplitInfo(key, val);
+ try {
+ validatorMap.put(infos.qname, getValidator(infos.value));
+ } catch (Exception e) {
+ LOGGER.warning("validator not found " + val, e);
+ }
+ } if (key.startsWith(processorPrefix)) {
+ SplitInfo infos = new SplitInfo(key, val);
+ processorMap.put(infos.qname, infos.value);
+ } else if (key.startsWith(pattern)) {
props.put(key.substring(pattern.length()), val);
}
}
- if (!props.isEmpty()) {
- // WSHandler first look for a property PW_CALLBACK_CLASS
- // if not found, it gets the PW_CALLBACK_REF
- props.put(WSHandlerConstants.PW_CALLBACK_REF, new ServerPasswordHandler());
+
+ if (!validatorMap.isEmpty()) {
+ props.put(WSS4JInInterceptor.VALIDATOR_MAP, validatorMap);
+ }
+ if (!processorMap.isEmpty()) {
+ props.put(WSS4JInInterceptor.PROCESSOR_MAP, processorMap);
}
return props;
}
+ private static Object getValidator(String validator) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (cl == null) {
+ cl = ConfigureCxfSecurity.class.getClassLoader();
+ }
+ return cl.loadClass(validator).newInstance();
+ }
+
public static final void setupWSS4JChain(Endpoint endpoint, Map<String, Object> inProps, Map<String, Object> outProps) {
if (null != inProps && !inProps.isEmpty()) {
@@ -81,4 +118,38 @@ public class ConfigureCxfSecurity {
setupWSS4JChain(endpoint, p);
}
+ /**
+ * split {<namespace>}<local> = foo
+ * useful because in the namespace there is at least a '.' which is a separator for Proeprties
+ * and escaping doesn't always work.
+ */
+ private static class SplitInfo {
+ public QName qname;
+ public String value;
+
+ public SplitInfo(final String key, final String val) {
+ String k = key;
+ int startIdx = k.indexOf('{');
+ if (startIdx > 0) {
+ k = k.substring(startIdx);
+ }
+
+ value = val;
+
+ int idx = value.indexOf("=");
+ if (idx > 0) {
+ k = k + ':' + value.substring(0, idx);
+ value = value.substring(idx + 1);
+ }
+ k = k.trim();
+ value = value.trim();
+
+ final int start = k.indexOf('{');
+ final int end = k.indexOf('}');
+ final String ns = k.substring(start + 1, end);
+ final String local = k.substring(end + 1);
+
+ qname = new QName(ns, local);
+ }
+ }
}
Modified: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfEndpoint.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfEndpoint.java?rev=1144006&r1=1144005&r2=1144006&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfEndpoint.java (original)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfEndpoint.java Thu Jul 7 19:50:02 2011
@@ -27,19 +27,26 @@ import org.apache.cxf.jaxws.support.JaxW
import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
import org.apache.cxf.service.Service;
import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.DestinationFactory;
+import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.apache.cxf.transport.http.DestinationRegistry;
+import org.apache.cxf.transport.http.HTTPTransportFactory;
+import org.apache.cxf.transport.http.HttpDestinationFactory;
import org.apache.openejb.core.webservices.HandlerResolverImpl;
import org.apache.openejb.core.webservices.PortData;
+import javax.naming.Context;
import javax.xml.transform.Source;
import javax.xml.ws.Binding;
import javax.xml.ws.handler.Handler;
import javax.xml.ws.http.HTTPBinding;
import javax.xml.ws.soap.SOAPBinding;
-import javax.naming.Context;
-import java.net.MalformedURLException;
-import java.net.URL;
+import java.io.IOException;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.Executor;
public abstract class CxfEndpoint {
@@ -61,10 +68,10 @@ public abstract class CxfEndpoint {
protected HandlerResolverImpl handlerResolver;
- protected HttpTransportFactory httpTransportFactory;
+ protected HTTPTransportFactory httpTransportFactory;
public CxfEndpoint(Bus bus, PortData port, Context context,
- Object implementor, HttpTransportFactory httpTransportFactory) {
+ Object implementor, HTTPTransportFactory httpTransportFactory) {
this.bus = bus;
this.port = port;
this.context = context;
@@ -73,36 +80,12 @@ public abstract class CxfEndpoint {
this.bus.setExtension(this, CxfEndpoint.class);
}
- protected URL getWsdlURL(URL configurationBaseUrl, String wsdlFile) {
- URL wsdlURL = null;
- if (wsdlFile != null && wsdlFile.trim().length() > 0) {
- wsdlFile = wsdlFile.trim();
- try {
- wsdlURL = new URL(wsdlFile);
- } catch (MalformedURLException e) {
- // Not a URL, try as a resource
- wsdlURL = getImplementorClass().getResource("/" + wsdlFile);
-
- if (wsdlURL == null && configurationBaseUrl != null) {
- // Cannot get it as a resource, try with
- // configurationBaseUrl
- try {
- wsdlURL = new URL(configurationBaseUrl, wsdlFile);
- } catch (MalformedURLException ee) {
- // ignore
- }
- }
- }
- }
- return wsdlURL;
- }
-
protected Class getImplementorClass() {
return this.implementor.getClass();
}
protected org.apache.cxf.endpoint.Endpoint getEndpoint() {
- return ((ServerImpl) getServer()).getEndpoint();
+ return getServer().getEndpoint();
}
public boolean isSOAP11() {
@@ -167,13 +150,7 @@ public abstract class CxfEndpoint {
@Override
protected BindingInfo createBindingInfo() {
- BindingInfo bindingInfo = super.createBindingInfo();
-
- if(httpTransportFactory != null) {
- httpTransportFactory.registerDestinationFactory();
- }
-
- return bindingInfo;
+ return super.createBindingInfo();
}
}
@@ -184,6 +161,7 @@ public abstract class CxfEndpoint {
svrFactory.setServiceFactory(serviceFactory);
svrFactory.setStart(false);
svrFactory.setServiceBean(implementor);
+ svrFactory.setDestinationFactory(httpTransportFactory);
if (HTTPBinding.HTTP_BINDING.equals(implInfo.getBindingType())) {
svrFactory.setTransportId("http://cxf.apache.org/bindings/xformat");
Modified: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java?rev=1144006&r1=1144005&r2=1144006&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java (original)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java Thu Jul 7 19:50:02 2011
@@ -20,24 +20,22 @@ package org.apache.openejb.server.cxf;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.extension.ExtensionManagerBus;
-import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.apache.cxf.transport.http.HTTPTransportFactory;
import org.apache.openejb.core.webservices.PortData;
+import org.apache.openejb.server.httpd.HttpListener;
import org.apache.openejb.server.httpd.HttpRequest;
import org.apache.openejb.server.httpd.HttpResponse;
-import org.apache.openejb.server.httpd.HttpListener;
-import org.apache.openejb.server.webservices.saaj.SaajUniverse;
-import java.io.OutputStream;
-import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
public abstract class CxfWsContainer implements HttpListener {
protected final Bus bus;
protected final PortData port;
- protected HttpDestination destination;
+ protected AbstractHTTPDestination destination;
protected CxfEndpoint endpoint;
- protected HttpTransportFactory httpTransportFactory;
+ protected HTTPTransportFactory httpTransportFactory;
public CxfWsContainer(Bus bus, PortData port) {
this.bus = bus;
@@ -48,13 +46,12 @@ public abstract class CxfWsContainer imp
httpTransportFactory = new HttpTransportFactory(bus);
httpTransportFactory.setTransportIds(ids);
- httpTransportFactory.registerDestinationFactory();
}
public void start() {
endpoint = createEndpoint();
endpoint.publish("http://nopath");
- destination = (HttpDestination) endpoint.getServer().getDestination();
+ destination = (AbstractHTTPDestination) endpoint.getServer().getDestination();
}
protected abstract CxfEndpoint createEndpoint();
@@ -71,51 +68,7 @@ public abstract class CxfWsContainer imp
}
public void onMessage(HttpRequest request, HttpResponse response) throws Exception {
- if (request.getMethod().equals(HttpRequest.Method.GET.name())) {
- processGET(request, response);
- } else {
- processPOST(request, response);
- }
- }
-
- protected void processGET(HttpRequest request, HttpResponse response) throws Exception {
- boolean wsdlRequest = request.getParameter("wsdl") != null ||
- request.getParameter("WSDL") != null ||
- request.getParameter("xsd") != null ||
- request.getParameter("XSD") != null;
-
- if (wsdlRequest) {
- getWsdl(request, response);
- } else if (endpoint.isSOAP11()) {
- EndpointInfo ei = this.destination.getEndpointInfo();
- response.setContentType("text/html");
- PrintWriter pw = new PrintWriter(response.getOutputStream());
- pw.write("<html><title>Web Service</title><body>");
- pw.write("Hi, this is '" + ei.getService().getName().getLocalPart() + "' web service.");
- pw.write("</body></html>");
- pw.flush();
- } else {
- processPOST(request, response);
- }
- }
-
- protected void processPOST(HttpRequest request, HttpResponse response) throws Exception {
- SaajUniverse universe = new SaajUniverse();
- universe.set(SaajUniverse.DEFAULT);
- try {
- destination.invoke(request, response);
- } finally {
- universe.unset();
- }
- }
-
- private void getWsdl(HttpRequest request, HttpResponse response) throws Exception {
- WsdlQueryHandler queryHandler = new WsdlQueryHandler(this.bus);
- String requestUri = request.getURI().toString();
- EndpointInfo ei = this.destination.getEndpointInfo();
- OutputStream out = response.getOutputStream();
- response.setContentType("text/xml");
- queryHandler.writeResponse(requestUri, null, ei, out);
+ destination.invoke(null, request.getServletContext(), request, response);
}
/*
Modified: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/HttpDestination.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/HttpDestination.java?rev=1144006&r1=1144005&r2=1144006&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/HttpDestination.java (original)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/HttpDestination.java Thu Jul 7 19:50:02 2011
@@ -29,6 +29,7 @@ import org.apache.cxf.transport.ConduitI
import org.apache.cxf.transport.Destination;
import org.apache.cxf.transport.MessageObserver;
import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.apache.cxf.transport.http.DestinationRegistry;
import org.apache.cxf.transport.http.HTTPSession;
import org.apache.cxf.ws.addressing.EndpointReferenceType;
import org.apache.openejb.server.httpd.HttpRequest;
@@ -51,325 +52,11 @@ import java.util.Map;
import java.util.logging.Logger;
public class HttpDestination extends AbstractHTTPDestination {
- private MessageObserver messageObserver;
- private boolean passSecurityContext = false;
- private CxfEndpoint endpoint;
-
- public HttpDestination(Bus bus, ConduitInitiator conduitInitiator, EndpointInfo endpointInfo) throws IOException {
- super(bus, conduitInitiator, endpointInfo, true);
- this.endpoint = bus.getExtension(CxfEndpoint.class);
- }
-
- private Binding getBinding() {
- return this.endpoint.getEndpoint().getBinding();
- }
-
- public void setPassSecurityContext(boolean passSecurityContext) {
- this.passSecurityContext = passSecurityContext;
- }
-
- public boolean getPassSecurityContext() {
- return this.passSecurityContext;
- }
-
- public EndpointInfo getEndpointInfo() {
- return this.endpointInfo;
- }
-
- public void invoke(HttpRequest request, HttpResponse response) throws Exception {
- MessageImpl message = new MessageImpl();
- message.setContent(InputStream.class, request.getInputStream());
- message.setDestination(this);
-
- message.put(HttpRequest.class, request);
- message.put(HttpResponse.class, response);
-
- final HttpServletRequest servletRequest = (HttpServletRequest) request.getAttribute(HttpRequest.SERVLET_REQUEST);
- message.put(HTTP_REQUEST, servletRequest);
-
- HttpServletResponse servletResponse = (HttpServletResponse) request.getAttribute(HttpRequest.SERVLET_RESPONSE);
- message.put(HTTP_RESPONSE, servletResponse);
-
- ServletContext servletContext = (ServletContext) request.getAttribute(HttpRequest.SERVLET_CONTEXT);
- message.put(HTTP_CONTEXT, servletContext);
-
- if (this.passSecurityContext && servletRequest != null) {
- message.put(SecurityContext.class, new SecurityContext() {
- public Principal getUserPrincipal() {
- return servletRequest.getUserPrincipal();
- }
-
- public boolean isUserInRole(String role) {
- return servletRequest.isUserInRole(role);
- }
- });
- }
-
- // this calls copyRequestHeaders()
- setHeaders(message);
-
- message.put(Message.HTTP_REQUEST_METHOD, request.getMethod().toString());
- message.put(Message.PATH_INFO, request.getURI().getPath());
- message.put(Message.QUERY_STRING, request.getURI().getFragment());
- message.put(Message.CONTENT_TYPE, request.getContentType());
- if (servletRequest != null) {
- message.put(Message.ENCODING, getCharacterEncoding(servletRequest.getCharacterEncoding()));
- }
-
- ExchangeImpl exchange = new ExchangeImpl();
- exchange.setInMessage(getBinding().createMessage(message));
- exchange.setSession(new HTTPSession(servletRequest));
-
- getMessageObserver().onMessage(message);
+ public HttpDestination(Bus bus, DestinationRegistry registry, EndpointInfo endpointInfo, String path) throws IOException {
+ super(bus, registry, endpointInfo, path, true);
}
- private static String getCharacterEncoding(String encoding) {
- if (encoding != null) {
- encoding = encoding.trim();
- // work around a bug with Jetty which results in the character
- // encoding not being trimmed correctly:
- // http://jira.codehaus.org/browse/JETTY-302
- if (encoding.endsWith("\"")) {
- encoding = encoding.substring(0, encoding.length() - 1);
- }
- }
- return encoding;
- }
-
- protected void copyRequestHeaders(Message message, Map<String, List<String>> headers) {
- HttpServletRequest servletRequest = (HttpServletRequest) message.get(MessageContext.SERVLET_REQUEST);
- if (servletRequest != null) {
- Enumeration names = servletRequest.getHeaderNames();
- while (names.hasMoreElements()) {
- String name = (String) names.nextElement();
-
- List<String> headerValues = headers.get(name);
- if (headerValues == null) {
- headerValues = new ArrayList<String>();
- headers.put(name, headerValues);
- }
-
- Enumeration values = servletRequest.getHeaders(name);
- while (values.hasMoreElements()) {
- String value = (String) values.nextElement();
- headerValues.add(value);
- }
- }
- }
- }
-
- public Logger getLogger() {
+ @Override public Logger getLogger() {
return Logger.getLogger(HttpDestination.class.getName());
}
-
- public Conduit getInbuiltBackChannel(Message inMessage) {
- return new BackChannelConduit(null, inMessage);
- }
-
- public Conduit getBackChannel(Message inMessage, Message partialResponse, EndpointReferenceType address) throws IOException {
- Conduit backChannel = null;
- if (address == null) {
- backChannel = new BackChannelConduit(address, inMessage);
- } else {
- if (partialResponse != null) {
- // setup the outbound message to for 202 Accepted
- partialResponse.put(Message.RESPONSE_CODE, HttpURLConnection.HTTP_ACCEPTED);
- backChannel = new BackChannelConduit(address, inMessage);
- } else {
- backChannel = conduitInitiator.getConduit(endpointInfo, address);
- // ensure decoupled back channel input stream is closed
- backChannel.setMessageObserver(new MessageObserver() {
- public void onMessage(Message m) {
- if (m.getContentFormats().contains(InputStream.class)) {
- InputStream is = m.getContent(InputStream.class);
- try {
- is.close();
- } catch (Exception e) {
- // ignore
- }
- }
- }
- });
- }
- }
- return backChannel;
- }
-
- public void shutdown() {
- }
-
- public synchronized MessageObserver getMessageObserver() {
- return messageObserver;
- }
-
- public synchronized void setMessageObserver(MessageObserver messageObserver) {
- this.messageObserver = messageObserver;
- }
-
- protected class BackChannelConduit implements Conduit {
-
- protected Message request;
- protected EndpointReferenceType target;
-
- BackChannelConduit(EndpointReferenceType target, Message request) {
- this.target = target;
- this.request = request;
- }
-
- public void close(Message msg) throws IOException {
- msg.getContent(OutputStream.class).close();
- }
-
- /**
- * Register a message observer for incoming messages.
- *
- * @param observer the observer to notify on receipt of incoming
- */
- public void setMessageObserver(MessageObserver observer) {
- // shouldn't be called for a back channel conduit
- }
-
- public void prepare(Message message) throws IOException {
- send(message);
- }
-
- /**
- * Send an outbound message, assumed to contain all the name-value
- * mappings of the corresponding input message (if any).
- *
- * @param message the message to be sent.
- */
- public void send(Message message) throws IOException {
- HttpResponse response = request.get(HttpResponse.class);
-
- // handle response headers
- updateResponseHeaders(message);
-
- Map<String, List<String>> protocolHeaders = getProtocolHeaders(message);
-
- // set headers of the HTTP response object
- for (Map.Entry<String, List<String>> entry : protocolHeaders.entrySet()) {
- String headerName = entry.getKey();
- String headerValue = getHeaderValue(entry.getValue());
- response.setHeader(headerName, headerValue);
- }
-
- message.setContent(OutputStream.class, new WrappedOutputStream(message, response));
- }
-
- /**
- * @return the reference associated with the target Destination
- */
- public EndpointReferenceType getTarget() {
- return target;
- }
-
- /**
- * Retreive the back-channel Destination.
- *
- * @return the backchannel Destination (or null if the backchannel is
- * built-in)
- */
- public Destination getBackChannel() {
- return null;
- }
-
- /**
- * Close the conduit
- */
- public void close() {
- }
- }
-
- private String getHeaderValue(List<String> values) {
- Iterator iter = values.iterator();
- StringBuffer buf = new StringBuffer();
- while (iter.hasNext()) {
- buf.append(iter.next());
- if (iter.hasNext()) {
- buf.append(", ");
- }
- }
- return buf.toString();
- }
-
- protected void setContentType(Message message, HttpResponse response) {
- Map<String, List<String>> protocolHeaders = getProtocolHeaders(message);
-
- if (protocolHeaders == null || !protocolHeaders.containsKey(Message.CONTENT_TYPE)) {
- String ct = (String) message.get(Message.CONTENT_TYPE);
- String enc = (String) message.get(Message.ENCODING);
-
- if (null != ct) {
- if (enc != null && ct.indexOf("charset=") == -1) {
- ct = ct + "; charset=" + enc;
- }
- response.setContentType(ct);
- } else if (enc != null) {
- response.setContentType("text/xml; charset=" + enc);
- }
- }
- }
-
- @SuppressWarnings({"unchecked"})
- private Map<String, List<String>> getProtocolHeaders(Message message) {
- Map<String, List<String>> protocolHeaders = (Map<String, List<String>>) message.get(Message.PROTOCOL_HEADERS);
- return protocolHeaders;
- }
-
- private class WrappedOutputStream extends OutputStream {
-
- private Message message;
- private HttpResponse response;
- private OutputStream rawOutputStream;
-
- WrappedOutputStream(Message message, HttpResponse response) {
- this.message = message;
- this.response = response;
- }
-
- public void write(int b) throws IOException {
- flushHeaders();
- this.rawOutputStream.write(b);
- }
-
- public void write(byte b[]) throws IOException {
- flushHeaders();
- this.rawOutputStream.write(b);
- }
-
- public void write(byte b[], int off, int len) throws IOException {
- flushHeaders();
- this.rawOutputStream.write(b, off, len);
- }
-
- public void flush() throws IOException {
- flushHeaders();
- this.rawOutputStream.flush();
- }
-
- public void close() throws IOException {
- flushHeaders();
- this.rawOutputStream.close();
- }
-
- protected void flushHeaders() throws IOException {
- if (this.rawOutputStream != null) {
- return;
- }
-
- // set response code
- Integer i = (Integer) this.message.get(Message.RESPONSE_CODE);
- if (i != null) {
- this.response.setStatus(i.intValue());
- }
-
- // set content-type
- setContentType(this.message, this.response);
-
- this.rawOutputStream = this.response.getOutputStream();
- }
-
- }
-
}
Modified: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/HttpTransportFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/HttpTransportFactory.java?rev=1144006&r1=1144005&r2=1144006&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/HttpTransportFactory.java (original)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/HttpTransportFactory.java Thu Jul 7 19:50:02 2011
@@ -20,38 +20,21 @@ package org.apache.openejb.server.cxf;
import org.apache.cxf.Bus;
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.transport.Destination;
-import org.apache.cxf.transport.DestinationFactory;
-import org.apache.cxf.transport.DestinationFactoryManager;
-import org.apache.cxf.transport.http.AbstractHTTPTransportFactory;
+import org.apache.cxf.transport.http.HTTPTransportFactory;
import java.io.IOException;
-public class HttpTransportFactory extends AbstractHTTPTransportFactory implements DestinationFactory {
+public class HttpTransportFactory extends HTTPTransportFactory {
public HttpTransportFactory() {
- super();
+ // no-op
}
public HttpTransportFactory(Bus bus) {
setBus(bus);
- }
- public Destination getDestination(EndpointInfo endpointInfo) throws IOException {
- HttpDestination destination = new HttpDestination(getBus(), this, endpointInfo);
- configure(destination);
- return destination;
}
-
- /**
- * Registers our destination factory
- */
- public void registerDestinationFactory() {
- DestinationFactoryManager factoryManager = bus.getExtension(DestinationFactoryManager.class);
- factoryManager.registerDestinationFactory("http://cxf.apache.org/transports/http/configuration", this);
- factoryManager.registerDestinationFactory("http://cxf.apache.org/bindings/xformat", this);
- factoryManager.registerDestinationFactory("http://www.w3.org/2003/05/soap/bindings/HTTP/", this);
- factoryManager.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", this);
- factoryManager.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/http/", this);
- factoryManager.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", this);
+ @Override public Destination getDestination(EndpointInfo endpointInfo) throws IOException {
+ return new HttpDestination(getBus(), getRegistry(), endpointInfo, endpointInfo.getAddress());
}
}
Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/OpenEJBLoginValidator.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/OpenEJBLoginValidator.java?rev=1144006&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/OpenEJBLoginValidator.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/OpenEJBLoginValidator.java Thu Jul 7 19:50:02 2011
@@ -0,0 +1,49 @@
+package org.apache.openejb.server.cxf;
+
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.spi.SecurityService;
+import org.apache.ws.security.WSPasswordCallback;
+import org.apache.ws.security.WSSecurityException;
+import org.apache.ws.security.handler.RequestData;
+import org.apache.ws.security.message.token.UsernameToken;
+import org.apache.ws.security.validate.UsernameTokenValidator;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.LoginException;
+import java.io.IOException;
+
+/**
+ * @author Romain Manni-Bucau
+ */
+public class OpenEJBLoginValidator extends UsernameTokenValidator {
+ @Override protected void verifyDigestPassword(UsernameToken usernameToken,
+ RequestData data) throws WSSecurityException {
+ // check password
+ super.verifyDigestPassword(usernameToken, data);
+
+ // get the plain text password
+ WSPasswordCallback pwCb = new WSPasswordCallback(usernameToken.getName(),
+ null, usernameToken.getPasswordType(), WSPasswordCallback.USERNAME_TOKEN, data);
+ try {
+ data.getCallbackHandler().handle(new Callback[]{pwCb});
+ } catch (Exception e) {
+ // no-op: the login will fail
+ }
+
+ // log the user
+ final String user = usernameToken.getName();
+ final String password = pwCb.getPassword();
+ SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
+ Object token;
+ try {
+ securityService.disassociate();
+
+ token = securityService.login(user, password);
+ securityService.associate(token);
+
+ } catch (LoginException e) {
+ throw new SecurityException("cannot log user " + user, e);
+ }
+ }
+}
Modified: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbEndpoint.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbEndpoint.java?rev=1144006&r1=1144005&r2=1144006&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbEndpoint.java (original)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbEndpoint.java Thu Jul 7 19:50:02 2011
@@ -26,13 +26,13 @@ import org.apache.cxf.interceptor.Interc
import org.apache.cxf.jaxws.handler.logical.LogicalHandlerInInterceptor;
import org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor;
import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.apache.cxf.transport.http.HTTPTransportFactory;
import org.apache.openejb.BeanContext;
import org.apache.openejb.core.webservices.JaxWsUtils;
import org.apache.openejb.core.webservices.PortData;
import org.apache.openejb.server.cxf.ConfigureCxfSecurity;
import org.apache.openejb.server.cxf.CxfEndpoint;
import org.apache.openejb.server.cxf.CxfServiceConfiguration;
-import org.apache.openejb.server.cxf.HttpTransportFactory;
import org.apache.openejb.server.cxf.JaxWsImplementorInfoImpl;
import javax.xml.ws.WebServiceException;
@@ -44,7 +44,7 @@ import java.util.List;
public class EjbEndpoint extends CxfEndpoint {
private final BeanContext beanContext;
- public EjbEndpoint(Bus bus, PortData portData, BeanContext beanContext, HttpTransportFactory httpTransportFactory) {
+ public EjbEndpoint(Bus bus, PortData portData, BeanContext beanContext, HTTPTransportFactory httpTransportFactory) {
super(bus, portData, beanContext.getJndiEnc(), beanContext.getBeanClass(), httpTransportFactory);
this.beanContext = beanContext;
@@ -96,7 +96,7 @@ public class EjbEndpoint extends CxfEndp
}
- private static void removeHandlerInterceptors(List<Interceptor> interceptors) {
+ private static void removeHandlerInterceptors(List<? extends Interceptor> interceptors) {
for (Interceptor interceptor : interceptors) {
if (interceptor instanceof MustUnderstandInterceptor || interceptor instanceof LogicalHandlerInInterceptor || interceptor instanceof SOAPHandlerInterceptor) {
interceptors.remove(interceptor);
Modified: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbWsContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbWsContainer.java?rev=1144006&r1=1144005&r2=1144006&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbWsContainer.java (original)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbWsContainer.java Thu Jul 7 19:50:02 2011
@@ -38,6 +38,6 @@ public class EjbWsContainer extends CxfW
public void start() {
super.start();
- this.destination.setPassSecurityContext(true);
+ // removed?: this.destination.setPassSecurityContext(true);
}
}
Modified: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoWsContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoWsContainer.java?rev=1144006&r1=1144005&r2=1144006&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoWsContainer.java (original)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoWsContainer.java Thu Jul 7 19:50:02 2011
@@ -41,6 +41,6 @@ public class PojoWsContainer extends Cxf
public void start() {
super.start();
- this.destination.setPassSecurityContext(true);
+ // removed?: this.destination.setPassSecurityContext(true);
}
}