class 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();

}