KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > carol > util > csiv2 > SasHelper


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: SasHelper.java,v 1.1 2004/12/13 16:24:13 benoitf Exp $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.carol.util.csiv2;
26
27 import java.rmi.Remote JavaDoc;
28 import java.util.Hashtable JavaDoc;
29
30 import javax.naming.InitialContext JavaDoc;
31 import javax.naming.NamingException JavaDoc;
32
33 import org.objectweb.carol.jndi.spi.JacORBIIOPContext;
34
35 /**
36  * Utility class for binding object with Csiv2 policy
37  * @author Florent Benoit
38  */

39 public class SasHelper {
40
41     /**
42      * Utility class, no public constructor
43      */

44     private SasHelper() {
45
46     }
47
48     /**
49      * Allow to bind object to registry with a given SAS component.
50      * <p> Use for CsiV2 policy binding
51      * @param jndiName the name to bind for registry
52      * @param remoteObj the object to bind
53      * @param sasComponent the object containing CsiV2 compound sec mech configuration
54      * @throws NamingException if the bound cannot be done
55      */

56     public static void rebind(String JavaDoc jndiName, Remote JavaDoc remoteObj, SasComponent sasComponent) throws NamingException JavaDoc {
57         if (sasComponent != null) {
58             Hashtable JavaDoc env = new Hashtable JavaDoc();
59             env.put(JacORBIIOPContext.SAS_COMPONENT, sasComponent);
60             new InitialContext JavaDoc(env).rebind(jndiName, remoteObj);
61         } else {
62             new InitialContext JavaDoc().rebind(jndiName, remoteObj);
63         }
64     }
65
66 }
Popular Tags