Package org.drasyl.node.identity
Class IdentityManager
java.lang.Object
org.drasyl.node.identity.IdentityManager
-
Method Summary
Modifier and TypeMethodDescriptionstatic voiddeleteIdentityFile(Path path) Deletes the identity file specified in the configuration.static booleanisIdentityFilePresent(Path path) Returnstrueif the identity filepathexists.static IdentityreadIdentityFile(Path path) Reads the identity fromcode.static voidwriteIdentityFile(Path path, Identity identity) Writes the identityidentityto the filepath.
-
Method Details
-
isIdentityFilePresent
Returnstrueif the identity filepathexists. Otherwisefalseis returned.- Parameters:
path- path to identity file- Returns:
trueif file exists
-
readIdentityFile
Reads the identity fromcode. ThrowsIOExceptionif 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 identityidentityto the filepath. Attention: Ifpathalready 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
-