diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/auth/OptionalAccess.java b/service/src/main/java/org/whispersystems/textsecuregcm/auth/OptionalAccess.java index b1225ca67..7cd8a9197 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/auth/OptionalAccess.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/auth/OptionalAccess.java @@ -55,7 +55,7 @@ public class OptionalAccess { } //noinspection ConstantConditions - if (requestAccount.isPresent() && (!targetAccount.isPresent() || (targetAccount.isPresent() && !targetAccount.get().isEnabled()))) { + if (requestAccount.isPresent() && (targetAccount.isEmpty() || (targetAccount.isPresent() && !targetAccount.get().isEnabled()))) { throw new WebApplicationException(Response.Status.NOT_FOUND); } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java index 438cef7a8..1183a6994 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java @@ -165,7 +165,6 @@ public class ProfileController { return getVersionedProfile(requestAccount, accessKey, uuid, version, Optional.of(credentialRequest)); } - @SuppressWarnings("OptionalIsPresent") private Optional getVersionedProfile(Optional requestAccount, Optional accessKey, UUID uuid, @@ -176,7 +175,7 @@ public class ProfileController { if (!isZkEnabled) throw new WebApplicationException(Response.Status.NOT_FOUND); try { - if (!requestAccount.isPresent() && !accessKey.isPresent()) { + if (requestAccount.isEmpty() && accessKey.isEmpty()) { throw new WebApplicationException(Response.Status.UNAUTHORIZED); } @@ -229,13 +228,13 @@ public class ProfileController { Optional uuid = usernamesManager.get(username); - if (!uuid.isPresent()) { + if (uuid.isEmpty()) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build()); } Optional accountProfile = accountsManager.get(uuid.get()); - if (!accountProfile.isPresent()) { + if (accountProfile.isEmpty()) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build()); } @@ -258,8 +257,8 @@ public class ProfileController { UUID uuid) throws InvalidInputException { - if (!encodedProfileCredentialRequest.isPresent()) return Optional.empty(); - if (!profile.isPresent()) return Optional.empty(); + if (encodedProfileCredentialRequest.isEmpty()) return Optional.empty(); + if (profile.isEmpty()) return Optional.empty(); try { ProfileKeyCommitment commitment = new ProfileKeyCommitment(profile.get().getCommitment()); @@ -296,7 +295,7 @@ public class ProfileController { @QueryParam("ca") boolean useCaCertificate) throws RateLimitExceededException { - if (!requestAccount.isPresent() && !accessKey.isPresent()) { + if (requestAccount.isEmpty() && accessKey.isEmpty()) { throw new WebApplicationException(Response.Status.UNAUTHORIZED); }