Search in sources :

Example 1 with PrivacyIdProvider

use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider in project besu by hyperledger.

the class PrivateWebSocketMethodsFactory method methods.

public Collection<JsonRpcMethod> methods() {
    final SubscriptionRequestMapper subscriptionRequestMapper = new SubscriptionRequestMapper();
    final PrivacyIdProvider privacyIdProvider = PrivacyIdProvider.build(privacyParameters);
    final PrivacyController privacyController = createPrivacyController();
    return Set.of(new PrivSubscribe(subscriptionManager, subscriptionRequestMapper, privacyController, privacyIdProvider), new PrivUnsubscribe(subscriptionManager, subscriptionRequestMapper, privacyController, privacyIdProvider));
}
Also used : MultiTenancyPrivacyController(org.hyperledger.besu.ethereum.privacy.MultiTenancyPrivacyController) PrivacyController(org.hyperledger.besu.ethereum.privacy.PrivacyController) RestrictedDefaultPrivacyController(org.hyperledger.besu.ethereum.privacy.RestrictedDefaultPrivacyController) PluginPrivacyController(org.hyperledger.besu.ethereum.privacy.PluginPrivacyController) FlexiblePrivacyController(org.hyperledger.besu.ethereum.privacy.FlexiblePrivacyController) SubscriptionRequestMapper(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.request.SubscriptionRequestMapper) PrivacyIdProvider(org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider)

Example 2 with PrivacyIdProvider

use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider in project besu by hyperledger.

the class PrivacyApiGroupJsonRpcMethods method create.

@Override
protected Map<String, JsonRpcMethod> create() {
    final PrivateMarkerTransactionFactory markerTransactionFactory = createPrivateMarkerTransactionFactory();
    final PrivacyIdProvider enclavePublicProvider = PrivacyIdProvider.build(privacyParameters);
    final PrivacyController privacyController = createPrivacyController();
    return create(privacyController, enclavePublicProvider, markerTransactionFactory).entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> createPrivacyMethod(privacyParameters, entry.getValue())));
}
Also used : PrivacyController(org.hyperledger.besu.ethereum.privacy.PrivacyController) RestrictedDefaultPrivacyController(org.hyperledger.besu.ethereum.privacy.RestrictedDefaultPrivacyController) PluginPrivacyController(org.hyperledger.besu.ethereum.privacy.PluginPrivacyController) MultiTenancyPrivacyController(org.hyperledger.besu.ethereum.privacy.MultiTenancyPrivacyController) FlexiblePrivacyController(org.hyperledger.besu.ethereum.privacy.FlexiblePrivacyController) PrivacyController(org.hyperledger.besu.ethereum.privacy.PrivacyController) RestrictedDefaultPrivacyController(org.hyperledger.besu.ethereum.privacy.RestrictedDefaultPrivacyController) PluginPrivacyController(org.hyperledger.besu.ethereum.privacy.PluginPrivacyController) ProtocolSchedule(org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule) PrivacyQueries(org.hyperledger.besu.ethereum.api.query.PrivacyQueries) DisabledPrivacyRpcMethod(org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.DisabledPrivacyRpcMethod) PrivacyIdProvider(org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider) ChainHeadPrivateNonceProvider(org.hyperledger.besu.ethereum.privacy.ChainHeadPrivateNonceProvider) Map(java.util.Map) BigInteger(java.math.BigInteger) MultiTenancyRpcMethodDecorator(org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.MultiTenancyRpcMethodDecorator) MultiTenancyPrivacyController(org.hyperledger.besu.ethereum.privacy.MultiTenancyPrivacyController) TransactionPool(org.hyperledger.besu.ethereum.eth.transactions.TransactionPool) PrivateTransactionSimulator(org.hyperledger.besu.ethereum.privacy.PrivateTransactionSimulator) BlockchainQueries(org.hyperledger.besu.ethereum.api.query.BlockchainQueries) RandomSigningPrivateMarkerTransactionFactory(org.hyperledger.besu.ethereum.privacy.markertransaction.RandomSigningPrivateMarkerTransactionFactory) Collectors(java.util.stream.Collectors) PrivateNonceProvider(org.hyperledger.besu.ethereum.privacy.PrivateNonceProvider) GasCalculator(org.hyperledger.besu.evm.gascalculator.GasCalculator) RpcMethod(org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod) FlexiblePrivacyController(org.hyperledger.besu.ethereum.privacy.FlexiblePrivacyController) PrivateMarkerTransactionFactory(org.hyperledger.besu.plugin.services.privacy.PrivateMarkerTransactionFactory) Optional(java.util.Optional) FixedKeySigningPrivateMarkerTransactionFactory(org.hyperledger.besu.ethereum.privacy.markertransaction.FixedKeySigningPrivateMarkerTransactionFactory) JsonRpcMethod(org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod) PrivacyParameters(org.hyperledger.besu.ethereum.core.PrivacyParameters) RandomSigningPrivateMarkerTransactionFactory(org.hyperledger.besu.ethereum.privacy.markertransaction.RandomSigningPrivateMarkerTransactionFactory) PrivateMarkerTransactionFactory(org.hyperledger.besu.plugin.services.privacy.PrivateMarkerTransactionFactory) FixedKeySigningPrivateMarkerTransactionFactory(org.hyperledger.besu.ethereum.privacy.markertransaction.FixedKeySigningPrivateMarkerTransactionFactory) PrivacyIdProvider(org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider) Map(java.util.Map)

Example 3 with PrivacyIdProvider

use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider in project besu by hyperledger.

the class PrivacyApiGroupJsonRpcMethodsTest method rpcsCreatedWithoutMultiTenancyUseFixedEnclavePublicKey.

@Test
public void rpcsCreatedWithoutMultiTenancyUseFixedEnclavePublicKey() {
    when(privacyParameters.isEnabled()).thenReturn(true);
    when(privacyParameters.getPrivacyUserId()).thenReturn(DEFAULT_ENCLAVE_PUBLIC_KEY);
    final User user = createUser(DEFAULT_ENCLAVE_PUBLIC_KEY);
    privacyApiGroupJsonRpcMethods.create();
    final PrivacyIdProvider privacyIdProvider = privacyApiGroupJsonRpcMethods.privacyIdProvider;
    assertThat(privacyIdProvider.getPrivacyUserId(Optional.of(user))).isEqualTo(DEFAULT_ENCLAVE_PUBLIC_KEY);
    assertThat(privacyIdProvider.getPrivacyUserId(Optional.empty())).isEqualTo(DEFAULT_ENCLAVE_PUBLIC_KEY);
}
Also used : User(io.vertx.ext.auth.User) PrivacyIdProvider(org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider) Test(org.junit.Test)

Example 4 with PrivacyIdProvider

use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider in project besu by hyperledger.

the class PrivacyApiGroupJsonRpcMethodsTest method rpcsCreatedWithMultiTenancyAndWithoutUserFail.

@Test
public void rpcsCreatedWithMultiTenancyAndWithoutUserFail() {
    when(privacyParameters.isEnabled()).thenReturn(true);
    when(privacyParameters.isMultiTenancyEnabled()).thenReturn(true);
    privacyApiGroupJsonRpcMethods.create();
    final PrivacyIdProvider privacyIdProvider = privacyApiGroupJsonRpcMethods.privacyIdProvider;
    assertThatThrownBy(() -> privacyIdProvider.getPrivacyUserId(Optional.empty())).isInstanceOf(IllegalStateException.class).hasMessage("Request does not contain an authorization token");
}
Also used : PrivacyIdProvider(org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider) Test(org.junit.Test)

Example 5 with PrivacyIdProvider

use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider in project besu by hyperledger.

the class PrivacyApiGroupJsonRpcMethodsTest method rpcsCreatedWithMultiTenancyUseEnclavePublicKeyFromRequest.

@Test
public void rpcsCreatedWithMultiTenancyUseEnclavePublicKeyFromRequest() {
    when(privacyParameters.isEnabled()).thenReturn(true);
    when(privacyParameters.isMultiTenancyEnabled()).thenReturn(true);
    final User user1 = createUser("key1");
    final User user2 = createUser("key2");
    privacyApiGroupJsonRpcMethods.create();
    final PrivacyIdProvider privacyIdProvider = privacyApiGroupJsonRpcMethods.privacyIdProvider;
    assertThat(privacyIdProvider.getPrivacyUserId(Optional.of(user1))).isEqualTo("key1");
    assertThat(privacyIdProvider.getPrivacyUserId(Optional.of(user2))).isEqualTo("key2");
}
Also used : User(io.vertx.ext.auth.User) PrivacyIdProvider(org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider) Test(org.junit.Test)

Aggregations

PrivacyIdProvider (org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider)6 PrivacyController (org.hyperledger.besu.ethereum.privacy.PrivacyController)3 Test (org.junit.Test)3 User (io.vertx.ext.auth.User)2 Map (java.util.Map)2 JsonRpcMethod (org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod)2 BlockchainQueries (org.hyperledger.besu.ethereum.api.query.BlockchainQueries)2 PrivacyParameters (org.hyperledger.besu.ethereum.core.PrivacyParameters)2 TransactionPool (org.hyperledger.besu.ethereum.eth.transactions.TransactionPool)2 ProtocolSchedule (org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule)2 FlexiblePrivacyController (org.hyperledger.besu.ethereum.privacy.FlexiblePrivacyController)2 MultiTenancyPrivacyController (org.hyperledger.besu.ethereum.privacy.MultiTenancyPrivacyController)2 PluginPrivacyController (org.hyperledger.besu.ethereum.privacy.PluginPrivacyController)2 RestrictedDefaultPrivacyController (org.hyperledger.besu.ethereum.privacy.RestrictedDefaultPrivacyController)2 PrivateMarkerTransactionFactory (org.hyperledger.besu.plugin.services.privacy.PrivateMarkerTransactionFactory)2 BigInteger (java.math.BigInteger)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 RpcApis (org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis)1 RpcMethod (org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod)1