package cn.anicert.secure.access.utils;

import cn.anicert.secure.access.config.ConfigReader;
import cn.anicert.secure.access.config.bean.AccessConfig;
import cn.anicert.secure.access.enums.Configs;

public class ConfigUtil {
    private static AccessConfig accessConfig;

    public static synchronized void initConfig(String... filePath) {
        accessConfig = ConfigReader.readConfig(filePath);
    }

    public static synchronized void initConfig(AccessConfig config) {
        accessConfig = config;
    }

    public static AccessConfig getConfig() {
        return accessConfig;
    }

    public static void updateConfigDataEncryptKey(String newKey) {
        accessConfig=ConfigReader.writeConfig(Configs.dataEncryptKey.getKey(), newKey);
    }
}
