use of tech.pegasys.signers.hashicorp.config.KeyDefinition in project web3signer by ConsenSys.
the class AbstractArtifactSignerFactory method extractBytesFromVault.
protected Bytes extractBytesFromVault(final HashicorpSigningMetadata metadata) {
final Optional<TlsOptions> tlsOptions = buildTlsOptions(metadata);
try {
final HashicorpConnection connection = hashicorpConnectionFactory.create(new ConnectionParameters(metadata.getServerHost(), Optional.ofNullable(metadata.getServerPort()), tlsOptions, Optional.ofNullable(metadata.getTimeout())));
final String secret = connection.fetchKey(new KeyDefinition(metadata.getKeyPath(), Optional.ofNullable(metadata.getKeyName()), metadata.getToken()));
return Bytes.fromHexString(secret);
} catch (final Exception e) {
throw new SigningMetadataException("Failed to fetch secret from hashicorp vault", e);
}
}
use of tech.pegasys.signers.hashicorp.config.KeyDefinition in project web3signer by ConsenSys.
the class AbstractArtifactSignerFactory method extractBytesFromVault.
protected Bytes extractBytesFromVault(final HashicorpSigningMetadata metadata) {
final Optional<TlsOptions> tlsOptions = buildTlsOptions(metadata);
try {
final HashicorpConnection connection = hashicorpConnectionFactory.create(new ConnectionParameters(metadata.getServerHost(), Optional.ofNullable(metadata.getServerPort()), tlsOptions, Optional.ofNullable(metadata.getTimeout())));
final String secret = connection.fetchKey(new KeyDefinition(metadata.getKeyPath(), Optional.ofNullable(metadata.getKeyName()), metadata.getToken()));
return Bytes.fromHexString(secret);
} catch (final Exception e) {
throw new SigningMetadataException("Failed to fetch secret from hashicorp vault", e);
}
}
use of tech.pegasys.signers.hashicorp.config.KeyDefinition in project signers by ConsenSys.
the class TomlConfigLoader method parse.
public HashicorpKeyConfig parse(final String tableName) {
final TomlParser tomlParser = new TomlParser();
final TomlParseResult tomlResult = tomlParser.getTomlParseResult(fileToParse);
TomlTable tableToParse = tomlResult;
if (tableName != null) {
tableToParse = tomlResult.getTable(tableName);
}
if (tableToParse == null) {
final String error = String.format("Toml table %s is missing", tableName);
throw new HashicorpException(constructErrorMessage(error));
}
final KeyDefinition keyDefinition = loadKeyDefinition(tableToParse);
final ConnectionParameters connectionsParams = loadConnectionParams(tableToParse);
return new HashicorpKeyConfig(connectionsParams, keyDefinition);
}
Aggregations