001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.geronimo.corba.security; 018 019 import org.apache.commons.logging.Log; 020 import org.apache.commons.logging.LogFactory; 021 import org.apache.geronimo.corba.ORBConfiguration; 022 import org.apache.geronimo.corba.util.Util; 023 import org.omg.CORBA.LocalObject; 024 import org.omg.PortableInterceptor.ORBInitInfo; 025 import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName; 026 import org.omg.PortableInterceptor.ORBInitializer; 027 028 029 /** 030 * @version $Revision: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $ 031 */ 032 public class SecurityInitializer extends LocalObject implements ORBInitializer { 033 034 private final Log log = LogFactory.getLog(SecurityInitializer.class); 035 036 public SecurityInitializer() { 037 if (log.isDebugEnabled()) log.debug("SecurityInitializer.<init>"); 038 } 039 040 /** 041 * Called during ORB initialization. If it is expected that initial 042 * services registered by an interceptor will be used by other 043 * interceptors, then those initial services shall be registered at 044 * this point via calls to 045 * <code>ORBInitInfo.register_initial_reference</code>. 046 * 047 * @param info provides initialization attributes and operations by 048 * which Interceptors can be registered. 049 */ 050 public void pre_init(ORBInitInfo info) { 051 } 052 053 /** 054 * Called during ORB initialization. If a service must resolve initial 055 * references as part of its initialization, it can assume that all 056 * initial references will be available at this point. 057 * <p/> 058 * Calling the <code>post_init</code> operations is not the final 059 * task of ORB initialization. The final task, following the 060 * <code>post_init</code> calls, is attaching the lists of registered 061 * interceptors to the ORB. Therefore, the ORB does not contain the 062 * interceptors during calls to <code>post_init</code>. If an 063 * ORB-mediated call is made from within <code>post_init</code>, no 064 * request interceptors will be invoked on that call. 065 * Likewise, if an operation is performed which causes an IOR to be 066 * created, no IOR interceptors will be invoked. 067 * 068 * @param info provides initialization attributes and 069 * operations by which Interceptors can be registered. 070 */ 071 public void post_init(ORBInitInfo info) { 072 073 try { 074 if (log.isDebugEnabled()) log.debug("Registering interceptors and policy factories"); 075 076 ORBConfiguration config = Util.getRegisteredORB(info.orb_id()); 077 078 try { 079 info.add_client_request_interceptor(new ClientSecurityInterceptor()); 080 info.add_server_request_interceptor(new ServerSecurityInterceptor()); 081 info.add_ior_interceptor(new IORSecurityInterceptor(config.getTssConfig())); 082 } catch (DuplicateName dn) { 083 log.error("Error registering interceptor", dn); 084 } 085 086 info.register_policy_factory(ClientPolicyFactory.POLICY_TYPE, new ClientPolicyFactory()); 087 info.register_policy_factory(ServerPolicyFactory.POLICY_TYPE, new ServerPolicyFactory()); 088 } catch (RuntimeException re) { 089 log.error("Error registering interceptor", re); 090 throw re; 091 } 092 } 093 094 }