Search in sources :

Example 1 with AccountabilityConfigurationObject

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();
}
Also used : AccountabilityConfigurationData(org.eclipse.winery.repository.rest.resources.apiData.AccountabilityConfigurationData) AccountabilityConfigurationObject(org.eclipse.winery.common.configuration.AccountabilityConfigurationObject) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with AccountabilityConfigurationObject

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();
    }
}
Also used : AccountabilityConfigurationManager(org.eclipse.winery.common.configuration.AccountabilityConfigurationManager) AccountabilityConfigurationObject(org.eclipse.winery.common.configuration.AccountabilityConfigurationObject) IOException(java.io.IOException) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT)

Example 3 with AccountabilityConfigurationObject

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;
}
Also used : BlockchainException(org.eclipse.winery.accountability.exceptions.BlockchainException) AccountabilityException(org.eclipse.winery.accountability.exceptions.AccountabilityException) BlockchainAccess(org.eclipse.winery.accountability.blockchain.BlockchainAccess) ImmutableStorageProvider(org.eclipse.winery.accountability.storage.ImmutableStorageProvider) AccountabilityConfigurationObject(org.eclipse.winery.common.configuration.AccountabilityConfigurationObject)

Aggregations

AccountabilityConfigurationObject (org.eclipse.winery.common.configuration.AccountabilityConfigurationObject)3 IOException (java.io.IOException)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 PUT (javax.ws.rs.PUT)1 Produces (javax.ws.rs.Produces)1 BlockchainAccess (org.eclipse.winery.accountability.blockchain.BlockchainAccess)1 AccountabilityException (org.eclipse.winery.accountability.exceptions.AccountabilityException)1 BlockchainException (org.eclipse.winery.accountability.exceptions.BlockchainException)1 ImmutableStorageProvider (org.eclipse.winery.accountability.storage.ImmutableStorageProvider)1 AccountabilityConfigurationManager (org.eclipse.winery.common.configuration.AccountabilityConfigurationManager)1 AccountabilityConfigurationData (org.eclipse.winery.repository.rest.resources.apiData.AccountabilityConfigurationData)1