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.
    • 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 IdentityManagerException
        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 IdentityManagerException is thrown.
        Throws:
        IdentityManagerException - if identity could not be loaded or created
      • getIdentity

        public Identity getIdentity()
        Returns:
        returns the node identity.
      • deleteIdentityFile

        public static void deleteIdentityFile​(Path path)
                                       throws IdentityManagerException
        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:
        IdentityManagerException