Class NodeInformation

java.lang.Object
i5.las2peer.p2p.NodeInformation
All Implemented Interfaces:
XmlAble

public class NodeInformation extends Object implements XmlAble
A NodeInformation gives basic information about a node.
  • Constructor Details

    • NodeInformation

      public NodeInformation()
      create a new standard node information
    • NodeInformation

      public NodeInformation(ServiceAgentImpl[] hostedServiceAgents)
      create a standard node information for a node hosting the given services
      Parameters:
      hostedServiceAgents - A bunch of service agents hosted on this node
  • Method Details

    • getOrganization

      public String getOrganization()
      get the organization, this node is hosted by
      Returns:
      organization name
    • getAdminName

      public String getAdminName()
      get the name of the admin stored in this information
      Returns:
      admin real name
    • getAdminEmail

      public String getAdminEmail()
      get the admin email address of this node information
      Returns:
      email address
    • getDescription

      public String getDescription()
      get the description entry
      Returns:
      a node description
    • getHostedServices

      public List<ServiceNameVersion> getHostedServices()
      get an array with the class names of all services hosted at the node described with this information
      Returns:
      array with service class names
    • setSignature

      public void setSignature(byte[] signature)
      for the node itself: set the signature before sending
      Parameters:
      signature - A signature to set
    • getSignature

      public byte[] getSignature()
    • setNodeHandle

      public void setNodeHandle(Serializable nodeHandle)
      for the node itself: deliver the handle
      Parameters:
      nodeHandle - A node handle to set
    • setNodeKey

      public void setNodeKey(PublicKey nodeKey)
      for the node itself: deliver the key
      Parameters:
      nodeKey - A node public key to set
    • verifySignature

      public void verifySignature() throws InternalSecurityException
      verify the signature
      Throws:
      InternalSecurityException - If verifying the signature fails
    • getSignatureContent

      public byte[] getSignatureContent()
      the content for the signature
      Returns:
      an array containing the signature content as bytes
    • getNodeHandle

      public Object getNodeHandle()
      get the handle of the described node
      Returns:
      a node handle, either Long or NodeHandle
    • getNodeKey

      public PublicKey getNodeKey()
      get the public encryption key of the node
      Returns:
      the public node key
    • isComplete

      public boolean isComplete()
      check, if all relevant information is given
      Returns:
      true, if at least node key, signature and node handle are provided.
    • toXmlString

      public String toXmlString()
      Description copied from interface: XmlAble
      Returns a XML representation of this object.
      Specified by:
      toXmlString in interface XmlAble
      Returns:
      a XML String representation
    • toString

      public String toString()
      return all information stored here as XML string
      Overrides:
      toString in class Object
    • createFromXmlFile

      public static NodeInformation createFromXmlFile(String filename) throws MalformedXMLException, IOException
      factory: create a NodeInformation instance from a XML file
      Parameters:
      filename - A name for a file containing the XML data
      Returns:
      the node information contained in the given XML file
      Throws:
      MalformedXMLException - If the XML data is malformed
      IOException - If reading the file fails
    • createFromXmlFile

      public static NodeInformation createFromXmlFile(String filename, ServiceAgentImpl[] serviceAgents) throws MalformedXMLException, IOException
      factory: create a NodeInformation instance from a XML file and set the hosted services
      Parameters:
      filename - A filename to read from
      serviceAgents - A bunch of service agents hosted on this node
      Returns:
      a node information
      Throws:
      MalformedXMLException - If the XML data is malformed
      IOException - If reading the file fails
    • createFromXml

      public static NodeInformation createFromXml(String xml) throws MalformedXMLException
      factory create a node information instance from an XML string
      Parameters:
      xml - An XML data string
      Returns:
      node information contained in the given XML string
      Throws:
      MalformedXMLException - If the XML data string is malformed
    • main

      public static void main(String[] argv)
      command line tool for generating a description XML file
      Parameters:
      argv - A bunch of args