1 29 30 package hero.client.importLdap; 31 50 51 import hero.interfaces.BnLdap; 53 import hero.interfaces.BnLdapHome; 54 import hero.interfaces.BnLdapUtil; 55 56 import javax.security.auth.login.LoginContext ; 58 import javax.security.auth.login.LoginException ; 59 60 65 public class ClientUpdateBn { 66 67 70 public static void main(String args[]) { 71 72 75 char[] password = args[1].toCharArray(); 76 SimpleCallbackHandler handler = 77 new SimpleCallbackHandler(args[0], password); 78 try { 79 LoginContext lc = new LoginContext ("TestClient", handler); 80 lc.login(); 81 } catch (LoginException e) { 82 System.err.println("Error Client while trying the authentication"); 83 e.printStackTrace(); 84 85 } 86 87 BnLdapHome home = null; 89 try { 90 home = BnLdapUtil.getHome(); 91 } catch (Exception e) { 92 System.err.println("Cannot lookup BnLdapHome: " + e); 93 System.exit(2); 94 } 95 96 BnLdap t1 = null; 98 try { 99 System.out.println("Create a bean bnLdap"); 100 t1 = home.create(); 101 } catch (Exception e) { 102 System.err.println("Cannot create BnLdapBean : " + e); 103 System.exit(2); 104 } 105 106 109 110 try { 111 t1.importLdapUsers(); 112 } catch (Exception e) { 113 System.err.println("Error Importing users from Ldap to Bonita database: " + e); 114 System.exit(2); 115 } 116 117 118 121 try { 122 t1.remove(); 123 } catch (Exception 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 |