KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > iiop > csiv2 > SASClientInitializer


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.iiop.csiv2;
23
24 /***************************************
25  * *
26  * JBoss: The OpenSource J2EE WebOS *
27  * *
28  * Distributable under LGPL license. *
29  * See terms of license at gnu.org. *
30  * *
31  ***************************************/

32
33 import org.omg.CORBA.LocalObject JavaDoc;
34 import org.omg.IOP.Codec JavaDoc;
35 import org.omg.IOP.ENCODING_CDR_ENCAPS JavaDoc;
36 import org.omg.IOP.Encoding JavaDoc;
37 import org.omg.PortableInterceptor.ORBInitInfo JavaDoc;
38 import org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName JavaDoc;
39 import org.omg.PortableInterceptor.ORBInitializer JavaDoc;
40
41 /**
42  * This is an <code>org.omg.PortableInterceptor.ORBInitializer</code> that
43  * initializes the Security Attibute Service (SAS).
44  *
45  * @author <a HREF="mailto:reverbel@ime.usp.br">Francisco Reverbel</a>
46  * @version $Revision: 37459 $
47  */

48 public class SASClientInitializer
49    extends LocalObject JavaDoc
50    implements ORBInitializer JavaDoc
51 {
52
53    public SASClientInitializer()
54    {
55       // do nothing
56
}
57     
58    // org.omg.PortableInterceptor.ORBInitializer operations ---------
59

60    public void pre_init(ORBInitInfo JavaDoc info)
61    {
62       try
63       {
64          // Create and register the SASCurrent
65
SASCurrent sasCurrent = new SASCurrentImpl();
66          info.register_initial_reference("SASCurrent", sasCurrent);
67
68          // The SASCurrent still needs to be initialized.
69
// Its initialization is deferred to post_init, as it needs
70
// to call resolve_initial_references.
71
}
72       catch(InvalidName JavaDoc e)
73       {
74          throw new RuntimeException JavaDoc("Could not register initial " +
75             "reference for SASCurrent: " + e);
76       }
77    }
78
79    public void post_init(ORBInitInfo JavaDoc info)
80    {
81       try
82       {
83          org.omg.CORBA.Object JavaDoc obj;
84
85          // Use CDR encapsulations with GIOP 1.0 encoding
86
Encoding JavaDoc encoding = new Encoding JavaDoc(ENCODING_CDR_ENCAPS.value,
87             (byte) 1, /* GIOP version */
88             (byte) 0 /* GIOP revision*/);
89          Codec JavaDoc codec = info.codec_factory().create_codec(encoding);
90             
91          // Create and register client interceptor
92
obj = info.resolve_initial_references("SASCurrent");
93          SASCurrentImpl sasCurrentImpl = (SASCurrentImpl) obj;
94          SASClientInterceptor clientInterceptor =
95             new SASClientInterceptor(codec);
96          info.add_client_request_interceptor(clientInterceptor);
97
98          // Create and register server interceptor
99
SASTargetInterceptor serverInterceptor =
100             new SASTargetInterceptor(codec);
101          info.add_server_request_interceptor(serverInterceptor);
102  
103          // Initialize the SASCurrent implementation
104
sasCurrentImpl.init(serverInterceptor);
105       }
106       catch(Exception JavaDoc e)
107       {
108          throw new RuntimeException JavaDoc("Unexpected " + e);
109       }
110    }
111
112 }
113
Popular Tags