openejb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r452600 [3/3] - in /incubator/openejb/trunk/openejb2: ./ modules/ modules/openejb-builder/src/test/java/org/apache/openejb/corba/security/config/tss/ modules/openejb-core/src/main/java/org/apache/openejb/corba/ modules/openejb-core/src/main...
Date Tue, 03 Oct 2006 19:29:45 GMT
Added: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapter.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapter.java?view=auto&rev=452600
==============================================================================
--- incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapter.java (added)
+++ incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapter.java Tue Oct  3 12:29:42 2006
@@ -0,0 +1,355 @@
+/**
+  * 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.yoko;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Properties;
+import java.net.InetSocketAddress;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.omg.CORBA.ORB;
+import org.omg.CSIIOP.EstablishTrustInClient;
+import org.omg.Security.Confidentiality;
+import org.omg.Security.EstablishTrustInTarget;
+import org.omg.Security.NoProtection;
+
+import org.apache.geronimo.gbean.GBeanLifecycle;
+
+import org.apache.geronimo.security.deploy.DefaultDomainPrincipal;
+import org.apache.geronimo.security.deploy.DefaultPrincipal;
+import org.apache.geronimo.security.deploy.DefaultRealmPrincipal;
+
+import org.apache.openejb.corba.CORBABean;
+import org.apache.openejb.corba.CSSBean;
+import org.apache.openejb.corba.NameService;
+import org.apache.openejb.corba.ORBConfiguration;
+import org.apache.openejb.corba.security.config.ConfigAdapter;
+import org.apache.openejb.corba.security.config.ConfigException;
+import org.apache.openejb.corba.security.config.css.CSSCompoundSecMechConfig;
+import org.apache.openejb.corba.security.config.css.CSSCompoundSecMechListConfig;
+import org.apache.openejb.corba.security.config.css.CSSConfig;
+import org.apache.openejb.corba.security.config.tss.TSSConfig;
+import org.apache.openejb.corba.security.config.ssl.SSLConfig;
+import org.apache.openejb.corba.security.config.tss.TSSSSLTransportConfig;
+import org.apache.openejb.corba.security.config.tss.TSSTransportMechConfig;
+
+import org.apache.yoko.orb.CosNaming.tnaming.TransientNameService;
+import org.apache.yoko.orb.CosNaming.tnaming.TransientServiceException;
+
+
+/**
+ * A ConfigAdapter instance for the Apache Yoko
+ * CORBA support.
+ * @version $Revision$ $Date$
+ */
+public class ORBConfigAdapter implements GBeanLifecycle, ConfigAdapter {
+
+    private final Log log = LogFactory.getLog(ORBConfigAdapter.class);
+
+    // static registry used to hook up bean instances with
+    private static final HashMap registry = new HashMap();
+
+    public ORBConfigAdapter() {
+    }
+
+    /**
+     * Start the config adapter GBean.  This is basically
+     * an opportunity to set any system properties
+     * required to make the ORB hook ups.  In particular,
+     * this makes the ORB hookups for the RMI over IIOP
+     * support.
+     *
+     * @exception Exception
+     */
+    public void doStart() throws Exception {
+        // define the default ORB for ORB.init();
+        System.setProperty("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+        System.setProperty("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
+
+        // redirect the RMI implementation to use the Yoko ORB.
+        System.setProperty("javax.rmi.CORBA.PortableRemoteObjectClass", "org.apache.yoko.rmi.impl.PortableRemoteObjectImpl");
+        System.setProperty("javax.rmi.CORBA.StubClass", "org.apache.yoko.rmi.impl.StubImpl");
+        // this hooks the util class and allows us to override certain functions
+        System.setProperty("javax.rmi.CORBA.UtilClass", "org.apache.openejb.corba.util.UtilDelegateImpl");
+        // this tells the openejb UtilDelegateImpl which implementation to delegate non-overridden
+        // operations to.
+        System.setProperty("org.apache.openejb.corba.UtilDelegateClass", "org.apache.yoko.rmi.impl.UtilImpl");
+        log.debug("Started  Yoko ORBConfigAdapter");
+    }
+
+    public void doStop() throws Exception {
+        // nothing really required here.
+        log.debug("Stopped Yoko ORBConfigAdapter");
+    }
+
+    public void doFail() {
+        // nothing much to do.
+        log.warn("Failed Yoko ORBConfigAdapter");
+    }
+
+    /**
+     * Create an ORB for a CORBABean server context.
+     *
+     * @param server The CORBABean that owns this ORB's configuration.
+     *
+     * @return An ORB instance configured for the CORBABean.
+     * @exception ConfigException
+     */
+    public ORB createServerORB(CORBABean server)  throws ConfigException {
+        return createORB(server.getURI(), (ORBConfiguration)server, translateToArgs(server), translateToProps(server));
+    }
+
+    /**
+     * Create an ORB for a CSSBean client context.
+     *
+     * @param client The configured CSSBean used for access.
+     *
+     * @return An ORB instance configured for this client access.
+     * @exception ConfigException
+     */
+    public ORB createClientORB(CSSBean client)  throws ConfigException {
+        return createORB(client.getURI(), (ORBConfiguration)client, translateToArgs(client), translateToProps(client));
+    }
+
+    /**
+     * Create a transient name service instance using the
+     * specified host name and port.
+     *
+     * @param host   The String host name.
+     * @param port   The port number of the listener.
+     *
+     * @return An opaque object that represents the name service.
+     * @exception ConfigException
+     */
+    public Object createNameService(String host, int port) throws ConfigException {
+        try {
+            // create a name service using the supplied host and publish under the name "NameService"
+            TransientNameService service = new TransientNameService(host, port, "NameService");
+            service.run();
+            // the service instance is returned as an opaque object.
+            return service;
+        } catch (TransientServiceException e) {
+            throw new ConfigException("Error starting transient name service", e);
+        }
+    }
+
+    /**
+     * Destroy a name service instance created by a
+     * prior call to createNameService().
+     *
+     * @param ns     The opaque name service object returned from a
+     *               prior call to createNameService().
+     */
+    public void destroyNameService(Object ns) {
+        // The name service instance handles its own shutdown.
+        ((TransientNameService)ns).destroy();
+    }
+
+    /**
+     * Static method used by SocketFactory instances to
+     * retrieve the CORBABean or CSSBean that holds its
+     * configuration information.  The String name has
+     * been passed to the SocketFactory as part of its
+     * initialization parameters.
+     *
+     * @param name   The name of the bean holding the configuration
+     *               information.
+     *
+     * @return The bean mapping for this SocketFactory instance.
+     */
+    public static ORBConfiguration getConfiguration(String name) {
+        return (ORBConfiguration)registry.get(name);
+    }
+
+    /**
+     * Create an ORB instance using the configured argument
+     * and property bundles.
+     *
+     * @param name   The String name of the configuration GBean used to
+     *               create this ORB.
+     * @param config The GBean configuration object required by the
+     *               SocketFactory instance.
+     * @param args   The String arguments passed to ORB.init().
+     * @param props  The property bundle passed to ORB.init().
+     *
+     * @return An ORB constructed from the provided args and properties.
+     */
+    private ORB createORB(String name, ORBConfiguration config, String[] args, Properties props) {
+        try {
+            // we need to stuff this reference in the registry so that the SocketFactory can find it
+            // when it initializes.
+            registry.put(name, config);
+            return ORB.init(args, props);
+
+        } finally {
+            // remove the configuration object from the registry now that the ORB has initialized.  We
+            // don't want to create a memory leak on the GBean.
+            registry.remove(name);
+        }
+    }
+
+    /**
+     * Translate a CORBABean configuration into an
+     * array of arguments used to configure the ORB
+     * instance.
+     *
+     * @param server The CORBABean we're creating an ORB instance for.
+     *
+     * @return A String{} array containing the initialization
+     *         arguments.
+     * @exception ConfigException
+     */
+    private String[] translateToArgs(CORBABean server) throws ConfigException {
+        ArrayList list = new ArrayList();
+
+        TSSConfig config = server.getTssConfig();
+
+        // if the TSSConfig includes principal information, we need to add argument values
+        // for this information.
+        DefaultPrincipal principal = config.getDefaultPrincipal();
+        if (principal != null) {
+            if (principal instanceof DefaultRealmPrincipal) {
+                DefaultRealmPrincipal realmPrincipal = (DefaultRealmPrincipal) principal;
+                list.add("default-realm-principal::" + realmPrincipal.getRealm() + ":" + realmPrincipal.getDomain() + ":"
+                         + realmPrincipal.getPrincipal().getClassName() + ":" + realmPrincipal.getPrincipal().getPrincipalName());
+            } else if (principal instanceof DefaultDomainPrincipal) {
+                DefaultDomainPrincipal domainPrincipal = (DefaultDomainPrincipal) principal;
+                list.add("default-domain-principal::" + domainPrincipal.getDomain() + ":"
+                         + domainPrincipal.getPrincipal().getClassName() + ":" + domainPrincipal.getPrincipal().getPrincipalName());
+            } else {
+                list.add("default-principal::" + principal.getPrincipal().getClassName() + ":" + principal.getPrincipal().getPrincipalName());
+            }
+        }
+
+        // enable the connection plugin
+        enableSocketFactory(server.getURI(), list);
+
+        NameService nameService = server.getNameService();
+        // if we have a name service to enable as an initial ref, add it to the init processing.
+        if (nameService != null) {
+            list.add("-ORBInitRef");
+            list.add("NameService=" + nameService.getURI());
+        }
+
+        if (log.isDebugEnabled()) {
+            for (Iterator iter = list.iterator(); iter.hasNext();) {
+                log.debug(iter.next());
+            }
+        }
+
+        return (String[]) list.toArray(new String[list.size()]);
+    }
+
+    private Properties translateToProps(CORBABean server) throws ConfigException {
+        Properties result = new Properties();
+
+        result.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+        result.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
+        result.put("org.omg.PortableInterceptor.ORBInitializerClass.org.apache.openejb.corba.transaction.TransactionInitializer", "");
+        result.put("org.omg.PortableInterceptor.ORBInitializerClass.org.apache.openejb.corba.security.SecurityInitializer", "");
+        result.put("org.omg.PortableInterceptor.ORBInitializerClass.org.apache.openejb.yoko.ORBInitializer", "");
+
+        result.put("yoko.orb.oa.endpoint", "iiop --host " + server.getHost() + " --port " + server.getPort());
+
+        if (log.isDebugEnabled()) {
+            log.debug("translateToProps(TSSConfig)");
+            for (Enumeration iter = result.keys(); iter.hasMoreElements();) {
+                String key = (String) iter.nextElement();
+                log.debug(key + " = " + result.getProperty(key));
+            }
+        }
+        return result;
+    }
+
+    /**
+     * Translate a CSSBean configuration into the
+     * argument bundle needed to instantiate the
+     * ORB instance.
+     *
+     * @param client The CSSBean holding the configuration.
+     *
+     * @return A String array to be passed to ORB.init().
+     * @exception ConfigException
+     */
+    private String[] translateToArgs(CSSBean client) throws ConfigException {
+        ArrayList list = new ArrayList();
+
+        // enable the connection plugin
+        enableSocketFactory(client.getURI(), list);
+
+        if (log.isDebugEnabled()) {
+            for (Iterator iter = list.iterator(); iter.hasNext();) {
+                log.debug(iter.next());
+            }
+        }
+
+        return (String[]) list.toArray(new String[list.size()]);
+    }
+
+    /**
+     * Add arguments to the ORB.init() argument list
+     * required to enable the SocketFactory used for
+     * SSL support.
+     *
+     * @param uri    The URI name of the configuration GBean (either a
+     *               CSSBean or a CORBABean).
+     * @param args
+     */
+    private void enableSocketFactory(String uri, List args) {
+        args.add("-IIOPconnectionHelper");
+        args.add("org.apache.openejb.yoko.SocketFactory");
+        args.add("-IIOPconnectionHelperArgs");
+        args.add(uri);
+    }
+
+
+    /**
+     * Translate a CSSBean configuration into the
+     * property bundle necessary to configure the
+     * ORB instance.
+     *
+     * @param client The CSSBean holding the configuration.
+     *
+     * @return A property bundle that can be passed to ORB.init();
+     * @exception ConfigException
+     */
+    private Properties translateToProps(CSSBean client) throws ConfigException {
+        Properties result = new Properties();
+
+        result.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+        result.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
+        result.put("org.omg.PortableInterceptor.ORBInitializerClass.org.apache.openejb.corba.transaction.TransactionInitializer", "");
+        result.put("org.omg.PortableInterceptor.ORBInitializerClass.org.apache.openejb.corba.security.SecurityInitializer", "");
+        result.put("org.omg.PortableInterceptor.ORBInitializerClass.org.apache.openejb.yoko.ORBInitializer", "");
+
+        if (log.isDebugEnabled()) {
+            log.debug("translateToProps(CSSConfig)");
+            for (Enumeration iter = result.keys(); iter.hasMoreElements();) {
+                String key = (String) iter.nextElement();
+                log.debug(key + " = " + result.getProperty(key));
+            }
+        }
+        return result;
+    }
+}

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapter.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapterGBean.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapterGBean.java?view=auto&rev=452600
==============================================================================
--- incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapterGBean.java (added)
+++ incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapterGBean.java Tue Oct  3 12:29:42 2006
@@ -0,0 +1,45 @@
+/**
+  * 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.yoko;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public final class ORBConfigAdapterGBean extends org.apache.openejb.corba.security.config.ConfigAdapterGBean {
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    public ORBConfigAdapterGBean() {
+    }
+
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(ORBConfigAdapterGBean.class, "ORB Configuration Adapater", ORBConfigAdapter.class, NameFactory.ORB_CONFIG);
+        infoFactory.setConstructor(new String[]{});
+        infoFactory.addInterface(org.apache.openejb.corba.security.config.ConfigAdapter.class);
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}
+

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapterGBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapterGBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapterGBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBInitializer.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBInitializer.java?view=auto&rev=452600
==============================================================================
--- incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBInitializer.java (added)
+++ incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBInitializer.java Tue Oct  3 12:29:42 2006
@@ -0,0 +1,82 @@
+/**
+  * 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.yoko;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.omg.CORBA.LocalObject;
+import org.omg.PortableInterceptor.ORBInitInfo;
+import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class ORBInitializer extends LocalObject implements org.omg.PortableInterceptor.ORBInitializer {
+
+    private final Log log = LogFactory.getLog(ORBInitializer.class);
+
+    public ORBInitializer() {
+        if (log.isDebugEnabled()) log.debug("ORBInitializer.<init>");
+    }
+
+    /**
+     * Called during ORB initialization.  If it is expected that initial
+     * services registered by an interceptor will be used by other
+     * interceptors, then those initial services shall be registered at
+     * this point via calls to
+     * <code>ORBInitInfo.register_initial_reference</code>.
+     *
+     * @param info provides initialization attributes and operations by
+     *             which Interceptors can be registered.
+     */
+    public void pre_init(ORBInitInfo info) {
+    }
+
+    /**
+     * Called during ORB initialization. If a service must resolve initial
+     * references as part of its initialization, it can assume that all
+     * initial references will be available at this point.
+     * <p/>
+     * Calling the <code>post_init</code> operations is not the final
+     * task of ORB initialization. The final task, following the
+     * <code>post_init</code> calls, is attaching the lists of registered
+     * interceptors to the ORB. Therefore, the ORB does not contain the
+     * interceptors during calls to <code>post_init</code>. If an
+     * ORB-mediated call is made from within <code>post_init</code>, no
+     * request interceptors will be invoked on that call.
+     * Likewise, if an operation is performed which causes an IOR to be
+     * created, no IOR interceptors will be invoked.
+     *
+     * @param info provides initialization attributes and
+     *             operations by which Interceptors can be registered.
+     */
+    public void post_init(ORBInitInfo info) {
+
+        try {
+            if (log.isDebugEnabled()) log.debug("Registering IOR interceptor");
+
+            try {
+                info.add_server_request_interceptor(new ServiceContextInterceptor());
+            } catch (DuplicateName dn) {
+                log.error("Error registering interceptor", dn);
+            }
+        } catch (RuntimeException re) {
+            log.error("Error registering interceptor", re);
+            throw re;
+        }
+    }
+}

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBInitializer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBInitializer.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBInitializer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ServiceContextInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ServiceContextInterceptor.java?view=auto&rev=452600
==============================================================================
--- incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ServiceContextInterceptor.java (added)
+++ incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ServiceContextInterceptor.java Tue Oct  3 12:29:42 2006
@@ -0,0 +1,95 @@
+/**
+  * 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.yoko;
+
+import java.net.Socket;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSocket;
+
+import org.apache.yoko.orb.PortableInterceptor.ServerRequestInfoExt;
+import org.apache.yoko.orb.OCI.TransportInfo;
+import org.apache.yoko.orb.OCI.IIOP.TransportInfo_impl;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.omg.CORBA.LocalObject;
+import org.omg.PortableInterceptor.ServerRequestInfo;
+import org.omg.PortableInterceptor.ServerRequestInterceptor;
+
+import org.apache.openejb.corba.security.SSLSessionManager;
+
+/**
+ * A service context interceptor to help manage
+ * SSL security information for incoming connections.
+ * @version $Revision$ $Date$
+ */
+final class ServiceContextInterceptor extends LocalObject implements ServerRequestInterceptor {
+
+    private final Log log = LogFactory.getLog(ServiceContextInterceptor.class);
+
+    public ServiceContextInterceptor() {
+        if (log.isDebugEnabled()) log.debug("<init>");
+    }
+
+    public void receive_request(ServerRequestInfo ri) {
+    }
+
+    public void receive_request_service_contexts(ServerRequestInfo ri) {
+
+        if (log.isDebugEnabled()) log.debug("Looking for SSL Session");
+
+        // for an incoming request, we need to see if the request is coming in on
+        // an SSLSocket.  If this is using a secure connection, then we register the
+        // request and SSLSession with the session manager.
+        ServerRequestInfoExt riExt = (ServerRequestInfoExt) ri;
+        TransportInfo_impl connection = (TransportInfo_impl)riExt.getTransportInfo();
+        if (connection != null) {
+            Socket socket = connection.socket();
+            if (socket != null && socket instanceof SSLSocket) {
+                if (log.isDebugEnabled()) log.debug("Found SSL Session");
+                SSLSocket sslSocket = (SSLSocket) socket;
+
+                SSLSessionManager.setSSLSession(ri.request_id(), sslSocket.getSession());
+            }
+        }
+    }
+
+    public void send_exception(ServerRequestInfo ri) {
+        // clean any SSL session information if we registered.
+        SSLSession old = SSLSessionManager.clearSSLSession(ri.request_id());
+        if (log.isDebugEnabled() && old != null) log.debug("Removing SSL Session for send_exception");
+    }
+
+    public void send_other(ServerRequestInfo ri) {
+        // clean any SSL session information if we registered.
+        SSLSession old = SSLSessionManager.clearSSLSession(ri.request_id());
+        if (log.isDebugEnabled() && old != null) log.debug("Removing SSL Session for send_reply");
+    }
+
+    public void send_reply(ServerRequestInfo ri) {
+        // clean any SSL session information if we registered.
+        SSLSession old = SSLSessionManager.clearSSLSession(ri.request_id());
+        if (log.isDebugEnabled() && old != null) log.debug("Removing SSL Session for send_reply");
+    }
+
+    public void destroy() {
+        if (log.isDebugEnabled()) log.debug("Destroy");
+    }
+
+    public String name() {
+        return "org.apache.openejb.yoko.ServiceContextInterceptor";
+    }
+}

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ServiceContextInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ServiceContextInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ServiceContextInterceptor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/SocketFactory.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/SocketFactory.java?view=auto&rev=452600
==============================================================================
--- incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/SocketFactory.java (added)
+++ incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/SocketFactory.java Tue Oct  3 12:29:42 2006
@@ -0,0 +1,440 @@
+/**
+  * 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.yoko;
+
+import java.io.IOException;
+import java.net.ConnectException;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.URI;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import javax.net.ssl.SSLServerSocket;
+import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.omg.CORBA.COMM_FAILURE;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.ORB;
+import org.omg.CSIIOP.Confidentiality;
+import org.omg.CSIIOP.EstablishTrustInClient;
+import org.omg.CSIIOP.EstablishTrustInTarget;
+import org.omg.CSIIOP.NoProtection;
+import org.omg.CSIIOP.TAG_CSI_SEC_MECH_LIST;
+import org.omg.IOP.TaggedComponent;
+import org.omg.CORBA.DynAnyPackage.Invalid;
+import org.omg.CORBA.Policy;
+import org.omg.IOP.IOR;
+
+import org.apache.openejb.corba.ORBConfiguration;
+import org.apache.openejb.corba.security.config.ConfigUtil;
+import org.apache.openejb.corba.security.config.tss.TSSCompoundSecMechListConfig;
+import org.apache.openejb.corba.security.config.tss.TSSSSLTransportConfig;
+import org.apache.openejb.corba.security.config.tss.TSSTransportMechConfig;
+import org.apache.openejb.corba.security.config.css.CSSConfig;
+import org.apache.openejb.corba.security.config.tss.TSSConfig;
+import org.apache.openejb.corba.security.config.ssl.SSLConfig;
+import org.apache.openejb.corba.security.config.ssl.SSLCipherSuiteDatabase;
+import org.apache.openejb.corba.util.Util;
+
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.KernelRegistry;
+
+import org.apache.yoko.orb.OCI.IIOP.ConnectionHelper;
+import org.apache.yoko.orb.OCI.ProfileInfo;
+import org.apache.yoko.orb.OCI.ProfileInfoHolder;
+
+
+/**
+ * Socket factory instance used to interface openejb2
+ * with the Yoko ORB.  Also enables the ORB for
+ * SSL-type connections.
+ * @version $Revision$ $Date$
+ */
+public class SocketFactory implements ConnectionHelper {
+
+    private final static Log log = LogFactory.getLog(SocketFactory.class);
+
+    // The initialized SSLSocketFactory obtained from the Geronimo KeystoreManager.
+    private SSLSocketFactory socketFactory = null;
+    // The initialized SSLServerSocketFactory obtained from the Geronimo KeystoreManager.
+    private SSLServerSocketFactory serverSocketFactory = null;
+    // the ORB consumer that defines our configuration
+    private ORBConfiguration config;
+    // The initialized SSLConfig we use to retrieve the SSL socket factories.
+    private SSLConfig sslConfig = null;
+    // The set of cypher suites we use with the SSL connection.
+    private String[] cipherSuites;
+    // indicates whether client authentication is supported by this transport.
+    private boolean clientAuthSupported;
+    // indicates whether client authentication is required by this transport.
+    private boolean clientAuthRequired;
+    // supports and requires values used to retrieve the cipher suites.
+    int supports = NoProtection.value;
+    int requires = NoProtection.value;
+    // the orb we're attached to
+    private ORB orb;
+
+    public SocketFactory() {
+    }
+
+    /**
+     * Initialize the socket factory instance.
+     *
+     * @param orb        The hosting ORB.
+     * @param configName The initialization parameter passed to the socket factor.
+     *                   This contains the abstract name of our configurator,
+     *                   which we retrieve from a registry.
+     */
+    public void init(ORB orb, String configName) {
+        this.orb = orb;
+        clientAuthSupported = false;
+        clientAuthRequired = false;
+        // retrieve the configuration from the config adapter registry.
+        config = (ORBConfiguration)ORBConfigAdapter.getConfiguration(configName);
+        if (config == null) {
+            throw new RuntimeException("Unable to resolve ORB configuration " + configName);
+        }
+        // get the configuration from the hosting bean and decode what needs to be implemented.
+        sslConfig = config.getSslConfig();
+        TSSConfig tssConfig = config.getTssConfig();
+        TSSTransportMechConfig transportMech = tssConfig.getTransport_mech();
+        // if we have a transport mech defined, this is the configuration for any listeners we end up
+        // creating.
+        if (transportMech != null) {
+            if (transportMech instanceof TSSSSLTransportConfig) {
+                TSSSSLTransportConfig transportConfig = (TSSSSLTransportConfig) transportMech;
+                supports = transportConfig.getSupports();
+                requires = transportConfig.getRequires();
+            }
+        }
+
+        // now set our listener creation flags based on the supports and requires values from the
+        // TSS config.
+        if ((supports & EstablishTrustInClient.value) != 0) {
+            clientAuthSupported = true;
+
+            if ((requires & EstablishTrustInClient.value) != 0) {
+                clientAuthRequired = true;
+            }
+        }
+
+        if ((supports & EstablishTrustInTarget.value) != 0) {
+            clientAuthSupported = true;
+
+            if ((requires & EstablishTrustInTarget.value) != 0) {
+                clientAuthRequired = true;
+            }
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("Creating Yoko SocketFactor for GBean " + configName);
+            log.debug("   SUPPORTS: " + ConfigUtil.flags(supports));
+            log.debug("   REQUIRES: " + ConfigUtil.flags(requires));
+        }
+    }
+
+    /**
+     * Create a client socket of the appropriate
+     * type using the provided IOR and Policy information.
+     *
+     * @param ior      The target IOR of the connection.
+     * @param policies Policies in effect for this ORB.
+     * @param address  The target address of the connection.
+     * @param port     The connection port.
+     *
+     * @return A Socket (either plain or SSL) configured for connection
+     *         to the target.
+     * @exception IOException
+     * @exception ConnectException
+     */
+    public Socket createSocket(IOR ior, Policy[] policies, InetAddress address, int port) throws IOException, ConnectException {
+        ProfileInfoHolder holder = new ProfileInfoHolder();
+        // we need to extract the profile information from the IOR to see if this connection has
+        // any transport-level security defined.
+        if (org.apache.yoko.orb.OCI.IIOP.Util.extractProfileInfo(ior, holder)) {
+            ProfileInfo profileInfo = holder.value;
+            for (int i = 0; i < profileInfo.components.length; i++) {
+                // we're lookoing for the security mechanism items.
+                if (profileInfo.components[i].tag == TAG_CSI_SEC_MECH_LIST.value) {
+                    try {
+                        // decode and pull the transport information.
+                        TSSCompoundSecMechListConfig config = TSSCompoundSecMechListConfig.decodeIOR(Util.getCodec(), profileInfo.components[i]);
+                        for (int j = 0; j < config.size(); j++) {
+                            TSSTransportMechConfig transport_mech = config.mechAt(j).getTransport_mech();
+                            if (transport_mech instanceof TSSSSLTransportConfig) {
+                                TSSSSLTransportConfig transportConfig = (TSSSSLTransportConfig) transport_mech;
+
+                                int supports = transportConfig.getSupports();
+                                int requires = transportConfig.getRequires();
+
+                                if (log.isDebugEnabled()) {
+
+                                    log.debug("IOR from target " + address.getHostName() + ":" + port);
+                                    log.debug("   SUPPORTS: " + ConfigUtil.flags(supports));
+                                    log.debug("   REQUIRES: " + ConfigUtil.flags(requires));
+                                }
+
+                                // if we don't require any TLS, then just create a plain socket.
+                                if ((NoProtection.value & requires) == NoProtection.value) {
+                                    break;
+                                }
+                                // we need SSL, so create an SSLSocket for this connection.
+                                return createSSLSocket(address.getHostName(), port, supports, requires);
+                            }
+                        }
+                    } catch (Exception e) {
+                        // do nothing
+                    }
+                }
+            }
+        }
+
+        // if security is not required, just create a plain Socket.
+        if (log.isDebugEnabled()) log.debug("Created plain endpoint to " + address.getHostName() + ":" + port);
+        return new Socket(address, port);
+    }
+
+    /**
+     * Create a loopback connection to the hosting
+     * ORB.
+     *
+     * @param address The address information for the server.
+     * @param port    The target port.
+     *
+     * @return An appropriately configured socket based on the
+     *         listener characteristics.
+     * @exception IOException
+     * @exception ConnectException
+     */
+    public Socket createSelfConnection(InetAddress address, int port) throws IOException, ConnectException {
+        // the requires information tells us whether we created a plain or SSL listener.  We need to create one
+        // of the matching type.
+
+        if ((NoProtection.value & requires) == NoProtection.value) {
+            if (log.isDebugEnabled()) log.debug("Created plain endpoint to " + address.getHostName() + ":" + port);
+            return new Socket(address, port);
+        }
+        else {
+            return createSSLSocket(address.getHostName(), port, supports, requires);
+        }
+    }
+
+    /**
+     * Create a server socket listening on the given port.
+     *
+     * @param port    The target listening port.
+     * @param backlog The desired backlog value.
+     *
+     * @return An appropriate server socket for this connection.
+     * @exception IOException
+     * @exception ConnectException
+     */
+    public ServerSocket createServerSocket(int port, int backlog)  throws IOException, ConnectException {
+        // if no protection is required, just create a plain socket.
+        if ((NoProtection.value & requires) == NoProtection.value) {
+            if (log.isDebugEnabled()) log.debug("Created plain server socket for port " + port);
+            return new ServerSocket(port, backlog);
+        }
+        else {
+            // SSL is required.  Create one from the SSLServerFactory retrieved from the config.  This will
+            // require additional QOS configuration after creation.
+            SSLServerSocket serverSocket = (SSLServerSocket)getServerSocketFactory().createServerSocket(port, backlog);
+            configureServerSocket(serverSocket);
+            return serverSocket;
+        }
+    }
+
+    /**
+     * Create a server socket for this connection.
+     *
+     * @param port    The target listener port.
+     * @param backlog The requested backlog value for the connection.
+     * @param address The host address information we're publishing under.
+     *
+     * @return An appropriately configured ServerSocket for this
+     *         connection.
+     * @exception IOException
+     * @exception ConnectException
+     */
+    public ServerSocket createServerSocket(int port, int backlog, InetAddress address) throws IOException, ConnectException {
+        // if no protection is required, just create a plain socket.
+        System.out.println("Creating a server socket on port " + port);
+        if ((NoProtection.value & requires) == NoProtection.value) {
+            if (log.isDebugEnabled()) log.debug("Created plain server socket for port " + port);
+            return new ServerSocket(port, backlog, address);
+        }
+        else {
+            // SSL is required.  Create one from the SSLServerFactory retrieved from the config.  This will
+            // require additional QOS configuration after creation.
+            SSLServerSocket serverSocket = (SSLServerSocket)getServerSocketFactory().createServerSocket(port, backlog, address);
+            configureServerSocket(serverSocket);
+            return serverSocket;
+        }
+    }
+
+    /**
+     * On-demand creation of an SSL socket factory, using the provided
+     * Geronimo SSLConfig information.
+     *
+     * @return The SSLSocketFactory this connection should be using to create
+     *         secure connections.
+     */
+    private SSLSocketFactory getSocketFactory() throws IOException {
+        // first use?
+        if (socketFactory == null) {
+            // the SSLConfig is optional, so if it's not there, use the default SSLSocketFactory.
+            if (sslConfig == null) {
+                socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
+            }
+            else {
+                // ask the SSLConfig bean to create a factory for us.
+                try {
+                    socketFactory = (SSLSocketFactory)sslConfig.createSSLFactory(Thread.currentThread().getContextClassLoader());
+                } catch (Exception e) {
+                    throw new IOException("Unable to create client SSL socket factory: " + e.getMessage());
+                }
+            }
+        }
+        return socketFactory;
+    }
+
+    /**
+     * On-demand creation of an SSL server socket factory, using the provided
+     * Geronimo SSLConfig information.
+     *
+     * @return The SSLServerSocketFactory this connection should be using to create
+     *         secure connections.
+     */
+    private SSLServerSocketFactory getServerSocketFactory() throws IOException {
+        // first use?
+        if (serverSocketFactory == null) {
+            // the SSLConfig is optional, so if it's not there, use the default SSLSocketFactory.
+            if (sslConfig == null) {
+                serverSocketFactory = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
+            }
+            else {
+                try {
+                    serverSocketFactory = (SSLServerSocketFactory)sslConfig.createSSLServerFactory(Thread.currentThread().getContextClassLoader());
+                } catch (Exception e) {
+                    throw new IOException("Unable to create server SSL socket factory: " + e.getMessage());
+                }
+            }
+            // we have a socket factory....now get our cipher suite set based on our requirements and what's
+            // available from the factory.
+            if (cipherSuites == null) {
+                cipherSuites = SSLCipherSuiteDatabase.getCipherSuites(requires, supports, serverSocketFactory.getSupportedCipherSuites());
+            }
+        }
+        return serverSocketFactory;
+    }
+
+
+    /**
+     * Set the server socket configuration to our required
+     * QOS values.
+     *
+     * @param serverSocket
+     *               The newly created SSLServerSocket.
+     *
+     * @exception IOException
+     * @exception ConnectException
+     */
+    private void configureServerSocket(SSLServerSocket serverSocket) throws IOException, ConnectException {
+        // set the authentication value and cipher suite info.
+        serverSocket.setEnabledCipherSuites(cipherSuites);
+        serverSocket.setWantClientAuth(clientAuthSupported);
+        serverSocket.setNeedClientAuth(clientAuthRequired);
+        serverSocket.setSoTimeout(60 * 1000);
+
+        if (log.isDebugEnabled()) {
+            log.debug("Created SSL server socket on port " + serverSocket.getLocalPort());
+            log.debug("    client authentication " + (clientAuthSupported ? "SUPPORTED" : "UNSUPPORTED"));
+            log.debug("    client authentication " + (clientAuthRequired ? "REQUIRED" : "OPTIONAL"));
+            log.debug("    cipher suites:");
+
+            for (int i = 0; i < cipherSuites.length; i++) {
+                log.debug("    " + cipherSuites[i]);
+            }
+        }
+    }
+
+    /**
+     * Create an SSL client socket using the IOR-encoded
+     * security characteristics.
+     *
+     * @param host     The target host name.
+     * @param port     The target connection port.
+     * @param supports The connections supports information.
+     * @param requires The connection requires information.
+     *
+     * @return An appropriately configured client SSLSocket.
+     * @exception IOException
+     * @exception ConnectException
+     */
+    private Socket createSSLSocket(String host, int port, int supports, int requires) throws IOException, ConnectException {
+        SSLSocketFactory factory = getSocketFactory();
+        SSLSocket socket = (SSLSocket) factory.createSocket(host, port);
+
+        socket.setSoTimeout(60 * 1000);
+
+        // figure out the supports and requires information from the flag values.
+        boolean authSupported = false;
+        boolean authRequired = false;
+
+        if ((supports & EstablishTrustInClient.value) != 0) {
+            authSupported = true;
+
+            if ((requires & EstablishTrustInClient.value) != 0) {
+                authRequired = true;
+            }
+        }
+
+        if ((supports & EstablishTrustInTarget.value) != 0) {
+            authSupported = true;
+
+            if ((requires & EstablishTrustInTarget.value) != 0) {
+                authSupported = true;
+            }
+        }
+
+        // get a set of cipher suites appropriate for this connections requirements.
+        // We request this for each connection, since the outgoing IOR's requirements may be different from
+        // our server listener requirements.
+        String[] iorSuites = SSLCipherSuiteDatabase.getCipherSuites(requires, supports, serverSocketFactory.getSupportedCipherSuites());
+        socket.setEnabledCipherSuites(iorSuites);
+        socket.setWantClientAuth(authSupported);
+        socket.setNeedClientAuth(authRequired);
+
+        if (log.isDebugEnabled()) {
+            log.debug("Created SSL socket to " + host + ":" + port);
+            log.debug("    client authentication " + (authSupported ? "SUPPORTED" : "UNSUPPORTED"));
+            log.debug("    client authentication " + (authRequired ? "REQUIRED" : "OPTIONAL"));
+            log.debug("    cipher suites:");
+
+            for (int i = 0; i < iorSuites.length; i++) {
+                log.debug("    " + iorSuites[i]);
+            }
+        }
+        return socket;
+    }
+}

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/SocketFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/SocketFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/SocketFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/test/java/org/apache/openejb/corba/security/config/tss/TSSConfigEditorTest.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/test/java/org/apache/openejb/corba/security/config/tss/TSSConfigEditorTest.java?view=auto&rev=452600
==============================================================================
--- incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/test/java/org/apache/openejb/corba/security/config/tss/TSSConfigEditorTest.java (added)
+++ incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/test/java/org/apache/openejb/corba/security/config/tss/TSSConfigEditorTest.java Tue Oct  3 12:29:42 2006
@@ -0,0 +1,102 @@
+/**
+  * 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.corba.security.config.tss;
+
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+
+import org.apache.geronimo.common.DeploymentException;
+
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.kernel.Jsr77Naming;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.Naming;
+import org.apache.geronimo.kernel.repository.Artifact;
+
+import org.omg.CORBA.SystemException;
+import org.apache.openejb.corba.CORBABean;
+import org.apache.openejb.corba.security.config.ConfigAdapter;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class TSSConfigEditorTest extends TestCase {
+
+    private XmlObject getXmlObject(String xmlString) throws XmlException {
+        XmlObject xmlObject = XmlObject.Factory.parse(xmlString);
+        XmlCursor xmlCursor = xmlObject.newCursor();
+        try {
+            xmlCursor.toFirstChild();
+            return xmlCursor.getObject();
+        } finally {
+            xmlCursor.dispose();
+        }
+    }
+
+    private static final String TEST_XML4 = "            <tss:tss xmlns:tss=\"http://openejb.apache.org/xml/ns/corba-tss-config-2.1\" xmlns:sec=\"http://geronimo.apache.org/xml/ns/security-1.2\">\n" +
+                                            "                <tss:default-principal>\n" +
+                                            "                    <sec:principal class=\"org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal\" name=\"guest\"/>\n" +
+                                            "                </tss:default-principal>\n" +
+                                            "                <tss:SSL port=\"6685\" hostname=\"localhost\">\n" +
+                                            "                    <tss:supports>Integrity Confidentiality EstablishTrustInTarget EstablishTrustInClient</tss:supports>\n" +
+                                            "                    <tss:requires>Integrity Confidentiality EstablishTrustInClient</tss:requires>\n" +
+                                            "                </tss:SSL>\n" +
+                                            "                <tss:compoundSecMechTypeList>\n" +
+                                            "                    <tss:compoundSecMech>\n" +
+                                            "                        <tss:GSSUP targetName=\"geronimo-properties-realm\"/>\n" +
+                                            "                        <tss:sasMech>\n" +
+                                            "                            <tss:identityTokenTypes><tss:ITTAnonymous/><tss:ITTPrincipalNameGSSUP principal-class=\"org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal\" domain=\"foo\"/><tss:ITTDistinguishedName domain=\"foo\"/><tss:ITTX509CertChain domain=\"foo\"/></tss:identityTokenTypes>\n" +
+                                            "                        </tss:sasMech>\n" +
+                                            "                    </tss:compoundSecMech>\n" +
+                                            "                </tss:compoundSecMechTypeList>\n" +
+                                            "            </tss:tss>";
+
+    public void testCORBABean() throws Exception {
+        ClassLoader classLoader = getClass().getClassLoader();
+        Naming naming = new Jsr77Naming();
+        AbstractName testName = naming.createRootName(new Artifact("test", "stuff", "", "ear"), "gbean", NameFactory.CORBA_SERVICE) ;
+        ConfigAdapter configAdapter = new org.apache.openejb.yoko.ORBConfigAdapter();
+        CORBABean corbaBean = new CORBABean(testName, configAdapter, "localhost", 8050, classLoader, null, null, null);
+        XmlObject xmlObject = getXmlObject(TEST_XML4);
+        TSSConfigEditor editor = new TSSConfigEditor();
+        Object o = editor.getValue(xmlObject, null, classLoader);
+        TSSConfig tss = (TSSConfig) o;
+
+        corbaBean.setTssConfig(tss);
+
+        try {
+            corbaBean.doStart();
+        } catch(SystemException se) {
+            se.printStackTrace();
+            fail(se.getCause().getMessage());
+        } finally {
+            try {
+                corbaBean.doStop();
+            } catch (Throwable e) {
+
+            }
+        }
+    }
+}
+

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/test/java/org/apache/openejb/corba/security/config/tss/TSSConfigEditorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/test/java/org/apache/openejb/corba/security/config/tss/TSSConfigEditorTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/test/java/org/apache/openejb/corba/security/config/tss/TSSConfigEditorTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/test/java/org/apache/openejb/yoko/NameServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/test/java/org/apache/openejb/yoko/NameServiceTest.java?view=auto&rev=452600
==============================================================================
--- incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/test/java/org/apache/openejb/yoko/NameServiceTest.java (added)
+++ incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/test/java/org/apache/openejb/yoko/NameServiceTest.java Tue Oct  3 12:29:42 2006
@@ -0,0 +1,88 @@
+/**
+  * 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.yoko;
+
+import java.util.Properties;
+import java.io.File;
+
+import org.apache.openejb.corba.NameService;
+
+import junit.framework.TestCase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
+import org.apache.geronimo.system.serverinfo.BasicServerInfo;
+import org.omg.CORBA.ORB;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContextExt;
+import org.omg.CosNaming.NamingContextExtHelper;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class NameServiceTest extends TestCase {
+    private static final Log log = LogFactory.getLog(NameServiceTest.class);
+    private ORB orb;
+    private NameService nameService;
+
+    protected void setUp() throws Exception {
+        // before we do anything make sure the sun orb is present
+        try {
+            getClass().getClassLoader().loadClass("org.apache.yoko.orb.CosNaming.tnaming.TransientNameService");
+        } catch (ClassNotFoundException e) {
+            log.info("Yoko orb is not present in this vm, so this test can't run");
+            return;
+        }
+
+        String tmpDir = System.getProperty("java.io.tmpdir");
+        ServerInfo serverInfo = new BasicServerInfo(tmpDir);
+
+        ORBConfigAdapter adapter = new ORBConfigAdapter();
+        // make sure all system properties are initialized.
+        adapter.doStart();
+        nameService = new NameService(serverInfo, adapter, "localhost", 8050);
+        nameService.doStart();
+
+        // create the ORB
+        Properties properties = new Properties();
+        String[] initArgs = { "-ORBInitRef", "NameService=" + nameService.getURI() };
+        orb = ORB.init(initArgs, properties);
+    }
+
+    protected void tearDown() throws Exception {
+        if (nameService == null) {
+            return;
+        }
+        orb.destroy();
+        nameService.doStop();
+    }
+
+    public void testOrb() throws Exception {
+        if (nameService == null) {
+            return;
+        }
+
+        NamingContextExt ctx = NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));
+        NamingContextExt rootNamingContext = ctx;
+        NameComponent name[] = ctx.to_name("foo/bar/baz");
+        for (int i = 0; i < name.length; i++) {
+            NameComponent nameComponent = name[i];
+            ctx = NamingContextExtHelper.narrow(ctx.bind_new_context(new NameComponent[] {nameComponent}));
+        }
+        ctx.rebind(ctx.to_name("plan"), rootNamingContext);
+    }
+}

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/test/java/org/apache/openejb/yoko/NameServiceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/test/java/org/apache/openejb/yoko/NameServiceTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/test/java/org/apache/openejb/yoko/NameServiceTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/openejb/trunk/openejb2/modules/pom.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb2/modules/pom.xml?view=diff&rev=452600&r1=452599&r2=452600
==============================================================================
--- incubator/openejb/trunk/openejb2/modules/pom.xml (original)
+++ incubator/openejb/trunk/openejb2/modules/pom.xml Tue Oct  3 12:29:42 2006
@@ -11,15 +11,30 @@
         <version>2.2-incubating-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
-    
+
     <artifactId>modules</artifactId>
     <name>OpenEJB :: Modules</name>
     <packaging>pom</packaging>
-    
+
     <modules>
         <module>openejb-pkgen-builder</module>
         <module>openejb-core</module>
         <module>openejb-builder</module>
+        <module>openejb-yoko</module>
     </modules>
+
+    <profiles>
+        <profile>
+            <id>sunorb</id>
+            <activation>
+                <property>
+                    <name>sunorb</name>
+                </property>
+            </activation>
+            <modules>
+                <module>openejb-sunorb</module>
+            </modules>
+        </profile>
+    </profiles>
 
 </project>

Modified: incubator/openejb/trunk/openejb2/pom.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb2/pom.xml?view=diff&rev=452600&r1=452599&r2=452600
==============================================================================
--- incubator/openejb/trunk/openejb2/pom.xml (original)
+++ incubator/openejb/trunk/openejb2/pom.xml Tue Oct  3 12:29:42 2006
@@ -9,9 +9,7 @@
     <groupId>org.apache.openejb</groupId>
     <artifactId>openejb</artifactId>
     <packaging>pom</packaging>
-
     <version>2.2-incubating-SNAPSHOT</version>
-
     <inceptionYear>1999</inceptionYear>
     <description>OpenEJB EJB Container</description>
     <url>http://incubator.apache.org/projects/openejb</url>
@@ -62,6 +60,7 @@
         <tranqlVendorsVersion>1.1</tranqlVendorsVersion>
         <tranqlVersion>1.4-SNAPSHOT</tranqlVersion>
         <xmlbeansVersion>2.0.0</xmlbeansVersion>
+        <yokoVersion>1.0-incubating-M1-SNAPSHOT</yokoVersion>
     </properties>
 
     <organization>
@@ -659,6 +658,18 @@
                 <scope>test</scope>
             </dependency>
 
+            <dependency>
+                <groupId>org.apache.yoko</groupId>
+                <artifactId>yoko-core</artifactId>
+                <version>${yokoVersion}</version>
+            </dependency>
+
+            <dependency>
+                <groupId>org.apache.yoko</groupId>
+                <artifactId>yoko-spec-corba</artifactId>
+                <version>${yokoVersion}</version>
+            </dependency>
+
         </dependencies>
     </dependencyManagement>
 
@@ -673,7 +684,6 @@
 
     <build>
         <defaultGoal>install</defaultGoal>
-
         <pluginManagement>
             <plugins>
                 <plugin>



Mime
View raw message