Class IdentityManager

  • public class IdentityManager
    extends Object
    This class holds the identity of the node. Messages to the node are addressed to the identity. In a future release, messages will be signed and encrypted with public-private key pairs contained in the identity.
    • Field Detail


        public static final byte POW_DIFFICULTY
    • Constructor Detail

      • IdentityManager

        public IdentityManager​(DrasylConfig config)
        Manages the identity at the specified file path. If there is no identity at this file path yet, a new one is created.
    • Method Detail

      • loadOrCreateIdentity

        public void loadOrCreateIdentity()
                                  throws IOException
        Attempts to load the identity defined in the configuration: First it tries to read the key pair directly from the configuration. If no key pair is specified there, the identity is loaded from the identity file path specified in the configuration. If the file does not exist, a new identity is generated and written to the file. If all this fails and no identity can be loaded, an IOException is thrown.
        IOException - if identity could not be loaded or created
      • generateIdentity

        public static Identity generateIdentity()
                                         throws IOException
        Generates a new random identity.
        the generated identity
        IOException - if an identity could not be generated
      • getIdentity

        public Identity getIdentity()
        returns the node identity.
      • 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!

        IOException - if identity file could not be deleted