From ea70e1b347c49e41eb2b77d1aa783fb86321bc8d Mon Sep 17 00:00:00 2001 From: Colin McDonald Date: Wed, 13 Jul 2016 19:37:51 -0400 Subject: [PATCH] Remove ip null checks directly before a call to IpUtils#isValidIp, as IpUtils#isValidIp will perform a null check automatically --- src/main/java/net/frozenorb/apiv3/model/User.java | 2 +- .../frozenorb/apiv3/route/users/GETUsersIdRequiresTotp.java | 2 +- src/main/java/net/frozenorb/apiv3/util/TotpUtils.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/frozenorb/apiv3/model/User.java b/src/main/java/net/frozenorb/apiv3/model/User.java index b59e876..27db18e 100644 --- a/src/main/java/net/frozenorb/apiv3/model/User.java +++ b/src/main/java/net/frozenorb/apiv3/model/User.java @@ -410,7 +410,7 @@ public final class User { return; } - if (ip == null || !IpUtils.isValidIp(ip)) { + if (!IpUtils.isValidIp(ip)) { callback.onResult(RequiresTotpResult.REQUIRED_NO_EXEMPTIONS, null); return; } diff --git a/src/main/java/net/frozenorb/apiv3/route/users/GETUsersIdRequiresTotp.java b/src/main/java/net/frozenorb/apiv3/route/users/GETUsersIdRequiresTotp.java index 61df223..c4e9c41 100644 --- a/src/main/java/net/frozenorb/apiv3/route/users/GETUsersIdRequiresTotp.java +++ b/src/main/java/net/frozenorb/apiv3/route/users/GETUsersIdRequiresTotp.java @@ -25,7 +25,7 @@ public final class GETUsersIdRequiresTotp implements Handler { String userIp = ctx.request().getParam("userIp"); - if (userIp != null && IpUtils.isValidIp(userIp)) { + if (IpUtils.isValidIp(userIp)) { ErrorUtils.respondInvalidInput(ctx, "Ip address \"" + userIp + "\" is not valid."); return; } diff --git a/src/main/java/net/frozenorb/apiv3/util/TotpUtils.java b/src/main/java/net/frozenorb/apiv3/util/TotpUtils.java index 77e94cb..3e1f7fe 100644 --- a/src/main/java/net/frozenorb/apiv3/util/TotpUtils.java +++ b/src/main/java/net/frozenorb/apiv3/util/TotpUtils.java @@ -26,7 +26,7 @@ public class TotpUtils { } public static void isPreAuthorized(User user, String ip, SingleResultCallback callback) { - if (ip == null || !IpUtils.isValidIp(ip)) { + if (!IpUtils.isValidIp(ip)) { callback.onResult(false, null); return; } @@ -41,7 +41,7 @@ public class TotpUtils { } public static void markPreAuthorized(User user, String ip, long duration, TimeUnit unit, SingleResultCallback callback) { - if (ip == null || !IpUtils.isValidIp(ip)) { + if (!IpUtils.isValidIp(ip)) { callback.onResult(null, null); return; }