1 import org.openafs.jafs.ErrorTable;
6 * A common error testing class for the native methods
11 Properties properties;
12 String cellName = null;
13 String username = null;
14 String password = null;
16 org.openafs.jafs.Cell cellHandle;
17 org.openafs.jafs.Token token;
23 System.loadLibrary("pwd");
24 } catch (Exception e) {
30 AdminTest() throws Exception
32 InputStream in = new FileInputStream("adminTest.properties");
33 if (in == null) throw new FileNotFoundException("adminTest.properties");
34 properties = new Properties();
36 cellName = getProperty("cellName", cellName);
37 //username = getProperty("username", username);
38 //password = getProperty("password", password);
40 private String getProperty(String name, String dflt)
42 String p = properties.getProperty(name);
43 return (p == null) ? dflt : p;
45 private int getProperty(String name, int dflt)
47 String p = properties.getProperty(name);
52 return Integer.parseInt(p);
53 } catch (Exception e) {
59 private void authenticate() throws IOException
62 System.out.println(" [user: " + username + "@" + cellName + "]");
63 token = new org.openafs.jafs.Token( username, password, cellName );
64 cellHandle = new org.openafs.jafs.Cell( token );
65 } catch ( org.openafs.jafs.AFSException e ) {
66 System.out.println( "Unexpected Exception\n Error: " + ErrorTable.getMessage(e.getErrorCode()) +
67 "\n Cell: " + cellName + "\n Username: " + username);
72 private void listCell() throws Exception
75 System.out.println("======================================");
76 System.out.println("LISTING CELL INFO");
77 System.out.println("Total Number of Users: " + cellHandle.getUserCount());
78 System.out.println("Total Number of Groups: " + cellHandle.getGroupCount());
79 System.out.println("Total Number of Servers: " + cellHandle.getServerCount());
80 System.out.println("======================================");
81 } catch (Exception e) {
86 private void listUser(String name) throws Exception
89 System.out.println("Name is null!");
92 org.openafs.jafs.User[] users = cellHandle.getUsers();
94 System.out.println("Searching for user: " + name + "...");
95 for (int i = 0; i < users.length; i++) {
96 if (name.equals(users[i].getName())) {
97 System.out.println("User found!\n");
98 //System.out.println(users[i].getInfo());
99 System.out.println(users[i].toString());
100 System.out.println("Membership: " + users[i].getGroupMembershipCount());
101 System.out.println("Groups Owned: " + users[i].getGroupsOwnedCount());
105 System.out.println("User '" + name + "' could not be found!");
106 } catch (Exception e) {
111 private void listUsers() throws Exception
113 org.openafs.jafs.User[] users = cellHandle.getUsers();
115 System.out.println("======================================");
116 System.out.println("LISTING USERS");
117 for (int i = 0; i < users.length; i++) {
118 System.out.println("User " + i + " = " + users[i].getName());
120 System.out.println("======================================");
121 System.out.println("Total Number of Users: " + users.length);
122 } catch (Exception e) {
127 private void listGroup(String name) throws Exception
130 System.out.println("Name is null!");
133 org.openafs.jafs.Group[] groups = cellHandle.getGroups();
135 System.out.println("Searching for group: " + name + "...");
136 for (int i = 0; i < groups.length; i++) {
137 if (name.equals(groups[i].getName())) {
138 System.out.println("Group found!\n");
140 //System.out.println(groups[i].getInfo());
141 System.out.println(groups[i].toString());
142 System.out.println("Membership: " + groups[i].getMembershipCount());
146 System.out.println("Group '" + name + "' could not be found!");
147 } catch (Exception e) {
152 private void listGroups() throws Exception
154 org.openafs.jafs.Group[] groups = cellHandle.getGroups();
156 System.out.println("======================================");
157 System.out.println("LISTING GROUPS");
158 for (int i = 0; i < groups.length; i++) {
159 System.out.println("Group " + i + " = " + groups[i].getName());
161 System.out.println("======================================");
162 System.out.println("Total Number of Groups: " + groups.length);
163 } catch (Exception e) {
168 private void listGroupsX() throws Exception
170 org.openafs.jafs.Group[] groups = cellHandle.getGroups();
172 System.out.println("======================================");
173 System.out.println("LISTING GROUPS");
174 for (int i = 0; i < groups.length; i++) {
175 System.out.println("Group " + i + " = " + groups[i].getName());
177 System.out.println("======================================");
178 System.out.println("Total Number of Groups: " + groups.length);
179 } catch (Exception e) {
184 private void listServer(String name) throws Exception
187 System.out.println("Name is null!");
190 org.openafs.jafs.Server[] servers = cellHandle.getServers();
192 System.out.println("Searching for server: " + name + "...");
193 for (int i = 0; i < servers.length; i++) {
194 if (name.equals(servers[i].getName())) {
195 System.out.println("Server found!\n");
196 //System.out.println(servers[i].getInfo());
197 System.out.println(servers[i].toString());
198 System.out.println("# of Partition: " + servers[i].getPartitionCount());
199 System.out.println("# of Admins: " + servers[i].getAdminCount());
200 System.out.println("# of Keys: " + servers[i].getKeyCount());
201 System.out.println("# of Processes: " + servers[i].getProcessCount());
202 System.out.println("# of IP Addresses: " + servers[i].getIPAddresses().length);
203 for (int x = 0; x < servers[i].getIPAddresses().length; x++) {
204 System.out.println(" -> IP " + x + ": " + servers[i].getIPAddresses()[x]);
209 System.out.println("Server '" + name + "' could not be found!");
210 } catch (org.openafs.jafs.AFSException e) {
211 System.out.println("ERROR: " + ErrorTable.getMessage(e.getErrorCode()));
212 } catch (Exception e) {
217 private void listServers() throws Exception
219 org.openafs.jafs.Server[] servers = cellHandle.getServers();
221 System.out.println("======================================");
222 System.out.println("LISTING SERVERS");
223 for (int i = 0; i < servers.length; i++) {
224 System.out.println("Server " + i + " = " + servers[i].toString());
226 System.out.println("======================================");
227 System.out.println("Total Number of Servers: " + servers.length);
228 } catch (Exception e) {
234 private void listPartition(String name) throws Exception
237 System.out.println("Name is null!");
240 org.openafs.jafs.Server[] servers = cellHandle.getServers();
242 System.out.println("Searching for partition: " + name + "...");
243 for (int i = 0; i < servers.length; i++) {
244 System.out.println(" Server " + i + " = " + servers[i].getName());
245 if (!servers[i].isFileServer() || servers[i].isBadFileServer()) {
246 System.out.println(" (not a file server)");
248 org.openafs.jafs.Partition[] partitions = servers[i].getPartitions();
249 for (int p = 0; p < partitions.length; p++) {
250 if (name.equals(partitions[p].getName())) {
251 System.out.println("Partition found!\n");
252 //System.out.println(partitions[p].getInfo());
253 System.out.println(partitions[p].toString());
254 System.out.println("Volume count: " + partitions[i].getVolumeCount());
259 System.out.println("Done");
260 } catch (Exception e) {
265 private void listPartitions() throws Exception
268 org.openafs.jafs.Server[] servers = cellHandle.getServers();
270 System.out.println("======================================");
271 System.out.println("LISTING PARTITIONS");
272 for (int i = 0; i < servers.length; i++) {
273 System.out.println("Server " + i + " = " + servers[i].getName());
274 if (!servers[i].isFileServer() || servers[i].isBadFileServer()) {
275 System.out.println(" (not a file server)");
277 org.openafs.jafs.Partition[] partitions = servers[i].getPartitions();
278 n += partitions.length;
279 for (int p = 0; p < partitions.length; p++) {
280 System.out.println(" Partition " + p + " = " + partitions[p].toString());
284 System.out.println("======================================");
285 System.out.println("Total Number of Servers: " + servers.length);
286 System.out.println("Total Number of Partitions: " + n);
287 } catch (Exception e) {
293 private void enumeratePartitions(String serverName, int start, int end) throws Exception
296 org.openafs.jafs.Server server = cellHandle.getServer(serverName);
298 System.out.println("======================================");
299 System.out.println("ENUMERATING PARTITIONS FROM " + start + " to " + end);
300 Enumeration e = server.getPartitionEnumeration();
303 while (e.hasMoreElements()) {
304 System.out.println(" " + i + " -> " + e.nextElement());
306 //if (i >= end) break;
309 System.out.println("======================================");
310 } catch (Exception e) {
316 private void listVolume(String name) throws Exception
319 System.out.println("Name is null!");
322 org.openafs.jafs.Server[] servers = cellHandle.getServers();
324 System.out.println("Searching for volume: " + name + "...");
325 for (int i = 0; i < servers.length; i++) {
326 System.out.println(" Server " + i + " = " + servers[i].getName());
327 if (!servers[i].isFileServer() || servers[i].isBadFileServer()) {
328 System.out.println(" (not a file server)");
330 org.openafs.jafs.Partition[] partitions = servers[i].getPartitions();
331 for (int p = 0; p < partitions.length; p++) {
332 System.out.println(" Partition " + p + " = " + partitions[p].getName());
333 org.openafs.jafs.Volume[] volumes = partitions[p].getVolumes();
334 for (int v = 0; v < volumes.length; v++) {
335 if (name.equals(volumes[v].getName())) {
336 System.out.println(" Volume found!\n");
337 //System.out.println(volumes[v].getInfo());
338 System.out.println(volumes[v].toString());
339 System.out.println("Quota: " + volumes[v].getQuota());
345 System.out.println("Done");
346 } catch (Exception e) {
351 private void listVolumes() throws Exception
355 org.openafs.jafs.Server[] servers = cellHandle.getServers();
357 System.out.println("======================================");
358 System.out.println("LISTING PARTITIONS");
359 for (int i = 0; i < servers.length; i++) {
360 System.out.println("Server " + i + " = " + servers[i].getName());
361 if (!servers[i].isFileServer() || servers[i].isBadFileServer()) {
362 System.out.println(" (not a file server)");
364 org.openafs.jafs.Partition[] partitions = servers[i].getPartitions();
365 nP += partitions.length;
366 for (int p = 0; p < partitions.length; p++) {
367 System.out.println(" Partition " + p + " = " + partitions[p].getName());
368 org.openafs.jafs.Volume[] volumes = partitions[p].getVolumes();
369 nV += volumes.length;
370 for (int v = 0; v < volumes.length; v++) {
371 System.out.println(" Volume " + v + " = " + volumes[v].getName());
376 System.out.println("======================================");
377 System.out.println("Total Number of Servers: " + servers.length);
378 System.out.println("Total Number of Partitions: " + nP);
379 System.out.println("Total Number of Volumes: " + nV);
380 } catch (Exception e) {
386 private void enumerateVolumes(String serverName, String partitionName, int start, int length) throws Exception
390 org.openafs.jafs.Server server = cellHandle.getServer(serverName);
391 org.openafs.jafs.Partition partition = server.getPartition(partitionName);
393 System.out.println("======================================");
394 System.out.println("ENUMERATING PARTITIONS FROM " + start + " to " + (start + length));
395 Enumeration e = partition.getVolumeEnumeration(start);
398 while (e.hasMoreElements()) {
399 System.out.println(" " + i + " -> " + e.nextElement());
402 if (n >= length) break;
405 System.out.println("======================================");
406 } catch (Exception e) {
412 private void listProcess(String name) throws Exception
415 System.out.println("Name is null!");
418 org.openafs.jafs.Server[] servers = cellHandle.getServers();
420 System.out.println("Searching for process: " + name + "...");
421 for (int i = 0; i < servers.length; i++) {
422 System.out.println(" Server " + i + " = " + servers[i].getName());
423 org.openafs.jafs.Process[] processes = servers[i].getProcesses();
424 for (int p = 0; p < processes.length; p++) {
425 if (name.equals(processes[p].getName())) {
426 System.out.println("Process found!\n");
427 //System.out.println(processes[p].getInfo());
428 System.out.println(processes[p].toString());
432 System.out.println("Done");
433 } catch (Exception e) {
438 private void listProcesses() throws Exception
441 org.openafs.jafs.Server[] servers = cellHandle.getServers();
443 System.out.println("======================================");
444 System.out.println("LISTING PROCESSES");
445 for (int i = 0; i < servers.length; i++) {
446 System.out.println("Server " + i + " = " + servers[i].getName());
447 org.openafs.jafs.Process[] processes = servers[i].getProcesses();
448 n += processes.length;
449 for (int p = 0; p < processes.length; p++) {
450 System.out.println(" Process " + p + " = " + processes[p].getName());
453 System.out.println("======================================");
454 System.out.println("Total Number of Servers: " + servers.length);
455 System.out.println("Total Number of Processes: " + n);
456 } catch (Exception e) {
461 private void listACL(String path) throws Exception
464 System.out.println("======================================");
465 System.out.println("LISTING ACL for: \n\t" + path);
468 org.openafs.jafs.ACL acl = new org.openafs.jafs.ACL(path);
469 System.out.println(acl.toString());
471 System.out.println("======================================");
472 } catch (org.openafs.jafs.AFSException e) {
473 System.out.println("AFS Error: " + e.getMessage());
474 } catch (Exception e) {
479 private void setACL(String path) throws Exception
482 System.out.println("======================================");
483 System.out.println("SETTING ACL for: \n\t" + path);
487 org.openafs.jafs.ACL acl = new org.openafs.jafs.ACL(path);
488 System.out.println(acl.toString());
490 org.openafs.jafs.ACL.Entry entry = new org.openafs.jafs.ACL.Entry( username, 29 );
491 acl.addPositiveEntry(entry);
493 System.out.println("Adding ACL entry: " + entry + "\n");
494 System.out.println("ACL after modifications:");
495 System.out.println(acl.toString());
497 System.out.println("======================================");
498 } catch (org.openafs.jafs.AFSException e) {
499 System.out.println("AFS Error: " + e.getMessage());
500 } catch (Exception e) {
505 private void listDir(String path) throws Exception
508 System.out.println("======================================");
509 System.out.println("LISTING Directory for: \n\t" + path);
513 org.openafs.jafs.File file = new org.openafs.jafs.File(path);
514 String[] e = file.list();
516 System.out.println( file.getErrorMessage() );
518 for (int i = 0; i < e.length; i++) {
519 System.out.println(e[i]);
523 System.out.println("======================================");
524 } catch (org.openafs.jafs.AFSSecurityException e) {
525 System.out.println("AFS Security Error: " + e.getMessage());
526 } catch (org.openafs.jafs.AFSException e) {
527 System.out.println("AFS Error: " + e.getMessage());
528 } catch (Exception e) {
533 private void setUserGroupQuota() throws Exception
535 org.openafs.jafs.User user = cellHandle.getUser( username );
537 System.out.println("======================================");
538 System.out.println("SETTING GROUP QUOTA FOR " + user.getName());
539 user.setGroupCreationQuota(-1);
540 user.setGroupCreationQuota(20);
541 user.setGroupCreationQuota(0);
542 System.out.println("======================================");
543 } catch (Exception e) {
548 private void salvage(String name, String serverName, String partitionName) throws Exception
550 org.openafs.jafs.Server server = cellHandle.getServer(serverName);
551 org.openafs.jafs.Partition partition = server.getPartition(partitionName);
552 org.openafs.jafs.Volume volume = partition.getVolume(name);
554 System.out.println("======================================");
555 System.out.println("SALVAGING VOLUME " + volume.getName());
557 System.out.println("======================================");
558 } catch (Exception e) {
563 private void release(String name, String serverName, String partitionName) throws Exception
565 org.openafs.jafs.Server server = cellHandle.getServer(serverName);
566 org.openafs.jafs.Partition partition = server.getPartition(partitionName);
567 org.openafs.jafs.Volume volume = partition.getVolume(name);
569 System.out.println("======================================");
570 System.out.println("RELEASING VOLUME " + volume.getName());
572 System.out.println("======================================");
573 } catch (Exception e) {
578 private void createReadOnly(String name, String serverName, String partitionName) throws Exception
580 org.openafs.jafs.Server server = cellHandle.getServer(serverName);
581 org.openafs.jafs.Partition partition = server.getPartition(partitionName);
582 org.openafs.jafs.Volume volume = partition.getVolume(name);
584 System.out.println("======================================");
585 System.out.println("CREATING READ-ONLY REPLICA OF VOLUME " + volume.getName());
586 //volume.createReadOnly(cellHandle.getServer(server), cellHandle.getPartition(server, partition));
587 //volume.create( cellHandle, vosHandle, -1, newVolumeName, 0 );
588 volume.createReadOnly(partition);
589 System.out.println("======================================");
590 } catch (Exception e) {
595 private void createBackup(String name, String serverName, String partitionName) throws Exception
597 org.openafs.jafs.Server server = cellHandle.getServer(serverName);
598 org.openafs.jafs.Partition partition = server.getPartition(partitionName);
599 org.openafs.jafs.Volume volume = partition.getVolume(name);
601 System.out.println("======================================");
602 System.out.println("CREATING BACKUP REPLICA OF VOLUME " + volume.getName());
603 volume.createBackup();
604 System.out.println("======================================");
605 } catch (Exception e) {
612 * takes in String representing a system command, executes it,
613 * and waits for it to finish.
617 private void execute( String command ) throws IOException
619 //System.out.println( "Executing: " + command );
620 java.lang.Process proc = Runtime.getRuntime().exec( command );
621 // System.out.println( command );
624 } catch ( InterruptedException e ) {
625 throw new IOException( "Interrupted system command: " + command );
629 private void printVersionInfo() throws Exception
631 System.out.println("JAFS native library build information:");
632 System.out.println("\tDescription: " + org.openafs.jafs.VersionInfo.getDescription());
633 System.out.println("\tBuild Platform: " + org.openafs.jafs.VersionInfo.getBuildPlatform());
634 System.out.println("\tBuild Time: " + org.openafs.jafs.VersionInfo.getBuildDate());
635 System.out.println("\tBuild Number: " + org.openafs.jafs.VersionInfo.getBuildNumber());
636 System.out.println("\tBuild Version: " + org.openafs.jafs.VersionInfo.getVersion());
637 System.out.println("\tFull Version: " + org.openafs.jafs.VersionInfo.getFullVersion());
641 * Get password from native library
643 //private static native String getNativePassword();
645 private static String getPassword() throws IOException
648 MaskingThread mt = new MaskingThread( "Please enter your AFS password: " );
649 Thread t = new Thread( mt );
653 char c = (char)System.in.read();
656 c = (char) System.in.read();
662 } else if ( c == '\n' ) {
671 private static String getUsername()
673 System.out.print("Please enter your AFS username: ");
674 BufferedReader r = new BufferedReader( new InputStreamReader(System.in) );
677 } catch (Exception e) {
678 System.out.println("Error trying to read your username.");
684 private static void printUsage()
686 System.out.println("Usage:");
687 System.out.println(" AdminTest [auth] [cell] [user] [group] [server]");
688 System.out.println(" [partition] [volume] [key] [process]");
689 System.out.println("");
690 System.out.println(" AdminTest [list users] [list user <username>]");
691 System.out.println(" [list groups] [list group <group name>]");
692 System.out.println(" [list servers] [list server <server name>]");
693 System.out.println(" [list partitions] [list partition <partition name>]");
694 System.out.println(" [list volumes] [list volume <volume name>]");
695 System.out.println(" [list processes] [list process <process name>]");
696 System.out.println(" [list cell]");
697 System.out.println(" [list dir <path>]");
698 System.out.println(" [list acl <path>]");
699 System.out.println(" [set acl <path>]");
700 System.out.println(" [enum partitions <server> <start> <length>]");
701 System.out.println(" [enum volumes <server> <partition> <start> <length>]");
702 System.out.println(" [vol salvage <volume name> <server> <partition>]");
703 System.out.println(" [vol backup <volume name> <server> <partition>]");
704 System.out.println(" [vol release <volume name> <server> <partition>]");
705 System.out.println(" [vol replicate <volume name> <server> <partition>]");
706 System.out.println("");
707 System.out.println(" -v or -version Display version of JAFS library");
708 System.out.println("");
709 System.out.println(" -u <username>");
710 System.out.println(" -p <password>");
711 System.out.println("");
712 System.out.println("Example:");
713 System.out.println(" AdminTest list users -u admin -p testpass");
714 System.out.println("\nie: AdminTest cell\nThe above example will run the AdminTest program,\ntesting 'cell' functionality.");
716 public static void main(String[] args) throws Exception
718 AdminTest at = new AdminTest();
720 for (int i = 0; i < args.length; i++) {
721 if (args[i].startsWith("-h") || args[i].startsWith("h")) {
724 } else if (args[i].equals("-u")) {
726 at.username = args[i];
727 } else if (args[i].equals("-p")) {
729 at.password = args[i];
730 } else if (args[i].equals("-g") || args[i].equals("--graphical")) {
732 PasswordPrompt p = new PasswordPrompt("AFS Admin Account");
734 String[] info = new String[2];
735 while ( p.isShowing() ) {
739 p.setUserInfo( info );
740 at.username = info[0];
741 at.password = info[1];
742 } catch (Exception e2) {
745 } else if (args[i].equals("-v") || args[i].equals("-version")) {
747 at.printVersionInfo();
752 if ( at.username == null ) at.username = getUsername();
753 if ( at.password == null ) at.password = getPassword();
757 if ( args.length > 0 ) run( at, args );
761 System.out.print("Command: ");
762 BufferedReader r = new BufferedReader( new InputStreamReader(System.in) );
764 run( at, split( r.readLine() ) );
765 } catch (Exception e) {
766 System.out.println("Error trying to read command.");
770 } catch (ArrayIndexOutOfBoundsException e) {
774 private static void run( AdminTest at, String[] args ) throws Exception
777 for (int i = 0; i < args.length; i++) {
778 if (args[i].equals("auth")) {
779 System.out.println("not available");
781 } else if (args[i].equals("enum")) {
783 if (args[i].equals("partitions")) {
784 String serverName = args[i++];
785 int start = Integer.parseInt(args[i++]);
786 int end = Integer.parseInt(args[i++]);
787 at.enumeratePartitions(serverName, start, end);
788 } else if (args[i].equals("volumes")) {
789 String serverName = args[++i];
790 String partitionName = args[++i];
791 int start = Integer.parseInt(args[++i]);
792 int end = Integer.parseInt(args[++i]);
793 at.enumerateVolumes(serverName, partitionName, start, end);
796 } else if (args[i].equals("list")) {
798 if (args[i].equals("users")) {
800 } else if (args[i].equals("user")) {
802 at.listUser(args[i]);
803 } else if (args[i].equals("groups")) {
805 } else if (args[i].equals("groupsx")) {
807 } else if (args[i].equals("group")) {
809 at.listGroup(args[i]);
810 } else if (args[i].equals("servers")) {
812 } else if (args[i].equals("server")) {
814 at.listServer(args[i]);
815 } else if (args[i].equals("partitions")) {
817 } else if (args[i].equals("partition")) {
819 at.listPartition(args[i]);
820 } else if (args[i].equals("volumes")) {
822 } else if (args[i].equals("volume")) {
824 at.listVolume(args[i]);
825 } else if (args[i].equals("processes")) {
827 } else if (args[i].equals("process")) {
829 at.listProcess(args[i]);
830 } else if (args[i].equals("cell")) {
832 } else if (args[i].equals("acl")) {
835 } else if (args[i].equals("dir")) {
839 } else if (args[i].equals("set")) {
841 if (args[i].equals("user")) {
843 if (args[i].equals("group-quota")) {
844 at.setUserGroupQuota();
846 } else if (args[i].equals("group")) {
847 } else if (args[i].equals("acl")) {
851 } else if (args[i].equals("vol")) {
853 if (args[i].equals("salvage")) {
855 String name = args[i];
857 String server = args[i];
859 String partition = args[i];
860 at.salvage(name, server, partition);
861 } else if (args[i].equals("backup")) {
863 String name = args[i];
865 String server = args[i];
867 String partition = args[i];
868 at.createBackup(name, server, partition);
869 } else if (args[i].equals("release")) {
871 String name = args[i];
873 String server = args[i];
875 String partition = args[i];
876 at.release(name, server, partition);
877 } else if (args[i].equals("replicate")) {
879 String name = args[i];
881 String server = args[i];
883 String partition = args[i];
884 at.createReadOnly(name, server, partition);
886 } else if (args[i].equals("cell")) {
888 System.out.println("Not Available");
889 } else if (args[i].equals("user")) {
891 System.out.println("Not Available");
892 } else if (args[i].equals("group")) {
894 System.out.println("Not Available");
895 } else if (args[i].equals("server")) {
897 System.out.println("Not Available");
898 } else if (args[i].equals("partition") || args[i].equals("part")) {
899 //at.testPartition();
900 System.out.println("Not Available");
901 } else if (args[i].equals("volume")) {
903 System.out.println("Not Available");
904 } else if (args[i].equals("key")) {
906 System.out.println("Not Available");
907 } else if (args[i].equals("process") || args[i].equals("proc")) {
909 System.out.println("Not Available");
910 } else if (args[i].equals("h") || args[i].equals("help")) {
912 } else if (args[i].equals("q") || args[i].equals("quit")) {
914 } else if (args[i].equals("-u") || args[i].equals("-p")) {
916 } else if (args[i].equals("-g") || args[i].equals("--graphical")) {
919 System.out.println("Invalid Argument: " + args[i]);
922 } catch (ArrayIndexOutOfBoundsException e) {
927 private static String[] split( String str )
930 StringTokenizer st = new StringTokenizer(str);
931 String[] tokens = new String[st.countTokens()];
932 while (st.hasMoreTokens()) {
933 tokens[i++] = st.nextToken().trim();
938 private static class MaskingThread extends Thread
940 private boolean stop = false;
942 private String prompt;
944 public MaskingThread( String prompt )
946 this.prompt = prompt;
953 MaskingThread.sleep(1);
954 } catch (InterruptedException e ) {
958 System.out.print("\r" + prompt );
963 public void stopMasking()