Package org.drasyl.identity
Class IdentityManager
java.lang.Object
org.drasyl.identity.IdentityManager
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionIdentityManager
(DrasylConfig config) Manages the identity at the specified file path. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
deleteIdentityFile
(Path path) Deletes the identity file specified in the configuration.static Identity
Generates a new random identity.void
Attempts to load the identity defined in the configuration: First it tries to read the key pair directly from the configuration.
-
Field Details
-
POW_DIFFICULTY
public static final short POW_DIFFICULTY- See Also:
-
-
Constructor Details
-
IdentityManager
Manages the identity at the specified file path. If there is no identity at this file path yet, a new one is created.
-
-
Method Details
-
loadOrCreateIdentity
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, anIdentityManagerException
is thrown.- Throws:
IdentityManagerException
- if identity could not be loaded or created
-
generateIdentity
Generates a new random identity.- Returns:
- the generated identity
- Throws:
IdentityManagerException
- if an identity could not be generated
-
getPublicKey
-
getPrivateKey
-
getProofOfWork
-
getIdentity
- Returns:
- returns the node identity.
-
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:
IdentityManagerException
-