[Webfunds-commits] java/webfunds/sox Account.java

Ian Grigg iang@cypherpunks.ai
Wed, 11 Apr 2001 15:14:25 -0400 (AST)


iang        01/04/11 15:14:24

  Modified:    webfunds/sox Account.java
  Log:
  cleanup, diags, changed "issuer" to "server",
  example uses Utils.exampleKeyPair() ...

Revision  Changes    Path
1.74      +35 -29    java/webfunds/sox/Account.java

Index: Account.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/Account.java,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- Account.java	2001/03/18 23:23:12	1.73
+++ Account.java	2001/04/11 19:14:24	1.74
@@ -1,4 +1,4 @@
-/* $Id: Account.java,v 1.73 2001/03/18 23:23:12 iang Exp $
+/* $Id: Account.java,v 1.74 2001/04/11 19:14:24 iang Exp $
  *
  * Copyright (c) Systemics Inc. 1995-2000 on behalf of
  * The WebFunds Development Team. All rights reserved.
@@ -27,7 +27,7 @@
  * information, except perhaps for holding a key passphrase,
  * which is not stored in the Store (only in a runtime object).
  *
- * @version $Revision: 1.73 $
+ * @version $Revision: 1.74 $
  * @author  Jeroen C. van Gelderen (gelderen@webfunds.org)
  * @author  Unknown
  */
@@ -83,7 +83,11 @@
     public void         setFlags(long f)  { flags |= f; }
     public boolean      isFlags(long f)   { return (flags & f) == f; }
 
-    static void logmsg(String s)                { System.err.println(s) ; }
+    
+    protected static final String TAB = "       ",
+                                  fix = "Ac: ",
+                                  NL = "\n" + TAB + fix;
+    static void logmsg(String s)        { System.err.println(TAB + fix + s) ; }
 
     /**
      * The public key that verifies account transactions.
@@ -119,8 +123,9 @@
     protected Hashtable subs = new Hashtable();
 
     /**
-     * Subaccounts need some way to find an Issuer for an Item.
-     * The Issuer doesn't do anything until asked.
+     * Subaccounts need some way to find a SOX Server for an Item.
+     * The SOX Server doesn't do anything until asked.
+     * XXX: change Issuer all to Server.
      */
     protected IssuerFinder finder = null;
     public IssuerFinder getFinder()            { return finder ; }
@@ -332,19 +337,19 @@
     }
 
     /**
-     * To add a sub into the account.
-     * Passive, no initialisation.
+     *  To add a sub into the account.
+     *  Passive, no initialisation.
      */
     public void insertSub(SubAccount sub)
     {
-        sub.setAccount(this);      // I know how to find issuers.
+        sub.setAccount(this);      // I know how to find SOX Servers.
         ItemId item = sub.getItemId();
         subs.put(item, sub);
     }
 
 
     /**
-     * To add a new sub into the account.
+     *  Add a new sub into the account and initialise it.
      */
     public void newSub(SubAccount sub)
         throws SOXSubAccountException, SOXAccountException
@@ -501,7 +506,7 @@
                            webfunds.utils.Hex.printable(type.getBytes()) +
                            "  (" +
                               ((buf==null) ? "<null?>" : (buf.length+" bytes"))
-                           + ")\n" + ex);
+                           + ")" + NL + ex);
                     continue ;
                 }
 
@@ -512,7 +517,7 @@
                 try {
                     obj = cuss.getConstructor(argTypes).newInstance(argObjs);
                 } catch (Exception ex) {
-                    logmsg("not a known class (" + i + "): " + type + "\n"+ex);
+                    logmsg("not a known class (" + i + "): " + type + NL + ex);
                     continue ;
                 }
 
@@ -532,7 +537,7 @@
             return false ;
 
         Account other = (Account)obj;
-logmsg("1");
+// logmsg("1");
 
         AccountId otherId; 
         otherId = other.getId(); 
@@ -547,22 +552,22 @@
                 return false ;
         }
 
-logmsg("2");
+// logmsg("2");
         String hisName = other.getName();
         if (name == null)
         {
-logmsg("2.a <<" + hisName + ">>");
+// logmsg("2.a <<" + hisName + ">>");
             if (hisName != null)
                 return false ;
         }
         else
         {
-logmsg("2.b " + name );
+// logmsg("2.b " + name );
             if (!name.equals(hisName))
                 return false ;
         }
 
-logmsg("4");
+// logmsg("4");
         String hisAppl = other.getApplication();
         if (appl == null)
         {
@@ -575,11 +580,11 @@
                 return false ;
         }
 
-logmsg("6");
+// logmsg("6");
         if (flags != other.flags)
             return false;
 
-logmsg("7");
+// logmsg("7");
         //int nel = this.getItemIds().length;
         //int len = other.getItemIds().length;
         if (other.getItemIds().length != subs.size())
@@ -587,7 +592,7 @@
             return false ;
         }
 
-logmsg("8");
+// logmsg("8");
         SubAccount[] mySubs  =  this.getSubAccounts();
         for (int i = 0; i < mySubs.length; i++)
         {
@@ -600,7 +605,7 @@
 
             // doesn't cope with duplicates in mySubs and extras in hisSubs!
         }
-logmsg("9");
+// logmsg("9");
         
 
         return true;
@@ -611,11 +616,12 @@
      */
     public String toString()
     {
-        String s = "Account: " + name + " (flags==" + flags +")\n";
-        s += "\tappl==" + appl + "\n";
+        String s = "Account: " + name + " (flags==" + flags +")";
+        s += " [appl==" + appl + "]";
 
-        s += "\tPublic: "+pubKey+"\n";
-        s += "\tPrivate: "+key;
+        // s += "\tPublic: "+pubKey+"\n";
+        // s += "\tPrivate: "+key;
+
         return s;
     }
 
@@ -623,12 +629,12 @@
 
     public static Account example()
     {
-        java.security.KeyPair kp = Crypto.generateKeys(384);
+        java.security.KeyPair kp = Utils.exampleKeyPair();
+
+        // Crypto.generateKeys(384);
 
-        PublicKey  pub  = kp.getPublic(); // Utils.examplePublicKey();
-//logmsg("got a pub  " + pub);
-        PrivateKey priv = kp.getPrivate(); // Utils.examplePrivateKey();
-//logmsg("got a priv " + priv);
+        PublicKey  pub  = kp.getPublic();
+        PrivateKey priv = kp.getPrivate();
 
         Account ac;
         try {