Package org.drasyl.node.identity
Class IdentityManager
java.lang.Object
org.drasyl.node.identity.IdentityManager
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
deleteIdentityFile
(Path path) Deletes the identity file specified in the configuration.static boolean
isIdentityFilePresent
(Path path) Returnstrue
if the identity filepath
exists.static Identity
readIdentityFile
(Path path) Reads the identity fromcode
.static void
writeIdentityFile
(Path path, Identity identity) Writes the identityidentity
to the filepath
.
-
Method Details
-
isIdentityFilePresent
Returnstrue
if the identity filepath
exists. Otherwisefalse
is returned.- Parameters:
path
- path to identity file- Returns:
true
if file exists
-
readIdentityFile
Reads the identity fromcode
. ThrowsIOException
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
Writes the identityidentity
to the filepath
. Attention: Ifpath
already contains an identity, it will be overwritten without warning.- Parameters:
path
- path where the identity should be written toidentity
- this identity is written to the file- Throws:
IOException
- if the identity could not be written to the file
-
deleteIdentityFile
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
-