Skip to content

Commit

Permalink
ARC-979: Sonar findings
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasrichner-oviva committed Jan 30, 2024
1 parent 163760e commit c1d7a73
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class JwsVerifier {

private JwsVerifier() {}

@SuppressWarnings("java:S2583")
public static boolean verify(@NonNull JWKSet jwks, @NonNull JWSObject jws) {

if (jwks == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public static RuntimeException notAnIdpList(String actualType) {
"JWS is not of type idp-list but rather '%s'".formatted(actualType));
}

public static RuntimeException emptyIdpList(URI master) {
return new RuntimeException("list of idps empty from '%s'".formatted(master));
}

public static RuntimeException badSignature(Exception cause) {
return new RuntimeException("bad signature", cause);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private List<IdpEntity> mustFetchIdpList() {

var idpJws = apiClient.fetchIdpList(URI.create(idpListEndpoint));
if (idpJws == null || idpJws.body() == null || idpJws.body().idpEntities() == null) {
throw new RuntimeException("unable to fetch IDP list from '%s'".formatted(fedMasterUri));
throw FederationExceptions.emptyIdpList(fedMasterUri);
}

return idpJws.body().idpEntities();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

public class HttpExceptions {

private HttpExceptions() {}

public static RuntimeException httpFailBadStatus(String method, URI uri, int status) {
return httpFail(method, uri, "bad status %d".formatted(status));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public Response call(Request req) {
var res = httpClient.send(builder.build(), BodyHandlers.ofByteArray());
return toResponse(res);
} catch (IOException e) {
var msg = "failed to request '%s %s'".formatted(req.method(), req.uri());
throw new RuntimeException(msg, e);
throw HttpExceptions.httpFailCausedBy(req.method(), req.uri(), e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
public class JWKSetConverter extends StdConverter<JWKSet, Map<String, Object>> {

@Override
@SuppressWarnings("java:S1168")
public Map<String, Object> convert(JWKSet value) {
if (value == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.oviva.gesundheitsid.util;

import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.type.TypeReference;
Expand All @@ -21,7 +20,7 @@ public JWKSetDeserializer(Class<?> vc) {

@Override
public JWKSet deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JacksonException {
throws IOException {

var node = jsonParser.getCodec().readTree(jsonParser);

Expand All @@ -41,7 +40,7 @@ public JWKDeserializer(Class<?> vc) {

@Override
public JWK deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JacksonException {
throws IOException {

Map<String, Object> map =
jsonParser.getCodec().readValue(jsonParser, new TypeReference<Map<String, Object>>() {});
Expand Down

0 comments on commit c1d7a73

Please sign in to comment.