@API(status = INTERNAL)
public class EncryptorConstructors
public Encryptor()Methods
JsonObject loadEncryptedSession(Path, SecretKey, EventBus)Loads the encrypted session from disk and returns the decrypted json object.SecretKey loadOrCreateMasterKey(Path, EventBus)Loads the master key, if it already exists, or creates a new one and saves it to disk.void saveEncryptedSession(JsonObject, SecretKey, Path, EventBus)Encrypts the session json and saves it to disk.public static JsonObject loadEncryptedSession(Path sessionFile, SecretKey masterKey, EventBus eventBus) throws ExceptionLoads the encrypted session from disk and returns the decrypted json object.
| Parameters | ||
|---|---|---|
sessionFile | Path | The file where it will load the session from |
masterKey | SecretKey | The master key, used to decrypt the file |
eventBus | EventBus | |
| Returns | ||
JsonObject | The decrypted session as a JsonObject, or null if no session file exists | |
| Throws | ||
Exception | ||
public static SecretKey loadOrCreateMasterKey(Path keyFile, EventBus eventBus) throws ExceptionLoads the master key, if it already exists, or creates a new one and saves it to disk.
| Parameters | ||
|---|---|---|
keyFile | Path | The file to check for |
eventBus | EventBus | |
| Returns | ||
SecretKey | The SecretKey that will be used to encrypt and decrypt the refreshtoken | |
| Throws | ||
Exception | When something goes wrong with file access or key generation | |
public static void saveEncryptedSession(
JsonObject sessionJson,
SecretKey masterKey,
Path sessionFile,
EventBus eventBus
) throws ExceptionEncrypts the session json and saves it to disk.
The session can be loaded again with loadEncryptedSession(Path, SecretKey, EventBus)
| Parameters | ||
|---|---|---|
sessionJson | JsonObject | The JSON object of the Session |
masterKey | SecretKey | The SecretKey to encrypt and decrypt the session |
sessionFile | Path | The File to save the Session to |
eventBus | EventBus | |
| Throws | ||
Exception | When encrypting or writing to the file fails | |