Class Fc3tuple

java.lang.Object
  extended by Fc3tuple

public final class Fc3tuple
extends java.lang.Object

Each feralcore node has an associated Fc3tuple. An Fc3tuple object fully defines all the information needed to send a packet to this feralcore node. It includes the needed Internet address, port, and public key. It also contains a time-stamp that is used to convey the "freshness" of the Fc3tuple object.


Field Summary
static Fc3tuple EMPTYFC3TUPLE
           
 
Constructor Summary
Fc3tuple(Serverinfo sinf, ByteArray pkey, long ts)
          Constructs a new Fc3tuple object.
 
Method Summary
static Fc3tupledres deserialize(ByteArray inarray)
          Factory method that deserializes the input inarray and returns the resulting object to the caller.
 boolean equals(java.lang.Object o)
          Returns true if and only if the Serverinfo object in this matches the Fc3tuple that is passed in within the input parameter o.
 ByteArray getpublickey()
          Returns a copy of the public key object contained in this.
 Serverinfo getserverinfo()
          Returns a copy of the Serverinfo object contained in this.
 long gettimestamp()
          Returns the time-stamp contained in this.
 int hashCode()
          Returns a hashcode computed on a serialized object of this.
static boolean isemptyfc3tuple(Fc3tuple in)
           
 ByteArray serialize()
          Returns the data members of this serialized into byte array.
static int serializedlength()
          Returns the length in bytes of this when it is serialized.
 java.lang.String toString()
          Returns a printable string that displays the data members in this.
static Fc3tuple updatetimestamp(java.lang.String alias, Fc3tuple in)
          Factory method that takes as input an Fc3tuple object and returns a copy of it with an updated time-stamp.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTYFC3TUPLE

public static final Fc3tuple EMPTYFC3TUPLE
Constructor Detail

Fc3tuple

public Fc3tuple(Serverinfo sinf,
                ByteArray pkey,
                long ts)
         throws java.lang.CloneNotSupportedException
Constructs a new Fc3tuple object. Sets the internal data members to be sinf, pkey, and ts.

Parameters:
sinf - The Internet address and port of the feralcore node
pkey - The public key of the feralcore node
ts - The time-stamp for the Fc3tuple object
Throws:
java.lang.CloneNotSupportedException
Method Detail

isemptyfc3tuple

public static boolean isemptyfc3tuple(Fc3tuple in)
                               throws java.lang.CloneNotSupportedException
Throws:
java.lang.CloneNotSupportedException

updatetimestamp

public static Fc3tuple updatetimestamp(java.lang.String alias,
                                       Fc3tuple in)
                                throws FeralcoreException,
                                       java.io.UnsupportedEncodingException,
                                       java.io.IOException,
                                       java.lang.CloneNotSupportedException
Factory method that takes as input an Fc3tuple object and returns a copy of it with an updated time-stamp. It gets the time by calling YYtime.yycurrenttimemillis(java.lang.String, java.lang.String). The String alias is used to help guard against time-based attacks on feralcore (e.g., if an adversary tries to forge NTP packets en route to the server hosting the feralcore instance).

Parameters:
alias - Name of the "user" currently running the program containing this Fc3tuple object.
in - The Fc3tuple that gets its time-stamp updated.
Throws:
FeralcoreException
java.io.UnsupportedEncodingException
java.io.IOException
java.lang.CloneNotSupportedException

equals

public boolean equals(java.lang.Object o)
Returns true if and only if the Serverinfo object in this matches the Fc3tuple that is passed in within the input parameter o.

Overrides:
equals in class java.lang.Object
Parameters:
o - The Fc3tuple object that gets compared.

hashCode

public int hashCode()
Returns a hashcode computed on a serialized object of this.

Overrides:
hashCode in class java.lang.Object

getserverinfo

public Serverinfo getserverinfo()
                         throws java.lang.CloneNotSupportedException
Returns a copy of the Serverinfo object contained in this.

Throws:
java.lang.CloneNotSupportedException

getpublickey

public ByteArray getpublickey()
Returns a copy of the public key object contained in this.


gettimestamp

public long gettimestamp()
Returns the time-stamp contained in this.


serialize

public ByteArray serialize()
Returns the data members of this serialized into byte array.


serializedlength

public static int serializedlength()
Returns the length in bytes of this when it is serialized. Since Serverinfo always serializes to a fixed length, Fc3tuple objects always serialize to a fixed length. The output of this member function is therefore always the same.


deserialize

public static Fc3tupledres deserialize(ByteArray inarray)
                                throws FeralcoreException,
                                       java.lang.CloneNotSupportedException
Factory method that deserializes the input inarray and returns the resulting object to the caller. If deserialization fails then null is returned.

Parameters:
inarray - untrusted input byte array that supposedly encodes an Fc3tuple object
Throws:
FeralcoreException
java.lang.CloneNotSupportedException

toString

public java.lang.String toString()
Returns a printable string that displays the data members in this.

Overrides:
toString in class java.lang.Object