From e4210ebde79cfcc76e37a95544b10e5df556eba6 Mon Sep 17 00:00:00 2001 From: Daniel McCoy Stephenson Date: Wed, 13 Mar 2024 12:50:53 -0600 Subject: [PATCH] Cleaned up changes to Asn1EncodedDataRouter class --- .../services/asn1/Asn1EncodedDataRouter.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/Asn1EncodedDataRouter.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/Asn1EncodedDataRouter.java index e4f5cb5c3..18e18c066 100644 --- a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/Asn1EncodedDataRouter.java +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/Asn1EncodedDataRouter.java @@ -175,7 +175,6 @@ public void processEncodedTim(ServiceRequest request, JSONObject consumedObj) { String hexEncodedTim = mfObj.getString(BYTES); logger.debug("Encoded message - phase 1: {}", hexEncodedTim); - logger.debug("Is header present? {}", isHeaderPresent(hexEncodedTim)); //use Asnc1 library to decode the encoded tim returned from ASNC1; another class two blockers: decode the tim and decode the message-sign if (odeProperties.dataSigningEnabled()) { @@ -231,7 +230,7 @@ public void processEncodedTim(ServiceRequest request, JSONObject consumedObj) { // if header is present, strip it if (isHeaderPresent(hexEncodedTim)) { String header = hexEncodedTim.substring(0, hexEncodedTim.indexOf("001F") + 4); - logger.debug("Stripping header from message: {}", header); + logger.debug("Stripping header from unsigned message: {}", header); hexEncodedTim = stripHeader(hexEncodedTim); mfObj.remove(BYTES); mfObj.put(BYTES, hexEncodedTim); @@ -244,7 +243,6 @@ public void processEncodedTim(ServiceRequest request, JSONObject consumedObj) { if (null != request.getSnmp() && null != request.getRsus() && null != hexEncodedTim) { logger.info("Sending message to RSUs..."); - logger.debug("Is header present? {}", isHeaderPresent(hexEncodedTim)); asn1CommandManager.sendToRsus(request, hexEncodedTim); } @@ -252,7 +250,6 @@ public void processEncodedTim(ServiceRequest request, JSONObject consumedObj) { // Case 2 only logger.debug("Publishing message for round 2 encoding!"); - logger.debug("Is header present? {}", isHeaderPresent(hexEncodedTim)); String xmlizedMessage = asn1CommandManager.packageSignedTimIntoAsd(request, hexEncodedTim); stringMsgProducer.send(odeProperties.getKafkaTopicAsn1EncoderInput(), null, xmlizedMessage); @@ -332,20 +329,23 @@ public void processEncodedTimUnsecured(ServiceRequest request, JSONObject consum String encodedTim = mfObj.getString(BYTES); // if header is present, strip it - logger.debug("Is header present? {}", isHeaderPresent(encodedTim)); if (isHeaderPresent(encodedTim)) { String header = encodedTim.substring(0, encodedTim.indexOf("001F") + 4); - logger.debug("Stripping header from message: {}", header); + logger.debug("Stripping header from unsigned message: {}", header); encodedTim = stripHeader(encodedTim); + mfObj.remove(BYTES); + mfObj.put(BYTES, encodedTim); + dataObj.remove(MESSAGE_FRAME); + dataObj.put(MESSAGE_FRAME, mfObj); + consumedObj.remove(AppContext.PAYLOAD_STRING); + consumedObj.put(AppContext.PAYLOAD_STRING, dataObj); } logger.debug("Encoded message - phase 2: {}", encodedTim); - logger.debug("Is header present? {}", isHeaderPresent(encodedTim)); // only send message to rsu if snmp, rsus, and message frame fields are present if (null != request.getSnmp() && null != request.getRsus() && null != encodedTim) { logger.debug("Encoded message phase 3: {}", encodedTim); - logger.debug("Is header present? {}", isHeaderPresent(encodedTim)); asn1CommandManager.sendToRsus(request, encodedTim); } } @@ -357,11 +357,7 @@ public void processEncodedTimUnsecured(ServiceRequest request, JSONObject consum * Checks if header is present in encoded message */ private boolean isHeaderPresent(String encodedTim) { - boolean toReturn = encodedTim.indexOf("001F") > 0; - if (toReturn) { - logger.warn("Header found in encoded message: {}", encodedTim); - } - return toReturn; + return encodedTim.indexOf("001F") > 0; } /**