This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class RpcStartFlowResponse( | |
val flowId: FlowId, | |
val clientId: String? | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@CordaSerializable | |
data class RpcStartFlowRequest( | |
val flowName: String, | |
val clientId: String, | |
val parameters: RpcStartFlowRequestParameters | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@StartableByRPC | |
public class SampleFlow implements Flow<SignedTransactionDigest> { | |
private RpcStartFlowRequestParameters params; | |
@CordaInject | |
private JsonMarshallingService jsonMarshallingService; | |
@JsonConstructor | |
public SampleFlow(RpcStartFlowRequestParameters params) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) throws Exception{ | |
// Establish connection, get attestation and send bid code here. | |
... | |
byte[] encryptedReply = new byte[fromHost.readInt()]; | |
System.out.println("Reading reply mail of length " + encryptedReply.length + " bytes."); | |
fromHost.readFully(encryptedReply); | |
EnclaveMail reply = postOffice.decryptMail(encryptedReply); | |
System.out.println("Enclave gave us the answer '" + new String(reply.getBodyAsBytes()) + "'"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static int getUserBidInput(String args[]) throws Exception{ | |
if(args.length > 0 && args[0].equals("BID")) { | |
System.out.println("Please enter your Bid Amount"); | |
System.out.println(); | |
System.out.println("---------------------------"); | |
System.out.println("Bid Amount: "); | |
BufferedReader reader = | |
new BufferedReader(new InputStreamReader(System.in)); | |
String bidAmount = reader.readLine(); | |
return Integer.valueOf(bidAmount); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) throws Exception{ | |
// Establish connection and get attestaion code here | |
... | |
int bid = getUserBidInput(args); | |
Output serializedOutput = serializeMessage(messageType, bid); | |
PrivateKey myKey = Curve25519PrivateKey.random(); | |
PostOffice postOffice = attestation.createPostOffice(myKey, UUID.randomUUID().toString()); | |
byte[] encryptedMail = postOffice.encryptMail(serializedOutput.getBuffer()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Pair<DataInputStream, DataOutputStream> establishConnection() throws Exception{ | |
DataInputStream fromHost; | |
DataOutputStream toHost; | |
while (true) { | |
try { | |
System.out.println("Attempting to connect to Host at localhost:5051"); | |
Socket socket = new Socket(); | |
socket.connect(new InetSocketAddress(InetAddress.getLoopbackAddress(), 5051), 10000); | |
fromHost = new DataInputStream(socket.getInputStream()); | |
toHost = new DataOutputStream(socket.getOutputStream()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AuctionClient { | |
public static void main(String[] args) throws Exception{ | |
Pair<DataInputStream, DataOutputStream> streams = establishConnection(); | |
DataInputStream fromHost = streams.getFirst(); | |
DataOutputStream toHost = streams.getSecond(); | |
EnclaveInstanceInfo attestation = getAttestation(fromHost); | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void recieveMailFromClientAndDeliverToEnclave(Socket clientSocket, String routingHint){ | |
try { | |
DataInputStream input = new DataInputStream(clientSocket.getInputStream()); | |
byte[] mailBytes = new byte[input.readInt()]; | |
input.readFully(mailBytes); | |
enclaveHost.deliverMail(1, mailBytes, routingHint); | |
}catch (IOException ioException){ | |
ioException.printStackTrace(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void sendMessageToClient(String routingHint, byte[] content){ | |
try { | |
Socket clientSocket = clientMap.get(routingHint); | |
DataOutputStream outputStream = new DataOutputStream(clientSocket.getOutputStream()); | |
outputStream.writeInt(content.length); | |
outputStream.write(content); | |
outputStream.flush(); | |
}catch (IOException ioe){ | |
ioe.printStackTrace(); | |
return; |