All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.akeyless.config.ConfigUtils Maven / Gradle / Ivy

There is a newer version: 0.0.10
Show newest version
package com.akeyless.config;

import com.akeyless.exceptions.AkeylessRuntimeException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.nio.file.Path;

public class ConfigUtils {

    public static AkeylessUserConfiguration loadSdkConfigurationFromFile(Path filePath)
            throws FileNotFoundException, AkeylessRuntimeException {
        return loadConfigFromFile(filePath, AkeylessUserConfiguration.class);
    }

    private static  T loadConfigFromFile(Path configurationFile, Class c) throws FileNotFoundException,
            AkeylessRuntimeException {
        Reader configReader = new FileReader(configurationFile.toFile());

        ObjectMapper mapper = new ObjectMapper();
        T config;
        try {
            config = mapper.readValue(configReader, c);
        } catch (IOException e) {
            throw new AkeylessRuntimeException(e);
        }
        return config;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy