private static File getEncryptionFile() { String param = System.getProperty(ENCRYPTION_KEY); if (param == null) { return null; } File encryptionKeyFile = new File(param); if (!encryptionKeyFile.exists()) { if (Boolean.getBoolean(INIT_KEY_IF_MISSING)) { try { Files.write(encryptionKeyFile.toPath(), EncryptorService.generateKey()); } catch (Exception e) { throw new LocalizableValidationException(e, "Error initializing the encryption key file '" + param + "'!", "common.encryption.file.init", param); } } else { throw new LocalizableValidationException("File '" + param + "' does not exist!", "common.encryption.file.missing", param); } } return encryptionKeyFile; }
private static File getEncryptionFile() { String param = System.getProperty(ENCRYPTION_KEY); if (param == null) { return null; } File encryptionKeyFile = new File(param); if (!encryptionKeyFile.exists()) { if (Boolean.getBoolean(INIT_KEY_IF_MISSING)) { try { Files.write(encryptionKeyFile.toPath(), EncryptorService.generateKey()); } catch (Exception e) { throw new LocalizableValidationException(e, "Error initializing the encryption key file '" + param + "'!", "common.encryption.file.init", param); } } else { throw new LocalizableValidationException("File '" + param + "' does not exist!", "common.encryption.file.missing", param); } } return encryptionKeyFile; }