private void prepareData(ApplicationMessage msg) { if (msg.getDataConfig() != null) { msg.setData(msg.getDataConfig()); } else { msg.setData(chooser.getLastHandledApplicationMessageData()); } LOGGER.debug("Data: " + ArrayConverter.bytesToHexString(msg.getData().getValue())); }
/** * Reads the next bytes as the Data and writes them in the message * * @param msg * Message to write in */ private void parseData(ApplicationMessage msg) { msg.setData(parseByteArrayField(getBytesLeft())); LOGGER.debug("Data: " + ArrayConverter.bytesToHexString(msg.getData().getValue())); }
@Override public void adjustTLSContext(ApplicationMessage message) { tlsContext.setLastHandledApplicationMessageData(message.getData().getValue()); String readableAppData = ArrayConverter.bytesToHexString(tlsContext.getLastHandledApplicationMessageData()); if (tlsContext.getTalkingConnectionEndType() == tlsContext.getChooser().getMyConnectionPeer()) { LOGGER.debug("Received Data:" + readableAppData); } else { LOGGER.debug("Send Data:" + readableAppData); } } }
/** * Receives bytes and decrypts ApplicationMessage contents * * @return Received bytes The bytes which are received * @throws java.io.IOException * If something goes wrong during the receive */ public byte[] receiveBytes() throws IOException { ReceiveAction action = new ReceiveAction(new ApplicationMessage()); action.setConnectionAlias(state.getTlsContext().getConnection().getAlias()); action.execute(state); List<ProtocolMessage> recievedMessages = action.getReceivedMessages(); List<ApplicationMessage> recievedAppMessages = new LinkedList<>(); for (ProtocolMessage message : recievedMessages) { if (message instanceof ApplicationMessage) { recievedAppMessages.add((ApplicationMessage) message); } } ByteArrayOutputStream stream = new ByteArrayOutputStream(); for (ApplicationMessage message : recievedAppMessages) { stream.write(message.getData().getValue()); } return stream.toByteArray(); }