maguro      2005/03/07 23:08:32

  Added:       modules/core/src/java/org/openejb/corba/openorb
                        OpenORBConfigAdapter.java OpenORBInitializer.java
                        ServiceContextInterceptor.java
  Log:

  Intermediate CORBA checkin.
  
  Revision  Changes    Path
  1.1                  
openejb/modules/core/src/java/org/openejb/corba/openorb/OpenORBConfigAdapter.java
  
  Index: OpenORBConfigAdapter.java
  ===================================================================
  /**
   * Redistribution and use of this software and associated documentation
   * ("Software"), with or without modification, are permitted provided
   * that the following conditions are met:
   *
   * 1. Redistributions of source code must retain copyright
   *    statements and notices.  Redistributions must also contain a
   *    copy of this document.
   *
   * 2. Redistributions in binary form must reproduce the
   *    above copyright notice, this list of conditions and the
   *    following disclaimer in the documentation and/or other
   *    materials provided with the distribution.
   *
   * 3. The name "OpenEJB" must not be used to endorse or promote
   *    products derived from this Software without prior written
   *    permission of The OpenEJB Group.  For written permission,
   *    please contact [EMAIL PROTECTED]
   *
   * 4. Products derived from this Software may not be called "OpenEJB"
   *    nor may "OpenEJB" appear in their names without prior written
   *    permission of The OpenEJB Group. OpenEJB is a registered
   *    trademark of The OpenEJB Group.
   *
   * 5. Due credit should be given to the OpenEJB Project
   *    (http://openejb.sf.net/).
   *
   * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
   * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
   * THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * Copyright 2005 (C) The OpenEJB Group. All Rights Reserved.
   *
   * $Id: OpenORBConfigAdapter.java,v 1.1 2005/03/08 04:08:31 maguro Exp $
   */
  package org.openejb.corba.openorb;
  
  import java.util.ArrayList;
  import java.util.Properties;
  
  import org.omg.Security.Confidentiality;
  import org.omg.Security.EstablishTrustInClient;
  import org.omg.Security.EstablishTrustInTarget;
  import org.omg.Security.NoProtection;
  
  import org.openejb.corba.security.config.ConfigAdapter;
  import org.openejb.corba.security.config.ConfigException;
  import org.openejb.corba.security.config.css.CSSCompoundSecMechConfig;
  import org.openejb.corba.security.config.css.CSSCompoundSecMechListConfig;
  import org.openejb.corba.security.config.css.CSSConfig;
  import org.openejb.corba.security.config.tss.TSSConfig;
  import org.openejb.corba.security.config.tss.TSSSSLTransportConfig;
  import org.openejb.corba.security.config.tss.TSSTransportMechConfig;
  
  
  /**
   * @version $Revision: 1.1 $ $Date: 2005/03/08 04:08:31 $
   */
  public class OpenORBConfigAdapter implements ConfigAdapter {
  
      public String[] translateToArgs(TSSConfig config) throws ConfigException {
          ArrayList list = new ArrayList();
          return (String[]) list.toArray(new String[list.size()]);
      }
  
      public Properties translateToProps(TSSConfig config) throws 
ConfigException {
          Properties props = new Properties();
  
          TSSTransportMechConfig transportMech = config.getTransport_mech();
          if (transportMech != null) {
              if (transportMech instanceof TSSSSLTransportConfig) {
                  TSSSSLTransportConfig sslConfig = (TSSSSLTransportConfig) 
transportMech;
                  short supports = sslConfig.getSupports();
                  short requires = sslConfig.getRequires();
  
                  props.put("ssliop.port", Short.toString(sslConfig.getPort()));
  
                  if (sslConfig.getHandshakeTimeout() > 0) {
                      props.put("ssliop.server.handshake.timeout", 
Short.toString(sslConfig.getHandshakeTimeout()));
                  }
  
                  if ((supports & Confidentiality.value) != 0) {
                      props.put("ssliop.server.encrypt.support", "true");
                      if ((requires & Confidentiality.value) != 0) {
                          props.put("ssliop.server.encrypt.requires", "true");
                      }
                  }
                  if ((supports & EstablishTrustInTarget.value) != 0) {
                      props.put("ssliop.server.auth.support", "true");
  
                      if ((requires & EstablishTrustInTarget.value) != 0) {
                          props.put("ssliop.server.auth", "true");
                      }
                  }
                  if ((supports & EstablishTrustInClient.value) != 0) {
                      props.put("ssliop.server.auth.support", "true");
  
                      if ((requires & EstablishTrustInClient.value) != 0) {
                          props.put("ssliop.server.authClient", "true");
                      }
                  }
  
                  props.put("ssliop.server.AllowBiDir", "true");
                  props.put("ssliop.iiopport.disable", "true");
                  props.put("ssliop.SSLContextFinderClass", 
"org.openorb.orb.ssl.JSSEContextFinder");
              }
          }
          return props;
      }
  
      public String[] translateToArgs(CSSConfig config) throws ConfigException {
          ArrayList list = new ArrayList();
          return (String[]) list.toArray(new String[list.size()]);
      }
  
      public Properties translateToProps(CSSConfig config) throws 
ConfigException {
          Properties props = new Properties();
  
          short supports = 0;
          short requires = 0;
          CSSCompoundSecMechListConfig mechList = config.getMechList();
          for (int i = 0; i < mechList.size(); i++) {
              CSSCompoundSecMechConfig mech = mechList.mechAt(i);
  
              supports |= mech.getTransport_mech().getSupports();
              requires |= mech.getTransport_mech().getRequires();
          }
  
          if ((supports & NoProtection.value) != 0) {
              props.put("secure.client.allowUnsecure", "true");
          }
          if ((supports & Confidentiality.value) != 0) {
              props.put("ssliop.client.encrypt.support", "true");
              if ((requires & Confidentiality.value) != 0) {
                  props.put("ssliop.client.encrypt.requires", "true");
              }
          }
          if ((supports & EstablishTrustInTarget.value) != 0) {
              props.put("ssliop.client.auth.support", "true");
  
              if ((requires & EstablishTrustInTarget.value) != 0) {
                  props.put("ssliop.client.auth.requires", "true");
              }
          }
          if ((supports & EstablishTrustInClient.value) != 0) {
              props.put("ssliop.client.auth.support", "true");
          }
  
          props.put("ssliop.SSLContextFinderClass", 
"org.openorb.orb.ssl.JSSEContextFinder");
  
          return props;
      }
  }
  
  
  
  1.1                  
openejb/modules/core/src/java/org/openejb/corba/openorb/OpenORBInitializer.java
  
  Index: OpenORBInitializer.java
  ===================================================================
  /**
   * Redistribution and use of this software and associated documentation
   * ("Software"), with or without modification, are permitted provided
   * that the following conditions are met:
   *
   * 1. Redistributions of source code must retain copyright
   *    statements and notices.  Redistributions must also contain a
   *    copy of this document.
   *
   * 2. Redistributions in binary form must reproduce the
   *    above copyright notice, this list of conditions and the
   *    following disclaimer in the documentation and/or other
   *    materials provided with the distribution.
   *
   * 3. The name "OpenEJB" must not be used to endorse or promote
   *    products derived from this Software without prior written
   *    permission of The OpenEJB Group.  For written permission,
   *    please contact [EMAIL PROTECTED]
   *
   * 4. Products derived from this Software may not be called "OpenEJB"
   *    nor may "OpenEJB" appear in their names without prior written
   *    permission of The OpenEJB Group. OpenEJB is a registered
   *    trademark of The OpenEJB Group.
   *
   * 5. Due credit should be given to the OpenEJB Project
   *    (http://openejb.sf.net/).
   *
   * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
   * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
   * THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * Copyright 2001 (C) The OpenEJB Group. All Rights Reserved.
   *
   * $Id: OpenORBInitializer.java,v 1.1 2005/03/08 04:08:31 maguro Exp $
   */
  package org.openejb.corba.openorb;
  
  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;
  import org.omg.PortableInterceptor.ORBInitializer;
  
  
  /**
   * @version $Revision: 1.1 $ $Date: 2005/03/08 04:08:31 $
   */
  public class OpenORBInitializer extends LocalObject implements ORBInitializer 
{
  
      private final Log log = LogFactory.getLog(OpenORBInitializer.class);
  
      /**
       * 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 {
              info.add_server_request_interceptor(new 
ServiceContextInterceptor());
          } catch (DuplicateName dn) {
              log.error("Error registering interceptor", dn);
          }
      }
  }
  
  
  
  1.1                  
openejb/modules/core/src/java/org/openejb/corba/openorb/ServiceContextInterceptor.java
  
  Index: ServiceContextInterceptor.java
  ===================================================================
  /**
   * Redistribution and use of this software and associated documentation
   * ("Software"), with or without modification, are permitted provided
   * that the following conditions are met:
   *
   * 1. Redistributions of source code must retain copyright
   *    statements and notices.  Redistributions must also contain a
   *    copy of this document.
   *
   * 2. Redistributions in binary form must reproduce the
   *    above copyright notice, this list of conditions and the
   *    following disclaimer in the documentation and/or other
   *    materials provided with the distribution.
   *
   * 3. The name "OpenEJB" must not be used to endorse or promote
   *    products derived from this Software without prior written
   *    permission of The OpenEJB Group.  For written permission,
   *    please contact [EMAIL PROTECTED]
   *
   * 4. Products derived from this Software may not be called "OpenEJB"
   *    nor may "OpenEJB" appear in their names without prior written
   *    permission of The OpenEJB Group. OpenEJB is a registered
   *    trademark of The OpenEJB Group.
   *
   * 5. Due credit should be given to the OpenEJB Project
   *    (http://openejb.sf.net/).
   *
   * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
   * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
   * THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * Copyright 2001 (C) The OpenEJB Group. All Rights Reserved.
   *
   * $Id: ServiceContextInterceptor.java,v 1.1 2005/03/08 04:08:31 maguro Exp $
   */
  package org.openejb.corba.openorb;
  
  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.openorb.orb.net.ServerRequest;
  import org.openorb.orb.net.Transport;
  import org.openorb.orb.ssl.SSLTransport;
  
  import org.openejb.corba.security.SSLSessionManager;
  
  
  /**
   * @version $Revision: 1.1 $ $Date: 2005/03/08 04:08:31 $
   */
  final class ServiceContextInterceptor extends LocalObject implements 
ServerRequestInterceptor {
  
      private final Log log = 
LogFactory.getLog(ServiceContextInterceptor.class);
  
      public void receive_request(ServerRequestInfo ri) {
      }
  
      public void receive_request_service_contexts(ServerRequestInfo ri) {
          if (ri instanceof ServerRequest) {
              Transport transport = ((ServerRequest) ri).channel().transport();
              if (transport instanceof SSLTransport) {
                  SSLTransport sslTransport = (SSLTransport) transport;
                  SSLSessionManager.setSSLSession(ri.request_id(), 
sslTransport.getSocketSession());
              }
          }
      }
  
      public void send_exception(ServerRequestInfo ri) {
          SSLSessionManager.clearSSLSession(ri.request_id());
      }
  
      public void send_other(ServerRequestInfo ri) {
          SSLSessionManager.clearSSLSession(ri.request_id());
      }
  
      public void send_reply(ServerRequestInfo ri) {
          SSLSessionManager.clearSSLSession(ri.request_id());
      }
  
      public void destroy() {
      }
  
      public String name() {
          return "org.openejb.corba.openorb.ServiceContextInterceptor";
      }
  }
  
  
  

Reply via email to