classinternalinternalSource
@API(status = INTERNAL)
public class Encryptor

Constructors

public Encryptor()

Methods

public static JsonObject loadEncryptedSession(Path sessionFile, SecretKey masterKey, EventBus eventBus) throws Exception
Loads the encrypted session from disk and returns the decrypted json object.
Parameters
sessionFilePathThe file where it will load the session from
masterKeySecretKeyThe master key, used to decrypt the file
eventBusEventBus
Returns
JsonObjectThe decrypted session as a JsonObject, or null if no session file exists
Throws
Exception
public static SecretKey loadOrCreateMasterKey(Path keyFile, EventBus eventBus) throws Exception
Loads the master key, if it already exists, or creates a new one and saves it to disk.
Parameters
keyFilePathThe file to check for
eventBusEventBus
Returns
SecretKeyThe SecretKey that will be used to encrypt and decrypt the refreshtoken
Throws
ExceptionWhen something goes wrong with file access or key generation
public static void saveEncryptedSession(
    JsonObject sessionJson,
    SecretKey masterKey,
    Path sessionFile,
    EventBus eventBus
) throws Exception
Encrypts the session json and saves it to disk.

The session can be loaded again with loadEncryptedSession(Path, SecretKey, EventBus)

Parameters
sessionJsonJsonObjectThe JSON object of the Session
masterKeySecretKeyThe SecretKey to encrypt and decrypt the session
sessionFilePathThe File to save the Session to
eventBusEventBus
Throws
ExceptionWhen encrypting or writing to the file fails