java: isac.util.tactics .. end renamed, formatted, inst_var_, import cleaned
2 * @author Walther Neuper, member of the ISAC-team,
3 * Copyright (c) 2005 by Walther Neuper
4 * created Mar 12, 2005 8:09:42 AM
5 * Institute for Softwaretechnology, Graz University of Technology, Austria.
7 * Use is subject to PGPL license terms.
9 package isac.util.users;
11 import java.io.FileInputStream;
12 import java.io.FileNotFoundException;
13 import java.io.FileOutputStream;
14 import java.io.IOException;
15 import java.util.Enumeration;
16 import java.util.Properties;
19 * @author Walther Neuper
21 * contains passwords looking forward to handle security issues elsewhere
24 public class Accounts extends Properties {
26 public Accounts(String userpath) {
27 String filename = userpath + "accounts.txt";
29 FileInputStream propInFile = new FileInputStream(filename);
30 this.load(propInFile);
31 this.list(System.out);
32 } catch (FileNotFoundException e) {
33 System.err.println("Can?t find " + filename);
34 } catch (IOException e) {
35 System.err.println("I/O failed.");
39 public boolean exists(String username) {
40 Enumeration keys = this.propertyNames();//WN050311 how better ?
42 while (keys.hasMoreElements()) {
43 key = (String) keys.nextElement();
44 if (key.compareTo(username) == 0)
50 //WN050311 just for creation of the first file
51 //beware of the fix path !
52 public static void main(String[] args) {
53 Accounts acs = new Accounts("isac/xmldata/users");
54 acs.setProperty("x", "x");
55 acs.setProperty("y", "y");
56 acs.setProperty("anonymous", "anonymous");
58 String filename = "isac/xmldata/users/accounts.txt";
60 FileOutputStream propOutFile = new FileOutputStream(filename);
61 acs.store(propOutFile, "the list of isac users");
63 } catch (IOException e) {
64 System.err.println("I/O failed.");