/[gzz]/gzz/gzz/util/URN5Namespace.java
ViewVC logotype

Diff of /gzz/gzz/util/URN5Namespace.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by benja, Wed Jan 1 22:56:43 2003 UTC revision 1.5 by benja, Tue Jan 14 01:04:45 2003 UTC
# Line 62  public class URN5Namespace { Line 62  public class URN5Namespace {
62      private String namespace;      private String namespace;
63      private long nextNumber = 1;      private long nextNumber = 1;
64    
65      public URN5Namespace() {      /** Generate a sequence of base64 characters
66         *  with at least 160 bits of randomness.
67         */
68        public static synchronized String generateRandomChars() {
69          if(sr == null)          if(sr == null)
70              sr = new SecureRandom();              sr = new SecureRandom();
71    
72          namespace = "";          StringBuffer chars = new StringBuffer(NAMESPACECHARS);
73    
74          for(int i=0; i<NAMESPACECHARS; i++) {          for(int i=0; i<NAMESPACECHARS; i++) {
75              int x, n=0;              int x, n=0;
# Line 76  public class URN5Namespace { Line 79  public class URN5Namespace {
79                  if(n > 1000)                  if(n > 1000)
80                      throw new Error("ARGH!");                      throw new Error("ARGH!");
81              } while(x < 0 || x > 64); // step around a bug(?) in kaffe              } while(x < 0 || x > 64); // step around a bug(?) in kaffe
82              namespace = namespace + base64.charAt(x);              chars.append(base64.charAt(x));
83          }          }
84    
85            return chars.toString();
86        }
87    
88        public URN5Namespace() {
89            namespace = generateRandomChars();
90      }      }
91    
92      /** Get the base id of the namespace.      /** Get the base id of the namespace.

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26