Search in sources :

Example 1 with ContentEncrypter

use of org.jkiss.dbeaver.runtime.encode.ContentEncrypter in project dbeaver by serge-rider.

the class DataSourceSerializerModern method saveConfigFile.

private void saveConfigFile(File configFile, String contents, boolean teamPrivate, boolean encrypt) {
    try {
        byte[] binaryContents;
        if (encrypt) {
            // Serialize and encrypt
            ContentEncrypter encrypter = new ContentEncrypter(registry.getProject().getSecureStorage().getLocalSecretKey());
            binaryContents = encrypter.encrypt(contents);
        } else {
            binaryContents = contents.getBytes(StandardCharsets.UTF_8);
        }
        // Save result to file
        IOUtils.writeFileFromBuffer(configFile, binaryContents);
    } catch (Exception e) {
        log.error("Error saving configuration file " + configFile.getAbsolutePath(), e);
    }
}
Also used : ContentEncrypter(org.jkiss.dbeaver.runtime.encode.ContentEncrypter) DBException(org.jkiss.dbeaver.DBException)

Aggregations

DBException (org.jkiss.dbeaver.DBException)1 ContentEncrypter (org.jkiss.dbeaver.runtime.encode.ContentEncrypter)1