use of org.hyperledger.besu.ethereum.privacy.MultiTenancyPrivacyController in project besu by hyperledger.
the class PrivUnsubscribe method response.
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
try {
final PrivateUnsubscribeRequest unsubscribeRequest = getMapper().mapPrivateUnsubscribeRequest(requestContext);
if (privacyController instanceof MultiTenancyPrivacyController) {
checkIfPrivacyGroupMatchesAuthenticatedPrivacyUserId(requestContext, unsubscribeRequest.getPrivacyGroupId());
}
final boolean unsubscribed = subscriptionManager().unsubscribe(unsubscribeRequest);
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), unsubscribed);
} catch (final InvalidSubscriptionRequestException isEx) {
return new JsonRpcErrorResponse(requestContext.getRequest().getId(), JsonRpcError.INVALID_REQUEST);
} catch (final SubscriptionNotFoundException snfEx) {
return new JsonRpcErrorResponse(requestContext.getRequest().getId(), JsonRpcError.SUBSCRIPTION_NOT_FOUND);
}
}
use of org.hyperledger.besu.ethereum.privacy.MultiTenancyPrivacyController in project besu by hyperledger.
the class PrivNewFilter method response.
@Override
public JsonRpcResponse response(final JsonRpcRequestContext request) {
final String privacyGroupId = request.getRequiredParameter(0, String.class);
final FilterParameter filter = request.getRequiredParameter(1, FilterParameter.class);
final String privacyUserId = privacyIdProvider.getPrivacyUserId(request.getUser());
if (privacyController instanceof MultiTenancyPrivacyController) {
// no need to pass blockNumber. To create a filter, you need to be a current member of the
// group
checkIfPrivacyGroupMatchesAuthenticatedPrivacyUserId(privacyUserId, privacyGroupId);
}
if (!filter.isValid()) {
return new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
}
final String logFilterId = filterManager.installPrivateLogFilter(privacyGroupId, privacyUserId, filter.getFromBlock(), filter.getToBlock(), filter.getLogsQuery());
return new JsonRpcSuccessResponse(request.getRequest().getId(), logFilterId);
}
use of org.hyperledger.besu.ethereum.privacy.MultiTenancyPrivacyController in project besu by hyperledger.
the class PrivGetFilterLogs method response.
@Override
public JsonRpcResponse response(final JsonRpcRequestContext request) {
final String privacyGroupId = request.getRequiredParameter(0, String.class);
final String filterId = request.getRequiredParameter(1, String.class);
if (privacyController instanceof MultiTenancyPrivacyController) {
checkIfPrivacyGroupMatchesAuthenticatedPrivacyUserId(request, privacyGroupId);
}
final List<LogWithMetadata> logs = filterManager.logs(filterId);
if (logs != null) {
return new JsonRpcSuccessResponse(request.getRequest().getId(), new LogsResult(logs));
}
return new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.LOGS_FILTER_NOT_FOUND);
}
use of org.hyperledger.besu.ethereum.privacy.MultiTenancyPrivacyController in project besu by hyperledger.
the class PrivGetFilterChanges method response.
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final String privacyGroupId = requestContext.getRequiredParameter(0, String.class);
final String filterId = requestContext.getRequiredParameter(1, String.class);
if (privacyController instanceof MultiTenancyPrivacyController) {
checkIfPrivacyGroupMatchesAuthenticatedPrivacyUserId(requestContext, privacyGroupId);
}
final List<LogWithMetadata> logs = filterManager.logsChanges(filterId);
if (logs != null) {
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), new LogsResult(logs));
}
return new JsonRpcErrorResponse(requestContext.getRequest().getId(), JsonRpcError.FILTER_NOT_FOUND);
}
use of org.hyperledger.besu.ethereum.privacy.MultiTenancyPrivacyController in project besu by hyperledger.
the class PrivSubscribe method response.
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
try {
final String privacyUserId = privacyIdProvider.getPrivacyUserId(requestContext.getUser());
final PrivateSubscribeRequest subscribeRequest = getMapper().mapPrivateSubscribeRequest(requestContext, privacyUserId);
if (privacyController instanceof MultiTenancyPrivacyController) {
checkIfPrivacyGroupMatchesAuthenticatedPrivacyUserId(requestContext, subscribeRequest.getPrivacyGroupId());
}
final Long subscriptionId = subscriptionManager().subscribe(subscribeRequest);
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), Quantity.create(subscriptionId));
} catch (final InvalidSubscriptionRequestException isEx) {
return new JsonRpcErrorResponse(requestContext.getRequest().getId(), JsonRpcError.INVALID_REQUEST);
}
}
Aggregations