KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > security > iiop > Csiv2Initializer


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: Csiv2Initializer.java,v 1.1 2004/12/13 16:27:30 benoitf Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.security.iiop;
27
28 import org.omg.IOP.Codec JavaDoc;
29 import org.omg.IOP.ENCODING_CDR_ENCAPS JavaDoc;
30 import org.omg.IOP.Encoding JavaDoc;
31 import org.omg.IOP.CodecFactoryPackage.UnknownEncoding JavaDoc;
32 import org.omg.PortableInterceptor.ORBInitInfo JavaDoc;
33 import org.omg.PortableInterceptor.ORBInitializer JavaDoc;
34
35 import org.objectweb.carol.util.csiv2.SasPolicy;
36 import org.objectweb.carol.util.csiv2.SasPolicyFactory;
37
38 import org.objectweb.jonas.common.Log;
39
40 import org.objectweb.util.monolog.api.BasicLevel;
41 import org.objectweb.util.monolog.api.Logger;
42
43 /**
44  * Initializer of SAS interceptor
45  * @author Florent Benoit
46  */

47 public class Csiv2Initializer extends org.omg.CORBA.LocalObject JavaDoc implements ORBInitializer JavaDoc {
48
49     /**
50      * Logger
51      */

52     private static Logger logger = Log.getLogger(Log.JONAS_CSIV2_SECURITY_PREFIX);
53
54     /**
55      * Logger details (On catching exception)
56      */

57     private static Logger loggerDetails = Log.getLogger(Log.JONAS_CSIV2_DETAILS_SECURITY_PREFIX);
58
59     /**
60      * Called during ORB initialization. If a service must resolve initial
61      * references as part of its initialization, it can assume that all initial
62      * references will be available at this point.
63      * @param info provides initialization attributes and operations by which
64      * Interceptors can be registered.
65      */

66     public void post_init(ORBInitInfo JavaDoc info) {
67         // Interceptors (server, client, IOR)
68
if (logger.isLoggable(BasicLevel.DEBUG)) {
69             logger.log(BasicLevel.DEBUG, "Initializing SAS Interceptors");
70         }
71
72         // Codec for GIOP 1.2
73
Encoding JavaDoc encoding = new Encoding JavaDoc(ENCODING_CDR_ENCAPS.value, (byte) 1, (byte) 2);
74         Codec JavaDoc codec = null;
75         try {
76             codec = info.codec_factory().create_codec(encoding);
77         } catch (UnknownEncoding JavaDoc ue) {
78             String JavaDoc err = "Cannot use a given encoding : '" + ue.getMessage() + "'.";
79             logger.log(BasicLevel.ERROR, err);
80             throw new RuntimeException JavaDoc(err);
81         }
82
83         try {
84             info.add_server_request_interceptor(new Csiv2ServerInterceptor(codec, logger, loggerDetails));
85         } catch (Exception JavaDoc e) {
86             logger.log(BasicLevel.ERROR, "Unable to register CSIv2 server interceptor : '" + e.getMessage() + "'.");
87         }
88         try {
89             info.add_client_request_interceptor(new Csiv2ClientInterceptor(codec, logger, loggerDetails));
90         } catch (Exception JavaDoc e) {
91             logger.log(BasicLevel.ERROR, "Unable to register CSIv2 client interceptor : '" + e.getMessage() + "'.");
92         }
93
94         try {
95             info.add_ior_interceptor(new Csiv2IorInterceptor(codec, logger, loggerDetails));
96         } catch (Exception JavaDoc e) {
97             logger.log(BasicLevel.ERROR, "Unable to register CSIv2 IOR interceptor : '" + e.getMessage() + "'.");
98         }
99
100         // Factory
101
if (logger.isLoggable(BasicLevel.DEBUG)) {
102             logger.log(BasicLevel.DEBUG, "Initializing SAS policy factory");
103         }
104         info.register_policy_factory(SasPolicy.POLICY_TYPE, new SasPolicyFactory());
105
106     }
107
108     /**
109      * Called during ORB initialization. If it is expected that initial services
110      * registered by an interceptor will be used by other interceptors, then
111      * those initial services shall be registered at this point via calls to
112      * <code>ORBInitInfo.register_initial_reference</code>.
113      * @param info provides initialization attributes and operations by which
114      * Interceptors can be registered.
115      */

116     public void pre_init(ORBInitInfo JavaDoc info) {
117         // TODO Auto-generated method stub
118

119     }
120 }
Popular Tags