use of com.quorum.tessera.jaxrs.client.ClientFactory in project tessera by ConsenSys.
the class PayloadPublisherProvider method provider.
public static PayloadPublisher provider() {
Config config = ConfigFactory.create().getConfig();
Discovery partyInfoService = Discovery.create();
ClientFactory clientFactory = new ClientFactory();
Client client = clientFactory.buildFrom(config.getP2PServerConfig());
return new RestPayloadPublisher(client, partyInfoService);
}
use of com.quorum.tessera.jaxrs.client.ClientFactory in project tessera by ConsenSys.
the class PrivacyGroupPublisherProvider method provider.
public static PrivacyGroupPublisher provider() {
Discovery discovery = Discovery.create();
Config config = ConfigFactory.create().getConfig();
Client client = new ClientFactory().buildFrom(config.getP2PServerConfig());
return new RestPrivacyGroupPublisher(discovery, client);
}
use of com.quorum.tessera.jaxrs.client.ClientFactory in project tessera by ConsenSys.
the class PeerToPeerIT method benevolentNodeBecomesPossessedAndSendsInvalidKeyInRecipientList.
/*
A good node with valid key has a bad recipient in its party info
*/
@Test
public void benevolentNodeBecomesPossessedAndSendsInvalidKeyInRecipientList() throws Exception {
Party partyB = partyHelper.findByAlias(NodeAlias.B);
ServerConfig serverConfig = partyB.getConfig().getP2PServerConfig();
PublicKey publicKey = Optional.of(partyB).map(Party::getPublicKey).map(Base64.getDecoder()::decode).map(PublicKey::from).get();
Recipient itself = Recipient.of(publicKey, serverConfig.getServerUri().toString());
String validButIncorrectUrl = partyHelper.findByAlias(NodeAlias.C).getConfig().getP2PServerConfig().getServerAddress();
Recipient badRecipient = Recipient.of(PublicKey.from("OUCH".getBytes()), validButIncorrectUrl);
Set<Recipient> recipients = Stream.of(itself, badRecipient).collect(Collectors.toSet());
assertThat(recipients).containsExactlyInAnyOrder(itself, badRecipient);
PartyInfo partyInfo = new PartyInfo(serverConfig.getServerUri().toString(), recipients, Collections.emptySet());
Client client = new ClientFactory().buildFrom(serverConfig);
PartyInfoParser partyInfoParser = PartyInfoParser.create();
byte[] data = partyInfoParser.to(partyInfo);
StreamingOutput output = out -> out.write(data);
Response response = client.target(partyA.getP2PUri()).path("partyinfo").request().post(Entity.entity(output, MediaType.APPLICATION_OCTET_STREAM));
assertThat(response.getStatus()).isEqualTo(200);
}
use of com.quorum.tessera.jaxrs.client.ClientFactory in project tessera by ConsenSys.
the class PeerToPeerIT method benevolentNodeBecomesPosessedAndSendsInvalidUrlInRecipientList.
/*
A good node with valid key has a bad recipient in its party info.
The key is valid (node C's key) but there is a validation failure as
the url cannot be called.
*/
@Test
public void benevolentNodeBecomesPosessedAndSendsInvalidUrlInRecipientList() throws Exception {
Party partyB = partyHelper.findByAlias(NodeAlias.B);
ServerConfig serverConfig = Optional.of(partyB.getConfig()).map(Config::getP2PServerConfig).get();
PublicKey publicKey = Optional.of(partyB).map(Party::getPublicKey).map(Base64.getDecoder()::decode).map(PublicKey::from).get();
Recipient itself = Recipient.of(publicKey, serverConfig.getServerUri().toString());
String validKeyFromOtherNode = partyHelper.findByAlias(NodeAlias.C).getPublicKey();
PublicKey validButIncorrectKey = Optional.of(validKeyFromOtherNode).map(Base64.getDecoder()::decode).map(PublicKey::from).get();
Recipient badRecipient = Recipient.of(validButIncorrectKey, "http://bogus.supersnide.com:8829");
Set<Recipient> recipients = Stream.of(itself, badRecipient).collect(Collectors.toSet());
assertThat(recipients).containsExactlyInAnyOrder(itself, badRecipient);
PartyInfo partyInfo = new PartyInfo(serverConfig.getServerUri().toString(), recipients, Collections.emptySet());
Client client = new ClientFactory().buildFrom(serverConfig);
PartyInfoParser partyInfoParser = PartyInfoParser.create();
byte[] data = partyInfoParser.to(partyInfo);
StreamingOutput output = out -> out.write(data);
Response response = client.target(partyA.getP2PUri()).path("partyinfo").request().post(Entity.entity(output, MediaType.APPLICATION_OCTET_STREAM));
assertThat(response.getStatus()).isEqualTo(200);
}
use of com.quorum.tessera.jaxrs.client.ClientFactory in project tessera by ConsenSys.
the class EnclaveClientProvider method provider.
public static EnclaveClient provider() {
Config config = ConfigFactory.create().getConfig();
LOGGER.debug("Creating RestfulEnclaveClient with {}", config);
Optional<ServerConfig> enclaveServerConfig = config.getServerConfigs().stream().filter(sc -> sc.getApp() == AppType.ENCLAVE).findAny();
final ClientFactory clientFactory = new ClientFactory();
LOGGER.debug("Creating server context from config");
ServerConfig serverConfig = enclaveServerConfig.get();
LOGGER.debug("Created server context from config");
Client client = clientFactory.buildFrom(serverConfig);
LOGGER.info("Creating remoted enclave for {}", serverConfig.getServerUri());
return new RestfulEnclaveClient(client, serverConfig.getServerUri());
}
Aggregations