Skip to content

Commit

Permalink
fix code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
ubamrein committed Sep 14, 2020
1 parent ce3d8e9 commit 3dd66bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import org.dpppt.backend.sdk.ws.security.ValidateRequest.WrongScopeException;
import org.dpppt.backend.sdk.ws.security.signature.ProtoSignature;
import org.dpppt.backend.sdk.ws.util.ValidationUtils.BadBatchReleaseTimeException;
import org.dpppt.backend.sdk.ws.util.ValidationUtils.DelayedKeyDateClaimIsMissing;
import org.dpppt.backend.sdk.ws.util.ValidationUtils.DelayedKeyDateIsInvalid;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
Expand Down Expand Up @@ -71,8 +69,7 @@ public DebugController(
@RequestHeader(value = "User-Agent", required = true) String userAgent,
@RequestHeader(value = "X-Device-Name", required = true) String deviceName,
@AuthenticationPrincipal Object principal)
throws InvalidDateException, ClaimIsBeforeOnsetException, WrongScopeException,
InsertException {
throws WrongScopeException, InsertException {
var now = UTCInstant.now();
this.validateRequest.isValid(principal);

Expand Down Expand Up @@ -141,19 +138,6 @@ private void normalizeRequestTime(long now) {
}
}

@ExceptionHandler({DelayedKeyDateClaimIsMissing.class})
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ResponseEntity<String> delayedClaimIsWrong() {
return ResponseEntity.badRequest().body("DelayedKeyDateClaim is wrong");
}

@ExceptionHandler({DelayedKeyDateIsInvalid.class})
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ResponseEntity<String> delayedKeyDateIsInvalid() {
return ResponseEntity.badRequest()
.body("DelayedKeyDate must be between yesterday and tomorrow");
}

@ExceptionHandler({
IllegalArgumentException.class,
InvalidDateException.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ public void insertIntoDatabase(
var internalKeys = filterAndModify(keys, header, principal, now);
// if no keys remain or this is a fake request, just return. Else, insert the
// remaining keys.
if (internalKeys.isEmpty() || validationUtils.jwtIsFake(principal)) {
return;
} else {
if (!internalKeys.isEmpty() && !validationUtils.jwtIsFake(principal)) {
dataService.upsertExposees(internalKeys, now);
}
}
Expand All @@ -94,9 +92,7 @@ public void insertIntoDatabaseDEBUG(
var internalKeys = filterAndModify(keys, header, principal, now);
// if no keys remain or this is a fake request, just return. Else, insert the
// remaining keys.
if (internalKeys.isEmpty() || validationUtils.jwtIsFake(principal)) {
return;
} else {
if (!internalKeys.isEmpty() && !validationUtils.jwtIsFake(principal)) {
debugDataService.upsertExposees(deviceName, internalKeys);
}
}
Expand Down

0 comments on commit 3dd66bd

Please sign in to comment.