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

com.quorum.tessera.cli.parsers.ConfigConverter Maven / Gradle / Ivy

Go to download

Tessera is a stateless Java system that is used to enable the encryption, decryption, and distribution of private transactions for Quorum.

There is a newer version: 24.4.2
Show newest version
package com.quorum.tessera.cli.parsers;

import com.quorum.tessera.config.Config;
import com.quorum.tessera.config.ConfigFactory;
import com.quorum.tessera.config.util.ConfigFileStore;
import picocli.CommandLine;

import java.io.FileNotFoundException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class ConfigConverter implements CommandLine.ITypeConverter {

    @Override
    public Config convert(final String value) throws Exception {
        final ConfigFactory configFactory = ConfigFactory.create();

        final Path path = Paths.get(value);

        if (!Files.exists(path)) {
            throw new FileNotFoundException(String.format("%s not found.", path));
        }

        ConfigFileStore.create(path);

        try (InputStream in = Files.newInputStream(path)) {
            return configFactory.create(in);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy