/[gzz]/gzz/lava/gzz/storm/headers/UniqueHeader822.java
ViewVC logotype

Diff of /gzz/lava/gzz/storm/headers/UniqueHeader822.java

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

revision 1.1 by benja, Thu Nov 7 22:07:00 2002 UTC revision 1.2 by benja, Tue Jan 14 01:04:45 2003 UTC
# Line 21  UniqueHeader822.java Line 21  UniqueHeader822.java
21   * Written by Benja Fallenstein   * Written by Benja Fallenstein
22   */   */
23  package gzz.storm.headers;  package gzz.storm.headers;
24    import gzz.util.URN5Namespace;
25  import java.io.*;  import java.io.*;
26    import java.net.InetAddress;
27    import java.text.*;
28  import java.util.*;  import java.util.*;
29    
30  /** A header with some fields that make it unique.  /** A header with some fields that make it unique.
31   *  This is the standard header type for new Storm blocks.   *  This is the standard header type for new Storm blocks.
32   *  Basically, this is a canonicalized header with   *  Basically, this is a canonicalized header with
33   *  <code>Date</code>, <code>Injected-By</code> and   *  <code>Date</code>, <code>X-Injected-By</code> and
34   *  <code>Random-Bytes</code> headers added.   *  <code>X-Storm-Random-Bytes</code> headers added.
35   */   */
36  public class UniqueHeader822 extends SortedHeader822 {  public class UniqueHeader822 extends SortedHeader822 {
37    
38        private static DateFormat dateFormat =
39            new SimpleDateFormat("EE, d MMM yyyy HH:mm:ss", Locale.ENGLISH);
40        static {
41            dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
42        }
43    
44      public UniqueHeader822() {      public UniqueHeader822() {
45          super();          super();
46          addUniqueFields();          addUniqueFields();
# Line 44  public class UniqueHeader822 extends Sor Line 53  public class UniqueHeader822 extends Sor
53    
54      /** Add the header fields that make this header unique. */      /** Add the header fields that make this header unique. */
55      protected void addUniqueFields() {      protected void addUniqueFields() {
56          // XXX          String name = System.getProperty("user.name");
57            // Also get the local host name...
58            try {
59                InetAddress addr = InetAddress.getLocalHost();
60                name = name + "@" + addr.getHostName();
61            } catch(Exception e) {
62            }
63            // XXX Potential problem: mangled user.name with e.g. newlines
64            if(name != null)
65                add("X-Injected-By", name);
66            
67            add("Date", dateFormat.format(new Date()) + " +0000");
68    
69            add("X-Storm-Random-Bytes", URN5Namespace.generateRandomChars());
70      }      }
71  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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