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: */package org.apache.geronimo.corba.security;
017:
018: import org.apache.commons.logging.Log;
019: import org.apache.commons.logging.LogFactory;
020: import org.apache.geronimo.corba.ORBConfiguration;
021: import org.apache.geronimo.corba.util.Util;
022: import org.omg.CORBA.LocalObject;
023: import org.omg.PortableInterceptor.ORBInitInfo;
024: import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
025: import org.omg.PortableInterceptor.ORBInitializer;
026:
027: /**
028: * @version $Revision: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
029: */
030: public class SecurityInitializer extends LocalObject implements
031: ORBInitializer {
032:
033: private final Log log = LogFactory
034: .getLog(SecurityInitializer.class);
035:
036: public SecurityInitializer() {
037: if (log.isDebugEnabled())
038: log.debug("SecurityInitializer.<init>");
039: }
040:
041: /**
042: * Called during ORB initialization. If it is expected that initial
043: * services registered by an interceptor will be used by other
044: * interceptors, then those initial services shall be registered at
045: * this point via calls to
046: * <code>ORBInitInfo.register_initial_reference</code>.
047: *
048: * @param info provides initialization attributes and operations by
049: * which Interceptors can be registered.
050: */
051: public void pre_init(ORBInitInfo info) {
052: }
053:
054: /**
055: * Called during ORB initialization. If a service must resolve initial
056: * references as part of its initialization, it can assume that all
057: * initial references will be available at this point.
058: * <p/>
059: * Calling the <code>post_init</code> operations is not the final
060: * task of ORB initialization. The final task, following the
061: * <code>post_init</code> calls, is attaching the lists of registered
062: * interceptors to the ORB. Therefore, the ORB does not contain the
063: * interceptors during calls to <code>post_init</code>. If an
064: * ORB-mediated call is made from within <code>post_init</code>, no
065: * request interceptors will be invoked on that call.
066: * Likewise, if an operation is performed which causes an IOR to be
067: * created, no IOR interceptors will be invoked.
068: *
069: * @param info provides initialization attributes and
070: * operations by which Interceptors can be registered.
071: */
072: public void post_init(ORBInitInfo info) {
073:
074: try {
075: if (log.isDebugEnabled())
076: log
077: .debug("Registering interceptors and policy factories");
078:
079: ORBConfiguration config = Util.getRegisteredORB(info
080: .orb_id());
081:
082: try {
083: info
084: .add_client_request_interceptor(new ClientSecurityInterceptor());
085: info
086: .add_server_request_interceptor(new ServerSecurityInterceptor());
087: info.add_ior_interceptor(new IORSecurityInterceptor(
088: config.getTssConfig()));
089: } catch (DuplicateName dn) {
090: log.error("Error registering interceptor", dn);
091: }
092:
093: info.register_policy_factory(
094: ClientPolicyFactory.POLICY_TYPE,
095: new ClientPolicyFactory());
096: info.register_policy_factory(
097: ServerPolicyFactory.POLICY_TYPE,
098: new ServerPolicyFactory());
099: } catch (RuntimeException re) {
100: log.error("Error registering interceptor", re);
101: throw re;
102: }
103: }
104:
105: }
|