Class IdentityManager

java.lang.Object
org.drasyl.node.identity.IdentityManager

public final class IdentityManager extends Object
Utility class for writing an Identity to a Path and vice versa.
  • Method Details

    • isIdentityFilePresent

      public static boolean isIdentityFilePresent(Path path)
      Returns true if the identity file path exists. Otherwise false is returned.
      Parameters:
      path - path to identity file
      Returns:
      true if file exists
    • readIdentityFile

      public static Identity readIdentityFile(Path path) throws IOException
      Reads the identity from code. Throws IOException if file cannot be read or file has unexpected content.
      Parameters:
      path - path to identity file
      Returns:
      The identity contained in the file
      Throws:
      IOException - if identity could not be read from file or has an invalid proof of work
    • writeIdentityFile

      public static void writeIdentityFile(Path path, Identity identity) throws IOException
      Writes the identity identity to the file path. Attention: If path already contains an identity, it will be overwritten without warning.
      Parameters:
      path - path where the identity should be written to
      identity - this identity is written to the file
      Throws:
      IOException - if the identity could not be written to the file
    • deleteIdentityFile

      public static void deleteIdentityFile(Path path) throws IOException
      Deletes the identity file specified in the configuration.

      ATTENTION: Messages directed to the present identity can then no longer be decrypted and read. This step is irreversible. Should only be used if the present identity should never be used again!

      Throws:
      IOException - if identity file could not be deleted