private ClientSync decodeEncryptedRequest(SessionAwareMessage message) throws GeneralSecurityException, PlatformEncDecException { SessionInfo session = message.getSessionInfo(); crypt.setSessionCipherPair(session.getCipherPair()); byte[] requestRaw = crypt.decodeData(message.getEncodedMessageData()); LOG.trace("Request data decrypted"); ClientSync request = decodePlatformLevelData(message.getPlatformId(), requestRaw); LOG.trace("Request data deserialized"); return request; }
private void processSessionResponse(SessionResponse message) throws GeneralSecurityException, PlatformEncDecException { SessionInfo session = message.getSessionInfo(); byte[] responseData = encodePlatformLevelData(message.getPlatformId(), message); LOG.trace("Response data serialized"); if (session.isEncrypted()) { crypt.setSessionCipherPair(session.getCipherPair()); responseData = crypt.encodeData(responseData); LOG.trace("Response data crypted"); } ChannelContext context = message.getSessionInfo().getCtx(); MessageBuilder converter = message.getMessageBuilder(); Object[] objects = converter.build(responseData, session.isEncrypted()); if (objects != null && objects.length > 0) { for (Object object : objects) { context.write(object); } context.flush(); } }