7 Commits

Author SHA1 Message Date
62cc4de690 deps: update jackson to 3.0.0-rc5
All checks were successful
CI / build (17) (push) Successful in 39s
CI / build (true, 21) (push) Successful in 38s
Migrate packages from com.fasterxml.jackson to tools.jackson, adjust
exception handling and remove JSR310 module and replace with new
JavaTimeFeature flags.
2025-05-28 20:35:44 +02:00
6a813b2541 update language level to Java 17 2025-04-12 11:42:17 +02:00
4bd6039827 deps: update jackson to 2.19.0 (#97)
All checks were successful
CI / build-with-it (11, 1.2.0) (push) Successful in 53s
CI / build-with-it (11, 1.19.0) (push) Successful in 1m0s
CI / build-with-it (17, 1.2.0) (push) Successful in 55s
CI / build-with-it (17, 1.19.0) (push) Successful in 1m0s
CI / build-with-it (21, 1.2.0) (push) Successful in 50s
CI / build-with-it (true, 21, 1.19.0) (push) Successful in 56s
2025-04-27 17:25:23 +02:00
80abbda46f docs: update version and features in README
All checks were successful
CI / build (11) (push) Successful in 39s
CI / build (17) (push) Successful in 39s
CI / build (true, 21) (push) Successful in 34s
CI / build-with-it (11, 1.2.0) (push) Successful in 55s
CI / build-with-it (11, 1.19.0) (push) Successful in 1m2s
CI / build-with-it (17, 1.2.0) (push) Successful in 54s
CI / build-with-it (17, 1.19.0) (push) Successful in 1m0s
CI / build-with-it (21, 1.2.0) (push) Successful in 52s
CI / build-with-it (true, 21, 1.19.0) (push) Successful in 59s
2025-04-24 18:36:36 +02:00
a8e85b88d1 test: use WireMockTest annotation 2025-04-24 18:30:32 +02:00
91baed4fe5 test: update wiremock to 3.13.0 2025-04-24 18:30:04 +02:00
2ea261d36a prepare for next development iteration
All checks were successful
CI / build (11) (push) Successful in 36s
CI / build (17) (push) Successful in 36s
CI / build (true, 21) (push) Successful in 28s
2025-04-13 12:25:18 +02:00
9 changed files with 103 additions and 112 deletions

View File

@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
jdk: [ 11, 17, 21 ] jdk: [ 17, 21 ]
vault: [ '1.2.0', '1.19.0' ] vault: [ '1.2.0', '1.19.0' ]
include: include:
- jdk: 21 - jdk: 21

View File

@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
jdk: [ 11, 17, 21 ] jdk: [ 17, 21 ]
include: include:
- jdk: 21 - jdk: 21
analysis: true analysis: true

View File

@ -1,3 +1,13 @@
## unreleased
### Breaking
* Requires Java 17 or later
* Required Jackson 3
### Dependencies
* Updated Jackson to 3.0.0
## 1.5.0 (2025-04-13) ## 1.5.0 (2025-04-13)
### Deprecations ### Deprecations
@ -13,9 +23,6 @@
### Fix ### Fix
* Fix initialization from environment without explicit port * Fix initialization from environment without explicit port
### Dependencies
* Updated Jackson to 2.18.3 (#90)
### Test ### Test
* Tested against Vault 1.2 to 1.19 * Tested against Vault 1.2 to 1.19

View File

@ -28,8 +28,9 @@ Java Vault Connector is a connector library for [Vault](https://www.vaultproject
* Delete secrets * Delete secrets
* Renew/revoke leases * Renew/revoke leases
* Raw secret content or JSON decoding * Raw secret content or JSON decoding
* SQL secret handling
* KV v1 and v2 support * KV v1 and v2 support
* Database secret handling
* Transit API support
* Connector Factory with builder pattern * Connector Factory with builder pattern
* Tested against Vault 1.2 to 1.19 * Tested against Vault 1.2 to 1.19
@ -39,7 +40,7 @@ Java Vault Connector is a connector library for [Vault](https://www.vaultproject
<dependency> <dependency>
<groupId>de.stklcode.jvault</groupId> <groupId>de.stklcode.jvault</groupId>
<artifactId>jvault-connector</artifactId> <artifactId>jvault-connector</artifactId>
<version>1.4.0</version> <version>1.5.0</version>
</dependency> </dependency>
``` ```

24
pom.xml
View File

@ -4,7 +4,7 @@
<groupId>de.stklcode.jvault</groupId> <groupId>de.stklcode.jvault</groupId>
<artifactId>jvault-connector</artifactId> <artifactId>jvault-connector</artifactId>
<version>1.5.0</version> <version>1.5.1-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
@ -33,7 +33,7 @@
<connection>scm:git:git://github.com/stklcode/jvaultconnector.git</connection> <connection>scm:git:git://github.com/stklcode/jvaultconnector.git</connection>
<developerConnection>scm:git:git@github.com:stklcode/jvaultconnector.git</developerConnection> <developerConnection>scm:git:git@github.com:stklcode/jvaultconnector.git</developerConnection>
<url>https://github.com/stklcode/jvaultconnector</url> <url>https://github.com/stklcode/jvaultconnector</url>
<tag>v1.5.0</tag> <tag>HEAD</tag>
</scm> </scm>
<issueManagement> <issueManagement>
@ -43,20 +43,14 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.outputTimestamp>2025-04-13T09:25:23Z</project.build.outputTimestamp>
<argLine></argLine> <argLine></argLine>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>tools.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
<version>2.18.3</version> <version>3.0.0-rc5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.18.3</version>
</dependency> </dependency>
<dependency> <dependency>
@ -80,7 +74,7 @@
<dependency> <dependency>
<groupId>org.wiremock</groupId> <groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId> <artifactId>wiremock</artifactId>
<version>3.12.1</version> <version>3.13.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -111,7 +105,7 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version> <version>3.14.0</version>
<configuration> <configuration>
<release>11</release> <release>17</release>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
@ -131,7 +125,7 @@
<configuration> <configuration>
<argLine> <argLine>
@{argLine} @{argLine}
--add-opens de.stklcode.jvault.connector/de.stklcode.jvault.connector.test=com.fasterxml.jackson.databind --add-opens de.stklcode.jvault.connector/de.stklcode.jvault.connector.test=tools.jackson.databind
</argLine> </argLine>
</configuration> </configuration>
</plugin> </plugin>
@ -208,7 +202,7 @@
<version>[3.6.3,)</version> <version>[3.6.3,)</version>
</requireMavenVersion> </requireMavenVersion>
<requireJavaVersion> <requireJavaVersion>
<version>[11,)</version> <version>[17,)</version>
</requireJavaVersion> </requireJavaVersion>
</rules> </rules>
</configuration> </configuration>
@ -254,7 +248,7 @@
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>3.11.2</version> <version>3.11.2</version>
<configuration> <configuration>
<source>11</source> <source>17</source>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>

View File

@ -1,12 +1,11 @@
package de.stklcode.jvault.connector.internal; package de.stklcode.jvault.connector.internal;
import com.fasterxml.jackson.core.JsonProcessingException; import tools.jackson.core.JacksonException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import de.stklcode.jvault.connector.exception.*; import de.stklcode.jvault.connector.exception.*;
import de.stklcode.jvault.connector.model.response.ErrorResponse; import de.stklcode.jvault.connector.model.response.ErrorResponse;
import tools.jackson.databind.cfg.DateTimeFeature;
import tools.jackson.databind.json.JsonMapper;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.TrustManagerFactory;
@ -66,9 +65,8 @@ public final class RequestHelper implements Serializable {
this.tlsVersion = tlsVersion; this.tlsVersion = tlsVersion;
this.trustedCaCert = trustedCaCert; this.trustedCaCert = trustedCaCert;
this.jsonMapper = JsonMapper.builder() this.jsonMapper = JsonMapper.builder()
.addModule(new JavaTimeModule()) .enable(DateTimeFeature.WRITE_DATES_AS_TIMESTAMPS)
.enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .disable(DateTimeFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)
.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)
.build(); .build();
} }
@ -89,7 +87,7 @@ public final class RequestHelper implements Serializable {
// Generate JSON from payload. // Generate JSON from payload.
try { try {
req.POST(HttpRequest.BodyPublishers.ofString(jsonMapper.writeValueAsString(payload), UTF_8)); req.POST(HttpRequest.BodyPublishers.ofString(jsonMapper.writeValueAsString(payload), UTF_8));
} catch (JsonProcessingException e) { } catch (JacksonException e) {
throw new InvalidRequestException(Error.PARSE_RESPONSE, e); throw new InvalidRequestException(Error.PARSE_RESPONSE, e);
} }
@ -120,7 +118,7 @@ public final class RequestHelper implements Serializable {
try { try {
String response = post(path, payload, token); String response = post(path, payload, token);
return jsonMapper.readValue(response, target); return jsonMapper.readValue(response, target);
} catch (IOException e) { } catch (JacksonException e) {
throw new InvalidResponseException(Error.PARSE_RESPONSE, e); throw new InvalidResponseException(Error.PARSE_RESPONSE, e);
} }
} }
@ -159,7 +157,7 @@ public final class RequestHelper implements Serializable {
// Generate JSON from payload. // Generate JSON from payload.
try { try {
req.PUT(HttpRequest.BodyPublishers.ofString(jsonMapper.writeValueAsString(payload), UTF_8)); req.PUT(HttpRequest.BodyPublishers.ofString(jsonMapper.writeValueAsString(payload), UTF_8));
} catch (JsonProcessingException e) { } catch (JacksonException e) {
throw new InvalidRequestException("Payload serialization failed", e); throw new InvalidRequestException("Payload serialization failed", e);
} }
@ -190,7 +188,7 @@ public final class RequestHelper implements Serializable {
try { try {
String response = put(path, payload, token); String response = put(path, payload, token);
return jsonMapper.readValue(response, target); return jsonMapper.readValue(response, target);
} catch (IOException e) { } catch (JacksonException e) {
throw new InvalidResponseException(Error.PARSE_RESPONSE, e); throw new InvalidResponseException(Error.PARSE_RESPONSE, e);
} }
} }
@ -302,7 +300,7 @@ public final class RequestHelper implements Serializable {
try { try {
String response = get(path, payload, token); String response = get(path, payload, token);
return jsonMapper.readValue(response, target); return jsonMapper.readValue(response, target);
} catch (IOException e) { } catch (JacksonException e) {
throw new InvalidResponseException(Error.PARSE_RESPONSE, e); throw new InvalidResponseException(Error.PARSE_RESPONSE, e);
} }
} }
@ -443,7 +441,7 @@ public final class RequestHelper implements Serializable {
throw new InvalidResponseException(Error.RESPONSE_CODE, response.statusCode(), er.toString()); throw new InvalidResponseException(Error.RESPONSE_CODE, response.statusCode(), er.toString());
} }
} }
} catch (IOException ignored) { } catch (IOException | JacksonException ignored) {
// Exception ignored. // Exception ignored.
} }
} }

View File

@ -17,14 +17,12 @@
package de.stklcode.jvault.connector.model.response; package de.stklcode.jvault.connector.model.response;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import de.stklcode.jvault.connector.exception.InvalidResponseException; import de.stklcode.jvault.connector.exception.InvalidResponseException;
import de.stklcode.jvault.connector.model.response.embedded.VersionMetadata; import de.stklcode.jvault.connector.model.response.embedded.VersionMetadata;
import tools.jackson.core.JacksonException;
import tools.jackson.databind.cfg.DateTimeFeature;
import tools.jackson.databind.json.JsonMapper;
import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.util.Map; import java.util.Map;
@ -86,9 +84,8 @@ public abstract class SecretResponse extends VaultDataResponse {
return type.cast(rawValue); return type.cast(rawValue);
} else { } else {
var om = JsonMapper.builder() var om = JsonMapper.builder()
.addModule(new JavaTimeModule()) .enable(DateTimeFeature.WRITE_DATES_AS_TIMESTAMPS)
.enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .disable(DateTimeFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)
.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)
.build(); .build();
if (rawValue instanceof String) { if (rawValue instanceof String) {
@ -97,7 +94,7 @@ public abstract class SecretResponse extends VaultDataResponse {
return om.readValue(om.writeValueAsString(rawValue), type); return om.readValue(om.writeValueAsString(rawValue), type);
} }
} }
} catch (IOException e) { } catch (JacksonException e) {
throw new InvalidResponseException("Unable to parse response payload: " + e.getMessage()); throw new InvalidResponseException("Unable to parse response payload: " + e.getMessage());
} }
} }

View File

@ -26,12 +26,11 @@ module de.stklcode.jvault.connector {
exports de.stklcode.jvault.connector.model.response; exports de.stklcode.jvault.connector.model.response;
exports de.stklcode.jvault.connector.model.response.embedded; exports de.stklcode.jvault.connector.model.response.embedded;
opens de.stklcode.jvault.connector.model to com.fasterxml.jackson.databind; opens de.stklcode.jvault.connector.model to tools.jackson.databind;
opens de.stklcode.jvault.connector.model.response to com.fasterxml.jackson.databind; opens de.stklcode.jvault.connector.model.response to tools.jackson.databind;
opens de.stklcode.jvault.connector.model.response.embedded to com.fasterxml.jackson.databind; opens de.stklcode.jvault.connector.model.response.embedded to tools.jackson.databind;
requires java.net.http; requires java.net.http;
requires com.fasterxml.jackson.annotation; requires com.fasterxml.jackson.annotation;
requires com.fasterxml.jackson.databind; requires tools.jackson.databind;
requires com.fasterxml.jackson.datatype.jsr310;
} }

View File

@ -17,13 +17,13 @@
package de.stklcode.jvault.connector; package de.stklcode.jvault.connector;
import com.github.tomakehurst.wiremock.client.WireMock; import com.github.tomakehurst.wiremock.client.WireMock;
import com.github.tomakehurst.wiremock.junit5.WireMockExtension; import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
import com.github.tomakehurst.wiremock.junit5.WireMockTest;
import de.stklcode.jvault.connector.exception.ConnectionException; import de.stklcode.jvault.connector.exception.ConnectionException;
import de.stklcode.jvault.connector.exception.InvalidResponseException; import de.stklcode.jvault.connector.exception.InvalidResponseException;
import de.stklcode.jvault.connector.exception.PermissionDeniedException; import de.stklcode.jvault.connector.exception.PermissionDeniedException;
import de.stklcode.jvault.connector.exception.VaultConnectorException; import de.stklcode.jvault.connector.exception.VaultConnectorException;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.function.Executable; import org.junit.jupiter.api.function.Executable;
import java.io.IOException; import java.io.IOException;
@ -36,9 +36,7 @@ import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.util.Collections; import java.util.Collections;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.github.tomakehurst.wiremock.client.WireMock.anyUrl;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
/** /**
@ -48,18 +46,15 @@ import static org.junit.jupiter.api.Assertions.*;
* @author Stefan Kalscheuer * @author Stefan Kalscheuer
* @since 0.7.0 * @since 0.7.0
*/ */
@WireMockTest
class HTTPVaultConnectorTest { class HTTPVaultConnectorTest {
@RegisterExtension
static WireMockExtension wireMock = WireMockExtension.newInstance()
.options(wireMockConfig().dynamicPort())
.build();
/** /**
* Test exceptions thrown during request. * Test exceptions thrown during request.
*/ */
@Test @Test
void requestExceptionTest() throws IOException, URISyntaxException { void requestExceptionTest(WireMockRuntimeInfo wireMock) throws IOException, URISyntaxException {
HTTPVaultConnector connector = HTTPVaultConnector.builder(wireMock.url("/")).withTimeout(250).build(); HTTPVaultConnector connector = HTTPVaultConnector.builder(wireMock.getHttpBaseUrl()).withTimeout(250).build();
// Test invalid response code. // Test invalid response code.
final int responseCode = 400; final int responseCode = 400;
@ -94,9 +89,9 @@ class HTTPVaultConnectorTest {
assertInstanceOf(IOException.class, e.getCause(), "Unexpected cause"); assertInstanceOf(IOException.class, e.getCause(), "Unexpected cause");
// Now simulate a failing request that succeeds on second try. // Now simulate a failing request that succeeds on second try.
connector = HTTPVaultConnector.builder(wireMock.url("/")).withNumberOfRetries(1).withTimeout(250).build(); connector = HTTPVaultConnector.builder(wireMock.getHttpBaseUrl()).withNumberOfRetries(1).withTimeout(250).build();
wireMock.stubFor( stubFor(
WireMock.any(anyUrl()) WireMock.any(anyUrl())
.willReturn(aResponse().withStatus(500)) .willReturn(aResponse().withStatus(500))
.willReturn(aResponse().withStatus(500)) .willReturn(aResponse().withStatus(500))
@ -193,8 +188,8 @@ class HTTPVaultConnectorTest {
* Test behavior on unparsable responses. * Test behavior on unparsable responses.
*/ */
@Test @Test
void parseExceptionTest() throws URISyntaxException { void parseExceptionTest(WireMockRuntimeInfo wireMock) throws URISyntaxException {
HTTPVaultConnector connector = HTTPVaultConnector.builder(wireMock.url("/")).withTimeout(250).build(); HTTPVaultConnector connector = HTTPVaultConnector.builder(wireMock.getHttpBaseUrl()).withTimeout(250).build();
// Mock authorization. // Mock authorization.
setPrivate(connector, "authorized", true); setPrivate(connector, "authorized", true);
// Mock response. // Mock response.
@ -227,8 +222,8 @@ class HTTPVaultConnectorTest {
* Test requests that expect an empty response with code 204, but receive a 200 body. * Test requests that expect an empty response with code 204, but receive a 200 body.
*/ */
@Test @Test
void nonEmpty204ResponseTest() throws URISyntaxException { void nonEmpty204ResponseTest(WireMockRuntimeInfo wireMock) throws URISyntaxException {
HTTPVaultConnector connector = HTTPVaultConnector.builder(wireMock.url("/")).withTimeout(250).build(); HTTPVaultConnector connector = HTTPVaultConnector.builder(wireMock.getHttpBaseUrl()).withTimeout(250).build();
// Mock authorization. // Mock authorization.
setPrivate(connector, "authorized", true); setPrivate(connector, "authorized", true);
// Mock response. // Mock response.
@ -310,7 +305,7 @@ class HTTPVaultConnectorTest {
} }
private void mockHttpResponse(int status, String body, String contentType) { private void mockHttpResponse(int status, String body, String contentType) {
wireMock.stubFor( stubFor(
WireMock.any(anyUrl()).willReturn( WireMock.any(anyUrl()).willReturn(
aResponse().withStatus(status).withBody(body).withHeader("Content-Type", contentType) aResponse().withStatus(status).withBody(body).withHeader("Content-Type", contentType)
) )