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));
}
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())));
}
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);
}
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");
}
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");
}
Aggregations