use of org.eclipse.winery.common.configuration.AccountabilityConfigurationObject in project winery by eclipse.
the class AccountabilityConfigurationResource method getAccountabilityConfiguration.
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getAccountabilityConfiguration() {
AccountabilityConfigurationObject props = Environments.getInstance().getAccountabilityConfig();
AccountabilityConfigurationData result = new AccountabilityConfigurationData();
result.setAuthorizationSmartContractAddress(props.getEthereumAuthorizationSmartContractAddress());
result.setProvenanceSmartContractAddress(props.getEthereumProvenanceSmartContractAddress());
result.setBlockchainNodeUrl(props.getGethUrl());
result.setActiveKeystore(props.getEthereumCredentialsFileName());
result.setKeystorePassword(props.getEthereumPassword());
result.setSwarmGatewayUrl(props.getSwarmGatewayUrl());
return Response.ok(result).build();
}
use of org.eclipse.winery.common.configuration.AccountabilityConfigurationObject in project winery by eclipse.
the class AccountabilityConfigurationResource method setAccountabilityConfiguration.
@PUT
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response setAccountabilityConfiguration(@FormDataParam("keystoreFile") InputStream keystoreFileStream, @FormDataParam("keystoreFile") FormDataContentDisposition disposition, @FormDataParam("blockhainNodeUrl") String blockchainNodeUrl, @FormDataParam("keystorePassword") String keystorePassword, @FormDataParam("authorizationSmartContractAddress") String authorizationSmartContractAddress, @FormDataParam("provenanceSmartContractAddress") String provenanceSmartContractAddress, @FormDataParam("swarmGatewayUrl") String swarmGatewayUrl) {
AccountabilityConfigurationManager manager = AccountabilityConfigurationManager.getInstance();
try {
// sending a new keystore file is optional
if (keystoreFileStream != null && disposition != null) {
manager.setNewKeystoreFile(keystoreFileStream, disposition.getFileName());
}
AccountabilityConfigurationObject props = Environments.getInstance().getAccountabilityConfig();
props.setEthereumAuthorizationSmartContractAddress(authorizationSmartContractAddress);
props.setEthereumProvenanceSmartContractAddress(provenanceSmartContractAddress);
props.setGethUrl(blockchainNodeUrl);
props.setEthereumPassword(keystorePassword);
props.setSwarmGatewayUrl(swarmGatewayUrl);
Environments.save(props);
return Response.noContent().build();
} catch (IOException e) {
return Response.serverError().entity(e.getMessage()).build();
}
}
use of org.eclipse.winery.common.configuration.AccountabilityConfigurationObject in project winery by eclipse.
the class AccountabilityManagerFactory method getAccountabilityManager.
public static AccountabilityManager getAccountabilityManager() throws AccountabilityException {
if (Objects.isNull(accountabilityManager)) {
try {
AccountabilityConfigurationObject properties = Environments.getInstance().getAccountabilityConfig();
Environments.getInstance().addConfigurationChangeListener(() -> {
BlockchainFactory.reset();
ImmutableStorageProviderFactory.reset();
});
BlockchainAccess blockchain = BlockchainFactory.getBlockchainAccess(BlockchainFactory.AvailableBlockchains.ETHEREUM, properties);
ImmutableStorageProvider storageProvider = ImmutableStorageProviderFactory.getStorageProvider(ImmutableStorageProviderFactory.AvailableImmutableStorages.SWARM, properties);
accountabilityManager = new AccountabilityManagerImpl(blockchain, storageProvider);
} catch (BlockchainException e) {
String msg = "Could not instantiate accountability layer: " + e.getMessage();
LOGGER.error(msg, e);
throw new AccountabilityException(msg, e);
}
}
return accountabilityManager;
}
Aggregations