Just as with any on-wire message, we have no idea whether or not it
contains confidential information.
Mark log output as condidential and clean up surrounding code a bit.
Change-Id: I15e85449ecd7795a4a01b1267a46e4909d1049e7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
<groupId>org.opendaylight.aaa</groupId>
<artifactId>aaa-encrypt-service</artifactId>
</dependency>
<groupId>org.opendaylight.aaa</groupId>
<artifactId>aaa-encrypt-service</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.odlparent</groupId>
+ <artifactId>logging-markers</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>util</artifactId>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>util</artifactId>
package org.opendaylight.netconf.nettyutil.handler;
import com.google.common.annotations.VisibleForTesting;
package org.opendaylight.netconf.nettyutil.handler;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.channel.ChannelHandlerContext;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.channel.ChannelHandlerContext;
import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
import org.opendaylight.netconf.api.messages.NetconfMessage;
import org.opendaylight.netconf.api.xml.XmlUtil;
import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
import org.opendaylight.netconf.api.messages.NetconfMessage;
import org.opendaylight.netconf.api.xml.XmlUtil;
+import org.opendaylight.odlparent.logging.markers.Markers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
public final class NetconfXMLToHelloMessageDecoder extends ByteToMessageDecoder {
private static final Logger LOG = LoggerFactory.getLogger(NetconfXMLToHelloMessageDecoder.class);
public final class NetconfXMLToHelloMessageDecoder extends ByteToMessageDecoder {
private static final Logger LOG = LoggerFactory.getLogger(NetconfXMLToHelloMessageDecoder.class);
- private static final List<byte[]> POSSIBLE_ENDS = ImmutableList.of(
+ private static final List<byte[]> POSSIBLE_ENDS = List.of(
new byte[] { ']', '\n' },
new byte[] { ']', '\r', '\n' });
new byte[] { ']', '\n' },
new byte[] { ']', '\r', '\n' });
- private static final List<byte[]> POSSIBLE_STARTS = ImmutableList.of(
+ private static final List<byte[]> POSSIBLE_STARTS = List.of(
new byte[] { '[' },
new byte[] { '\r', '\n', '[' },
new byte[] { '\n', '[' });
new byte[] { '[' },
new byte[] { '\r', '\n', '[' },
new byte[] { '\n', '[' });
final NetconfMessage message = getNetconfMessage(additionalHeader, doc);
if (message instanceof HelloMessage) {
final NetconfMessage message = getNetconfMessage(additionalHeader, doc);
if (message instanceof HelloMessage) {
- Preconditions.checkState(!helloReceived,
- "Multiple hello messages received, unexpected hello: %s", message);
+ if (helloReceived) {
+ throw new IllegalStateException("Multiple hello messages received, unexpected hello: " + message);
+ }
out.add(message);
helloReceived = true;
out.add(message);
helloReceived = true;
- // Non hello message, suspend the message and insert into cache
- } else {
- Preconditions.checkState(helloReceived, "Hello message not received, instead received: %s", message);
+ } else if (helloReceived) {
+ // Non hello message, suspend the message and insert into cache
LOG.debug("Netconf message received during negotiation, caching {}", message);
nonHelloMessages.add(message);
LOG.debug("Netconf message received during negotiation, caching {}", message);
nonHelloMessages.add(message);
+ } else {
+ throw new IllegalStateException("Hello message not received, instead received: " + message);
}
} finally {
in.discardReadBytes();
}
} finally {
in.discardReadBytes();
private static void logMessage(final byte[] bytes) {
if (LOG.isDebugEnabled()) {
private static void logMessage(final byte[] bytes) {
if (LOG.isDebugEnabled()) {
- String string = StandardCharsets.UTF_8.decode(ByteBuffer.wrap(bytes)).toString();
- LOG.debug("Parsing message \n{}", string);
+ LOG.debug(Markers.confidential(), "Parsing message \n{}",
+ StandardCharsets.UTF_8.decode(ByteBuffer.wrap(bytes)).toString());