Class IdentityStore

java.lang.Object
net.messagevortex.asn1.AbstractBlock
net.messagevortex.asn1.IdentityStore
All Implemented Interfaces:
Serializable, Callable<Integer>, Block, Dumpable, RunningDaemon

public class IdentityStore extends AbstractBlock implements Serializable, Callable<Integer>, RunningDaemon
Stores all known identities of a node. Identities are stored as IdentityStoreBlocks.
See Also:
  • Field Details

  • Constructor Details

    • IdentityStore

      public IdentityStore()
    • IdentityStore

      public IdentityStore(byte[] b) throws IOException
      Throws:
      IOException
    • IdentityStore

      public IdentityStore(File f) throws IOException

      Create object from ASN.1 encoded file.

      Parameters:
      f - the file to be parsed
      Throws:
      IOException - if parsing of ASN.1 code fails
  • Method Details

    • resetDemo

      public static void resetDemo()
    • getIdentityStoreDemo

      public static IdentityStore getIdentityStoreDemo() throws IOException

      Creates a new complete dummy identity store suitable for testing purposes.

      Returns:
      returns a reference identity store
      Throws:
      IOException - if building of the store fails
    • getNewIdentityStoreDemo

      public static IdentityStore getNewIdentityStoreDemo(boolean complete) throws IOException

      Creates a new dummy identity store suitable for testing purposes.

      the identity store contains an own identity, one hundred node idetities and 40 recipient identities.

      Parameters:
      complete - if true the node and recipient identities contain the private key too
      Returns:
      the requested identity store
      Throws:
      IOException - if building of the store fails
    • getHostIdentity

      public AsymmetricKey getHostIdentity()

      Get the own identity key.

      Returns:
      the requested key
    • setHostIdentity

      public AsymmetricKey setHostIdentity(AsymmetricKey identity)

      Sets the owned key.

      Parameters:
      identity - identity key to be set as own key
      Returns:
      the previously set key
    • getIdentityList

      public String[] getIdentityList()
    • getAnonSet

      public Set<IdentityStoreBlock> getAnonSet(int size) throws IOException

      Gets a random set of known recipient identities.

      Parameters:
      size - the size of the anonymity set
      Returns:
      the anonymity set
      Throws:
      IOException - if requested anonymity set size is too big for this store
    • parse

      protected final void parse(byte[] p) throws IOException
      Overrides:
      parse in class AbstractBlock
      Throws:
      IOException
    • parse

      protected final void parse(org.bouncycastle.asn1.ASN1Encodable p) throws IOException
      Specified by:
      parse in class AbstractBlock
      Throws:
      IOException
    • add

      public void add(IdentityStoreBlock isb)

      Adds an existing identity store block to the store.

      Parameters:
      isb - the block to be added
    • removeAddress

      public void removeAddress(String nodeAddress) throws IOException

      removes a node address from the identity store.

      Parameters:
      nodeAddress - the node addrress to be removed
      Throws:
      IOException - if node address is not contained in identity store
    • toAsn1Object

      public org.bouncycastle.asn1.ASN1Object toAsn1Object(DumpType dumpType) throws IOException
      Description copied from interface: Dumpable

      Dumps an ASN.1 representation of the object.

      Specified by:
      toAsn1Object in interface Dumpable
      Parameters:
      dumpType - the dump type to be used
      Returns:
      the ASN.1 string representation of the object
      Throws:
      IOException - if dumping of the object fails due to an illegal internal state of the object
    • dumpValueNotation

      public String dumpValueNotation(String prefix, DumpType dumpType) throws IOException
      Specified by:
      dumpValueNotation in interface Block
      Throws:
      IOException
    • getIdentity

      public IdentityStoreBlock getIdentity(String id)
    • call

      public Integer call()
      Specified by:
      call in interface Callable<Integer>
    • startDaemon

      public void startDaemon()
      Description copied from interface: RunningDaemon

      Initializes and starts all threads required to run the daemon.

      Specified by:
      startDaemon in interface RunningDaemon
    • stopDaemon

      public void stopDaemon()
      Description copied from interface: RunningDaemon

      Stopps all daemon threads and frees all temporary resources.

      Specified by:
      stopDaemon in interface RunningDaemon
    • shutdownDaemon

      public void shutdownDaemon()
      Description copied from interface: RunningDaemon

      Shuts this class down.

      This frees all resources and ends all threads for an application or layer shutdown. It is not possible to call start() after running shutdown().

      Specified by:
      shutdownDaemon in interface RunningDaemon