Search in sources :

Example 1 with KeyGeneratorFactory

use of com.quorum.tessera.key.generation.KeyGeneratorFactory in project tessera by ConsenSys.

the class KeyGenCommandTest method beforeTest.

@Before
public void beforeTest() {
    keyGeneratorFactory = mock(KeyGeneratorFactory.class);
    configFileUpdaterWriter = mock(ConfigFileUpdaterWriter.class);
    passwordFileUpdaterWriter = mock(PasswordFileUpdaterWriter.class);
    keyDataMarshaller = mock(KeyDataMarshaller.class);
    keyGenCommand = new KeyGenCommand(keyGeneratorFactory, configFileUpdaterWriter, passwordFileUpdaterWriter, keyDataMarshaller);
    keyGenerator = mock(KeyGenerator.class);
    executionExceptionHandler = new CliExecutionExceptionHandler();
    parameterExceptionHandler = mock(CLIExceptionCapturer.class);
    commandLine = new CommandLine(keyGenCommand);
    commandLine.setExecutionExceptionHandler(executionExceptionHandler);
    commandLine.setParameterExceptionHandler(parameterExceptionHandler);
}
Also used : KeyGeneratorFactory(com.quorum.tessera.key.generation.KeyGeneratorFactory) PasswordFileUpdaterWriter(com.quorum.tessera.config.util.PasswordFileUpdaterWriter) CommandLine(picocli.CommandLine) CLIExceptionCapturer(com.quorum.tessera.cli.CLIExceptionCapturer) ConfigFileUpdaterWriter(com.quorum.tessera.config.util.ConfigFileUpdaterWriter) KeyGenerator(com.quorum.tessera.key.generation.KeyGenerator) Before(org.junit.Before)

Example 2 with KeyGeneratorFactory

use of com.quorum.tessera.key.generation.KeyGeneratorFactory in project tessera by ConsenSys.

the class KeyGenCommandFactory method create.

@Override
public <K> K create(Class<K> cls) throws Exception {
    try {
        if (cls != KeyGenCommand.class) {
            throw new RuntimeException(this.getClass().getSimpleName() + " cannot create instance of type " + cls.getSimpleName());
        }
        KeyGeneratorFactory keyGeneratorFactory = KeyGeneratorFactory.create();
        ConfigFileUpdaterWriter configFileUpdaterWriter = new ConfigFileUpdaterWriter(FilesDelegate.create());
        PasswordFileUpdaterWriter passwordFileUpdaterWriter = new PasswordFileUpdaterWriter(FilesDelegate.create());
        KeyDataMarshaller keyDataMarshaller = KeyDataMarshaller.create();
        return (K) new KeyGenCommand(keyGeneratorFactory, configFileUpdaterWriter, passwordFileUpdaterWriter, keyDataMarshaller);
    } catch (Exception e) {
        // fallback if missing
        return CommandLine.defaultFactory().create(cls);
    }
}
Also used : KeyGeneratorFactory(com.quorum.tessera.key.generation.KeyGeneratorFactory) PasswordFileUpdaterWriter(com.quorum.tessera.config.util.PasswordFileUpdaterWriter) ConfigFileUpdaterWriter(com.quorum.tessera.config.util.ConfigFileUpdaterWriter)

Aggregations

ConfigFileUpdaterWriter (com.quorum.tessera.config.util.ConfigFileUpdaterWriter)2 PasswordFileUpdaterWriter (com.quorum.tessera.config.util.PasswordFileUpdaterWriter)2 KeyGeneratorFactory (com.quorum.tessera.key.generation.KeyGeneratorFactory)2 CLIExceptionCapturer (com.quorum.tessera.cli.CLIExceptionCapturer)1 KeyGenerator (com.quorum.tessera.key.generation.KeyGenerator)1 Before (org.junit.Before)1 CommandLine (picocli.CommandLine)1