maguro      2005/03/07 23:08:28

  Modified:    modules/core/src/java/org/openejb/corba/security
                        ClientSecurityInterceptor.java
                        IORSecurityInterceptor.java
                        SecurityInitializer.java
                        ServerSecurityInterceptor.java
  Added:       modules/core/src/java/org/openejb/corba/security
                        ClientPolicy.java ClientPolicyFactory.java
                        ServerPolicy.java ServerPolicyFactory.java
  Log:

  Intermediate CORBA checkin.
  
  Revision  Changes    Path
  1.3       +37 -30    
openejb/modules/core/src/java/org/openejb/corba/security/ClientSecurityInterceptor.java
  
  Index: ClientSecurityInterceptor.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/corba/security/ClientSecurityInterceptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ClientSecurityInterceptor.java    13 Jan 2005 17:00:23 -0000      1.2
  +++ ClientSecurityInterceptor.java    8 Mar 2005 04:08:27 -0000       1.3
  @@ -44,60 +44,67 @@
    */
   package org.openejb.corba.security;
   
  +import java.util.List;
  +
   import org.omg.CORBA.LocalObject;
  +import org.omg.IOP.ServiceContext;
  +import org.omg.IOP.TAG_CSI_SEC_MECH_LIST;
  +import org.omg.IOP.TaggedComponent;
   import org.omg.PortableInterceptor.ClientRequestInfo;
   import org.omg.PortableInterceptor.ClientRequestInterceptor;
  -import org.omg.PortableInterceptor.ForwardRequest;
  +import org.openorb.orb.net.AbstractServerRequest;
  +
  +import org.openejb.corba.security.config.css.CSSCompoundSecMechConfig;
  +import org.openejb.corba.security.config.css.CSSConfig;
  +import org.openejb.corba.security.config.tss.TSSCompoundSecMechListConfig;
  +import org.openejb.corba.util.Util;
   
   
   /**
    * @version $Revision$ $Date$
    */
  -class ClientSecurityInterceptor extends LocalObject implements 
ClientRequestInterceptor {
  +final class ClientSecurityInterceptor extends LocalObject implements 
ClientRequestInterceptor {
   
  -    private final int slotId;
  -
  -    public ClientSecurityInterceptor(int slotId) {
  -        this.slotId = slotId;
  +    public ClientSecurityInterceptor() {
  +        AbstractServerRequest.disableServiceContextExceptions();
       }
   
  -    public void receive_exception(ClientRequestInfo ri) throws 
ForwardRequest {
  -        //To change body of implemented methods use File | Settings | File 
Templates.
  +    public void receive_exception(ClientRequestInfo ri) {
       }
   
  -    public void receive_other(ClientRequestInfo ri) throws ForwardRequest {
  -        //To change body of implemented methods use File | Settings | File 
Templates.
  +    public void receive_other(ClientRequestInfo ri) {
       }
   
       public void receive_reply(ClientRequestInfo ri) {
  -        //To change body of implemented methods use File | Settings | File 
Templates.
       }
   
       public void send_poll(ClientRequestInfo ri) {
  -        //To change body of implemented methods use File | Settings | File 
Templates.
       }
   
  -    public void send_request(ClientRequestInfo ri) throws ForwardRequest {
  -        //To change body of implemented methods use File | Settings | File 
Templates.
  +    public void send_request(ClientRequestInfo ri) {
  +        try {
  +            TaggedComponent tc = 
ri.get_effective_component(TAG_CSI_SEC_MECH_LIST.value);
  +            TSSCompoundSecMechListConfig csml = 
TSSCompoundSecMechListConfig.decodeIOR(Util.getCodec(), tc);
  +
  +            ClientPolicy policy = (ClientPolicy) 
ri.get_request_policy(ClientPolicyFactory.POLICY_TYPE);
  +            if (policy.getConfig() == null) return;
  +
  +            CSSConfig config = policy.getConfig();
  +            List compat = config.findCompatibleSet(csml);
  +
  +            if (compat.size() == 0) return;
  +
  +            ServiceContext context = ((CSSCompoundSecMechConfig) 
compat.get(0)).generateServiceContext();
  +
  +            ri.add_request_service_context(context, true);
  +        } catch (Exception ue) {
  +        }
       }
   
       public void destroy() {
  -        //To change body of implemented methods use File | Settings | File 
Templates.
       }
   
  -    /**
  -     * Returns the name of the interceptor.
  -     * <p/>
  -     * Each Interceptor may have a name that may be used administratively
  -     * to order the lists of Interceptors. Only one Interceptor of a given
  -     * name can be registered with the ORB for each Interceptor type. An
  -     * Interceptor may be anonymous, i.e., have an empty string as the name
  -     * attribute. Any number of anonymous Interceptors may be registered with
  -     * the ORB.
  -     *
  -     * @return the name of the interceptor.
  -     */
       public String name() {
  -        return "ClientSecurityInterceptor";
  +        return "org.openejb.corba.security.ClientSecurityInterceptor";
       }
   }
  
  
  
  1.3       +24 -13    
openejb/modules/core/src/java/org/openejb/corba/security/IORSecurityInterceptor.java
  
  Index: IORSecurityInterceptor.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/corba/security/IORSecurityInterceptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IORSecurityInterceptor.java       13 Jan 2005 17:00:23 -0000      1.2
  +++ IORSecurityInterceptor.java       8 Mar 2005 04:08:27 -0000       1.3
  @@ -44,33 +44,44 @@
    */
   package org.openejb.corba.security;
   
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +import org.omg.CORBA.INV_POLICY;
   import org.omg.CORBA.LocalObject;
  +import org.omg.IOP.TAG_INTERNET_IOP;
   import org.omg.PortableInterceptor.IORInfo;
   import org.omg.PortableInterceptor.IORInterceptor;
   
  +import org.openejb.corba.util.Util;
  +
   
   /**
    * @version $Revision$ $Date$
    */
  -class IORSecurityInterceptor extends LocalObject implements IORInterceptor {
  -
  -    private final int slotId;
  +final class IORSecurityInterceptor extends LocalObject implements 
IORInterceptor {
   
  -    IORSecurityInterceptor(int slotId) {
  -        this.slotId = slotId;
  -    }
  +    private final Log log = LogFactory.getLog(IORSecurityInterceptor.class);
   
       public void establish_components(IORInfo info) {
  -        int i = 0;
  -        //todo: consider this autogenerated code
  +
  +        try {
  +            ServerPolicy policy = (ServerPolicy) 
info.get_effective_policy(ServerPolicyFactory.POLICY_TYPE);
  +
  +            if (policy.getConfig() == null) return;
  +
  +            
info.add_ior_component_to_profile(policy.getConfig().generateIOR(Util.getORB(), 
Util.getCodec()), TAG_INTERNET_IOP.value);
  +        } catch (INV_POLICY e) {
  +            // do nothing
  +        } catch (Exception e) {
  +            log.error("Generating IOR", e);
  +        }
       }
   
       public void destroy() {
  -        int i = 0;
  -        //todo: consider this autogenerated code
       }
   
       public String name() {
  -        return "IORSecurityInterceptor";
  +        return "org.openejb.corba.security.IORSecurityInterceptor";
       }
  +
   }
  
  
  
  1.3       +12 -13    
openejb/modules/core/src/java/org/openejb/corba/security/SecurityInitializer.java
  
  Index: SecurityInitializer.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/corba/security/SecurityInitializer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SecurityInitializer.java  13 Jan 2005 17:00:23 -0000      1.2
  +++ SecurityInitializer.java  8 Mar 2005 04:08:27 -0000       1.3
  @@ -56,9 +56,8 @@
    * @version $Revision$ $Date$
    */
   public class SecurityInitializer extends LocalObject implements 
ORBInitializer {
  -    private final Log log = LogFactory.getLog(SecurityInitializer.class);
   
  -    private static int slotId;
  +    private final Log log = LogFactory.getLog(SecurityInitializer.class);
   
       /**
        * Called during ORB initialization.  If it is expected that initial
  @@ -71,15 +70,6 @@
        *             which Interceptors can be registered.
        */
       public void pre_init(ORBInitInfo info) {
  -        slotId = info.allocate_slot_id();
  -
  -        try {
  -            info.add_client_request_interceptor(new 
ClientSecurityInterceptor(slotId));
  -            info.add_server_request_interceptor(new 
ServerSecurityInterceptor(slotId));
  -            info.add_ior_interceptor(new IORSecurityInterceptor(slotId));
  -        } catch (DuplicateName duplicateName) {
  -            duplicateName.printStackTrace();
  -        }
       }
   
       /**
  @@ -101,5 +91,14 @@
        *             operations by which Interceptors can be registered.
        */
       public void post_init(ORBInitInfo info) {
  +        try {
  +            info.add_client_request_interceptor(new 
ClientSecurityInterceptor());
  +            info.add_server_request_interceptor(new 
ServerSecurityInterceptor());
  +            info.add_ior_interceptor(new IORSecurityInterceptor());
  +        } catch (DuplicateName dn) {
  +            log.error("Error registering interceptor", dn);
  +        }
  +        info.register_policy_factory(ClientPolicyFactory.POLICY_TYPE, new 
ClientPolicyFactory());
  +        info.register_policy_factory(ServerPolicyFactory.POLICY_TYPE, new 
ServerPolicyFactory());
       }
   }
  
  
  
  1.3       +77 -34    
openejb/modules/core/src/java/org/openejb/corba/security/ServerSecurityInterceptor.java
  
  Index: ServerSecurityInterceptor.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/corba/security/ServerSecurityInterceptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServerSecurityInterceptor.java    13 Jan 2005 17:00:23 -0000      1.2
  +++ ServerSecurityInterceptor.java    8 Mar 2005 04:08:27 -0000       1.3
  @@ -44,66 +44,109 @@
    */
   package org.openejb.corba.security;
   
  +import javax.security.cert.X509Certificate;
  +import javax.net.ssl.SSLSession;
  +import javax.net.ssl.SSLPeerUnverifiedException;
  +
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +import org.omg.CORBA.Any;
  +import org.omg.CORBA.INTERNAL;
  +import org.omg.CORBA.INV_POLICY;
   import org.omg.CORBA.LocalObject;
  +import org.omg.CORBA.UserException;
  +import org.omg.CSI.MTCompleteEstablishContext;
  +import org.omg.CSI.MTContextError;
  +import org.omg.CSI.MTEstablishContext;
  +import org.omg.CSI.MTMessageInContext;
  +import org.omg.CSI.SASContextBody;
  +import org.omg.CSI.SASContextBodyHelper;
  +import org.omg.IOP.Codec;
  +import org.omg.IOP.SecurityAttributeService;
  +import org.omg.IOP.ServiceContext;
   import org.omg.PortableInterceptor.ForwardRequest;
   import org.omg.PortableInterceptor.ServerRequestInfo;
   import org.omg.PortableInterceptor.ServerRequestInterceptor;
  +import org.openorb.orb.net.AbstractServerRequest;
  +
  +import org.openejb.corba.security.wrappers.EstablishContextWrapper;
  +import org.openejb.corba.util.Util;
   
   
   /**
    * @version $Revision$ $Date$
    */
  -class ServerSecurityInterceptor extends LocalObject implements 
ServerRequestInterceptor {
  +final class ServerSecurityInterceptor extends LocalObject implements 
ServerRequestInterceptor {
   
  -    private final int slotId;
  +    private final Log log = 
LogFactory.getLog(ServerSecurityInterceptor.class);
   
  -    public ServerSecurityInterceptor(int slotId) {
  -        this.slotId = slotId;
  +    public ServerSecurityInterceptor() {
  +        AbstractServerRequest.disableServiceContextExceptions();
       }
   
       public void receive_request(ServerRequestInfo ri) throws ForwardRequest {
  -        int i = 0;
  -        //To change body of implemented methods use File | Settings | File 
Templates.
  +        try {
  +            SSLSession session = 
SSLSessionManager.getSSLSession(ri.request_id());
  +            X509Certificate[] chain = session.getPeerCertificateChain();
  +            String host = session.getPeerHost();
  +
  +            ServerPolicy policy = (ServerPolicy) 
ri.get_server_policy(ServerPolicyFactory.POLICY_TYPE);
  +            if (policy.getConfig() == null) return;
  +            ri.toString();
  +
  +            ServiceContext serviceContext = 
ri.get_request_service_context(SecurityAttributeService.value);
  +            if (serviceContext == null) return;
  +
  +            Codec codec = Util.getCodec();
  +            Any any = codec.decode_value(serviceContext.context_data, 
SASContextBodyHelper.type());
  +            SASContextBody contextBody = SASContextBodyHelper.extract(any);
  +
  +            short msgType = contextBody.discriminator();
  +            switch (msgType) {
  +                case MTEstablishContext.value:
  +                    EstablishContextWrapper establishMsg = new 
EstablishContextWrapper(contextBody.establish_msg());
  +
  +                    break;
  +
  +                case MTCompleteEstablishContext.value:
  +                    log.error("The CSIv2 TSS is not supposed to receive a 
CompleteEstablishContext message.");
  +                    throw new INTERNAL("The CSIv2 TSS is not supposed to 
receive a CompleteEstablishContext message.");
  +
  +                case MTContextError.value:
  +                    log.error("The CSIv2 TSS is not supposed to receive a 
CompleteEstablishContext message.");
  +                    throw new INTERNAL("The CSIv2 TSS is not supposed to 
receive a ContextError message.");
  +
  +                case MTMessageInContext.value:
  +                    log.error("The CSIv2 TSS is not supposed to receive a 
CompleteEstablishContext message.");
  +                    throw new INTERNAL("MessageInContext is currently not 
supported by this implementation.");
  +            }
  +
  +        } catch (INV_POLICY e) {
  +            // do nothing
  +        } catch (UserException ue) {
  +            log.error("UserException thrown", ue);
  +            throw new INTERNAL("UserException thrown: " + ue);
  +        } catch (SSLPeerUnverifiedException e) {
  +            // do nothing
  +        }
       }
   
  -    public void receive_request_service_contexts(ServerRequestInfo ri) 
throws ForwardRequest {
  -        int i = 0;
  -        //To change body of implemented methods use File | Settings | File 
Templates.
  +    public void receive_request_service_contexts(ServerRequestInfo ri) {
       }
   
  -    public void send_exception(ServerRequestInfo ri) throws ForwardRequest {
  -        int i = 0;
  -        //To change body of implemented methods use File | Settings | File 
Templates.
  +    public void send_exception(ServerRequestInfo ri) {
       }
   
  -    public void send_other(ServerRequestInfo ri) throws ForwardRequest {
  -        int i = 0;
  -        //To change body of implemented methods use File | Settings | File 
Templates.
  +    public void send_other(ServerRequestInfo ri) {
       }
   
       public void send_reply(ServerRequestInfo ri) {
  -        int i = 0;
  -        //To change body of implemented methods use File | Settings | File 
Templates.
       }
   
       public void destroy() {
  -        int i = 0;
  -        //To change body of implemented methods use File | Settings | File 
Templates.
       }
   
  -    /**
  -     * Returns the name of the interceptor.
  -     * <p/>
  -     * Each Interceptor may have a name that may be used administratively
  -     * to order the lists of Interceptors. Only one Interceptor of a given
  -     * name can be registered with the ORB for each Interceptor type. An
  -     * Interceptor may be anonymous, i.e., have an empty string as the name
  -     * attribute. Any number of anonymous Interceptors may be registered with
  -     * the ORB.
  -     *
  -     * @return the name of the interceptor.
  -     */
       public String name() {
  -        return "ServerSecurityInterceptor";
  +        return "org.openejb.corba.security.ServerSecurityInterceptor";
       }
   }
  
  
  
  1.1                  
openejb/modules/core/src/java/org/openejb/corba/security/ClientPolicy.java
  
  Index: ClientPolicy.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 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.org/).
   *
   * 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.
   *
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the OpenEJB Project.  For more information
   * please see <http://openejb.org/>.
   *
   * ====================================================================
   */
  package org.openejb.corba.security;
  
  import org.omg.CORBA.LocalObject;
  import org.omg.CORBA.Policy;
  
  import org.openejb.corba.security.config.css.CSSConfig;
  
  
  /**
   * @version $Rev: $ $Date: 2005/03/08 04:08:27 $
   */
  public class ClientPolicy extends LocalObject implements Policy {
  
      private final CSSConfig config;
  
      public ClientPolicy(CSSConfig ORBConfig) {
          this.config = ORBConfig;
      }
  
      public CSSConfig getConfig() {
          return config;
      }
  
      public int policy_type() {
          return ClientPolicyFactory.POLICY_TYPE;
      }
  
      public void destroy() {
      }
  
      public Policy copy() {
          return null;
      }
  }
  
  
  
  1.1                  
openejb/modules/core/src/java/org/openejb/corba/security/ClientPolicyFactory.java
  
  Index: ClientPolicyFactory.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 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.org/).
   *
   * 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.
   *
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the OpenEJB Project.  For more information
   * please see <http://openejb.org/>.
   *
   * ====================================================================
   */
  package org.openejb.corba.security;
  
  import org.omg.CORBA.Any;
  import org.omg.CORBA.LocalObject;
  import org.omg.CORBA.Policy;
  import org.omg.CORBA.PolicyError;
  import org.omg.PortableInterceptor.PolicyFactory;
  
  import org.openejb.corba.security.config.css.CSSConfig;
  
  
  /**
   * @version $Rev: $ $Date: 2005/03/08 04:08:27 $
   */
  public class ClientPolicyFactory extends LocalObject implements PolicyFactory 
{
  
      public final static int POLICY_TYPE = 0x41534601;
  
      public Policy create_policy(int type, Any value) throws PolicyError {
          if (type != POLICY_TYPE) throw new PolicyError();
  
          return new ClientPolicy((CSSConfig) value.extract_Value());
      }
  }
  
  
  
  1.1                  
openejb/modules/core/src/java/org/openejb/corba/security/ServerPolicy.java
  
  Index: ServerPolicy.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 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.org/).
   *
   * 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.
   *
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the OpenEJB Project.  For more information
   * please see <http://openejb.org/>.
   *
   * ====================================================================
   */
  package org.openejb.corba.security;
  
  import org.omg.CORBA.LocalObject;
  import org.omg.CORBA.Policy;
  
  import org.openejb.corba.security.config.tss.TSSConfig;
  
  
  /**
   * @version $Rev: $ $Date: 2005/03/08 04:08:27 $
   */
  public class ServerPolicy extends LocalObject implements Policy {
  
      private final TSSConfig TSSConfig;
  
      public ServerPolicy(TSSConfig TSSConfig) {
          this.TSSConfig = TSSConfig;
      }
  
      public TSSConfig getConfig() {
          return TSSConfig;
      }
  
      public int policy_type() {
          return ServerPolicyFactory.POLICY_TYPE;
      }
  
      public void destroy() {
      }
  
      public Policy copy() {
          return null;
      }
  }
  
  
  
  1.1                  
openejb/modules/core/src/java/org/openejb/corba/security/ServerPolicyFactory.java
  
  Index: ServerPolicyFactory.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 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.org/).
   *
   * 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.
   *
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the OpenEJB Project.  For more information
   * please see <http://openejb.org/>.
   *
   * ====================================================================
   */
  package org.openejb.corba.security;
  
  import org.omg.CORBA.Any;
  import org.omg.CORBA.LocalObject;
  import org.omg.CORBA.Policy;
  import org.omg.CORBA.PolicyError;
  import org.omg.PortableInterceptor.PolicyFactory;
  
  import org.openejb.corba.security.config.tss.TSSConfig;
  
  
  /**
   * @version $Rev: $ $Date: 2005/03/08 04:08:27 $
   */
  public class ServerPolicyFactory extends LocalObject implements PolicyFactory 
{
  
      public final static int POLICY_TYPE = 0x41534600;
  
      public Policy create_policy(int type, Any value) throws PolicyError {
          if (type != POLICY_TYPE) throw new PolicyError();
  
          return new ServerPolicy((TSSConfig) value.extract_Value());
      }
  }
  
  
  

Reply via email to