KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > client > importLdap > ClientUpdateBn


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

29
30 package hero.client.importLdap;
31 /*
32 *
33 * ClientUpdateBn.java
34 *
35 *
36 * This program is free software; you can redistribute it and/or
37 * modify it under the terms of the GNU Lesser General Public License
38 * as published by the Free Software Foundation; either version 2
39 * of the License, or (at your option) any later version.
40 *
41 * This program is distributed in the hope that it will be useful,
42 * but WITHOUT ANY WARRANTY; without even the implied warranty of
43 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44 * GNU Lesser General Public License for more details.
45 *
46 * You should have received a copy of the GNU Lesser General Public License
47 * along with this program; if not, write to the Free Software
48 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
49 */

50
51 // utilisation du BnLdap Bean
52
import hero.interfaces.BnLdap;
53 import hero.interfaces.BnLdapHome;
54 import hero.interfaces.BnLdapUtil;
55
56 // for J2EE security / for authentication with projectManagerBean
57
import javax.security.auth.login.LoginContext JavaDoc;
58 import javax.security.auth.login.LoginException JavaDoc;
59
60 /**
61  * Sample for Session Bean.
62  * Usage:
63  * java bnldap.ClientUpdateBn
64  */

65 public class ClientUpdateBn {
66
67     /****************************************************************
68                 main
69      ***************************************************************/

70     public static void main(String JavaDoc args[]) {
71
72         /****************************
73             Authentication
74         *****************************/

75         char[] password = args[1].toCharArray();
76         SimpleCallbackHandler handler =
77             new SimpleCallbackHandler(args[0], password);
78         try {
79             LoginContext JavaDoc lc = new LoginContext JavaDoc("TestClient", handler);
80             lc.login();
81         } catch (LoginException JavaDoc e) {
82             System.err.println("Error Client while trying the authentication");
83             e.printStackTrace();
84
85         }
86
87         // Connecting to BnLdapHome thru JNDI
88
BnLdapHome home = null;
89         try {
90             home = BnLdapUtil.getHome();
91         } catch (Exception JavaDoc e) {
92             System.err.println("Cannot lookup BnLdapHome: " + e);
93             System.exit(2);
94         }
95
96     // BnLdapBean creation
97
BnLdap t1 = null;
98     try {
99         System.out.println("Create a bean bnLdap");
100         t1 = home.create();
101     } catch (Exception JavaDoc e) {
102         System.err.println("Cannot create BnLdapBean : " + e);
103         System.exit(2);
104     }
105                 
106     /*******************************
107     Import users in bonita database
108     ********************************/

109         
110     try {
111     t1.importLdapUsers();
112     } catch (Exception JavaDoc e) {
113         System.err.println("Error Importing users from Ldap to Bonita database: " + e);
114         System.exit(2);
115     }
116                 
117     
118     /**********************
119        Remove Session Bean: BnLdapbean
120      **********************/

121     try {
122         t1.remove();
123     } catch (Exception JavaDoc e) {
124         System.out.println("Exception removing the BnLdap bean: "+e);
125         System.exit(2);
126     }
127     System.out.println("BnLdapbean removed.");
128     }
129
130
131
132 }
133
134     
135
Popular Tags