Skip to content

Commit

Permalink
no masking of sender addresses for outbound messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-Draeger committed Aug 30, 2024
1 parent c825a5d commit 4f5a0fd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@
@Singleton
public class MessageStorage implements AutoCloseable {

public static final String UNKNOWN_SENDER = "UNKNOWN";
public static final String DEFAULT_OUTBOUND_SENDER = "SDCcc";
private static final Logger LOG = LogManager.getLogger(MessageStorage.class);

private static final int FETCH_SIZE = 10;
Expand Down Expand Up @@ -320,21 +318,21 @@ protected MessageContent convertMessageToMessageContent(final Message message) {
}

private String getSender(final Message message) {
final CommunicationContext communicationContext = message.getCommunicationContext();
if (communicationContext == null) {
// NOTE: this should never happen. If it does, this should be considered a bug.
LOG.trace("Encountered message (uuid={}) without a CommunicationContext.", message);
testRunObserver.invalidateTestRun("Encountered message without a CommunicationContext.");
return null;
}
final TransportInfo transportInfo = communicationContext.getTransportInfo();
if (transportInfo == null) {
// NOTE: this should never happen. If it does, this should be considered a bug.
LOG.trace("Encountered message (uuid={}) without a TransportInfo.", message);
testRunObserver.invalidateTestRun("Encountered message without a TransportInfo.");
return null;
}
if (message.getDirection() == CommunicationLog.Direction.INBOUND) {
final CommunicationContext communicationContext = message.getCommunicationContext();
if (communicationContext == null) {
// NOTE: this should never happen. If it does, this should be considered a bug.
LOG.trace("Encountered message (uuid={}) without a CommunicationContext.", message);
testRunObserver.invalidateTestRun("Encountered message without a CommunicationContext.");
return null;
}
final TransportInfo transportInfo = communicationContext.getTransportInfo();
if (transportInfo == null) {
// NOTE: this should never happen. If it does, this should be considered a bug.
LOG.trace("Encountered message (uuid={}) without a TransportInfo.", message);
testRunObserver.invalidateTestRun("Encountered message without a TransportInfo.");
return null;
}
final Optional<String> remoteAddress = transportInfo.getRemoteAddress();
if (remoteAddress.isEmpty()) {
// NOTE: this should never happen. If it does, this should be considered a bug.
Expand All @@ -345,7 +343,15 @@ private String getSender(final Message message) {
return remoteAddress.orElseThrow();
}
} else if (message.getDirection() == CommunicationLog.Direction.OUTBOUND) {
return DEFAULT_OUTBOUND_SENDER;
final Optional<String> localAddress = transportInfo.getLocalAddress();
if (localAddress.isEmpty()) {
// NOTE: this should never happen. If it does, this should be considered a bug.
LOG.trace("Encountered outbound message (uuid={}) without a localAddress.", message);
testRunObserver.invalidateTestRun("Encountered outbound message without a localAddress.");
return null;
} else {
return localAddress.orElseThrow();
}
} else {
testRunObserver.invalidateTestRun("Encountered unknown direction in message.");
LOG.trace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
Expand Down Expand Up @@ -111,7 +112,7 @@ public MessageContent(
final Set<String> actions,
final String uuid,
final boolean isSOAP,
final String sender) {
@Nullable final String sender) {

this.body = body;
this.direction = direction;
Expand Down

0 comments on commit 4f5a0fd

Please sign in to comment.