@Test public void testReadException() throws IOException { envVariables.clear(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH); final File tempFile = tempDir.newFile("key.secret"); tempFile.setReadable(false); envVariables.set(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH, tempFile.getAbsolutePath()); assertThat(ConfigSecretReader.readSecretFromFile()).isEmpty(); }
public static Optional<char[]> readSecretFromFile() { final EnvironmentVariableProvider envProvider = new EnvironmentVariableProvider(); if (envProvider.hasEnv(EnvironmentVariables.CONFIG_SECRET_PATH)) { final Path secretPath = Paths.get(envProvider.getEnv(EnvironmentVariables.CONFIG_SECRET_PATH)); if (Files.exists(secretPath)) { try { return Optional.of(new String(Files.readAllBytes(secretPath)).trim().toCharArray()); } catch (IOException ex) { LOGGER.error("Error while reading secret from file"); } } } LOGGER.warn("Not able to find or read any secret for decrypting sensitive values in config."); return Optional.empty(); }
ConfigSecretReader { public static Optional<char[]> readSecretFromFile() { final EnvironmentVariableProvider envProvider = new EnvironmentVariableProvider(); if (envProvider.hasEnv(EnvironmentVariables.CONFIG_SECRET_PATH)) { final Path secretPath = Paths.get(envProvider.getEnv(EnvironmentVariables.CONFIG_SECRET_PATH)); if (Files.exists(secretPath)) { try { return Optional.of(new String(Files.readAllBytes(secretPath)).trim().toCharArray()); } catch (IOException ex) { LOGGER.error("Error while reading secret from file"); } } } LOGGER.warn("Not able to find or read any secret for decrypting sensitive values in config."); return Optional.empty(); } }
ConfigSecretReader { public static Optional<char[]> readSecretFromFile() { final EnvironmentVariableProvider envProvider = new EnvironmentVariableProvider(); if (envProvider.hasEnv(EnvironmentVariables.CONFIG_SECRET_PATH)) { final Path secretPath = Paths.get(envProvider.getEnv(EnvironmentVariables.CONFIG_SECRET_PATH)); if (Files.exists(secretPath)) { try { return Optional.of(new String(Files.readAllBytes(secretPath)).trim().toCharArray()); } catch (IOException ex) { LOGGER.error("Error while reading secret from file"); } } } LOGGER.warn("Not able to find or read any secret for decrypting sensitive values in config."); return Optional.empty(); } private  ConfigSecretReader(); }
ConfigSecretReader { public static Optional<char[]> readSecretFromFile() { final EnvironmentVariableProvider envProvider = new EnvironmentVariableProvider(); if (envProvider.hasEnv(EnvironmentVariables.CONFIG_SECRET_PATH)) { final Path secretPath = Paths.get(envProvider.getEnv(EnvironmentVariables.CONFIG_SECRET_PATH)); if (Files.exists(secretPath)) { try { return Optional.of(new String(Files.readAllBytes(secretPath)).trim().toCharArray()); } catch (IOException ex) { LOGGER.error("Error while reading secret from file"); } } } LOGGER.warn("Not able to find or read any secret for decrypting sensitive values in config."); return Optional.empty(); } private  ConfigSecretReader(); static Optional<char[]> readSecretFromFile(); static char[] readSecretFromConsole(); }
ConfigSecretReader { public static Optional<char[]> readSecretFromFile() { final EnvironmentVariableProvider envProvider = new EnvironmentVariableProvider(); if (envProvider.hasEnv(EnvironmentVariables.CONFIG_SECRET_PATH)) { final Path secretPath = Paths.get(envProvider.getEnv(EnvironmentVariables.CONFIG_SECRET_PATH)); if (Files.exists(secretPath)) { try { return Optional.of(new String(Files.readAllBytes(secretPath)).trim().toCharArray()); } catch (IOException ex) { LOGGER.error("Error while reading secret from file"); } } } LOGGER.warn("Not able to find or read any secret for decrypting sensitive values in config."); return Optional.empty(); } private  ConfigSecretReader(); static Optional<char[]> readSecretFromFile(); static char[] readSecretFromConsole();  }