This is an automated email from the ASF dual-hosted git repository. rzo1 pushed a commit to branch TOMEE-4700-10.x in repository https://gitbox.apache.org/repos/asf/tomee.git
commit 73fca228b988ec74b982aafb9025baaab93a61e9 Author: Richard Zowalla <[email protected]> AuthorDate: Mon Sep 7 20:56:49 2026 +0200 TOMEE-4700 [tomee-10.x]: Drop openejb-hessian --- server/openejb-hessian/pom.xml | 77 ------ .../java/org/apache/openejb/cdi/api/Hessian.java | 32 --- .../openejb/cdi/internal/HessianExtension.java | 214 --------------- .../hessian/HessianInitialContextFactory.java | 149 ----------- .../openejb/server/hessian/HessianRegistry.java | 32 --- .../server/hessian/HessianRegistryImpl.java | 74 ----- .../openejb/server/hessian/HessianServer.java | 155 ----------- .../openejb/server/hessian/HessianService.java | 282 ------------------- .../server/hessian/OpenEJBHessianServlet.java | 41 --- .../server/hessian/TomcatHessianRegistry.java | 298 --------------------- .../hessian | 10 - .../jakarta.enterprise.inject.spi.Extension | 1 - .../server/hessian/HessianCdiByConfigTest.java | 105 -------- .../openejb/server/hessian/HessianCdiTest.java | 116 -------- .../server/hessian/HessianInitialContextTest.java | 103 ------- .../server/hessian/HessianRegistryImplTest.java | 33 --- .../openejb/server/hessian/HessianServiceTest.java | 103 ------- .../server/hessian/LimitedBasicValveTest.java | 93 ------- server/pom.xml | 1 - 19 files changed, 1919 deletions(-) diff --git a/server/openejb-hessian/pom.xml b/server/openejb-hessian/pom.xml deleted file mode 100644 index d4f1c9b5a5..0000000000 --- a/server/openejb-hessian/pom.xml +++ /dev/null @@ -1,77 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - -Licensed to the Apache Software Foundation (ASF) under one or more -contributor license agreements. See the NOTICE file distributed with -this work for additional information regarding copyright ownership. -The ASF licenses this file to You under the Apache License, Version 2.0 -(the "License"); you may not use this file except in compliance with -the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <artifactId>server</artifactId> - <groupId>org.apache.tomee</groupId> - <version>10.3.0-SNAPSHOT</version> - </parent> - - <artifactId>openejb-hessian</artifactId> - <name>TomEE :: Server :: Hessian</name> - - <properties> - <tomee.build.name>${project.groupId}.server.hessian</tomee.build.name> - </properties> - <dependencies> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>openejb-http</artifactId> - <version>10.3.0-SNAPSHOT</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.tomcat</groupId> - <artifactId>tomcat-catalina</artifactId> - <version>${tomcat.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>tomee-catalina</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>com.caucho</groupId> - <artifactId>hessian</artifactId> - <version>4.0.66</version> - <scope>provided</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <reuseForks>false</reuseForks> - <argLine> - --add-opens=java.base/java.lang=ALL-UNNAMED - </argLine> - </configuration> - </plugin> - </plugins> - </build> -</project> diff --git a/server/openejb-hessian/src/main/java/org/apache/openejb/cdi/api/Hessian.java b/server/openejb-hessian/src/main/java/org/apache/openejb/cdi/api/Hessian.java deleted file mode 100644 index 68586ce960..0000000000 --- a/server/openejb-hessian/src/main/java/org/apache/openejb/cdi/api/Hessian.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.cdi.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -public @interface Hessian { - String path() default ""; - - boolean sendCollectionType() default true; - - Class<?> serializerFactory() default Object.class; -} diff --git a/server/openejb-hessian/src/main/java/org/apache/openejb/cdi/internal/HessianExtension.java b/server/openejb-hessian/src/main/java/org/apache/openejb/cdi/internal/HessianExtension.java deleted file mode 100644 index ab6370c426..0000000000 --- a/server/openejb-hessian/src/main/java/org/apache/openejb/cdi/internal/HessianExtension.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.cdi.internal; - -import org.apache.openejb.AppContext; -import org.apache.openejb.OpenEJBRuntimeException; -import org.apache.openejb.assembler.classic.AppInfo; -import org.apache.openejb.cdi.OpenEJBLifecycle; -import org.apache.openejb.cdi.api.Hessian; -import org.apache.openejb.core.WebContext; -import org.apache.openejb.loader.SystemInstance; -import org.apache.openejb.server.hessian.HessianRegistry; -import org.apache.openejb.server.hessian.HessianServer; -import org.apache.openejb.server.hessian.HessianService; -import org.apache.openejb.spi.ContainerSystem; -import org.apache.webbeans.config.WebBeansContext; -import org.apache.webbeans.container.BeanManagerImpl; - -import jakarta.enterprise.context.Dependent; -import jakarta.enterprise.event.Observes; -import jakarta.enterprise.inject.spi.AfterDeploymentValidation; -import jakarta.enterprise.inject.spi.Bean; -import jakarta.enterprise.inject.spi.BeanManager; -import jakarta.enterprise.inject.spi.BeforeBeanDiscovery; -import jakarta.enterprise.inject.spi.BeforeShutdown; -import jakarta.enterprise.inject.spi.Extension; -import jakarta.enterprise.inject.spi.ProcessBean; -import jakarta.enterprise.inject.spi.ProcessSessionBean; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.logging.Logger; - -public class HessianExtension implements Extension { - private static final Logger LOGGER = Logger.getLogger(HessianExtension.class.getName()); - - private final Collection<Deployment> toDeploy = new ArrayList<>(); - private final Collection<DeployedEndpoint> deployed = new ArrayList<>(); - - private AppInfo appInfo; - - protected void init(final @Observes BeforeBeanDiscovery beforeBeanDiscovery) { - appInfo = OpenEJBLifecycle.CURRENT_APP_INFO.get(); - if (appInfo == null) { - throw new IllegalStateException("Without OpenEJBLifecycle this Extension can't work correctly"); - } - } - - protected <X> void findHessianWebServices(final @Observes ProcessBean<X> processBean) { - if (ProcessSessionBean.class.isInstance(processBean)) { - return; - } - - final Bean<X> bean = processBean.getBean(); - final Class<?> beanClass = bean.getBeanClass(); - for (final Class<?> itf : beanClass.getInterfaces()) { - final Hessian hessian = itf.getAnnotation(Hessian.class); - final String key = "openejb.hessian." + beanClass.getName() + "_" + itf.getName() + ".path"; - final String path = appInfo.properties.getProperty(key, SystemInstance.get().getProperty(key)); - if (hessian != null || path != null) { - toDeploy.add(new Deployment(itf, path, bean)); - } - } - } - - protected void deploy(final @Observes AfterDeploymentValidation afterDeploymentValidation, final BeanManager bm) { - final HessianService service = SystemInstance.get().getComponent(HessianService.class); - if (service == null) { - LOGGER.severe("HessianService not yet started, no hessian CDI webservices will be deployed"); - return; - } - - final HessianRegistry registry = service.getRegistry(); - - final String appName = findAppName(); - for (final Deployment deployment : toDeploy) { - final Hessian hessian = deployment.itf.getAnnotation(Hessian.class); - final HessianServer server; - try { - server = new HessianServer(deployment.bean.getBeanClass().getClassLoader()); - } catch (final HessianServer.HessianIsMissingException e) { - LOGGER.info("Hessian is not available so openejb-hessian will not deploy any service"); - break; - } - - try { - if (hessian != null && hessian.serializerFactory() != Object.class && !hessian.serializerFactory().isInstance(server.getSerializerFactory())) { - server.serializerFactory(hessian.serializerFactory().newInstance()); - } - } catch (final Exception e) { - throw new OpenEJBRuntimeException(e); - } - if (hessian != null) { - server.sendCollectionType(hessian.sendCollectionType()); - } - if (Dependent.class.equals(deployment.bean.getScope())) { - LOGGER.warning("@Dependent can lead to memory leaks ATM"); - } - server.createSkeleton(bm.getReference(deployment.bean, deployment.itf, null), deployment.itf); - - final String name = getName(deployment.path, deployment.itf); - try { - LOGGER.info("Hessian(url=" + registry.deploy(deployment.itf.getClassLoader(), server, - service.getVirtualHost(), appName, - service.getAuthMethod(), service.getTransportGuarantee(), - service.getRealmName(), name) + ", interface=" + name + ")"); - deployed.add(new DeployedEndpoint(appName, name)); - } catch (final URISyntaxException e) { - throw new OpenEJBRuntimeException(e); - } - } - toDeploy.clear(); - } - - private String findAppName() { - if (appInfo.webAppAlone) { - return appInfo.webApps.iterator().next().contextRoot; - } - - for (final AppContext app : SystemInstance.get().getComponent(ContainerSystem.class).getAppContexts()) { - for (final WebContext webContext : app.getWebContexts()) { - if (isSameContext(webContext.getWebBeansContext())) { - String contextRoot = webContext.getContextRoot(); - if (contextRoot != null) { - if (contextRoot.startsWith("/")) { - return contextRoot.substring(1); - } - return contextRoot; - } - return webContext.getId(); - } - } - if (isSameContext(app.getWebBeansContext())) { - return app.getId(); - } - } - throw new IllegalArgumentException("Can't find application matching bean manager"); - } - - private boolean isSameContext(final WebBeansContext app) { - final BeanManagerImpl bm = app.getBeanManagerImpl(); - try { - return bm.isInUse() && equals(bm.getExtension(HessianExtension.class)); - } catch (final Exception e) { - return false; - } - } - - protected void shutdown(final @Observes BeforeShutdown unused) { - final HessianService service = SystemInstance.get().getComponent(HessianService.class); - if (service == null) { - return; - } - - final HessianRegistry registry = service.getRegistry(); - for (final DeployedEndpoint pair : deployed) { - registry.undeploy(service.getVirtualHost(), pair.app, pair.name); - LOGGER.info("Undeployed CDI hessian service " + pair.name); - } - deployed.clear(); - } - - private static String getName(final String path, final Class<?> itf) { - if (path != null) { - return path; - } - - final Hessian hessian = itf.getAnnotation(Hessian.class); - if (hessian != null) { - final String name = hessian.path(); - if (name.isEmpty()) { - return itf.getName(); - } - return name; - } - return itf.getName(); - } - - protected static class Deployment { - private final Class<?> itf; - private final String path; - private final Bean<?> bean; - - public Deployment(final Class<?> itf, final String path, final Bean<?> bean) { - this.itf = itf; - this.path = path; - this.bean = bean; - } - } - - protected static class DeployedEndpoint { - private final String app; - private final String name; - - protected DeployedEndpoint(final String app, final String name) { - this.app = app; - this.name = name; - } - } -} diff --git a/server/openejb-hessian/src/main/java/org/apache/openejb/client/hessian/HessianInitialContextFactory.java b/server/openejb-hessian/src/main/java/org/apache/openejb/client/hessian/HessianInitialContextFactory.java deleted file mode 100644 index d9c595270a..0000000000 --- a/server/openejb-hessian/src/main/java/org/apache/openejb/client/hessian/HessianInitialContextFactory.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.client.hessian; - -import org.apache.openejb.OpenEJBRuntimeException; -import org.apache.openejb.core.ivm.naming.ContextWrapper; -import org.apache.openejb.util.reflection.Reflections; - -import javax.naming.Context; -import javax.naming.Name; -import javax.naming.NamingException; -import javax.naming.spi.InitialContextFactory; -import java.lang.reflect.Constructor; -import java.util.Hashtable; - -// all is done by reflection to let the use provide hessian in the app -public class HessianInitialContextFactory implements InitialContextFactory { - public static final String API = "openejb.hessian.client.api"; - public static final String FORCE_SERIALIZABLE = "openejb.hessian.client.force-serializable"; - public static final String CHUNKED = "openejb.hessian.client.chunked"; - public static final String DEBUG = "openejb.hessian.client.debug"; - public static final String READ_TIMEOUT = "openejb.hessian.client.read-timeout"; - public static final String CONNECT_TIMEOUT = "openejb.hessian.client.connect-timeout"; - - private static final Class<?>[] BOOLEAN_PARAM = new Class<?>[]{boolean.class}; - private static final Class<?>[] LONG_PARAM = new Class<?>[]{long.class}; - private static final Class<?>[] STRING_PARAM = new Class<?>[]{String.class}; - private static final Class<?>[] CREATE_PARAM = new Class<?>[]{Class.class, String.class, ClassLoader.class}; - - @Override - public Context getInitialContext(final Hashtable<?, ?> environment) throws NamingException { - return new HessianContext(environment); - } - - private static class HessianContext extends ContextWrapper { - private final Hashtable<?, ?> environment; - private final ClassLoader loader; - private final String url; - private final Class<?> api; - private final boolean allowNonSerializable; - private final String user; - private final String password; - private final boolean chunked; - private final boolean debug; - private final int readTimeout; - private final int connectTimeout; - private final Constructor<?> factoryConstructor; - private final Constructor<?> serializerConstructor; - - public HessianContext(final Hashtable<?, ?> environment) { - super(null); // will lead to NPE if used but shouldn't be used in practise - this.environment = environment; - - String baseUrl = String.class.cast(environment.get(Context.PROVIDER_URL)); - if (baseUrl == null) { - throw new IllegalArgumentException("provider url should be set"); - } - if (!baseUrl.endsWith("/")) { - baseUrl += '/'; - } - - this.url = baseUrl; - - this.loader = Thread.currentThread().getContextClassLoader(); - this.user = String.class.cast(environment.get(Context.SECURITY_PRINCIPAL)); - this.password = String.class.cast(environment.get(Context.SECURITY_CREDENTIALS)); - this.allowNonSerializable = environment.get(FORCE_SERIALIZABLE) == null || !"true".equals(String.class.cast(environment.get(FORCE_SERIALIZABLE))); - this.chunked = environment.get(CHUNKED) == null || "true".equals(String.class.cast(environment.get(CHUNKED))); - this.debug = "true".equals(String.class.cast(environment.get(DEBUG))); - this.readTimeout = environment.get(READ_TIMEOUT) == null ? -1 : Integer.parseInt(String.class.cast(environment.get(READ_TIMEOUT))); - this.connectTimeout = environment.get(CONNECT_TIMEOUT) == null ? -1 : Integer.parseInt(String.class.cast(environment.get(CONNECT_TIMEOUT))); - - final String apiClassname = String.class.cast(environment.get(API)); - if (apiClassname != null) { - try { - api = loader.loadClass(apiClassname); - } catch (final ClassNotFoundException e) { - throw new OpenEJBRuntimeException(e); - } - } else { - api = null; - } - - try { - factoryConstructor = loader.loadClass("com.caucho.hessian.client.HessianProxyFactory").getConstructor(ClassLoader.class); - serializerConstructor = loader.loadClass("com.caucho.hessian.io.SerializerFactory").getConstructor(ClassLoader.class); - } catch (final Exception e) { - throw new OpenEJBRuntimeException(e); - } - } - - @Override - public Object lookup(final Name name) throws NamingException { - return lookup(name.toString()); - } - - @Override - public Object lookup(final String name) throws NamingException { - try { - final Object clientFactory = factoryConstructor.newInstance(loader); - final Object factory = serializerConstructor.newInstance(loader); - Reflections.invokeByReflection(factory, "setAllowNonSerializable", BOOLEAN_PARAM, new Object[]{allowNonSerializable}); - Reflections.invokeByReflection(clientFactory, "setSerializerFactory", new Class<?>[]{serializerConstructor.getDeclaringClass()}, new Object[]{factory}); - if (user != null) { - Reflections.invokeByReflection(clientFactory, "setUser", STRING_PARAM, new Object[]{user}); - Reflections.invokeByReflection(clientFactory, "setPassword", STRING_PARAM, new Object[]{password}); - } - Reflections.invokeByReflection(clientFactory, "setChunkedPost", BOOLEAN_PARAM, new Object[]{chunked}); - Reflections.invokeByReflection(clientFactory, "setDebug", BOOLEAN_PARAM, new Object[]{debug}); - Reflections.invokeByReflection(clientFactory, "setReadTimeout", LONG_PARAM, new Object[]{readTimeout}); - Reflections.invokeByReflection(clientFactory, "setConnectTimeout", LONG_PARAM, new Object[]{connectTimeout}); - - final String completeUrl = url + name; - try { - if (api != null) { // just use it - return Reflections.invokeByReflection(clientFactory, "create", CREATE_PARAM, new Object[]{api, completeUrl, loader}); - } - - return Reflections.invokeByReflection(clientFactory, "create", STRING_PARAM, new Object[]{completeUrl}); - } catch (final Exception e) { - throw new NamingException(e.getMessage()); - } - } catch (final Exception e) { - throw new OpenEJBRuntimeException(e); - } - - - } - - @Override - public Hashtable<?, ?> getEnvironment() throws NamingException { - return environment; - } - } -} diff --git a/server/openejb-hessian/src/main/java/org/apache/openejb/server/hessian/HessianRegistry.java b/server/openejb-hessian/src/main/java/org/apache/openejb/server/hessian/HessianRegistry.java deleted file mode 100644 index 29fa27841e..0000000000 --- a/server/openejb-hessian/src/main/java/org/apache/openejb/server/hessian/HessianRegistry.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.server.hessian; - -import org.apache.openejb.loader.SystemInstance; - -import java.net.URISyntaxException; - -public interface HessianRegistry { - static final String HESSIAN = SystemInstance.get().getProperty("openejb.hessian.subcontext", "/hessian/"); - - String deploy(ClassLoader loader, HessianServer server, - String host, String app, - String authMethod, String transportGuarantee, String realmName, - String name) throws URISyntaxException; - - public void undeploy(String host, String app, String name); -} diff --git a/server/openejb-hessian/src/main/java/org/apache/openejb/server/hessian/HessianRegistryImpl.java b/server/openejb-hessian/src/main/java/org/apache/openejb/server/hessian/HessianRegistryImpl.java deleted file mode 100644 index 7918a39610..0000000000 --- a/server/openejb-hessian/src/main/java/org/apache/openejb/server/hessian/HessianRegistryImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.server.hessian; - -import org.apache.openejb.OpenEJBRuntimeException; -import org.apache.openejb.loader.SystemInstance; -import org.apache.openejb.server.httpd.HttpListener; -import org.apache.openejb.server.httpd.HttpListenerRegistry; -import org.apache.openejb.server.httpd.HttpRequest; -import org.apache.openejb.server.httpd.HttpResponse; -import org.apache.openejb.server.httpd.OpenEJBHttpRegistry; -import org.apache.openejb.server.httpd.util.HttpUtil; - -public class HessianRegistryImpl extends OpenEJBHttpRegistry implements HessianRegistry { - @Override - public String deploy(final ClassLoader loader, final HessianServer listener, final String host, - final String app, final String authMethod, final String transportGuarantee, - final String realmName, final String name) { - if (authMethod != null && !"NONE".equalsIgnoreCase(authMethod)) { - throw new IllegalArgumentException("authMethod '" + authMethod + "' is not supported by the embedded hessian registry for '" + name - + "', use authMethod=NONE or the Tomcat registry"); - } - if (transportGuarantee != null && !"NONE".equalsIgnoreCase(transportGuarantee)) { - throw new IllegalArgumentException("transportGuarantee '" + transportGuarantee + "' is not supported by the embedded hessian registry for '" + name - + "', use transportGuarantee=NONE or the Tomcat registry"); - } - final String path = generateEndpointName(app, name); - addWrappedHttpListener(new HessianListener(listener), loader, path); - return HttpUtil.selectSingleAddress(getResolvedAddresses(path)); - } - - @Override - public void undeploy(String host, String app, String name) { - SystemInstance.get().getComponent(HttpListenerRegistry.class).removeHttpListener(generateEndpointName(app, name)); - } - - private static String generateEndpointName(final String app, final String name) { - return "/" + app + HESSIAN + name; - } - - protected static class HessianListener implements HttpListener { - private final HessianServer delegate; - - protected HessianListener(final HessianServer server) { - this.delegate = server; - } - - @Override - public void onMessage(final HttpRequest request, final HttpResponse response) throws Exception { - try { - delegate.invoke(request.getInputStream(), response.getOutputStream()); - } catch (final Throwable throwable) { - if (Exception.class.isInstance(throwable)) { - throw Exception.class.cast(throwable); - } - throw new OpenEJBRuntimeException(throwable.getMessage(), throwable); - } - } - } -} diff --git a/server/openejb-hessian/src/main/java/org/apache/openejb/server/hessian/HessianServer.java b/server/openejb-hessian/src/main/java/org/apache/openejb/server/hessian/HessianServer.java deleted file mode 100644 index 3ffd3a9ab3..0000000000 --- a/server/openejb-hessian/src/main/java/org/apache/openejb/server/hessian/HessianServer.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.server.hessian; - -import org.apache.openejb.OpenEJBRuntimeException; -import org.apache.openejb.util.reflection.Reflections; - -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.logging.Level; -import java.util.logging.Logger; - -// done by reflection to let hessian be in the app -public class HessianServer { - public static final String CONTENT_TYPE_HESSIAN = "application/x-hessian"; - - private static final Class<?>[] BOOLEAN_PARAM = new Class<?>[]{boolean.class}; - private static final Object[] TRUE_PARAM = new Object[]{true}; - - private final ClassLoader loader; - private final Class<?> serializerFactoryClass; - - private Object serializerFactory; - private Object skeleton; - private Logger debugLogger = null; - - public HessianServer(final ClassLoader classLoader) throws HessianIsMissingException { - this.loader = classLoader; - - try { - serializerFactoryClass = classLoader.loadClass("com.caucho.hessian.io.SerializerFactory"); - serializerFactory = serializerFactoryClass.getConstructor(ClassLoader.class).newInstance(loader); - } catch (final Exception e) { - throw new HessianIsMissingException(e); - } - Reflections.invokeByReflection(serializerFactory, "setAllowNonSerializable", BOOLEAN_PARAM, TRUE_PARAM); - } - - public HessianServer serializerFactory(final Object serializerFactory) { - this.serializerFactory = serializerFactory; - return this; - } - - public HessianServer sendCollectionType(final boolean sendCollectionType) { - Reflections.invokeByReflection(serializerFactory, "setSendCollectionType", BOOLEAN_PARAM, new Object[]{sendCollectionType}); - return this; - } - - public HessianServer debug(boolean debug) { - this.debugLogger = (debug ? Logger.getLogger("OpenEJB.hessian.DEBUG") : null); - return this; - } - - public HessianServer createSkeleton(final Object instance, final Class<?> itf) { - try { - skeleton = loader.loadClass("com.caucho.hessian.server.HessianSkeleton").getConstructor(Object.class, Class.class).newInstance(instance, itf); - } catch (final Exception e) { - throw new OpenEJBRuntimeException(e); - } - return this; - } - - public Object getSerializerFactory() { - return serializerFactory; - } - - public void invoke(final InputStream inputStream, final OutputStream outputStream) throws Throwable { - InputStream isToUse = inputStream; - OutputStream osToUse = outputStream; - - if (debugLogger != null && debugLogger.isLoggable(Level.FINE)) { - isToUse = InputStream.class.cast(loader.loadClass("com.caucho.hessian.io.HessianDebugInputStream").getConstructor(InputStream.class, Logger.class, Level.class).newInstance(inputStream, debugLogger, Level.FINE)); - Reflections.invokeByReflection(isToUse, "startTop2", new Class<?>[0], null); - - osToUse = OutputStream.class.cast(loader.loadClass("com.caucho.hessian.io.HessianDebugOutputStream").getConstructor(OutputStream.class, Logger.class, Level.class).newInstance(outputStream, debugLogger, Level.FINE)); - Reflections.invokeByReflection(osToUse, "startTop2", new Class<?>[0], null); - } - - if (!isToUse.markSupported()) { - isToUse = new BufferedInputStream(isToUse); - isToUse.mark(1); - } - - int code = isToUse.read(); - int major; - int minor; - - Object in; - Object out; - - if (code == 'H' || code == 'C') { // Hessian 2.0 stream - major = isToUse.read(); - minor = isToUse.read(); - if (major != 0x02) { - throw new IOException("Version " + major + "." + minor + " is not understood"); - } - in = loader.loadClass("com.caucho.hessian.io.Hessian2Input").getConstructor(InputStream.class).newInstance(isToUse); - out = loader.loadClass("com.caucho.hessian.io.Hessian2Output").getConstructor(OutputStream.class).newInstance(osToUse); - Reflections.invokeByReflection(in, "readCall", new Class<?>[0], null); - } else if (code == 'c') { // Hessian 1.0 call - major = isToUse.read(); - minor = isToUse.read(); - in = loader.loadClass("com.caucho.hessian.io.HessianInput").getConstructor(InputStream.class).newInstance(isToUse); - if (major >= 2) { - out = loader.loadClass("com.caucho.hessian.io.Hessian2Output").getConstructor(OutputStream.class).newInstance(osToUse); - } else { - out = loader.loadClass("com.caucho.hessian.io.HessianOutput").getConstructor(OutputStream.class).newInstance(osToUse); - } - } else { - throw new IOException("Expected 'H'/'C' (Hessian 2.0) or 'c' (Hessian 1.0) in hessian input at " + code); - } - - Reflections.invokeByReflection(in, "setSerializerFactory", new Class<?>[]{serializerFactoryClass}, new Object[]{serializerFactory}); - Reflections.invokeByReflection(out, "setSerializerFactory", new Class<?>[]{serializerFactoryClass}, new Object[]{serializerFactory}); - - try { - Reflections.invokeByReflection(skeleton, "invoke", new Class<?>[]{loader.loadClass("com.caucho.hessian.io.AbstractHessianInput"), loader.loadClass("com.caucho.hessian.io.AbstractHessianOutput")}, new Object[]{in, out}); - } finally { - try { - Reflections.invokeByReflection(in, "close", new Class<?>[0], null); - isToUse.close(); - } catch (final IOException ex) { - // ignore - } - try { - Reflections.invokeByReflection(out, "close", new Class<?>[0], null); - osToUse.close(); - } catch (final IOException ex) { - // ignore - } - } - } - - public static class HessianIsMissingException extends Exception { - public HessianIsMissingException(final Exception e) { - super(e); - } - } -} diff --git a/server/openejb-hessian/src/main/java/org/apache/openejb/server/hessian/HessianService.java b/server/openejb-hessian/src/main/java/org/apache/openejb/server/hessian/HessianService.java deleted file mode 100644 index 469262d1a4..0000000000 --- a/server/openejb-hessian/src/main/java/org/apache/openejb/server/hessian/HessianService.java +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.server.hessian; - -import org.apache.openejb.BeanContext; -import org.apache.openejb.OpenEJBRuntimeException; -import org.apache.openejb.assembler.classic.AppInfo; -import org.apache.openejb.assembler.classic.Assembler; -import org.apache.openejb.assembler.classic.EjbJarInfo; -import org.apache.openejb.assembler.classic.EnterpriseBeanInfo; -import org.apache.openejb.assembler.classic.event.AssemblerAfterApplicationCreated; -import org.apache.openejb.assembler.classic.event.AssemblerBeforeApplicationDestroyed; -import org.apache.openejb.assembler.classic.event.NewEjbAvailableAfterApplicationCreated; -import org.apache.openejb.loader.SystemInstance; -import org.apache.openejb.observer.Observes; -import org.apache.openejb.server.SelfManaging; -import org.apache.openejb.server.ServerService; -import org.apache.openejb.server.ServiceException; -import org.apache.openejb.server.httpd.HttpListenerRegistry; -import org.apache.openejb.spi.ContainerSystem; -import org.apache.openejb.util.LogCategory; -import org.apache.openejb.util.Logger; -import org.apache.openejb.util.proxy.ProxyEJB; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.Socket; -import java.net.URISyntaxException; -import java.util.Collection; -import java.util.Properties; - -public class HessianService implements ServerService, SelfManaging { - private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB_SERVER.createChild("hessian"), HessianService.class); - - private boolean disabled; - private boolean debug; - private boolean sendCollectionType; - private String serializerFactory; - private String realmName; - private String virtualHost; - private String transportGuarantee; - private String authMethod; - - private HessianRegistry registry; - - private void deploy(final AppInfo app, final Collection<BeanContext> beanContexts) { - if (disabled) { - return; - } - - for (final BeanContext beanContext : beanContexts) { - final Class<?> remoteItf = beanContext.getBusinessRemoteInterface(); - if (remoteItf == null) { - continue; - } - - final ClassLoader old = Thread.currentThread().getContextClassLoader(); - final ClassLoader classLoader = beanContext.getClassLoader(); - Thread.currentThread().setContextClassLoader(classLoader); - - try { - final HessianServer server; - try { - server = new HessianServer(classLoader).debug(debug); - } catch (final HessianServer.HessianIsMissingException e) { - LOGGER.info("Hessian is not available so openejb-hessian will not deploy any service"); - break; - } - - if (serializerFactory != null) { - try { - server.serializerFactory(classLoader.loadClass(serializerFactory).newInstance()).sendCollectionType(sendCollectionType); - } catch (final Exception e) { - throw new OpenEJBRuntimeException(e); - } - } else { - server.sendCollectionType(sendCollectionType); - } - - server.createSkeleton(ProxyEJB.simpleProxy(beanContext, new Class<?>[]{remoteItf}), remoteItf); - - try { - LOGGER.info("Hessian(url=" + registry.deploy(classLoader, server, virtualHost, appName(app, beanContext), authMethod, transportGuarantee, realmName, String.class.cast(beanContext.getDeploymentID())) + ", interface=" + remoteItf.getName() + ")"); - } catch (final URISyntaxException e) { - throw new OpenEJBRuntimeException(e); - } - } finally { - Thread.currentThread().setContextClassLoader(old); - } - } - } - - @Override - public void start() throws ServiceException { - SystemInstance.get().addObserver(this); - SystemInstance.get().setComponent(HessianService.class, this); - registry = setRegistry(); - - final Assembler assembler = SystemInstance.get().getComponent(Assembler.class); - if (assembler != null) { - for (final AppInfo appInfo : assembler.getDeployedApplications()) { - deploy(new AssemblerAfterApplicationCreated(appInfo, SystemInstance.get().getComponent(ContainerSystem.class).getAppContext(appInfo.appId), null)); - } - } - } - - private HessianRegistry setRegistry() { - HessianRegistry registry = SystemInstance.get().getComponent(HessianRegistry.class); - if (registry == null) { - try { // if tomcat - HessianService.class.getClassLoader().loadClass("org.apache.catalina.Context"); - registry = new TomcatHessianRegistry(); - } catch (final Throwable t) { // else if embedded - if (SystemInstance.get().getComponent(HttpListenerRegistry.class) != null) { - registry = new HessianRegistryImpl(); - } else { - throw new IllegalStateException("openejb-http is missing at classpath"); - } - } - SystemInstance.get().setComponent(HessianRegistry.class, registry); - } - return registry; - } - - public HessianRegistry getRegistry() { - return registry; - } - - @Override - public void stop() throws ServiceException { - SystemInstance.get().removeObserver(this); - } - - @Override - public void service(final InputStream in, final OutputStream out) throws ServiceException, IOException { - throw new UnsupportedOperationException(); - } - - @Override - public void service(final Socket socket) throws ServiceException, IOException { - throw new UnsupportedOperationException(); - } - - public void newEjbToDeploy(final @Observes NewEjbAvailableAfterApplicationCreated event) { - deploy(event.getApp(), event.getBeanContexts()); - } - - public void deploy(final @Observes AssemblerAfterApplicationCreated event) { - final AppInfo appInfo = event.getApp(); - deploy(appInfo, event.getContext().getBeanContexts()); - } - - public void undeploy(@Observes final AssemblerBeforeApplicationDestroyed event) { - if (disabled) { - return; - } - - for (final BeanContext beanContext : event.getContext().getBeanContexts()) { - final Class<?> remoteItf = beanContext.getBusinessRemoteInterface(); - if (remoteItf == null) { - continue; - } - - final String name = String.class.cast(beanContext.getDeploymentID()); - registry.undeploy(virtualHost, appName(event.getApp(), beanContext), name); - LOGGER.info("Undeployed hessian service " + name); - } - } - - public static String appName(final AppInfo app, final BeanContext beanContext) { - if (!app.webApps.isEmpty()) { - for (final EjbJarInfo ejbJar : app.ejbJars) { - for (final EnterpriseBeanInfo bean : ejbJar.enterpriseBeans) { - if (bean.ejbName.equals(beanContext.getEjbName())) { - if (ejbJar.webapp) { - return ejbJar.moduleName; - } - } - } - } - } - return app.appId; - } - - @Override - public String getName() { - return "hessian"; - } - - @Override - public String getIP() { - return "n/a"; - } - - @Override - public int getPort() { - return -1; - } - - public boolean isDisabled() { - return disabled; - } - - public void setDisabled(final boolean disabled) { - this.disabled = disabled; - } - - public boolean isDebug() { - return debug; - } - - public void setDebug(final boolean debug) { - this.debug = debug; - } - - public boolean isSendCollectionType() { - return sendCollectionType; - } - - public void setSendCollectionType(final boolean sendCollectionType) { - this.sendCollectionType = sendCollectionType; - } - - public String getRealmName() { - return realmName; - } - - public void setRealmName(final String realmName) { - this.realmName = realmName; - } - - public String getVirtualHost() { - return virtualHost; - } - - public void setVirtualHost(final String virtualHost) { - this.virtualHost = virtualHost; - } - - public String getTransportGuarantee() { - return transportGuarantee; - } - - public void setTransportGuarantee(final String transportGuarantee) { - this.transportGuarantee = transportGuarantee; - } - - public String getAuthMethod() { - return authMethod; - } - - public void setAuthMethod(final String authMethod) { - this.authMethod = authMethod; - } - - @Override - public void init(final Properties props) throws Exception { - disabled = Boolean.parseBoolean(props.getProperty("disabled", "false")); - debug = Boolean.parseBoolean(props.getProperty("debug", "false")); - sendCollectionType = Boolean.parseBoolean(props.getProperty("sendCollectionType", "false")); - realmName = props.getProperty("realmName"); - transportGuarantee = props.getProperty("transportGuarantee", "NONE"); - virtualHost = props.getProperty("virtualHost", "localhost"); - authMethod = props.getProperty("authMethod", "NONE"); - serializerFactory = props.getProperty("serializerFactory", null); - } -} diff --git a/server/openejb-hessian/src/main/java/org/apache/openejb/server/hessian/OpenEJBHessianServlet.java b/server/openejb-hessian/src/main/java/org/apache/openejb/server/hessian/OpenEJBHessianServlet.java deleted file mode 100644 index 2524898b74..0000000000 --- a/server/openejb-hessian/src/main/java/org/apache/openejb/server/hessian/OpenEJBHessianServlet.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.server.hessian; - -import jakarta.servlet.ServletException; -import jakarta.servlet.ServletRequest; -import jakarta.servlet.ServletResponse; -import jakarta.servlet.http.HttpServlet; -import java.io.IOException; - -public class OpenEJBHessianServlet extends HttpServlet { - private final HessianServer delegate; - - public OpenEJBHessianServlet(final HessianServer listener) { - this.delegate = listener; - } - - @Override - public void service(final ServletRequest req, final ServletResponse res) throws ServletException, IOException { - res.setContentType(HessianServer.CONTENT_TYPE_HESSIAN); - try { - delegate.invoke(req.getInputStream(), res.getOutputStream()); - } catch (final Throwable throwable) { - throw new ServletException(throwable); - } - } -} diff --git a/server/openejb-hessian/src/main/java/org/apache/openejb/server/hessian/TomcatHessianRegistry.java b/server/openejb-hessian/src/main/java/org/apache/openejb/server/hessian/TomcatHessianRegistry.java deleted file mode 100644 index 705c718be7..0000000000 --- a/server/openejb-hessian/src/main/java/org/apache/openejb/server/hessian/TomcatHessianRegistry.java +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.server.hessian; - -import org.apache.catalina.Container; -import org.apache.catalina.Context; -import org.apache.catalina.Engine; -import org.apache.catalina.Service; -import org.apache.catalina.Valve; -import org.apache.catalina.Wrapper; -import org.apache.catalina.authenticator.BasicAuthenticator; -import org.apache.catalina.authenticator.DigestAuthenticator; -import org.apache.catalina.authenticator.NonLoginAuthenticator; -import org.apache.catalina.authenticator.SSLAuthenticator; -import org.apache.catalina.connector.Connector; -import org.apache.catalina.connector.Request; -import org.apache.catalina.connector.Response; -import org.apache.catalina.core.StandardContext; -import org.apache.catalina.core.StandardServer; -import org.apache.commons.lang3.tuple.MutablePair; -import org.apache.commons.lang3.tuple.Pair; -import org.apache.openejb.assembler.classic.WebAppBuilder; -import org.apache.openejb.loader.SystemInstance; -import org.apache.openejb.server.httpd.util.HttpUtil; -import org.apache.tomcat.util.descriptor.web.LoginConfig; -import org.apache.tomcat.util.descriptor.web.SecurityCollection; -import org.apache.tomcat.util.descriptor.web.SecurityConstraint; -import org.apache.tomee.catalina.IgnoredStandardContext; -import org.apache.tomee.catalina.OpenEJBValve; -import org.apache.tomee.catalina.TomcatWebAppBuilder; -import org.apache.tomee.loader.TomcatHelper; - -import jakarta.servlet.ServletException; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class TomcatHessianRegistry implements HessianRegistry { - private static final String TOMEE_HESSIAN_SECURITY_ROLE_PREFIX = "tomee.hessian.security-role."; - - private final Map<String, Pair<Context, Integer>> fakeContexts = new HashMap<>(); - - private Engine engine; - private List<Connector> connectors; - - public TomcatHessianRegistry() { - final StandardServer standardServer = TomcatHelper.getServer(); - for (final Service service : standardServer.findServices()) { - if (Engine.class.isInstance(service.getContainer())) { - connectors = Arrays.asList(service.findConnectors()); - engine = Engine.class.cast(service.getContainer()); - break; - } - } - } - - @Override - public String deploy(final ClassLoader loader, final HessianServer listener, - final String hostname, final String app, - final String authMethod, final String transportGuarantee, - final String realmName, final String name) throws URISyntaxException { - Container host = engine.findChild(hostname); - if (host == null) { - host = engine.findChild(engine.getDefaultHost()); - if (host == null) { - throw new IllegalArgumentException("Invalid virtual host '" + engine.getDefaultHost() + "'. Do you have a matching Host entry in the server.xml?"); - } - } - - final String contextRoot = contextName(app); - Context context = Context.class.cast(host.findChild(contextRoot)); - final boolean applicationContext = context != null && !fakeContexts.containsKey(contextRoot); - if (context == null) { - Pair<Context, Integer> fakeContext = fakeContexts.get(contextRoot); - if (fakeContext != null) { - context = fakeContext.getLeft(); - fakeContext.setValue(fakeContext.getValue() + 1); - } else { - context = Context.class.cast(host.findChild(contextRoot)); - if (context == null) { - fakeContext = fakeContexts.get(contextRoot); - if (fakeContext == null) { - context = createNewContext(loader, authMethod, transportGuarantee, realmName, app); - fakeContext = new MutablePair<>(context, 1); - fakeContexts.put(contextRoot, fakeContext); - } else { - context = fakeContext.getLeft(); - fakeContext.setValue(fakeContext.getValue() + 1); - } - } - } - } - - final String realAuthMethod = authMethod == null ? null : authMethod.toUpperCase(); - if (applicationContext && realAuthMethod != null && !"NONE".equals(realAuthMethod)) { - // an existing web context keeps its own login configuration, only the BASIC valve can be added to it - if (!"BASIC".equals(realAuthMethod)) { - throw new IllegalArgumentException("authMethod '" + authMethod + "' cannot be applied to the existing context '" - + contextRoot + "', refusing to deploy hessian servlet '" + name + "'"); - } - if (transportGuarantee != null && !"NONE".equalsIgnoreCase(transportGuarantee)) { - throw new IllegalArgumentException("transportGuarantee '" + transportGuarantee + "' cannot be applied to the existing context '" - + contextRoot + "', refusing to deploy hessian servlet '" + name + "'"); - } - if (!StandardContext.class.isInstance(context)) { - throw new IllegalArgumentException("authMethod '" + authMethod + "' cannot be applied to context '" - + contextRoot + "' (" + context.getClass().getName() + "), refusing to deploy hessian servlet '" + name + "'"); - } - } - - final String servletMapping = generateServletPath(name); - - Wrapper wrapper = Wrapper.class.cast(context.findChild(servletMapping)); - if (wrapper != null) { - throw new IllegalArgumentException("Servlet " + servletMapping + " in web application context " + context.getName() + " already exists"); - } - - wrapper = context.createWrapper(); - wrapper.setName(HESSIAN.replace("/", "") + "_" + name); - wrapper.setServlet(new OpenEJBHessianServlet(listener)); - context.addChild(wrapper); - context.addServletMappingDecoded(servletMapping, wrapper.getName()); - - if ("BASIC".equals(realAuthMethod) && StandardContext.class.isInstance(context)) { - final StandardContext standardContext = StandardContext.class.cast(context); - - boolean found = false; - for (final Valve v : standardContext.getPipeline().getValves()) { - if (LimitedBasicValve.class.isInstance(v) || BasicAuthenticator.class.isInstance(v)) { - found = true; - break; - } - } - if (!found) { - standardContext.addValve(new LimitedBasicValve()); - } - } - - final List<String> addresses = new ArrayList<>(); - for (final Connector connector : connectors) { - for (final String mapping : wrapper.findMappings()) { - final URI address = new URI(connector.getScheme(), null, host.getName(), connector.getPort(), contextRoot + mapping, null, null); - addresses.add(address.toString()); - } - } - return HttpUtil.selectSingleAddress(addresses); - } - - private static Context createNewContext(final ClassLoader classLoader, final String rAuthMethod, final String rTransportGuarantee, final String realmName, final String name) { - String path = name; - if (path == null) { - path = "/"; - } - if (!path.startsWith("/")) { - path = "/" + path; - } - - final StandardContext context = new IgnoredStandardContext(); - context.setPath(path); - context.setDocBase(""); - context.setParentClassLoader(classLoader); - context.setDelegate(true); - context.setName(name); - TomcatWebAppBuilder.class.cast(SystemInstance.get().getComponent(WebAppBuilder.class)).initJ2EEInfo(context); - - // Configure security - String authMethod = rAuthMethod; - if (authMethod != null) { - authMethod = authMethod.toUpperCase(); - } - String transportGuarantee = rTransportGuarantee; - if (transportGuarantee != null) { - transportGuarantee = transportGuarantee.toUpperCase(); - } - if (authMethod != null && !"NONE".equals(authMethod)) { - if ("BASIC".equals(authMethod) || "DIGEST".equals(authMethod) || "CLIENT-CERT".equals(authMethod)) { - - //Setup a login configuration - final LoginConfig loginConfig = new LoginConfig(); - loginConfig.setAuthMethod(authMethod); - loginConfig.setRealmName(realmName); - context.setLoginConfig(loginConfig); - - //Setup a default Security Constraint - final String securityRole = SystemInstance.get().getProperty(TOMEE_HESSIAN_SECURITY_ROLE_PREFIX + name, "default"); - for (final String role : securityRole.split(",")) { - final SecurityCollection collection = new SecurityCollection(); - collection.addMethod("GET"); - collection.addMethod("POST"); - collection.addPattern("/*"); - collection.setName(role); - - final SecurityConstraint sc = new SecurityConstraint(); - sc.addAuthRole("*"); - sc.addCollection(collection); - sc.setAuthConstraint(true); - sc.setUserConstraint(transportGuarantee); - - context.addConstraint(sc); - context.addSecurityRole(role); - } - } else { - throw new IllegalArgumentException("Unsupported authMethod '" + rAuthMethod + "': supported values are BASIC, DIGEST and CLIENT-CERT"); - } - - //Set the proper authenticator - switch (authMethod) { - case "BASIC": - context.addValve(new BasicAuthenticator()); - break; - case "DIGEST": - context.addValve(new DigestAuthenticator()); - break; - case "CLIENT-CERT": - context.addValve(new SSLAuthenticator()); - break; - case "NONE": - context.addValve(new NonLoginAuthenticator()); - break; - } - - context.getPipeline().addValve(new OpenEJBValve()); - } else { - throw new IllegalArgumentException("Invalid authMethod: " + authMethod); - } - - return context; - } - - private static String generateServletPath(String name) { - return HESSIAN + name; - } - - private static String contextName(final String app) { - if (!app.startsWith("/") && !app.isEmpty()) { - return "/" + app; - } - return app; - } - - @Override - public void undeploy(final String hostname, final String app, final String name) { - Container host = engine.findChild(hostname); - if (host == null) { - host = engine.findChild(engine.getDefaultHost()); - if (host == null) { - throw new IllegalArgumentException("Invalid virtual host '" + engine.getDefaultHost() + "'. Do you have a matching Host entry in the server.xml?"); - } - } - - final String contextRoot = contextName(app); - final Pair<Context, Integer> fakeContext = fakeContexts.get(contextRoot); - - if (fakeContext != null) { - fakeContext.setValue(fakeContext.getValue() - 1); - if (fakeContext.getValue() == 0) { - fakeContexts.remove(contextRoot); - host.removeChild(fakeContext.getKey()); - } - } - } - - protected static class LimitedBasicValve extends BasicAuthenticator { - @Override - public void invoke(final Request request, final Response response) throws IOException, ServletException { - String requestURI = request.getDecodedRequestURI(); - final String contextPath = request.getContextPath(); - if (contextPath != null && !contextPath.isEmpty() && requestURI.startsWith(contextPath)) { - requestURI = requestURI.substring(contextPath.length()); - } - if (requestURI.startsWith(HESSIAN)) { - if (!authenticate(request, response)) { - return; - } - } - getNext().invoke(request, response); - } - } -} diff --git a/server/openejb-hessian/src/main/resources/META-INF/org.apache.openejb.server.ServerService/hessian b/server/openejb-hessian/src/main/resources/META-INF/org.apache.openejb.server.ServerService/hessian deleted file mode 100644 index d5d8e8c3e7..0000000000 --- a/server/openejb-hessian/src/main/resources/META-INF/org.apache.openejb.server.ServerService/hessian +++ /dev/null @@ -1,10 +0,0 @@ -server = org.apache.openejb.server.hessian.HessianService -disabled = ${openejb.profile.custom} - -# NONE, INTEGRAL or CONFIDENTIAL -transportGuarantee = NONE - -# NONE, BASIC -authMethod = NONE - -# realmName = diff --git a/server/openejb-hessian/src/main/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension b/server/openejb-hessian/src/main/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension deleted file mode 100644 index bc37b190a0..0000000000 --- a/server/openejb-hessian/src/main/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension +++ /dev/null @@ -1 +0,0 @@ -org.apache.openejb.cdi.internal.HessianExtension diff --git a/server/openejb-hessian/src/test/java/org/apache/openejb/server/hessian/HessianCdiByConfigTest.java b/server/openejb-hessian/src/test/java/org/apache/openejb/server/hessian/HessianCdiByConfigTest.java deleted file mode 100644 index 025897edb0..0000000000 --- a/server/openejb-hessian/src/test/java/org/apache/openejb/server/hessian/HessianCdiByConfigTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.server.hessian; - -import com.caucho.hessian.client.HessianProxyFactory; -import com.caucho.hessian.io.SerializerFactory; -import org.apache.openejb.jee.WebApp; -import org.apache.openejb.junit.ApplicationComposer; -import org.apache.openejb.testing.Classes; -import org.apache.openejb.testing.Configuration; -import org.apache.openejb.testing.EnableServices; -import org.apache.openejb.testing.Module; -import org.apache.openejb.testng.PropertiesBuilder; -import org.apache.openejb.util.NetworkUtil; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import jakarta.enterprise.context.ApplicationScoped; -import java.net.MalformedURLException; -import java.util.Properties; - -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; - -@EnableServices({"hessian", "httpejbd"}) -@RunWith(ApplicationComposer.class) -public class HessianCdiByConfigTest { - - private static int port = -1; - - @BeforeClass - public static void beforeClass() { - port = NetworkUtil.getNextAvailablePort(); - } - - @Module - @Classes(cdi = true, value = MyCdiHessianService.class) - public WebApp webApp() { - return new WebApp().contextRoot("web"); - } - - @Configuration - public Properties config() { - return new PropertiesBuilder().p("openejb.hessian." + MyCdiHessianService.class.getName() + "_" + CdiService.class.getName() + ".path", "foo") - .p("httpejbd.port", Integer.toString(port)).build(); - } - - @Test - public void client() throws MalformedURLException { - final ClassLoader loader = Thread.currentThread().getContextClassLoader(); - final HessianProxyFactory clientFactory = new HessianProxyFactory(loader); - final SerializerFactory factory = new SerializerFactory(loader); - factory.setAllowNonSerializable(true); - clientFactory.setSerializerFactory(factory); - final CdiService client = CdiService.class.cast(clientFactory.create(CdiService.class, "http://127.0.0.1:" + port + "/web/hessian/foo")); - - final Out out = client.call(new In("test")); - assertThat(out, instanceOf(Out.class)); - assertEquals("test", out.value); - } - - public static interface CdiService { - Out call(In in); - } - - @ApplicationScoped - public static class MyCdiHessianService implements CdiService { - @Override - public Out call(final In in) { - return new Out(in.value); - } - } - - public static class In { - private String value; - - public In(String value) { - this.value = value; - } - } - - public static class Out { - private String value; - - public Out(String value) { - this.value = value; - } - } -} diff --git a/server/openejb-hessian/src/test/java/org/apache/openejb/server/hessian/HessianCdiTest.java b/server/openejb-hessian/src/test/java/org/apache/openejb/server/hessian/HessianCdiTest.java deleted file mode 100644 index 5d67470f07..0000000000 --- a/server/openejb-hessian/src/test/java/org/apache/openejb/server/hessian/HessianCdiTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.server.hessian; - -import com.caucho.hessian.client.HessianProxyFactory; -import com.caucho.hessian.io.SerializerFactory; -import org.apache.openejb.cdi.api.Hessian; -import org.apache.openejb.jee.WebApp; -import org.apache.openejb.junit.ApplicationComposer; -import org.apache.openejb.testing.Classes; -import org.apache.openejb.testing.Configuration; -import org.apache.openejb.testing.EnableServices; -import org.apache.openejb.testing.Module; -import org.apache.openejb.testng.PropertiesBuilder; -import org.apache.openejb.util.NetworkUtil; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.inject.Inject; -import java.net.MalformedURLException; -import java.util.Properties; - -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; - -@EnableServices({"hessian", "httpejbd"}) -@RunWith(ApplicationComposer.class) -public class HessianCdiTest { - - private static int port = -1; - - @BeforeClass - public static void beforeClass() { - port = NetworkUtil.getNextAvailablePort(); - } - - @Configuration - public Properties props() { - return new PropertiesBuilder().p("httpejbd.port", Integer.toString(port)).build(); - } - - @Module - @Classes(cdi = true, value = {MyCdiHessianService.class, CdiBean.class}) - public WebApp webApp() { - return new WebApp().contextRoot("web"); - } - - @Test - public void client() throws MalformedURLException { - final ClassLoader loader = Thread.currentThread().getContextClassLoader(); - final HessianProxyFactory clientFactory = new HessianProxyFactory(loader); - final SerializerFactory factory = new SerializerFactory(loader); - factory.setAllowNonSerializable(true); - clientFactory.setSerializerFactory(factory); - final CdiService client = CdiService.class.cast(clientFactory.create(CdiService.class, "http://127.0.0.1:" + port + "/web/hessian/service")); - - final Out out = client.call(new In("test")); - assertThat(out, instanceOf(Out.class)); - assertEquals("test", out.value); - } - - @Hessian(path = "service") - public static interface CdiService { - Out call(In in); - } - - @ApplicationScoped - public static class MyCdiHessianService implements CdiService { - @Inject - private CdiBean bean; - - @Override - public Out call(final In in) { - assertNotNull(bean); - return new Out(in.value); - } - } - - public static class In { - private String value; - - public In(String value) { - this.value = value; - } - } - - public static class Out { - private String value; - - public Out(String value) { - this.value = value; - } - } - - public static class CdiBean { - - } -} diff --git a/server/openejb-hessian/src/test/java/org/apache/openejb/server/hessian/HessianInitialContextTest.java b/server/openejb-hessian/src/test/java/org/apache/openejb/server/hessian/HessianInitialContextTest.java deleted file mode 100644 index d7d217eaf6..0000000000 --- a/server/openejb-hessian/src/test/java/org/apache/openejb/server/hessian/HessianInitialContextTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.server.hessian; - -import org.apache.openejb.client.hessian.HessianInitialContextFactory; -import org.apache.openejb.junit.ApplicationComposer; -import org.apache.openejb.testing.Configuration; -import org.apache.openejb.testing.EnableServices; -import org.apache.openejb.testing.Module; -import org.apache.openejb.testng.PropertiesBuilder; -import org.apache.openejb.util.NetworkUtil; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import jakarta.ejb.Remote; -import jakarta.ejb.Singleton; -import javax.naming.Context; -import javax.naming.InitialContext; -import java.util.Properties; - -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; - -@EnableServices({"hessian", "httpejbd"}) -@RunWith(ApplicationComposer.class) -public class HessianInitialContextTest { - - private static int port = -1; - - @BeforeClass - public static void beforeClass() { - port = NetworkUtil.getNextAvailablePort(); - } - - @Configuration - public Properties props() { - return new PropertiesBuilder().p("httpejbd.port", Integer.toString(port)).build(); - } - - @Module - public Class<?>[] classes() { - return new Class<?>[]{Server.class}; - } - - @Test - public void client() throws Exception { - final MyApi client = MyApi.class.cast( - new InitialContext(new PropertiesBuilder() - .p(Context.INITIAL_CONTEXT_FACTORY, HessianInitialContextFactory.class.getName()) - .p(Context.PROVIDER_URL, "http://127.0.0.1:" + port + "/HessianInitialContextTest/hessian/") - .build()) - .lookup("Server")); - - final Out out = client.call(new In("test")); - assertThat(out, instanceOf(Out.class)); - assertEquals("test", out.value); - } - - @Remote - public static interface MyApi { - Out call(In in); - } - - @Singleton - public static class Server implements MyApi { - @Override - public Out call(final In in) { - return new Out(in.value); - } - } - - public static class In { - private String value; - - public In(final String value) { - this.value = value; - } - } - - public static class Out { - private String value; - - public Out(final String value) { - this.value = value; - } - } -} diff --git a/server/openejb-hessian/src/test/java/org/apache/openejb/server/hessian/HessianRegistryImplTest.java b/server/openejb-hessian/src/test/java/org/apache/openejb/server/hessian/HessianRegistryImplTest.java deleted file mode 100644 index 232673bdec..0000000000 --- a/server/openejb-hessian/src/test/java/org/apache/openejb/server/hessian/HessianRegistryImplTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.server.hessian; - -import org.junit.Test; - -public class HessianRegistryImplTest { - @Test(expected = IllegalArgumentException.class) - public void rejectsAuthMethod() { - new HessianRegistryImpl().deploy(Thread.currentThread().getContextClassLoader(), null, - "localhost", "myapp", "BASIC", "NONE", null, "MyBean"); - } - - @Test(expected = IllegalArgumentException.class) - public void rejectsTransportGuarantee() { - new HessianRegistryImpl().deploy(Thread.currentThread().getContextClassLoader(), null, - "localhost", "myapp", "NONE", "CONFIDENTIAL", null, "MyBean"); - } -} diff --git a/server/openejb-hessian/src/test/java/org/apache/openejb/server/hessian/HessianServiceTest.java b/server/openejb-hessian/src/test/java/org/apache/openejb/server/hessian/HessianServiceTest.java deleted file mode 100644 index c709a7ffa1..0000000000 --- a/server/openejb-hessian/src/test/java/org/apache/openejb/server/hessian/HessianServiceTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.server.hessian; - -import com.caucho.hessian.client.HessianProxyFactory; -import com.caucho.hessian.io.SerializerFactory; -import org.apache.openejb.junit.ApplicationComposer; -import org.apache.openejb.testing.Configuration; -import org.apache.openejb.testing.EnableServices; -import org.apache.openejb.testing.Module; -import org.apache.openejb.testng.PropertiesBuilder; -import org.apache.openejb.util.NetworkUtil; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import jakarta.ejb.Remote; -import jakarta.ejb.Singleton; -import java.net.MalformedURLException; -import java.util.Properties; - -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; - -@EnableServices({"hessian", "httpejbd"}) -@RunWith(ApplicationComposer.class) -public class HessianServiceTest { - - private static int port = -1; - - @BeforeClass - public static void beforeClass() { - port = NetworkUtil.getNextAvailablePort(); - } - - @Configuration - public Properties props() { - return new PropertiesBuilder().p("httpejbd.port", Integer.toString(port)).build(); - } - - @Module - public Class<?>[] classes() { - return new Class<?>[]{MyHessianWebService.class}; - } - - @Test - public void client() throws MalformedURLException { - final ClassLoader loader = Thread.currentThread().getContextClassLoader(); - final HessianProxyFactory clientFactory = new HessianProxyFactory(loader); - final SerializerFactory factory = new SerializerFactory(loader); - factory.setAllowNonSerializable(true); - clientFactory.setSerializerFactory(factory); - final HessianWebService client = HessianWebService.class.cast(clientFactory.create(HessianWebService.class, "http://127.0.0.1:" + port + "/HessianServiceTest/hessian/" + MyHessianWebService.class.getSimpleName())); - - final Out out = client.call(new In("test")); - assertThat(out, instanceOf(Out.class)); - assertEquals("test", out.value); - } - - @Remote - public static interface HessianWebService { - Out call(In in); - } - - @Singleton - public static class MyHessianWebService implements HessianWebService { - @Override - public Out call(final In in) { - return new Out(in.value); - } - } - - public static class In { - private String value; - - public In(String value) { - this.value = value; - } - } - - public static class Out { - private String value; - - public Out(String value) { - this.value = value; - } - } -} diff --git a/server/openejb-hessian/src/test/java/org/apache/openejb/server/hessian/LimitedBasicValveTest.java b/server/openejb-hessian/src/test/java/org/apache/openejb/server/hessian/LimitedBasicValveTest.java deleted file mode 100644 index 34a7fd5423..0000000000 --- a/server/openejb-hessian/src/test/java/org/apache/openejb/server/hessian/LimitedBasicValveTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.server.hessian; - -import org.apache.catalina.connector.Connector; -import org.apache.catalina.connector.Request; -import org.apache.catalina.connector.Response; -import org.apache.catalina.core.StandardContext; -import org.apache.catalina.core.StandardEngine; -import org.apache.catalina.core.StandardHost; -import org.apache.catalina.core.StandardService; -import org.apache.catalina.valves.ValveBase; -import org.junit.Test; - -import java.io.IOException; -import java.util.concurrent.atomic.AtomicBoolean; - -import jakarta.servlet.ServletException; -import jakarta.servlet.http.HttpServletResponse; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class LimitedBasicValveTest { - @Test - public void rootContext() throws Exception { - assertTrue(authenticates("", "/hessian/MyBean")); - assertFalse(authenticates("", "/other")); - } - - @Test - public void nonRootContext() throws Exception { - assertTrue(authenticates("/myapp", "/myapp/hessian/MyBean")); - assertFalse(authenticates("/myapp", "/myapp/other")); - } - - private static boolean authenticates(final String contextPath, final String uri) throws IOException, ServletException { - final AtomicBoolean authenticated = new AtomicBoolean(); - final AtomicBoolean invokedNext = new AtomicBoolean(); - - final TomcatHessianRegistry.LimitedBasicValve valve = new TomcatHessianRegistry.LimitedBasicValve() { - @Override - public boolean authenticate(final Request request, final HttpServletResponse response) { - authenticated.set(true); - return true; - } - }; - valve.setNext(new ValveBase() { - @Override - public void invoke(final Request request, final Response response) { - invokedNext.set(true); - } - }); - - final StandardEngine engine = new StandardEngine(); - engine.setService(new StandardService()); - final StandardHost host = new StandardHost(); - host.setParent(engine); - final StandardContext context = new StandardContext(); - context.setParent(host); - context.setPath(contextPath); - - final Connector connector = new Connector(); - final Request request = new Request(connector); - request.setCoyoteRequest(new org.apache.coyote.Request()); - request.getCoyoteRequest().requestURI().setString(uri); - request.getCoyoteRequest().decodedURI().setString(uri); - request.getMappingData().context = context; - request.getMappingData().contextSlashCount = contextPath.isEmpty() ? 0 : 1; - - final Response response = new Response(); - response.setCoyoteResponse(new org.apache.coyote.Response()); - - valve.invoke(request, response); - - assertTrue(invokedNext.get()); - return authenticated.get(); - } -} diff --git a/server/pom.xml b/server/pom.xml index 74e126029e..71301530e5 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -48,7 +48,6 @@ <module>openejb-ssh</module> <module>openejb-common-cli</module> <module>openejb-bonecp</module> - <module>openejb-hessian</module> </modules> <dependencies>
