Extend registrar allowed IPs auth exception text with IP address (#1726)

This commit is contained in:
Pavlo Tkach 2022-08-03 15:24:00 -04:00 committed by GitHub
parent a04420c873
commit 4399067ddd

View file

@ -114,7 +114,7 @@ public class TlsCredentials implements TransportCredentials {
"Authentication error: IP address %s is not allow-listed for registrar %s; allow list is:" "Authentication error: IP address %s is not allow-listed for registrar %s; allow list is:"
+ " %s", + " %s",
clientInetAddr, registrar.getRegistrarId(), ipAddressAllowList); clientInetAddr, registrar.getRegistrarId(), ipAddressAllowList);
throw new BadRegistrarIpAddressException(); throw new BadRegistrarIpAddressException(clientInetAddr);
} }
@VisibleForTesting @VisibleForTesting
@ -216,8 +216,12 @@ public class TlsCredentials implements TransportCredentials {
/** Registrar IP address is not in stored allow list. */ /** Registrar IP address is not in stored allow list. */
public static class BadRegistrarIpAddressException extends AuthenticationErrorException { public static class BadRegistrarIpAddressException extends AuthenticationErrorException {
BadRegistrarIpAddressException() { BadRegistrarIpAddressException(Optional<InetAddress> clientInetAddr) {
super("Registrar IP address is not in stored allow list"); super(
clientInetAddr.isPresent()
? String.format(
"Registrar IP address %s is not in stored allow list", clientInetAddr.get())
: "Registrar IP address is not in stored allow list");
} }
} }