01: ///////////////////////////////////////////////////////////////////////////////
02: //
03: // Copyright (C) 2003-@year@ by Thomas M. Hazel, MyOODB (www.myoodb.org)
04: //
05: // All Rights Reserved
06: //
07: // This program is free software; you can redistribute it and/or modify
08: // it under the terms of the GNU General Public License and GNU Library
09: // General Public License as published by the Free Software Foundation;
10: // either version 2, or (at your option) any later version.
11: //
12: // This program 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
15: // GNU General Public License and GNU Library General Public License
16: // for more details.
17: //
18: // You should have received a copy of the GNU General Public License
19: // and GNU Library General Public License along with this program; if
20: // not, write to the Free Software Foundation, 675 Mass Ave, Cambridge,
21: // MA 02139, USA.
22: //
23: ///////////////////////////////////////////////////////////////////////////////
24: package org.myoodb.admin;
25:
26: import org.myoodb.objects.*;
27:
28: public class Client {
29: public static int PORT = 54321;
30: public static String USERNAME = "admin";
31: public static String PASSWORD = "admin";
32:
33: public static void main(String args[]) throws Exception {
34: org.myoodb.MyOodbDatabase db = org.myoodb.MyOodbDatabase.open(
35: "tcp://localhost:" + PORT, USERNAME, PASSWORD);
36:
37: AdministratorManager administratorManager = (AdministratorManager) db
38: .getRoot("AdministratorManager");
39: if (administratorManager == null) {
40: administratorManager = (AdministratorManager) db
41: .createRoot("AdministratorManager",
42: "org.myoodb.objects.AdministratorManagerDbImpl");
43: //administratorManager = (AdministratorManager) db.createRoot("AdministratorManager", AdministratorManagerDbImpl.class);
44: }
45:
46: administratorManager.createUser("John Smith", "Happy Days");
47:
48: System.out.println("Created User Johm Smith with a password");
49:
50: if (administratorManager.isUserPassword("John Smith",
51: "Happy Days") == true) {
52: System.out.println("Yep, User John has a password");
53: } else {
54: System.out
55: .println("What is up, User John's password did not take");
56: }
57:
58: db.close();
59: db = org.myoodb.MyOodbDatabase.open("tcp://localhost:" + PORT,
60: "John Smith", "Happy Days");
61:
62: System.out.println("Logged in as User Johm Smith");
63:
64: db.close();
65: db = org.myoodb.MyOodbDatabase.open("tcp://localhost:" + PORT,
66: USERNAME, PASSWORD);
67:
68: administratorManager = (AdministratorManager) db
69: .getRoot("AdministratorManager");
70: administratorManager.deleteUser("John Smith");
71:
72: System.out.println("Deleted User Johm Smith");
73: }
74: }
|