Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating dependencies to latest ones @ 2024-01 #1887

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,37 @@

<!-- ### Compile dependencies versions -->
<minimal-json.version>0.9.5</minimal-json.version>
<jackson-bom.version>2.14.3</jackson-bom.version>
<typesafe-config.version>1.4.2</typesafe-config.version>
<jackson-bom.version>2.16.1</jackson-bom.version>
<typesafe-config.version>1.4.3</typesafe-config.version>
<ssl-config-core.version>0.6.1</ssl-config-core.version>
<kafka-client.version>3.5.1</kafka-client.version>
<kafka-client.version>3.6.1</kafka-client.version>
<hivemq-mqtt-client.version>1.3.3</hivemq-mqtt-client.version>
<sshd.version>2.9.2</sshd.version>
<eddsa.version>0.3.0</eddsa.version>
<lz4-java.version>1.8.0</lz4-java.version>

<pekko-bom.version>1.0.1</pekko-bom.version>
<pekko-bom.version>1.0.2</pekko-bom.version>
<pekko-http-bom.version>1.0.0</pekko-http-bom.version>
<pekko-persistence-mongodb.version>1.0.1</pekko-persistence-mongodb.version>
<pekko-persistence-mongodb.version>1.1.0</pekko-persistence-mongodb.version>
<pekko-persistence-inmemory.version>1.0.0</pekko-persistence-inmemory.version>
<pekko-management.version>1.0.0</pekko-management.version>
<pekko-connector-kafka.version>1.0.0</pekko-connector-kafka.version>
<parboiled.version>2.5.0</parboiled.version>
<parboiled.version>2.5.1</parboiled.version>

<!-- Necessary for pekko-persistence-mongodb -->
<metrics4-scala.version>4.2.9</metrics4-scala.version>

<!-- Keep these version consistent with pekko-persistence-mongodb.version's build.sbt -->
<mongo-java-driver.version>4.10.2</mongo-java-driver.version>
<mongo-java-driver.version>4.11.1</mongo-java-driver.version>

<jjwt.version>0.11.5</jjwt.version>
<jjwt.version>0.12.5</jjwt.version>
<asm.version>9.2</asm.version>
<qpid-jms-client.version>1.10.0</qpid-jms-client.version>
<qpid-jms-client.version>1.11.0</qpid-jms-client.version>
<pjfanning-pekko-rabbitmq.version>7.0.0</pjfanning-pekko-rabbitmq.version>
<amqp-client.version>5.18.0</amqp-client.version>
<reactive-streams.version>1.0.4</reactive-streams.version>
<netty-bom.version>4.1.99.Final</netty-bom.version>
<cloudevents.version>2.3.0</cloudevents.version>
<netty-bom.version>4.1.106.Final</netty-bom.version>
<cloudevents.version>2.5.0</cloudevents.version>

<slf4j.version>2.0.11</slf4j.version>
<logback.version>1.4.14</logback.version>
Expand All @@ -75,7 +75,7 @@
<janino.version>3.1.11</janino.version>

<!-- ### Metrics and Tracing -->
<kamon.version>2.6.6</kamon.version>
<kamon.version>2.7.0</kamon.version>

<jsr305.version>3.0.2</jsr305.version>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import org.apache.pekko.http.javadsl.model.HttpRequest;
import org.apache.pekko.http.javadsl.model.HttpResponse;
import org.apache.pekko.stream.Materializer;
import org.apache.pekko.stream.SystemMaterializer;
import org.apache.pekko.stream.javadsl.Sink;
import org.apache.pekko.util.ByteString;
import org.eclipse.ditto.base.model.exceptions.DittoRuntimeException;
import org.eclipse.ditto.gateway.api.GatewayAuthenticationProviderUnavailableException;
import org.eclipse.ditto.gateway.api.GatewayJwtIssuerNotSupportedException;
Expand Down Expand Up @@ -65,12 +71,6 @@
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.RemovalListener;

import org.apache.pekko.http.javadsl.model.HttpRequest;
import org.apache.pekko.http.javadsl.model.HttpResponse;
import org.apache.pekko.stream.Materializer;
import org.apache.pekko.stream.SystemMaterializer;
import org.apache.pekko.stream.javadsl.Sink;
import org.apache.pekko.util.ByteString;
import io.jsonwebtoken.JwtParser;
import io.jsonwebtoken.Jwts;

Expand Down Expand Up @@ -391,10 +391,10 @@ private static JwkInvalidException getJwkInvalidExceptionException(final String
}

private PublicKeyWithParser mapToPublicKeyWithParser(final PublicKey publicKey) {
final var jwtParserBuilder = Jwts.parserBuilder();
final JwtParser jwtParser = jwtParserBuilder.deserializeJsonWith(JjwtDeserializer.getInstance())
.setSigningKey(publicKey)
.setAllowedClockSkewSeconds(oAuthConfig.getAllowedClockSkew().getSeconds())
final var jwtParserBuilder = Jwts.parser();
final JwtParser jwtParser = jwtParserBuilder.json(JjwtDeserializer.getInstance())
.verifyWith(publicKey)
.clockSkewSeconds(oAuthConfig.getAllowedClockSkew().getSeconds())
.build();

return new PublicKeyWithParser(publicKey, jwtParser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ public void validate() throws ExecutionException, InterruptedException {
}

private JwtParser getJwtParser(final PublicKey publicKey) {
final var jwtParserBuilder = Jwts.parserBuilder();
return jwtParserBuilder.deserializeJsonWith(JjwtDeserializer.getInstance())
.setSigningKey(publicKey)
.setAllowedClockSkewSeconds(oAuthConfig.getAllowedClockSkew().getSeconds())
final var jwtParserBuilder = Jwts.parser();
return jwtParserBuilder.json(JjwtDeserializer.getInstance())
.verifyWith(publicKey)
.clockSkewSeconds(oAuthConfig.getAllowedClockSkew().getSeconds())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.json.JsonValue;
import org.apache.pekko.NotUsed;
import org.apache.pekko.stream.SourceRef;
import org.apache.pekko.stream.javadsl.Source;
import org.eclipse.ditto.base.model.common.ConditionChecker;
import org.eclipse.ditto.json.JsonValue;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;

import org.apache.pekko.NotUsed;
import org.apache.pekko.stream.SourceRef;
import org.apache.pekko.stream.javadsl.Source;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Wraps a {@link SourceRef} of {@link JsonValue}s. The purpose of this class is to make working with SourceRef type
Expand All @@ -51,7 +51,7 @@ private JsonValueSourceRef(final SourceRef<JsonValue> sourceRef) {
* @throws NullPointerException if {@code sourceRef} is {@code null}.
*/
@JsonCreator
public static JsonValueSourceRef of(final SourceRef<JsonValue> sourceRef) {
public static JsonValueSourceRef of(@JsonProperty("sourceRef") final SourceRef<JsonValue> sourceRef) {
return new JsonValueSourceRef(ConditionChecker.checkNotNull(sourceRef, "sourceRef"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@
*/
package org.eclipse.ditto.internal.utils.jwt;

import java.nio.charset.StandardCharsets;
import java.io.Reader;
import java.text.MessageFormat;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.common.ConditionChecker;
import org.eclipse.ditto.json.JsonArray;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonObject;
import org.eclipse.ditto.json.JsonValue;
import org.eclipse.ditto.json.JsonValueParser;

import io.jsonwebtoken.io.AbstractDeserializer;
import io.jsonwebtoken.io.DeserializationException;
import io.jsonwebtoken.io.Deserializer;

/**
* JJWT library Deserializer implementation which translates JSON strings to Java Objects (e.g. Maps).
*/
@Immutable
public final class JjwtDeserializer implements Deserializer<Map<String, ?>> {
public final class JjwtDeserializer extends AbstractDeserializer<Map<String, ?>> {

private static Deserializer<Map<String, ?>> instance;

Expand All @@ -49,27 +49,15 @@ public final class JjwtDeserializer implements Deserializer<Map<String, ?>> {
}

@Override
public Map<String, ?> deserialize(final byte[] bytes) {

ConditionChecker.argumentNotNull(bytes, "JSON byte array cannot be null");

if (bytes.length == 0) {
throw new DeserializationException("Invalid JSON: zero length byte array.");
}

@SuppressWarnings("unchecked")
protected Map<String, ?> doDeserialize(final Reader reader) throws Exception {
try {
return parse(new String(bytes, StandardCharsets.UTF_8));
return (Map<String, ?>) toJavaObject(JsonValueParser.fromReader().apply(reader));
} catch (final Exception e) {
throw new DeserializationException("Invalid JSON: " + e.getMessage(), e);
}
}

@SuppressWarnings("unchecked")
private static Map<String, ?> parse(final String json) {

return (Map<String, ?>) toJavaObject(JsonFactory.readFrom(json));
}

private static Map<String, Object> toJavaMap(final JsonObject jsonObject) {
return jsonObject.stream()
.collect(Collectors.toMap(JsonField::getKeyName, field -> toJavaObject(field.getValue())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package org.eclipse.ditto.internal.utils.jwt;

import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Calendar;
import java.util.Collection;
Expand All @@ -28,6 +30,7 @@
import org.eclipse.ditto.json.JsonObject;
import org.eclipse.ditto.json.JsonValue;

import io.jsonwebtoken.io.AbstractSerializer;
import io.jsonwebtoken.io.Encoders;
import io.jsonwebtoken.io.SerializationException;
import io.jsonwebtoken.io.Serializer;
Expand All @@ -39,7 +42,7 @@
* JJWT library Serializer implementation which translates Java Objects (e.g. Maps) to JSON strings.
*/
@Immutable
public final class JjwtSerializer implements Serializer<Map<String, ?>> {
public final class JjwtSerializer extends AbstractSerializer<Map<String, ?>> {

private static Serializer<Map<String, ?>> instance;

Expand All @@ -54,15 +57,12 @@ public final class JjwtSerializer implements Serializer<Map<String, ?>> {
}

@Override
public byte[] serialize(final Map<String, ?> t) {

protected void doSerialize(final Map<String, ?> stringMap, final OutputStream out) throws Exception {
try {
return toJson(t).toString().getBytes(StandardCharsets.UTF_8);
} catch (final SerializationException se) {
throw se;
} catch (final Exception e) {
out.write(toJson(stringMap).toString().getBytes(StandardCharsets.UTF_8));
} catch (final IOException e) {
throw new SerializationException("Unable to serialize object of type " +
Optional.ofNullable(t).map(obj -> obj.getClass().getName()).orElse("<null>") +
Optional.ofNullable(stringMap).map(obj -> obj.getClass().getName()).orElse("<null>") +
" to JSON: " + e.getMessage(), e);
}
}
Expand Down Expand Up @@ -91,7 +91,7 @@ private static JsonValue toJson(final Object input) {
return JsonFactory.newValue(Encoders.BASE64.encode((bytes)));
} else if (input instanceof char[] chars) {
return JsonFactory.newValue(new String(chars));
} else if (input instanceof Map map) {
} else if (input instanceof Map<?, ?> map) {
return toJsonObject(map);
} else if (input instanceof Collection<?> collection) {
return toJsonArray(collection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ public void foo() {
claims.put(Claims.ISSUER, KNOWN_ISS);
claims.put(Claims.SUBJECT, KNOWN_SUB);
final String compact = Jwts.builder()
.serializeToJsonWith(JjwtSerializer.getInstance())
.setClaims(claims)
.setExpiration(KNOWN_EXP)
.json(JjwtSerializer.getInstance())
.claims(claims)
.expiration(KNOWN_EXP)
.compact();

final Jwt jwt = Jwts.parserBuilder()
.deserializeJsonWith(JjwtDeserializer.getInstance())
final Jwt<?, ?> jwt = Jwts.parser().json(JjwtDeserializer.getInstance())
.unsecured()
.build()
.parse(compact);

final Object jwtBody = jwt.getBody();
final Object jwtBody = jwt.getPayload();

Assertions.assertThat(jwtBody).isInstanceOf(Claims.class);
Assertions.assertThat(((Claims) jwtBody)).containsEntry(Claims.ISSUER, KNOWN_ISS)
.containsEntry(Claims.SUBJECT, KNOWN_SUB)
.containsEntry(Claims.EXPIRATION, (int) (KNOWN_EXP.getTime() / 1000L));
.containsEntry(Claims.EXPIRATION, (KNOWN_EXP.getTime() / 1000L));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* for creating a new {@link JsonArray} or {@link JsonObject}.
*/
@NotThreadSafe
final class DefaultDittoJsonHandler extends DittoJsonHandler<List<JsonValue>, List<JsonField>, JsonValue> {
public final class DefaultDittoJsonHandler extends DittoJsonHandler<List<JsonValue>, List<JsonField>, JsonValue> {

private static final int DEFAULT_INITIAL_STRING_BUILDER_CAPACITY = 512;
private static final char DELIMITER = ',';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* This class provides access to functionality for parsing a {@link JsonValue} from various inputs.
*/
@Immutable
final class JsonValueParser {
public final class JsonValueParser {

@Nullable private static Function<String, JsonValue> fromStringInstance = null;

Expand Down
Loading