diff --git a/README.md b/README.md index 1a877891..54c0d070 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ![LowkeyVault](.github/assets/LowkeyVault-logo-full.png) [![GitHub license](https://img.shields.io/github/license/nagyesta/lowkey-vault?color=informational)](https://raw.githubusercontent.com/nagyesta/lowkey-vault/main/LICENSE) -[![Java version](https://img.shields.io/badge/Java%20version-11-yellow?logo=java)](https://img.shields.io/badge/Java%20version-11-yellow?logo=java) +[![Java version](https://img.shields.io/badge/Java%20version-17%20app|11%20libs-yellow?logo=java)](https://img.shields.io/badge/Java%20version-17%20app|11%20libs-yellow?logo=java) [![latest-release](https://img.shields.io/github/v/tag/nagyesta/lowkey-vault?color=blue&logo=git&label=releases&sort=semver)](https://github.com/nagyesta/lowkey-vault/releases) [![Maven Central](https://img.shields.io/maven-central/v/com.github.nagyesta.lowkey-vault/lowkey-vault-app?logo=apache-maven)](https://search.maven.org/search?q=com.github.nagyesta.lowkey-vault) [![Docker Hub](https://img.shields.io/docker/v/nagyesta/lowkey-vault?label=docker%20hub&logo=docker&sort=semver)](https://hub.docker.com/r/nagyesta/lowkey-vault) diff --git a/build.gradle b/build.gradle index 470a46e1..b44c2356 100644 --- a/build.gradle +++ b/build.gradle @@ -74,14 +74,7 @@ configure(subprojects.findAll({ mavenCentral() } - java { - sourceCompatibility = JavaVersion.VERSION_11 - toolchain { - languageVersion = JavaLanguageVersion.of(11) - } - withJavadocJar() - withSourcesJar() - } + javadoc.options.addStringOption('Xdoclint:none', '-quiet') jacocoTestReport { reports { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e8027f2a..17dd5e32 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,11 +1,11 @@ [versions] -springBoot = "2.7.14" -spring = "5.3.29" +springBoot = "3.1.2" +spring = "6.0.11" snakeYaml = "2.1" -tomcat = "9.0.79" -logback = "1.2.12" +tomcat = "10.1.12" +logback = "1.4.11" bouncycastle = "1.76" -hibernateValidator = "6.2.5.Final" +hibernateValidator = "8.0.1.Final" findbugs = "3.0.2" lombok = "1.18.28" handlebars="4.3.1" @@ -85,7 +85,7 @@ abort-mission-cucumber = { module = "com.github.nagyesta.abort-mission.boosters: cucumber-java = { module = "io.cucumber:cucumber-java", version.ref = "cucumber" } cucumber-testng = { module = "io.cucumber:cucumber-testng", version.ref = "cucumber" } -cucumber-spring = { module = "io.cucumber:cucumber-spring", version.ref = "cucumber" } +cucumber-picocontainer = { module = "io.cucumber:cucumber-picocontainer", version.ref = "cucumber" } jackson-bom = { module = "com.fasterxml.jackson:jackson-bom", version.ref = "jacksonBom" } jackson-core = { module = "com.fasterxml.jackson.core:jackson-core", version.ref = "jackson" } @@ -104,7 +104,7 @@ spring-boot-app = [ ] spring-test = ["spring-boot-starter-test", "spring-test", "snake-yaml"] logback = ["logback-classic", "logback-core"] -cucumber = ["cucumber-java", "cucumber-testng", "cucumber-spring"] +cucumber = ["cucumber-java", "cucumber-testng", "cucumber-picocontainer"] jackson = ["jackson-core", "jackson-annotations", "jackson-databind", "jackson-dataformat-xml", "jackson-datatype-jsr310"] tomcat = [ "tomcat-annotations-api", "tomcat-jsp-api", "tomcat-embed-core", "tomcat-embed-el", "tomcat-embed-jasper", "tomcat-embed-websocket" diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 90d22ac5..d1c2b467 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -18,12 +18,12 @@ - - - + + + - - + + @@ -34,12 +34,12 @@ - - - + + + - - + + @@ -47,9 +47,9 @@ - - - + + + @@ -184,11 +184,6 @@ - - - - - @@ -262,11 +257,6 @@ - - - - - @@ -277,11 +267,6 @@ - - - - - @@ -292,11 +277,6 @@ - - - - - @@ -307,11 +287,6 @@ - - - - - @@ -322,19 +297,14 @@ - - - - - - - - + + + @@ -342,11 +312,6 @@ - - - - - @@ -367,9 +332,9 @@ - - - + + + @@ -382,11 +347,6 @@ - - - - - @@ -722,12 +682,9 @@ - - - - - - + + + @@ -821,11 +778,6 @@ - - - - - @@ -1056,6 +1008,14 @@ + + + + + + + + @@ -1064,14 +1024,6 @@ - - - - - - - - @@ -1146,6 +1098,11 @@ + + + + + @@ -1161,6 +1118,27 @@ + + + + + + + + + + + + + + + + + + + + + @@ -1264,33 +1242,38 @@ - - - + + + - - + + - - - + + + + + + - - - + + + - - + + + + - - - + + + - - + + @@ -1301,12 +1284,12 @@ - - - + + + - - + + @@ -1314,9 +1297,9 @@ - - - + + + @@ -1372,12 +1355,17 @@ - - - + + + + + + + + - - + + @@ -1388,12 +1376,12 @@ - - - + + + - - + + @@ -1404,9 +1392,14 @@ - - - + + + + + + + + @@ -1461,20 +1454,20 @@ - - - + + + - - + + - - - + + + - - + + @@ -1871,17 +1864,22 @@ - - - + + + - - - + + + - - + + + + + + + @@ -1889,12 +1887,17 @@ - - - + + + + + + + + - - + + @@ -2025,68 +2028,68 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -2125,17 +2128,22 @@ - - - + + + - - + + + + + + + - - - + + + @@ -2193,6 +2201,11 @@ + + + + + @@ -2201,6 +2214,11 @@ + + + + + @@ -2287,12 +2305,22 @@ - - - + + + + + + + + + + + - - + + + + @@ -2373,27 +2401,27 @@ - - - + + + - - - + + + - - + + - - - + + + - - - + + + @@ -2451,27 +2479,27 @@ - - - - - - - - + + + + + + + + - - - + + + - - + + @@ -2549,11 +2577,6 @@ - - - - - @@ -2589,61 +2612,31 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2654,17 +2647,22 @@ + + + + + - - - + + + - - + + @@ -2675,20 +2673,12 @@ - - - + + + - - - - - - - - - - + + @@ -2699,24 +2689,11 @@ - - - - - - - - - - - - - @@ -2732,14 +2709,6 @@ - - - - - - - - @@ -2748,6 +2717,14 @@ + + + + + + + + @@ -2819,6 +2796,19 @@ + + + + + + + + + + + + + @@ -2875,12 +2865,12 @@ - - - + + + - - + + @@ -2898,11 +2888,6 @@ - - - - - @@ -2911,6 +2896,14 @@ + + + + + + + + @@ -2926,16 +2919,16 @@ - - - - - + + + + + @@ -3105,19 +3098,19 @@ - - - + + + - - - + + + - - - + + + @@ -3125,9 +3118,19 @@ - - - + + + + + + + + + + + + + @@ -3140,19 +3143,24 @@ - - - + + + + + + + + - - - + + + - - - + + + @@ -3160,14 +3168,14 @@ - - - + + + - - - + + + @@ -3175,9 +3183,9 @@ - - - + + + @@ -3195,19 +3203,19 @@ - - - + + + - - - + + + - - - + + + @@ -3215,34 +3223,34 @@ - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + diff --git a/lowkey-vault-app/README.md b/lowkey-vault-app/README.md index f7d34596..4a60bd5e 100644 --- a/lowkey-vault-app/README.md +++ b/lowkey-vault-app/README.md @@ -1,7 +1,7 @@ ![LowkeyVault](../.github/assets/LowkeyVault-logo-full.png) [![GitHub license](https://img.shields.io/github/license/nagyesta/lowkey-vault?color=informational)](https://raw.githubusercontent.com/nagyesta/lowkey-vault/main/LICENSE) -[![Java version](https://img.shields.io/badge/Java%20version-11-yellow?logo=java)](https://img.shields.io/badge/Java%20version-11-yellow?logo=java) +[![Java version](https://img.shields.io/badge/Java%20version-17-yellow?logo=java)](https://img.shields.io/badge/Java%20version-17-yellow?logo=java) [![latest-release](https://img.shields.io/github/v/tag/nagyesta/lowkey-vault?color=blue&logo=git&label=releases&sort=semver)](https://github.com/nagyesta/lowkey-vault/releases) [![Docker Hub](https://img.shields.io/docker/v/nagyesta/lowkey-vault?label=docker%20hub&logo=docker&sort=semver)](https://hub.docker.com/r/nagyesta/lowkey-vault) [![JavaCI](https://img.shields.io/github/actions/workflow/status/nagyesta/lowkey-vault/gradle.yml?logo=github&branch=main)](https://github.com/nagyesta/lowkey-vault/actions/workflows/gradle.yml) @@ -71,7 +71,7 @@ argument. 2. ```hostname:port``` (e.g. ```localhost:8443```) meaning, that we want to register an alias to exactly that host and port, which is defined 3. ```hostname:``` (e.g. ```localhost:```) - meaning that we want to register an alias to the the host defined in the ```hostname``` using the port set with + meaning that we want to register an alias to the host defined in the ```hostname``` using the port set with ```--server.port``` ```shell diff --git a/lowkey-vault-app/build.gradle b/lowkey-vault-app/build.gradle index 271c5ee3..54047f2e 100644 --- a/lowkey-vault-app/build.gradle +++ b/lowkey-vault-app/build.gradle @@ -28,6 +28,15 @@ dependencies { testImplementation libs.abort.mission.jupiter } +java { + sourceCompatibility = JavaVersion.VERSION_17 + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } + withJavadocJar() + withSourcesJar() +} + test { outputs.file(file("$buildDir/reports/abort-mission/abort-mission-report.json")) useJUnitPlatform() @@ -36,6 +45,7 @@ test { systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") systemProperty("junit.jupiter.execution.parallel.mode.classes.default", "concurrent") } + abortMission { toolVersion libs.versions.abortMission.get() } @@ -50,11 +60,12 @@ processResources { jar { enabled = false } + bootJar { archiveVersion.value(project.version as String) } -task regenerateCertJks(type: Exec) { +tasks.register('regenerateCertJks', Exec) { outputs.file("${project.projectDir}/src/main/resources/cert/keystore.jks") workingDir file("${project.projectDir}/src/main/resources/cert") outputs.upToDateWhen { false } @@ -80,7 +91,7 @@ task regenerateCertJks(type: Exec) { logging.captureStandardOutput LogLevel.INFO logging.captureStandardError LogLevel.ERROR } -task regenerateCert(type: Exec) { +tasks.register('regenerateCert', Exec) { outputs.file("${project.projectDir}/src/main/resources/cert/keystore.p12") outputs.file("${project.projectDir}/src/main/resources/cert/keystore.jks") inputs.file("${project.projectDir}/src/main/resources/cert/keystore.jks") diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/context/CertificateConverterConfiguration.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/context/CertificateConverterConfiguration.java index b4bed50e..cefe3018 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/context/CertificateConverterConfiguration.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/context/CertificateConverterConfiguration.java @@ -3,7 +3,6 @@ import com.github.nagyesta.lowkeyvault.mapper.common.registry.CertificateConverterRegistry; import com.github.nagyesta.lowkeyvault.mapper.v7_3.certificate.*; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.DependsOn; @@ -11,8 +10,11 @@ @Configuration public class CertificateConverterConfiguration { - @Autowired - private VaultService vaultService; + private final VaultService vaultService; + + public CertificateConverterConfiguration(final VaultService vaultService) { + this.vaultService = vaultService; + } @Bean public CertificateConverterRegistry certificateConverterRegistry() { diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/PingController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/PingController.java index f34e1a43..08f5fa30 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/PingController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/PingController.java @@ -7,7 +7,7 @@ @RestController public class PingController { - @GetMapping("/ping") + @GetMapping(value = {"/ping", "/ping/"}) public ResponseEntity ping() { return ResponseEntity.ok("pong"); } diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/VaultBackupManagementController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/VaultBackupManagementController.java index 3ef52fb2..b94399b0 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/VaultBackupManagementController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/VaultBackupManagementController.java @@ -46,9 +46,7 @@ public VaultBackupManagementController(@NonNull final VaultImporter vaultImporte @Override public void afterPropertiesSet() { - vaultImporter.getVaults().forEach((baseUri, vault) -> { - vaultImportExportExecutor.restoreVault(vaultImporter, baseUri, vault); - }); + vaultImporter.getVaults().forEach((baseUri, vault) -> vaultImportExportExecutor.restoreVault(vaultImporter, baseUri, vault)); } @Operation( @@ -64,7 +62,7 @@ public void afterPropertiesSet() { schema = @Schema(implementation = ErrorModel.class) ))}, requestBody = @RequestBody(content = @Content(mediaType = MimeTypeUtils.APPLICATION_JSON_VALUE))) - @GetMapping("/export") + @GetMapping(value = {"/export", "/export/"}) public ResponseEntity export() { log.info("Received request to export active vaults."); final List backupModels = vaultImportExportExecutor.backupVaultList(vaultService); diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/VaultManagementController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/VaultManagementController.java index 96b33478..628a9c77 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/VaultManagementController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/VaultManagementController.java @@ -12,16 +12,15 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; +import jakarta.validation.Valid; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; import java.net.URI; import java.util.List; -import java.util.stream.Collectors; import static com.github.nagyesta.lowkeyvault.openapi.Examples.*; import static org.springframework.util.MimeTypeUtils.APPLICATION_JSON_VALUE; @@ -57,7 +56,7 @@ public VaultManagementController(@NonNull final VaultService vaultService, content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = ErrorModel.class)))}, requestBody = @RequestBody( content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = VaultModel.class)))) - @PostMapping + @PostMapping(value = {"", "/"}) public ResponseEntity createVault(@Valid @org.springframework.web.bind.annotation.RequestBody final VaultModel model) { log.info("Received request to create vault with uri: {}, recovery level: {}, recoverable days: {}", model.getBaseUri(), model.getRecoveryLevel(), model.getRecoverableDays()); @@ -75,12 +74,12 @@ public ResponseEntity createVault(@Valid @org.springframework.web.bi @ApiResponse(responseCode = "500", description = "Internal error", content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = ErrorModel.class)))}, requestBody = @RequestBody(content = @Content(mediaType = APPLICATION_JSON_VALUE))) - @GetMapping + @GetMapping(value = {"", "/"}) public ResponseEntity> listVaults() { log.info("Received request to list vaults."); final List vaultFake = vaultService.list().stream() .map(vaultFakeToVaultModelConverter::convertNonNull) - .collect(Collectors.toUnmodifiableList()); + .toList(); log.info("Returning {} vaults.", vaultFake.size()); return ResponseEntity.ok(vaultFake); } @@ -94,12 +93,12 @@ public ResponseEntity> listVaults() { @ApiResponse(responseCode = "500", description = "Internal error", content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = ErrorModel.class)))}, requestBody = @RequestBody(content = @Content(mediaType = APPLICATION_JSON_VALUE))) - @GetMapping("/deleted") + @GetMapping(value = {"/deleted", "/deleted/"}) public ResponseEntity> listDeletedVaults() { log.info("Received request to list deleted vaults."); final List vaultFake = vaultService.listDeleted().stream() .map(vaultFakeToVaultModelConverter::convertNonNull) - .collect(Collectors.toUnmodifiableList()); + .toList(); log.info("Returning {} vaults.", vaultFake.size()); return ResponseEntity.ok(vaultFake); } @@ -117,9 +116,10 @@ public ResponseEntity> listDeletedVaults() { @ApiResponse(responseCode = "500", description = "Internal error", content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = ErrorModel.class)))}, parameters = { - @Parameter(name = "baseUri", example = BASE_URI, description = "The base URI of the vault we want delete.")}, + @Parameter(name = "baseUri", + example = BASE_URI, description = "The base URI of the vault we want delete.", required = true)}, requestBody = @RequestBody(content = @Content(mediaType = APPLICATION_JSON_VALUE))) - @DeleteMapping + @DeleteMapping(value = {"", "/"}) public ResponseEntity deleteVault(@RequestParam final URI baseUri) { log.info("Received request to delete vault with uri: {}", baseUri); return ResponseEntity.ok(vaultService.delete(baseUri)); @@ -137,9 +137,10 @@ public ResponseEntity deleteVault(@RequestParam final URI baseUri) { @ApiResponse(responseCode = "500", description = "Internal error", content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = ErrorModel.class)))}, parameters = { - @Parameter(name = "baseUri", example = BASE_URI, description = "The base URI of the vault we want to recover.")}, + @Parameter(name = "baseUri", + example = BASE_URI, description = "The base URI of the vault we want to recover.", required = true)}, requestBody = @RequestBody(content = @Content(mediaType = APPLICATION_JSON_VALUE))) - @PutMapping("/recover") + @PutMapping(value = {"/recover", "/recover/"}) public ResponseEntity recoverVault(@RequestParam final URI baseUri) { log.info("Received request to recover deleted vault with uri: {}", baseUri); vaultService.recover(baseUri); @@ -160,9 +161,10 @@ public ResponseEntity recoverVault(@RequestParam final URI baseUri) @ApiResponse(responseCode = "500", description = "Internal error", content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = ErrorModel.class)))}, parameters = { - @Parameter(name = "baseUri", example = BASE_URI, description = "The base URI of the vault we want to purge.")}, + @Parameter(name = "baseUri", + example = BASE_URI, description = "The base URI of the vault we want to purge.", required = true)}, requestBody = @RequestBody(content = @Content(mediaType = APPLICATION_JSON_VALUE))) - @DeleteMapping("/purge") + @DeleteMapping(value = {"/purge", "/purge/"}) public ResponseEntity purgeVault(@RequestParam final URI baseUri) { log.info("Received request to purge deleted vault with uri: {}", baseUri); return ResponseEntity.ok(vaultService.purge(baseUri)); @@ -181,13 +183,13 @@ public ResponseEntity purgeVault(@RequestParam final URI baseUri) { content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = ErrorModel.class)))}, parameters = { @Parameter(name = "baseUri", example = BASE_URI, - description = "The base URI of the vault we want to update."), + description = "The base URI of the vault we want to update.", required = true), @Parameter(name = "add", example = ALIAS1, - description = "The base URI we want to add to the aliases of the vault.", required = false), + description = "The base URI we want to add to the aliases of the vault."), @Parameter(name = "remove", example = ALIAS2, - description = "The base URI we want to remove from the aliases of the vault.", required = false)}, + description = "The base URI we want to remove from the aliases of the vault.")}, requestBody = @RequestBody(content = @Content(mediaType = APPLICATION_JSON_VALUE))) - @PatchMapping("/alias") + @PatchMapping(value = {"/alias", "/alias/"}) public ResponseEntity aliasUpdate(@RequestParam final URI baseUri, @RequestParam(required = false) final URI add, @RequestParam(required = false) final URI remove) { @@ -206,11 +208,11 @@ public ResponseEntity aliasUpdate(@RequestParam final URI baseUri, @ApiResponse(responseCode = "500", description = "Internal error", content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = ErrorModel.class)))}, parameters = { - @Parameter(name = "seconds", example = ONE, description = "The number of seconds we want to shift."), + @Parameter(name = "seconds", example = ONE, description = "The number of seconds we want to shift.", required = true), @Parameter(name = "regenerateCertificates", example = FALSE, description = "Whether we allow regeneration of certificates to let their validity match the new time-frame.")}, requestBody = @RequestBody(content = @Content(mediaType = APPLICATION_JSON_VALUE))) - @PutMapping(value = "/time/all", params = {"seconds"}) + @PutMapping(value = {"/time/all", "/time/all/"}, params = {"seconds"}) public ResponseEntity timeShiftAll( @RequestParam final int seconds, @RequestParam(required = false, defaultValue = "false") final boolean regenerateCertificates) { @@ -232,12 +234,13 @@ public ResponseEntity timeShiftAll( @ApiResponse(responseCode = "500", description = "Internal error", content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = ErrorModel.class)))}, parameters = { - @Parameter(name = "seconds", example = ONE, description = "The number of seconds we want to shift."), - @Parameter(name = "baseUri", example = BASE_URI, description = "The base URI of the vault we want to shift."), + @Parameter(name = "seconds", example = ONE, description = "The number of seconds we want to shift.", required = true), + @Parameter(name = "baseUri", + example = BASE_URI, description = "The base URI of the vault we want to shift.", required = true), @Parameter(name = "regenerateCertificates", example = FALSE, description = "Whether we allow regeneration of certificates to let their validity match the new time-frame.")}, requestBody = @RequestBody(content = @Content(mediaType = APPLICATION_JSON_VALUE))) - @PutMapping(value = "/time", params = {"baseUri", "seconds"}) + @PutMapping(value = {"/time", "/time/" }, params = {"baseUri", "seconds"}) public ResponseEntity timeShiftSingle( @RequestParam final URI baseUri, @RequestParam final int seconds, @RequestParam(required = false, defaultValue = "false") final boolean regenerateCertificates) { diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/BaseBackupRestoreController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/BaseBackupRestoreController.java index dcc595ac..16455570 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/BaseBackupRestoreController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/BaseBackupRestoreController.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Optional; import java.util.function.Function; -import java.util.stream.Collectors; /** * The base implementation of the backup/restore controllers. @@ -79,7 +78,7 @@ protected B backupEntity(final K entityId) { final List list = entities.getVersions(entityId).stream() .map(version -> getEntityByNameAndVersion(entityId.vault(), entityId.id(), version)) .map(registry().backupConverter(apiVersion())::convert) - .collect(Collectors.toUnmodifiableList()); + .toList(); return wrapBackup(list); } @@ -91,7 +90,7 @@ protected String getSingleEntityName(final B backupModel) { final List entityNames = backupModel.getValue().getVersions().stream() .map(BLI::getId) .distinct() - .collect(Collectors.toUnmodifiableList()); + .toList(); Assert.isTrue(entityNames.size() == 1, "All backup entities must belong to the same entity."); return entityNames.get(0); } @@ -100,7 +99,7 @@ protected URI getSingleBaseUri(final B backupModel) { final List uris = backupModel.getValue().getVersions().stream() .map(BLI::getVaultBaseUri) .distinct() - .collect(Collectors.toUnmodifiableList()); + .toList(); Assert.isTrue(uris.size() == 1, "All backup entities must be from the same vault."); return uris.get(0); } diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonCertificateBackupRestoreController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonCertificateBackupRestoreController.java index d04b5969..92471113 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonCertificateBackupRestoreController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonCertificateBackupRestoreController.java @@ -18,12 +18,12 @@ import com.github.nagyesta.lowkeyvault.service.certificate.impl.DefaultCertificateLifetimeActionPolicy; import com.github.nagyesta.lowkeyvault.service.vault.VaultFake; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; import org.springframework.lang.NonNull; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import java.util.List; import java.util.Objects; diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonCertificateController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonCertificateController.java index 550ee58f..39dea386 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonCertificateController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonCertificateController.java @@ -8,13 +8,13 @@ import com.github.nagyesta.lowkeyvault.service.certificate.id.CertificateEntityId; import com.github.nagyesta.lowkeyvault.service.certificate.id.VersionedCertificateEntityId; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; import org.springframework.lang.NonNull; import org.springframework.web.bind.annotation.RequestBody; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import java.util.Map; import java.util.Optional; diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonCertificatePolicyController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonCertificatePolicyController.java index 2135ad25..04bbc211 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonCertificatePolicyController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonCertificatePolicyController.java @@ -8,12 +8,12 @@ import com.github.nagyesta.lowkeyvault.service.certificate.ReadOnlyKeyVaultCertificateEntity; import com.github.nagyesta.lowkeyvault.service.certificate.id.VersionedCertificateEntityId; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; import org.springframework.lang.NonNull; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import java.util.Objects; diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonKeyBackupRestoreController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonKeyBackupRestoreController.java index 6637dbef..b8b6ad76 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonKeyBackupRestoreController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonKeyBackupRestoreController.java @@ -16,12 +16,12 @@ import com.github.nagyesta.lowkeyvault.service.key.impl.KeyImportInput; import com.github.nagyesta.lowkeyvault.service.vault.VaultFake; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; import org.springframework.lang.NonNull; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; /** diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonKeyController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonKeyController.java index c0462c6c..29d5fbaf 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonKeyController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonKeyController.java @@ -13,12 +13,12 @@ import com.github.nagyesta.lowkeyvault.service.key.id.KeyEntityId; import com.github.nagyesta.lowkeyvault.service.key.id.VersionedKeyEntityId; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; import org.springframework.lang.NonNull; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import java.util.Optional; diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonKeyCryptoController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonKeyCryptoController.java index 812eed6f..82b2f267 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonKeyCryptoController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonKeyCryptoController.java @@ -9,12 +9,12 @@ import com.github.nagyesta.lowkeyvault.model.v7_2.key.request.KeyVerifyParameters; import com.github.nagyesta.lowkeyvault.service.key.ReadOnlyKeyVaultKeyEntity; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; import org.springframework.lang.NonNull; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; @Slf4j diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonSecretBackupRestoreController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonSecretBackupRestoreController.java index a5f23a38..02513647 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonSecretBackupRestoreController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonSecretBackupRestoreController.java @@ -15,12 +15,12 @@ import com.github.nagyesta.lowkeyvault.service.secret.impl.SecretCreateInput; import com.github.nagyesta.lowkeyvault.service.vault.VaultFake; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; import org.springframework.lang.NonNull; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import java.util.Objects; diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonSecretController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonSecretController.java index 481ab191..551cb850 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonSecretController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/CommonSecretController.java @@ -12,12 +12,12 @@ import com.github.nagyesta.lowkeyvault.service.secret.id.SecretEntityId; import com.github.nagyesta.lowkeyvault.service.secret.id.VersionedSecretEntityId; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; import org.springframework.lang.NonNull; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; @Slf4j diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/util/CertificateRequestMapperUtil.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/util/CertificateRequestMapperUtil.java index ef3fe5dc..a26a4adf 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/util/CertificateRequestMapperUtil.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/common/util/CertificateRequestMapperUtil.java @@ -82,9 +82,9 @@ public static CertificateCreationInput convertPolicyToCertificateCreationInput( .contentType(CertContentType.byMimeType(policy.getSecretProperties().getContentType())) //x509 .subject(x509Properties.getSubject()) - .dnsNames(sans.map(SubjectAlternativeNames::getDnsNames).orElse(Set.of())) - .emails(sans.map(SubjectAlternativeNames::getEmails).orElse(Set.of())) - .upns(sans.map(SubjectAlternativeNames::getUpns).orElse(Set.of())) + .dnsNames(sans.map(SubjectAlternativeNames::dnsNames).orElse(Set.of())) + .emails(sans.map(SubjectAlternativeNames::emails).orElse(Set.of())) + .upns(sans.map(SubjectAlternativeNames::upns).orElse(Set.of())) .keyUsage(Objects.requireNonNullElse(x509Properties.getKeyUsage(), DEFAULT_KEY_USAGES)) .extendedKeyUsage(Objects.requireNonNullElse(x509Properties.getExtendedKeyUsage(), DEFAULT_EXT_KEY_USAGES)) .validityMonths(Objects.requireNonNullElse(x509Properties.getValidityMonths(), DEFAULT_VALIDITY_MONTHS)) diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/KeyBackupRestoreController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/KeyBackupRestoreController.java index 14655cf3..06d07784 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/KeyBackupRestoreController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/KeyBackupRestoreController.java @@ -6,6 +6,8 @@ import com.github.nagyesta.lowkeyvault.model.common.backup.KeyBackupModel; import com.github.nagyesta.lowkeyvault.model.v7_2.key.KeyVaultKeyModel; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -14,8 +16,6 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import static com.github.nagyesta.lowkeyvault.model.common.ApiConstants.API_VERSION_7_2; @@ -34,7 +34,7 @@ public KeyBackupRestoreController(@NonNull final KeyConverterRegistry registry, } @Override - @PostMapping(value = "/keys/{keyName}/backup", + @PostMapping(value = {"/keys/{keyName}/backup", "/keys/{keyName}/backup/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity backup( @@ -44,7 +44,7 @@ public ResponseEntity backup( } @Override - @PostMapping(value = "/keys/restore", + @PostMapping(value = {"/keys/restore", "/keys/restore/"}, params = API_VERSION_7_2, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/KeyController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/KeyController.java index bc9f1e67..1fc1a821 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/KeyController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/KeyController.java @@ -12,6 +12,8 @@ import com.github.nagyesta.lowkeyvault.model.v7_2.key.request.ImportKeyRequest; import com.github.nagyesta.lowkeyvault.model.v7_2.key.request.UpdateKeyRequest; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -20,8 +22,6 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import static com.github.nagyesta.lowkeyvault.model.common.ApiConstants.API_VERSION_7_2; @@ -40,7 +40,7 @@ public KeyController(@NonNull final KeyConverterRegistry registry, @NonNull fina } @Override - @PostMapping(value = "/keys/{keyName}/create", + @PostMapping(value = {"/keys/{keyName}/create", "/keys/{keyName}/create/"}, params = API_VERSION_7_2, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -52,7 +52,7 @@ public ResponseEntity create( } @Override - @PutMapping(value = "/keys/{keyName}", + @PutMapping(value = {"/keys/{keyName}", "/keys/{keyName}/"}, params = API_VERSION_7_2, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -64,7 +64,7 @@ public ResponseEntity importKey( } @Override - @DeleteMapping(value = "/keys/{keyName}", + @DeleteMapping(value = {"/keys/{keyName}", "/keys/{keyName}/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity delete( @@ -74,7 +74,7 @@ public ResponseEntity delete( } @Override - @GetMapping(value = "/keys/{keyName}/versions", + @GetMapping(value = {"/keys/{keyName}/versions", "/keys/{keyName}/versions/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity> versions( @@ -86,7 +86,7 @@ public ResponseEntity> versions( } @Override - @GetMapping(value = "/keys", + @GetMapping(value = {"/keys", "/keys/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity> listKeys( @@ -97,7 +97,7 @@ public ResponseEntity> listKeys( } @Override - @GetMapping(value = "/deletedkeys", + @GetMapping(value = {"/deletedkeys", "/deletedkeys/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity> listDeletedKeys( @@ -108,7 +108,7 @@ public ResponseEntity> listDe } @Override - @GetMapping(value = "/keys/{keyName}", + @GetMapping(value = {"/keys/{keyName}", "/keys/{keyName}/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity get( @@ -118,7 +118,7 @@ public ResponseEntity get( } @Override - @GetMapping(value = "/keys/{keyName}/{keyVersion}", + @GetMapping(value = {"/keys/{keyName}/{keyVersion}", "/keys/{keyName}/{keyVersion}/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity getWithVersion( @@ -129,7 +129,7 @@ public ResponseEntity getWithVersion( } @Override - @PatchMapping(value = "/keys/{keyName}/{keyVersion}", + @PatchMapping(value = {"/keys/{keyName}/{keyVersion}", "/keys/{keyName}/{keyVersion}/"}, params = API_VERSION_7_2, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -142,7 +142,7 @@ public ResponseEntity updateVersion( } @Override - @GetMapping(value = "/deletedkeys/{keyName}", + @GetMapping(value = {"/deletedkeys/{keyName}", "/deletedkeys/{keyName}/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity getDeletedKey( @@ -152,7 +152,7 @@ public ResponseEntity getDeletedKey( } @Override - @PostMapping(value = "/deletedkeys/{keyName}/recover", + @PostMapping(value = {"/deletedkeys/{keyName}/recover", "/deletedkeys/{keyName}/recover/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity recoverDeletedKey( @@ -162,7 +162,7 @@ public ResponseEntity recoverDeletedKey( } @Override - @DeleteMapping(value = "/deletedkeys/{keyName}", + @DeleteMapping(value = {"/deletedkeys/{keyName}", "/deletedkeys/{keyName}/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity purgeDeleted( diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/KeyCryptoController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/KeyCryptoController.java index a7c05087..ed1f3d22 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/KeyCryptoController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/KeyCryptoController.java @@ -10,6 +10,8 @@ import com.github.nagyesta.lowkeyvault.model.v7_2.key.request.KeySignParameters; import com.github.nagyesta.lowkeyvault.model.v7_2.key.request.KeyVerifyParameters; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -18,8 +20,6 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import static com.github.nagyesta.lowkeyvault.model.common.ApiConstants.API_VERSION_7_2; @@ -38,7 +38,8 @@ public KeyCryptoController(@NonNull final KeyConverterRegistry registry, @NonNul } @Override - @PostMapping(value = {"/keys/{keyName}/{keyVersion}/encrypt", "/keys/{keyName}/{keyVersion}/wrap"}, + @PostMapping(value = {"/keys/{keyName}/{keyVersion}/encrypt", "/keys/{keyName}/{keyVersion}/encrypt/", + "/keys/{keyName}/{keyVersion}/wrap", "/keys/{keyName}/{keyVersion}/wrap/"}, params = API_VERSION_7_2, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -51,7 +52,8 @@ public ResponseEntity encrypt( } @Override - @PostMapping(value = {"/keys/{keyName}/{keyVersion}/decrypt", "/keys/{keyName}/{keyVersion}/unwrap"}, + @PostMapping(value = {"/keys/{keyName}/{keyVersion}/decrypt", "/keys/{keyName}/{keyVersion}/decrypt/", + "/keys/{keyName}/{keyVersion}/unwrap", "/keys/{keyName}/{keyVersion}/unwrap/"}, params = API_VERSION_7_2, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -64,7 +66,7 @@ public ResponseEntity decrypt( } @Override - @PostMapping(value = "/keys/{keyName}/{keyVersion}/sign", + @PostMapping(value = {"/keys/{keyName}/{keyVersion}/sign", "/keys/{keyName}/{keyVersion}/sign/"}, params = API_VERSION_7_2, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -77,7 +79,7 @@ public ResponseEntity sign( } @Override - @PostMapping(value = "/keys/{keyName}/{keyVersion}/verify", + @PostMapping(value = {"/keys/{keyName}/{keyVersion}/verify", "/keys/{keyName}/{keyVersion}/verify/"}, params = API_VERSION_7_2, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/SecretBackupRestoreController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/SecretBackupRestoreController.java index 5d742837..a477ff26 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/SecretBackupRestoreController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/SecretBackupRestoreController.java @@ -6,6 +6,8 @@ import com.github.nagyesta.lowkeyvault.model.common.backup.SecretBackupModel; import com.github.nagyesta.lowkeyvault.model.v7_2.secret.KeyVaultSecretModel; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -14,8 +16,6 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import static com.github.nagyesta.lowkeyvault.model.common.ApiConstants.API_VERSION_7_2; @@ -34,7 +34,7 @@ public SecretBackupRestoreController(@NonNull final SecretConverterRegistry regi } @Override - @PostMapping(value = "/secrets/{secretName}/backup", + @PostMapping(value = {"/secrets/{secretName}/backup", "/secrets/{secretName}/backup/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity backup(@PathVariable @Valid @Pattern(regexp = NAME_PATTERN) final String secretName, @@ -43,7 +43,7 @@ public ResponseEntity backup(@PathVariable @Valid @Pattern(re } @Override - @PostMapping(value = "/secrets/restore", + @PostMapping(value = {"/secrets/restore", "/secrets/restore/"}, params = API_VERSION_7_2, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/SecretController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/SecretController.java index 8da86f08..16854423 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/SecretController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_2/SecretController.java @@ -11,6 +11,8 @@ import com.github.nagyesta.lowkeyvault.model.v7_2.secret.request.CreateSecretRequest; import com.github.nagyesta.lowkeyvault.model.v7_2.secret.request.UpdateSecretRequest; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -19,8 +21,6 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import static com.github.nagyesta.lowkeyvault.model.common.ApiConstants.API_VERSION_7_2; @@ -39,7 +39,7 @@ public SecretController(@NonNull final SecretConverterRegistry registry, @NonNul } @Override - @PutMapping(value = "/secrets/{secretName}", + @PutMapping(value = {"/secrets/{secretName}", "/secrets/{secretName}/"}, params = API_VERSION_7_2, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -51,7 +51,7 @@ public ResponseEntity create( } @Override - @DeleteMapping(value = "/secrets/{secretName}", + @DeleteMapping(value = {"/secrets/{secretName}", "/secrets/{secretName}/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity delete( @@ -61,7 +61,7 @@ public ResponseEntity delete( } @Override - @GetMapping(value = "/secrets/{secretName}/versions", + @GetMapping(value = {"/secrets/{secretName}/versions", "/secrets/{secretName}/versions/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity> versions( @@ -73,7 +73,7 @@ public ResponseEntity> versions( } @Override - @GetMapping(value = "/secrets", + @GetMapping(value = {"/secrets", "/secrets/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity> listSecrets( @@ -84,7 +84,7 @@ public ResponseEntity> listSecret } @Override - @GetMapping(value = "/deletedsecrets", + @GetMapping(value = {"/deletedsecrets", "/deletedsecrets/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity> listDeletedSecrets( @@ -95,7 +95,7 @@ public ResponseEntity> lis } @Override - @GetMapping(value = "/secrets/{secretName}", + @GetMapping(value = {"/secrets/{secretName}", "/secrets/{secretName}/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity get( @@ -105,7 +105,7 @@ public ResponseEntity get( } @Override - @GetMapping(value = "/secrets/{secretName}/{secretVersion}", + @GetMapping(value = {"/secrets/{secretName}/{secretVersion}", "/secrets/{secretName}/{secretVersion}/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity getWithVersion( @@ -116,7 +116,7 @@ public ResponseEntity getWithVersion( } @Override - @PatchMapping(value = "/secrets/{secretName}/{secretVersion}", + @PatchMapping(value = {"/secrets/{secretName}/{secretVersion}", "/secrets/{secretName}/{secretVersion}/"}, params = API_VERSION_7_2, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -129,7 +129,7 @@ public ResponseEntity updateVersion( } @Override - @GetMapping(value = "/deletedsecrets/{secretName}", + @GetMapping(value = {"/deletedsecrets/{secretName}", "/deletedsecrets/{secretName}/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity getDeletedSecret( @@ -139,7 +139,7 @@ public ResponseEntity getDeletedSecret( } @Override - @DeleteMapping(value = "/deletedsecrets/{secretName}", + @DeleteMapping(value = {"/deletedsecrets/{secretName}", "/deletedsecrets/{secretName}/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity purgeDeleted( @@ -149,7 +149,7 @@ public ResponseEntity purgeDeleted( } @Override - @PostMapping(value = "/deletedsecrets/{secretName}/recover", + @PostMapping(value = {"/deletedsecrets/{secretName}/recover", "/deletedsecrets/{secretName}/recover/"}, params = API_VERSION_7_2, produces = APPLICATION_JSON_VALUE) public ResponseEntity recoverDeletedSecret( diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/CertificateBackupRestoreController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/CertificateBackupRestoreController.java index f0cd5795..b31b63a0 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/CertificateBackupRestoreController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/CertificateBackupRestoreController.java @@ -6,6 +6,8 @@ import com.github.nagyesta.lowkeyvault.model.common.backup.CertificateBackupModel; import com.github.nagyesta.lowkeyvault.model.v7_3.certificate.KeyVaultCertificateModel; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.DependsOn; @@ -15,8 +17,6 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import static com.github.nagyesta.lowkeyvault.model.common.ApiConstants.API_VERSION_7_3; @@ -37,21 +37,21 @@ public CertificateBackupRestoreController( } @Override - @PostMapping(value = "/certificates/{certificateName}/backup", + @PostMapping(value = {"/certificates/{certificateName}/backup", "/certificates/{certificateName}/backup/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity backup(@PathVariable @Valid @Pattern(regexp = NAME_PATTERN) final String certificateName, - @RequestAttribute(name = ApiConstants.REQUEST_BASE_URI) final URI baseUri) { + @RequestAttribute(name = ApiConstants.REQUEST_BASE_URI) final URI baseUri) { return super.backup(certificateName, baseUri); } @Override - @PostMapping(value = "/certificates/restore", + @PostMapping(value = {"/certificates/restore", "/certificates/restore/"}, params = API_VERSION_7_3, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) public ResponseEntity restore(@RequestAttribute(name = ApiConstants.REQUEST_BASE_URI) final URI baseUri, - @Valid @RequestBody final CertificateBackupModel certificateBackupModel) { + @Valid @RequestBody final CertificateBackupModel certificateBackupModel) { return super.restore(baseUri, certificateBackupModel); } diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/CertificateController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/CertificateController.java index c47a02be..b6e13ea5 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/CertificateController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/CertificateController.java @@ -6,6 +6,8 @@ import com.github.nagyesta.lowkeyvault.model.common.KeyVaultItemListModel; import com.github.nagyesta.lowkeyvault.model.v7_3.certificate.*; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -14,8 +16,6 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import static com.github.nagyesta.lowkeyvault.model.common.ApiConstants.API_VERSION_7_3; @@ -33,7 +33,8 @@ public CertificateController(@NonNull final CertificateConverterRegistry registr } @Override - @PostMapping(value = "/certificates/{certificateName}/create", + @PostMapping( + value = {"/certificates/{certificateName}/create", "/certificates/{certificateName}/create/"}, params = API_VERSION_7_3, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -45,7 +46,8 @@ public ResponseEntity create( } @Override - @PostMapping(value = "/certificates/{certificateName}/import", + @PostMapping( + value = {"/certificates/{certificateName}/import", "/certificates/{certificateName}/import/"}, params = API_VERSION_7_3, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -57,7 +59,8 @@ public ResponseEntity importCertificate( } @Override - @GetMapping(value = "/certificates/{certificateName}", + @GetMapping( + value = {"/certificates/{certificateName}", "/certificates/{certificateName}/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity get( @@ -67,7 +70,8 @@ public ResponseEntity get( } @Override - @GetMapping(value = "/certificates/{certificateName}/{certificateVersion}", + @GetMapping( + value = {"/certificates/{certificateName}/{certificateVersion}", "/certificates/{certificateName}/{certificateVersion}/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity getWithVersion( @@ -78,7 +82,8 @@ public ResponseEntity getWithVersion( } @Override - @DeleteMapping(value = "/certificates/{certificateName}", + @DeleteMapping( + value = {"/certificates/{certificateName}", "/certificates/{certificateName}/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity delete( @@ -88,7 +93,8 @@ public ResponseEntity delete( } @Override - @GetMapping(value = "/deletedcertificates/{certificateName}", + @GetMapping( + value = {"/deletedcertificates/{certificateName}", "/deletedcertificates/{certificateName}/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity getDeletedCertificate( @@ -98,7 +104,8 @@ public ResponseEntity getDeletedCertificate( } @Override - @PostMapping(value = "/deletedcertificates/{certificateName}/recover", + @PostMapping( + value = {"/deletedcertificates/{certificateName}/recover", "/deletedcertificates/{certificateName}/recover/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity recoverDeletedCertificate( @@ -108,7 +115,8 @@ public ResponseEntity recoverDeletedCertificate( } @Override - @DeleteMapping(value = "/deletedcertificates/{certificateName}", + @DeleteMapping( + value = {"/deletedcertificates/{certificateName}", "/deletedcertificates/{certificateName}/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity purgeDeleted( @@ -118,7 +126,8 @@ public ResponseEntity purgeDeleted( } @Override - @GetMapping(value = "/certificates/{certificateName}/versions", + @GetMapping( + value = {"/certificates/{certificateName}/versions", "/certificates/{certificateName}/versions/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity> versions( @@ -130,7 +139,8 @@ public ResponseEntity> versi } @Override - @GetMapping(value = "/certificates", + @GetMapping( + value = {"/certificates", "/certificates/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity> listCertificates( @@ -142,7 +152,8 @@ public ResponseEntity> listC } @Override - @GetMapping(value = "/deletedcertificates", + @GetMapping( + value = {"/deletedcertificates", "/deletedcertificates/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity> listDeletedCertificates( @@ -154,7 +165,8 @@ public ResponseEntity } @Override - @PatchMapping(value = "/certificates/{certificateName}/{certificateVersion}", + @PatchMapping( + value = {"/certificates/{certificateName}/{certificateVersion}", "/certificates/{certificateName}/{certificateVersion}/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity updateCertificateProperties( diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/CertificatePolicyController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/CertificatePolicyController.java index 667fae1a..be2ecc98 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/CertificatePolicyController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/CertificatePolicyController.java @@ -6,6 +6,8 @@ import com.github.nagyesta.lowkeyvault.model.v7_3.certificate.CertificatePolicyModel; import com.github.nagyesta.lowkeyvault.model.v7_3.certificate.KeyVaultPendingCertificateModel; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -14,8 +16,6 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import static com.github.nagyesta.lowkeyvault.model.common.ApiConstants.API_VERSION_7_3; @@ -33,7 +33,7 @@ public CertificatePolicyController(@NonNull final CertificateConverterRegistry r } @Override - @GetMapping(value = "/certificates/{certificateName}/pending", + @GetMapping(value = {"/certificates/{certificateName}/pending", "/certificates/{certificateName}/pending/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity pendingCreate( @@ -43,7 +43,7 @@ public ResponseEntity pendingCreate( } @Override - @DeleteMapping(value = "/certificates/{certificateName}/pending", + @DeleteMapping(value = {"/certificates/{certificateName}/pending", "/certificates/{certificateName}/pending/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity pendingDelete( @@ -53,7 +53,7 @@ public ResponseEntity pendingDelete( } @Override - @GetMapping(value = "/certificates/{certificateName}/policy", + @GetMapping(value = {"/certificates/{certificateName}/policy", "/certificates/{certificateName}/policy/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity getPolicy( @@ -63,7 +63,7 @@ public ResponseEntity getPolicy( } @Override - @PatchMapping(value = "/certificates/{certificateName}/policy", + @PatchMapping(value = {"/certificates/{certificateName}/policy", "/certificates/{certificateName}/policy/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity updatePolicy( diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyBackupRestoreController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyBackupRestoreController.java index e2833614..5bf00ecb 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyBackupRestoreController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyBackupRestoreController.java @@ -11,6 +11,8 @@ import com.github.nagyesta.lowkeyvault.service.key.ReadOnlyRotationPolicy; import com.github.nagyesta.lowkeyvault.service.key.id.KeyEntityId; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.DependsOn; @@ -20,8 +22,6 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import java.util.Optional; @@ -42,7 +42,7 @@ public KeyBackupRestoreController(@NonNull final KeyConverterRegistry registry, } @Override - @PostMapping(value = "/keys/{keyName}/backup", + @PostMapping(value = {"/keys/{keyName}/backup", "/keys/{keyName}/backup/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity @@ -52,7 +52,7 @@ public KeyBackupRestoreController(@NonNull final KeyConverterRegistry registry, } @Override - @PostMapping(value = "/keys/restore", + @PostMapping(value = {"/keys/restore", "/keys/restore/"}, params = API_VERSION_7_3, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyController.java index 3d9a71ac..e39e6921 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyController.java @@ -14,6 +14,8 @@ import com.github.nagyesta.lowkeyvault.service.key.ReadOnlyKeyVaultKeyEntity; import com.github.nagyesta.lowkeyvault.service.key.id.VersionedKeyEntityId; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -22,8 +24,6 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import static com.github.nagyesta.lowkeyvault.model.common.ApiConstants.API_VERSION_7_3; @@ -42,7 +42,7 @@ public KeyController(@NonNull final KeyConverterRegistry registry, @NonNull fina } @Override - @PostMapping(value = "/keys/{keyName}/create", + @PostMapping(value = {"/keys/{keyName}/create", "/keys/{keyName}/create/"}, params = API_VERSION_7_3, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -54,7 +54,7 @@ public ResponseEntity create( } @Override - @PutMapping(value = "/keys/{keyName}", + @PutMapping(value = {"/keys/{keyName}", "/keys/{keyName}/"}, params = API_VERSION_7_3, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -66,7 +66,7 @@ public ResponseEntity importKey( } @Override - @DeleteMapping(value = "/keys/{keyName}", + @DeleteMapping(value = {"/keys/{keyName}", "/keys/{keyName}/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity delete( @@ -76,7 +76,7 @@ public ResponseEntity delete( } @Override - @GetMapping(value = "/keys/{keyName}/versions", + @GetMapping(value = {"/keys/{keyName}/versions", "/keys/{keyName}/versions/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity> versions( @@ -88,7 +88,7 @@ public ResponseEntity> versions( } @Override - @GetMapping(value = "/keys", + @GetMapping(value = {"/keys", "/keys/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity> listKeys( @@ -99,7 +99,7 @@ public ResponseEntity> listKeys( } @Override - @GetMapping(value = "/deletedkeys", + @GetMapping(value = {"/deletedkeys", "/deletedkeys/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity> listDeletedKeys( @@ -110,7 +110,7 @@ public ResponseEntity> listDe } @Override - @GetMapping(value = "/keys/{keyName}", + @GetMapping(value = {"/keys/{keyName}", "/keys/{keyName}/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity get( @@ -120,7 +120,7 @@ public ResponseEntity get( } @Override - @GetMapping(value = "/keys/{keyName}/{keyVersion}", + @GetMapping(value = {"/keys/{keyName}/{keyVersion}", "/keys/{keyName}/{keyVersion}/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity getWithVersion( @@ -131,7 +131,7 @@ public ResponseEntity getWithVersion( } @Override - @PatchMapping(value = "/keys/{keyName}/{keyVersion}", + @PatchMapping(value = {"/keys/{keyName}/{keyVersion}", "/keys/{keyName}/{keyVersion}/"}, params = API_VERSION_7_3, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -143,7 +143,7 @@ public ResponseEntity updateVersion( return super.updateVersion(keyName, keyVersion, baseUri, request); } - @PostMapping(value = "/keys/{keyName}/rotate", + @PostMapping(value = {"/keys/{keyName}/rotate", "/keys/{keyName}/rotate/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity rotateKey( @@ -158,7 +158,7 @@ public ResponseEntity rotateKey( } @Override - @GetMapping(value = "/deletedkeys/{keyName}", + @GetMapping(value = {"/deletedkeys/{keyName}", "/deletedkeys/{keyName}/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity getDeletedKey( @@ -168,7 +168,7 @@ public ResponseEntity getDeletedKey( } @Override - @PostMapping(value = "/deletedkeys/{keyName}/recover", + @PostMapping(value = {"/deletedkeys/{keyName}/recover", "/deletedkeys/{keyName}/recover/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity recoverDeletedKey( @@ -178,7 +178,7 @@ public ResponseEntity recoverDeletedKey( } @Override - @DeleteMapping(value = "/deletedkeys/{keyName}", + @DeleteMapping(value = {"/deletedkeys/{keyName}", "/deletedkeys/{keyName}/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity purgeDeleted( diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyCryptoController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyCryptoController.java index 67c7f05e..4b14f5e2 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyCryptoController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyCryptoController.java @@ -13,6 +13,8 @@ import com.github.nagyesta.lowkeyvault.model.v7_3.key.RandomBytesResponse; import com.github.nagyesta.lowkeyvault.service.key.util.KeyGenUtil; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -21,8 +23,6 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import static com.github.nagyesta.lowkeyvault.model.common.ApiConstants.API_VERSION_7_3; @@ -41,7 +41,8 @@ public KeyCryptoController(@NonNull final KeyConverterRegistry registry, @NonNul } @Override - @PostMapping(value = {"/keys/{keyName}/{keyVersion}/encrypt", "/keys/{keyName}/{keyVersion}/wrap"}, + @PostMapping(value = {"/keys/{keyName}/{keyVersion}/encrypt", "/keys/{keyName}/{keyVersion}/encrypt/", + "/keys/{keyName}/{keyVersion}/wrap", "/keys/{keyName}/{keyVersion}/wrap/"}, params = API_VERSION_7_3, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -54,7 +55,8 @@ public ResponseEntity encrypt( } @Override - @PostMapping(value = {"/keys/{keyName}/{keyVersion}/decrypt", "/keys/{keyName}/{keyVersion}/unwrap"}, + @PostMapping(value = {"/keys/{keyName}/{keyVersion}/decrypt", "/keys/{keyName}/{keyVersion}/decrypt/", + "/keys/{keyName}/{keyVersion}/unwrap", "/keys/{keyName}/{keyVersion}/unwrap/"}, params = API_VERSION_7_3, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -67,7 +69,7 @@ public ResponseEntity decrypt( } @Override - @PostMapping(value = "/keys/{keyName}/{keyVersion}/sign", + @PostMapping(value = {"/keys/{keyName}/{keyVersion}/sign", "/keys/{keyName}/{keyVersion}/sign/"}, params = API_VERSION_7_3, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -80,7 +82,7 @@ public ResponseEntity sign( } @Override - @PostMapping(value = "/keys/{keyName}/{keyVersion}/verify", + @PostMapping(value = {"/keys/{keyName}/{keyVersion}/verify", "/keys/{keyName}/{keyVersion}/verify/"}, params = API_VERSION_7_3, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -92,7 +94,7 @@ public ResponseEntity verify( return super.verify(keyName, keyVersion, baseUri, request); } - @PostMapping(value = "/rng", + @PostMapping(value = {"/rng", "/rng/"}, params = API_VERSION_7_3, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyPolicyController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyPolicyController.java index 7a63fcae..cf9f0cf5 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyPolicyController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyPolicyController.java @@ -11,6 +11,8 @@ import com.github.nagyesta.lowkeyvault.service.key.RotationPolicy; import com.github.nagyesta.lowkeyvault.service.key.id.KeyEntityId; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; import org.springframework.lang.NonNull; @@ -18,8 +20,6 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import static com.github.nagyesta.lowkeyvault.model.common.ApiConstants.API_VERSION_7_3; @@ -36,7 +36,7 @@ public KeyPolicyController(@NonNull final KeyConverterRegistry registry, @NonNul super(registry, vaultService); } - @GetMapping(value = "/keys/{keyName}/rotationpolicy", + @GetMapping(value = {"/keys/{keyName}/rotationpolicy", "/keys/{keyName}/rotationpolicy/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity getRotationPolicy( @@ -47,7 +47,7 @@ public ResponseEntity getRotationPolicy( return getRotationPolicyResponseEntity(getVaultByUri(baseUri), entityId(baseUri, keyName), baseUri); } - @PutMapping(value = "/keys/{keyName}/rotationpolicy", + @PutMapping(value = {"/keys/{keyName}/rotationpolicy", "/keys/{keyName}/rotationpolicy/"}, params = API_VERSION_7_3, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/SecretBackupRestoreController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/SecretBackupRestoreController.java index dee4633b..97757d1c 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/SecretBackupRestoreController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/SecretBackupRestoreController.java @@ -6,6 +6,8 @@ import com.github.nagyesta.lowkeyvault.model.common.backup.SecretBackupModel; import com.github.nagyesta.lowkeyvault.model.v7_2.secret.KeyVaultSecretModel; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.DependsOn; @@ -15,8 +17,6 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import static com.github.nagyesta.lowkeyvault.model.common.ApiConstants.API_VERSION_7_3; @@ -36,7 +36,7 @@ public SecretBackupRestoreController(@NonNull final SecretConverterRegistry regi } @Override - @PostMapping(value = "/secrets/{secretName}/backup", + @PostMapping(value = {"/secrets/{secretName}/backup", "/secrets/{secretName}/backup/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity backup(@PathVariable @Valid @Pattern(regexp = NAME_PATTERN) final String secretName, @@ -45,7 +45,7 @@ public ResponseEntity backup(@PathVariable @Valid @Pattern(re } @Override - @PostMapping(value = "/secrets/restore", + @PostMapping(value = {"/secrets/restore", "/secrets/restore/"}, params = API_VERSION_7_3, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/SecretController.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/SecretController.java index 60e23268..0c354eef 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/SecretController.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/controller/v7_3/SecretController.java @@ -11,6 +11,8 @@ import com.github.nagyesta.lowkeyvault.model.v7_2.secret.request.CreateSecretRequest; import com.github.nagyesta.lowkeyvault.model.v7_2.secret.request.UpdateSecretRequest; import com.github.nagyesta.lowkeyvault.service.vault.VaultService; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Pattern; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -19,8 +21,6 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import javax.validation.constraints.Pattern; import java.net.URI; import static com.github.nagyesta.lowkeyvault.model.common.ApiConstants.API_VERSION_7_3; @@ -39,7 +39,7 @@ public SecretController(@NonNull final SecretConverterRegistry registry, @NonNul } @Override - @PutMapping(value = "/secrets/{secretName}", + @PutMapping(value = {"/secrets/{secretName}", "/secrets/{secretName}/"}, params = API_VERSION_7_3, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -51,7 +51,7 @@ public ResponseEntity create( } @Override - @DeleteMapping(value = "/secrets/{secretName}", + @DeleteMapping(value = {"/secrets/{secretName}", "/secrets/{secretName}/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity delete( @@ -61,7 +61,7 @@ public ResponseEntity delete( } @Override - @GetMapping(value = "/secrets/{secretName}/versions", + @GetMapping(value = {"/secrets/{secretName}/versions", "/secrets/{secretName}/versions/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity> versions( @@ -73,7 +73,7 @@ public ResponseEntity> versions( } @Override - @GetMapping(value = "/secrets", + @GetMapping(value = {"/secrets", "/secrets/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity> listSecrets( @@ -84,7 +84,7 @@ public ResponseEntity> listSecret } @Override - @GetMapping(value = "/deletedsecrets", + @GetMapping(value = {"/deletedsecrets", "/deletedsecrets/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity> listDeletedSecrets( @@ -95,7 +95,7 @@ public ResponseEntity> lis } @Override - @GetMapping(value = "/secrets/{secretName}", + @GetMapping(value = {"/secrets/{secretName}", "/secrets/{secretName}/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity get( @@ -105,7 +105,7 @@ public ResponseEntity get( } @Override - @GetMapping(value = "/secrets/{secretName}/{secretVersion}", + @GetMapping(value = {"/secrets/{secretName}/{secretVersion}", "/secrets/{secretName}/{secretVersion}/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity getWithVersion( @@ -116,7 +116,7 @@ public ResponseEntity getWithVersion( } @Override - @PatchMapping(value = "/secrets/{secretName}/{secretVersion}", + @PatchMapping(value = {"/secrets/{secretName}/{secretVersion}", "/secrets/{secretName}/{secretVersion}/"}, params = API_VERSION_7_3, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @@ -129,7 +129,7 @@ public ResponseEntity updateVersion( } @Override - @GetMapping(value = "/deletedsecrets/{secretName}", + @GetMapping(value = {"/deletedsecrets/{secretName}", "/deletedsecrets/{secretName}/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity getDeletedSecret( @@ -139,7 +139,7 @@ public ResponseEntity getDeletedSecret( } @Override - @DeleteMapping(value = "/deletedsecrets/{secretName}", + @DeleteMapping(value = {"/deletedsecrets/{secretName}", "/deletedsecrets/{secretName}/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity purgeDeleted( @@ -149,7 +149,7 @@ public ResponseEntity purgeDeleted( } @Override - @PostMapping(value = "/deletedsecrets/{secretName}/recover", + @PostMapping(value = {"/deletedsecrets/{secretName}/recover", "/deletedsecrets/{secretName}/recover/"}, params = API_VERSION_7_3, produces = APPLICATION_JSON_VALUE) public ResponseEntity recoverDeletedSecret( diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/filter/CommonAuthHeaderFilter.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/filter/CommonAuthHeaderFilter.java index 4989cff5..8f4a5406 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/filter/CommonAuthHeaderFilter.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/filter/CommonAuthHeaderFilter.java @@ -1,6 +1,10 @@ package com.github.nagyesta.lowkeyvault.filter; import com.github.nagyesta.lowkeyvault.model.common.ApiConstants; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpHeaders; import org.springframework.lang.NonNull; @@ -9,10 +13,6 @@ import org.springframework.util.StringUtils; import org.springframework.web.filter.OncePerRequestFilter; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.net.URI; import java.util.Set; diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/mapper/v7_3/key/KeyRotationPolicyToV73ModelConverter.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/mapper/v7_3/key/KeyRotationPolicyToV73ModelConverter.java index cbcbdefe..d7964bd5 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/mapper/v7_3/key/KeyRotationPolicyToV73ModelConverter.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/mapper/v7_3/key/KeyRotationPolicyToV73ModelConverter.java @@ -64,8 +64,8 @@ private List convertLifetimeActions(final Map convertLifetimeActions(final List lifetimeActions) { return lifetimeActions.stream() .map(this::convertLifetimeAction) - .collect(Collectors.toMap(LifetimeAction::getActionType, Function.identity())); + .collect(Collectors.toMap(LifetimeAction::actionType, Function.identity())); } private LifetimeAction convertLifetimeAction(final KeyLifetimeActionModel source) { diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/ErrorModel.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/ErrorModel.java index acb99986..fe702382 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/ErrorModel.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/ErrorModel.java @@ -1,17 +1,8 @@ package com.github.nagyesta.lowkeyvault.model.common; import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.ToString; - -@Getter -@ToString -@EqualsAndHashCode -public class ErrorModel { - @JsonProperty("error") - private final ErrorMessage error; +public record ErrorModel(@JsonProperty("error") ErrorMessage error) { public ErrorModel(final ErrorMessage error) { this.error = error; } diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/CertificateBackupList.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/CertificateBackupList.java index 22d42740..8b9f8810 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/CertificateBackupList.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/CertificateBackupList.java @@ -2,11 +2,11 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.github.nagyesta.lowkeyvault.model.v7_2.key.BackupListContainer; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; import lombok.EqualsAndHashCode; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; import java.util.List; @EqualsAndHashCode diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/CertificateBackupListItem.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/CertificateBackupListItem.java index 46250971..b3ca4fe7 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/CertificateBackupListItem.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/CertificateBackupListItem.java @@ -10,12 +10,11 @@ import com.github.nagyesta.lowkeyvault.model.v7_2.common.BaseBackupListItem; import com.github.nagyesta.lowkeyvault.model.v7_3.certificate.CertificatePolicyModel; import com.github.nagyesta.lowkeyvault.model.v7_3.certificate.CertificatePropertiesModel; +import jakarta.validation.constraints.NotNull; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -import javax.validation.constraints.NotNull; - @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/KeyBackupList.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/KeyBackupList.java index e4d082d3..01a42e36 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/KeyBackupList.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/KeyBackupList.java @@ -4,13 +4,16 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.github.nagyesta.lowkeyvault.model.v7_2.key.BackupListContainer; import com.github.nagyesta.lowkeyvault.model.v7_3.key.KeyRotationPolicyModel; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; import java.util.List; +@Getter @EqualsAndHashCode public class KeyBackupList implements BackupListContainer { @@ -20,24 +23,14 @@ public class KeyBackupList implements BackupListContainer { @JsonProperty("versions") private List versions = List.of(); - public List getVersions() { - return versions; - } - - public void setVersions(final List versions) { - this.versions = List.copyOf(versions); - } - + @Setter @Valid @JsonProperty("rotationPolicy") @JsonInclude(JsonInclude.Include.NON_NULL) private KeyRotationPolicyModel keyRotationPolicy; - public KeyRotationPolicyModel getKeyRotationPolicy() { - return keyRotationPolicy; + public void setVersions(final List versions) { + this.versions = List.copyOf(versions); } - public void setKeyRotationPolicy(final KeyRotationPolicyModel keyRotationPolicy) { - this.keyRotationPolicy = keyRotationPolicy; - } } diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/KeyBackupListItem.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/KeyBackupListItem.java index 10435261..410460dc 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/KeyBackupListItem.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/KeyBackupListItem.java @@ -4,13 +4,12 @@ import com.github.nagyesta.lowkeyvault.model.v7_2.common.BaseBackupListItem; import com.github.nagyesta.lowkeyvault.model.v7_2.key.KeyPropertiesModel; import com.github.nagyesta.lowkeyvault.model.v7_2.key.request.JsonWebKeyImportRequest; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/SecretBackupList.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/SecretBackupList.java index e97b777a..cb6546d0 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/SecretBackupList.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/SecretBackupList.java @@ -2,13 +2,15 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.github.nagyesta.lowkeyvault.model.v7_2.key.BackupListContainer; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; import lombok.EqualsAndHashCode; +import lombok.Getter; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; import java.util.List; +@Getter @EqualsAndHashCode public class SecretBackupList implements BackupListContainer { @@ -18,10 +20,6 @@ public class SecretBackupList implements BackupListContainer versions = List.of(); - public List getVersions() { - return versions; - } - public void setVersions(final List versions) { this.versions = List.copyOf(versions); } diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/SecretBackupListItem.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/SecretBackupListItem.java index 4236fd96..0f54867e 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/SecretBackupListItem.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/common/backup/SecretBackupListItem.java @@ -3,12 +3,11 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.github.nagyesta.lowkeyvault.model.v7_2.common.BaseBackupListItem; import com.github.nagyesta.lowkeyvault.model.v7_2.secret.SecretPropertiesModel; +import jakarta.validation.constraints.NotNull; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -import javax.validation.constraints.NotNull; - @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/json/util/AbstractBase64ZipDeserializer.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/json/util/AbstractBase64ZipDeserializer.java index 0a5d87cb..859db47f 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/json/util/AbstractBase64ZipDeserializer.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/json/util/AbstractBase64ZipDeserializer.java @@ -1,6 +1,5 @@ package com.github.nagyesta.lowkeyvault.model.json.util; -import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; @@ -29,7 +28,7 @@ protected AbstractBase64ZipDeserializer(final Base64Deserializer base64Deseriali } @Override - public E deserialize(final JsonParser jsonParser, final DeserializationContext context) throws IOException, JacksonException { + public E deserialize(final JsonParser jsonParser, final DeserializationContext context) throws IOException { final Optional bytes = Optional.ofNullable(base64Deserializer.deserializeBase64(jsonParser)); return bytes.filter(v -> v.length > 0) .map(this::decompressWrappedObject) diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/management/VaultBackupListModel.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/management/VaultBackupListModel.java index 0860ec2c..adc8139e 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/management/VaultBackupListModel.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/management/VaultBackupListModel.java @@ -2,11 +2,11 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; import lombok.Data; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; import java.util.List; @Data diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/management/VaultBackupModel.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/management/VaultBackupModel.java index 2fa06d97..2d20f8e7 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/management/VaultBackupModel.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/management/VaultBackupModel.java @@ -5,10 +5,10 @@ import com.github.nagyesta.lowkeyvault.model.common.backup.CertificateBackupList; import com.github.nagyesta.lowkeyvault.model.common.backup.KeyBackupList; import com.github.nagyesta.lowkeyvault.model.common.backup.SecretBackupList; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; import java.util.Map; @Data diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/management/VaultModel.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/management/VaultModel.java index d6c0f0d8..c84a8665 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/management/VaultModel.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/management/VaultModel.java @@ -8,9 +8,9 @@ import com.github.nagyesta.lowkeyvault.model.json.util.EpochSecondsSerializer; import com.github.nagyesta.lowkeyvault.model.v7_2.common.constants.RecoveryLevel; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import javax.validation.constraints.NotNull; import java.net.URI; import java.time.OffsetDateTime; import java.util.Set; diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/common/BaseBackupListItem.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/common/BaseBackupListItem.java index 1b86eaac..7ee51555 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/common/BaseBackupListItem.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/common/BaseBackupListItem.java @@ -3,11 +3,11 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.github.nagyesta.lowkeyvault.model.v7_2.BasePropertiesModel; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; import java.net.URI; import java.util.Map; diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/common/BaseBackupModel.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/common/BaseBackupModel.java index dd752d73..951a9df8 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/common/BaseBackupModel.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/common/BaseBackupModel.java @@ -3,11 +3,10 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.github.nagyesta.lowkeyvault.model.v7_2.BasePropertiesModel; import com.github.nagyesta.lowkeyvault.model.v7_2.key.BackupListContainer; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - /** * Base class of backup models. * diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/common/constants/RecoveryLevel.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/common/constants/RecoveryLevel.java index 264add45..4f981e43 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/common/constants/RecoveryLevel.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/common/constants/RecoveryLevel.java @@ -9,7 +9,7 @@ public enum RecoveryLevel { /** * Purgeable and not recoverable, subscription not protected. - * See: https://docs.microsoft.com/en-us/rest/api/keyvault/create-key/create-key#deletionrecoverylevel + * See: source */ PURGEABLE("Purgeable") { @Override @@ -31,7 +31,7 @@ public void checkValidRecoverableDays(final Integer recoverableDays) { }, /** * Purgeable and recoverable, subscription not protected. - * See: https://docs.microsoft.com/en-us/rest/api/keyvault/create-key/create-key#deletionrecoverylevel + * See: source */ RECOVERABLE_AND_PURGEABLE("Recoverable+Purgeable") { @Override @@ -41,12 +41,12 @@ public boolean isPurgeable() { }, /** * Recoverable, not purgeable, subscription not protected. - * See: https://docs.microsoft.com/en-us/rest/api/keyvault/create-key/create-key#deletionrecoverylevel + * See: source */ RECOVERABLE("Recoverable"), /** * Recoverable, not purgeable, subscription protected. - * See: https://docs.microsoft.com/en-us/rest/api/keyvault/create-key/create-key#deletionrecoverylevel + * See: source */ RECOVERABLE_AND_PROTECTED_SUBSCRIPTION("Recoverable+ProtectedSubscription") { @Override @@ -56,7 +56,7 @@ public boolean isSubscriptionProtected() { }, /** * Recoverable for a customized time, purgeable, subscription not protected. - * See: https://docs.microsoft.com/en-us/rest/api/keyvault/create-key/create-key#deletionrecoverylevel + * See: source */ CUSTOMIZED_RECOVERABLE_AND_PURGEABLE("CustomizedRecoverable+Purgeable") { @Override @@ -71,7 +71,7 @@ public boolean isCustomized() { }, /** * Recoverable for a customized time, not purgeable, subscription not protected. - * See: https://docs.microsoft.com/en-us/rest/api/keyvault/create-key/create-key#deletionrecoverylevel + * See: source */ CUSTOMIZED_RECOVERABLE("CustomizedRecoverable") { @Override @@ -82,7 +82,7 @@ public boolean isCustomized() { /** * Recoverable for a customized time, not purgeable, subscription protected. - * See: https://docs.microsoft.com/en-us/rest/api/keyvault/create-key/create-key#deletionrecoverylevel + * See: source */ CUSTOMIZED_RECOVERABLE_AND_PROTECTED_SUBSCRIPTION("CustomizedRecoverable+ProtectedSubscription") { @Override diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/constants/HashAlgorithm.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/constants/HashAlgorithm.java index a57bd3a2..c21fc00b 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/constants/HashAlgorithm.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/constants/HashAlgorithm.java @@ -1,5 +1,6 @@ package com.github.nagyesta.lowkeyvault.model.v7_2.key.constants; +import lombok.Getter; import org.bouncycastle.asn1.ASN1ObjectIdentifier; import org.bouncycastle.asn1.DERNull; import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; @@ -13,12 +14,13 @@ import java.security.spec.PSSParameterSpec; import java.util.Optional; -@SuppressWarnings("checkstyle:JavadocVariable") +@SuppressWarnings({"checkstyle:JavadocVariable", "LombokGetterMayBeUsed"}) public enum HashAlgorithm { SHA256("SHA-256", 32, NISTObjectIdentifiers.id_sha256), SHA384("SHA-384", 48, NISTObjectIdentifiers.id_sha384), SHA512("SHA-512", 64, NISTObjectIdentifiers.id_sha512); + @Getter private final String algorithmName; private final ASN1ObjectIdentifier algorithmIdentifier; private final int digestLength; @@ -29,10 +31,6 @@ public enum HashAlgorithm { this.digestLength = digestLength; } - public String getAlgorithmName() { - return algorithmName; - } - public byte[] encodeDigest(final byte[] digest) throws IOException { return new DigestInfo(new AlgorithmIdentifier(algorithmIdentifier, DERNull.INSTANCE), digest).getEncoded(); } diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/constants/KeyCurveName.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/constants/KeyCurveName.java index f1f707bb..8e2f73cf 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/constants/KeyCurveName.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/constants/KeyCurveName.java @@ -15,27 +15,31 @@ public enum KeyCurveName { /** * P-256. */ - P_256("P-256", "secp256r1", Set.of("prime256v1")), + P_256("P-256", "secp256r1", Set.of("prime256v1"), 256), /** * P-384. */ - P_384("P-384", "secp384r1", Set.of()), + P_384("P-384", "secp384r1", Set.of(), 384), /** * P-521. */ - P_521("P-521", "secp521r1", Set.of()), + P_521("P-521", "secp521r1", Set.of(), 521), /** * P-256K. */ - P_256K("P-256K", "secp256k1", Set.of()); + P_256K("P-256K", "secp256k1", Set.of(), 256); + private static final double BITS_PER_BYTE = 8.0D; private final String value; private final String alg; + + private final int bitLength; private final Set equivalentAlgs; - KeyCurveName(final String value, final String alg, final Set equivalentAlgs) { + KeyCurveName(final String value, final String alg, final Set equivalentAlgs, final int bitLength) { this.value = value; this.alg = alg; + this.bitLength = bitLength; final TreeSet algSet = new TreeSet<>(equivalentAlgs); algSet.add(alg); this.equivalentAlgs = algSet; @@ -59,4 +63,14 @@ public String getValue() { public AlgorithmParameterSpec getAlgSpec() { return new ECGenParameterSpec(alg); } + + @JsonIgnore + public int getBitLength() { + return bitLength; + } + + @JsonIgnore + public int getByteLength() { + return (int) Math.ceil(getBitLength() / BITS_PER_BYTE); + } } diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/constants/SignatureAlgorithm.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/constants/SignatureAlgorithm.java index 53f5f51d..4339ab96 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/constants/SignatureAlgorithm.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/constants/SignatureAlgorithm.java @@ -13,49 +13,29 @@ @SuppressWarnings("checkstyle:JavadocVariable") public enum SignatureAlgorithm { - ES256("ES256", "NONEwithECDSAinP1363Format", KeyType.EC, HashAlgorithm.SHA256) { + ES256("ES256", "NONEwithECDSA", KeyType.EC, HashAlgorithm.SHA256) { @Override public boolean isCompatibleWithCurve(final KeyCurveName keyCurveName) { return KeyCurveName.P_256 == keyCurveName; } - - @Override - public Signature getSignatureInstance() throws GeneralSecurityException { - return Signature.getInstance(getAlg()); - } }, - ES256K("ES256K", "NONEwithECDSAinP1363Format", KeyType.EC, HashAlgorithm.SHA256) { + ES256K("ES256K", "NONEwithECDSA", KeyType.EC, HashAlgorithm.SHA256) { @Override public boolean isCompatibleWithCurve(final KeyCurveName keyCurveName) { return KeyCurveName.P_256K == keyCurveName; } - - @Override - public Signature getSignatureInstance() throws GeneralSecurityException { - return Signature.getInstance(getAlg()); - } }, - ES384("ES384", "NONEwithECDSAinP1363Format", KeyType.EC, HashAlgorithm.SHA384) { + ES384("ES384", "NONEwithECDSA", KeyType.EC, HashAlgorithm.SHA384) { @Override public boolean isCompatibleWithCurve(final KeyCurveName keyCurveName) { return KeyCurveName.P_384 == keyCurveName; } - - @Override - public Signature getSignatureInstance() throws GeneralSecurityException { - return Signature.getInstance(getAlg()); - } }, - ES512("ES512", "NONEwithECDSAinP1363Format", KeyType.EC, HashAlgorithm.SHA512) { + ES512("ES512", "NONEwithECDSA", KeyType.EC, HashAlgorithm.SHA512) { @Override public boolean isCompatibleWithCurve(final KeyCurveName keyCurveName) { return KeyCurveName.P_521 == keyCurveName; } - - @Override - public Signature getSignatureInstance() throws GeneralSecurityException { - return Signature.getInstance(getAlg()); - } }, PS256("PS256", "NONEwithRSAandMGF1", KeyType.RSA, HashAlgorithm.SHA256) { @Override diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/CreateKeyRequest.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/CreateKeyRequest.java index e4c52997..6d42a1d2 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/CreateKeyRequest.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/CreateKeyRequest.java @@ -11,13 +11,13 @@ import com.github.nagyesta.lowkeyvault.service.key.impl.KeyCreationInput; import com.github.nagyesta.lowkeyvault.service.key.impl.OctKeyCreationInput; import com.github.nagyesta.lowkeyvault.service.key.impl.RsaKeyCreationInput; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; import lombok.Data; import org.springframework.lang.NonNull; import org.springframework.util.Assert; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; import java.math.BigInteger; import java.util.List; import java.util.Map; diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/ImportKeyRequest.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/ImportKeyRequest.java index b3259f77..34f2f5cb 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/ImportKeyRequest.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/ImportKeyRequest.java @@ -3,10 +3,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.github.nagyesta.lowkeyvault.model.v7_2.BasePropertiesUpdateModel; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; import java.util.Map; @SuppressWarnings("checkstyle:MagicNumber") diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/JsonWebKeyImportRequest.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/JsonWebKeyImportRequest.java index 13a684ef..e61c0aaf 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/JsonWebKeyImportRequest.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/JsonWebKeyImportRequest.java @@ -10,11 +10,11 @@ import com.github.nagyesta.lowkeyvault.model.v7_2.key.constants.KeyOperation; import com.github.nagyesta.lowkeyvault.model.v7_2.key.constants.KeyType; import com.github.nagyesta.lowkeyvault.model.v7_2.key.validator.*; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Null; +import jakarta.validation.constraints.Size; import lombok.Data; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Null; -import javax.validation.constraints.Size; import java.util.ArrayList; import java.util.List; diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/KeyOperationsParameters.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/KeyOperationsParameters.java index 799461e0..7974d4a4 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/KeyOperationsParameters.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/KeyOperationsParameters.java @@ -8,10 +8,10 @@ import com.github.nagyesta.lowkeyvault.model.json.util.Base64Deserializer; import com.github.nagyesta.lowkeyvault.model.json.util.Base64Serializer; import com.github.nagyesta.lowkeyvault.model.v7_2.key.constants.EncryptionAlgorithm; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; import java.util.Base64; import java.util.Optional; diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/KeySignParameters.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/KeySignParameters.java index 9b3e5027..392d1180 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/KeySignParameters.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/KeySignParameters.java @@ -4,10 +4,10 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.github.nagyesta.lowkeyvault.model.v7_2.key.constants.SignatureAlgorithm; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; import java.util.Base64; import java.util.Optional; diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/KeyVerifyParameters.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/KeyVerifyParameters.java index 36b37db0..61c5597e 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/KeyVerifyParameters.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/request/KeyVerifyParameters.java @@ -4,10 +4,10 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.github.nagyesta.lowkeyvault.model.v7_2.key.constants.SignatureAlgorithm; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; import java.util.Base64; import java.util.Optional; diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/validator/ImportKeyValidator.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/validator/ImportKeyValidator.java index f779643b..c1033511 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/validator/ImportKeyValidator.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/validator/ImportKeyValidator.java @@ -2,13 +2,13 @@ import com.github.nagyesta.lowkeyvault.model.v7_2.key.constants.KeyType; import com.github.nagyesta.lowkeyvault.model.v7_2.key.request.JsonWebKeyImportRequest; +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.Validator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import javax.validation.ConstraintViolation; -import javax.validation.Validator; import java.util.Set; @Component diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/validator/ValidImportKey.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/validator/ValidImportKey.java index 4d457bba..cae94348 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/validator/ValidImportKey.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/validator/ValidImportKey.java @@ -1,7 +1,8 @@ package com.github.nagyesta.lowkeyvault.model.v7_2.key.validator; -import javax.validation.Constraint; -import javax.validation.Payload; +import jakarta.validation.Constraint; +import jakarta.validation.Payload; + import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/secret/request/CreateSecretRequest.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/secret/request/CreateSecretRequest.java index 44ef5ee0..4d3a3c94 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/secret/request/CreateSecretRequest.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_2/secret/request/CreateSecretRequest.java @@ -3,10 +3,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.github.nagyesta.lowkeyvault.model.v7_2.secret.SecretPropertiesModel; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; import java.util.Map; @Data diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateImportRequest.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateImportRequest.java index 02dd7730..47f408ef 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateImportRequest.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateImportRequest.java @@ -6,10 +6,10 @@ import com.github.nagyesta.lowkeyvault.controller.common.util.CertificateRequestMapperUtil; import com.github.nagyesta.lowkeyvault.model.json.util.Base64CertDeserializer; import com.github.nagyesta.lowkeyvault.model.json.util.Base64CertSerializer; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; import java.util.Map; @Data diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateKeyModel.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateKeyModel.java index 7ead2082..e74b99b2 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateKeyModel.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateKeyModel.java @@ -4,12 +4,11 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.github.nagyesta.lowkeyvault.model.v7_2.key.constants.KeyCurveName; import com.github.nagyesta.lowkeyvault.model.v7_2.key.constants.KeyType; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; - @Data public class CertificateKeyModel { diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateLifetimeActionModel.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateLifetimeActionModel.java index 78877986..37014570 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateLifetimeActionModel.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateLifetimeActionModel.java @@ -6,11 +6,10 @@ import com.github.nagyesta.lowkeyvault.model.json.util.CertificateLifetimeActionDeserializer; import com.github.nagyesta.lowkeyvault.model.json.util.CertificateLifetimeActionSerializer; import com.github.nagyesta.lowkeyvault.service.certificate.CertificateLifetimeActionActivity; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - @Data public class CertificateLifetimeActionModel { diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateLifetimeActionTriggerModel.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateLifetimeActionTriggerModel.java index eade177a..d5192154 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateLifetimeActionTriggerModel.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateLifetimeActionTriggerModel.java @@ -4,12 +4,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.github.nagyesta.lowkeyvault.service.certificate.CertificateLifetimeActionTrigger; import com.github.nagyesta.lowkeyvault.service.certificate.CertificateLifetimeActionTriggerType; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; import lombok.Data; import lombok.NoArgsConstructor; import org.springframework.util.Assert; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; import java.util.Optional; @Data @@ -27,10 +27,10 @@ public class CertificateLifetimeActionTriggerModel { private Integer daysBeforeExpiry; public CertificateLifetimeActionTriggerModel(final CertificateLifetimeActionTrigger trigger) { - if (trigger.getTriggerType() == CertificateLifetimeActionTriggerType.DAYS_BEFORE_EXPIRY) { - this.daysBeforeExpiry = trigger.getValue(); + if (trigger.triggerType() == CertificateLifetimeActionTriggerType.DAYS_BEFORE_EXPIRY) { + this.daysBeforeExpiry = trigger.value(); } else { - this.lifetimePercentage = trigger.getValue(); + this.lifetimePercentage = trigger.value(); } } diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificatePolicyModel.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificatePolicyModel.java index b5d696c7..3fe6dfb5 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificatePolicyModel.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificatePolicyModel.java @@ -2,11 +2,11 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; import lombok.Data; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; import java.util.List; @Data diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateSecretModel.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateSecretModel.java index 539f5d82..136f9e42 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateSecretModel.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateSecretModel.java @@ -1,10 +1,9 @@ package com.github.nagyesta.lowkeyvault.model.v7_3.certificate; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import javax.validation.constraints.NotNull; - @Data public class CertificateSecretModel { diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CreateCertificateRequest.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CreateCertificateRequest.java index 911f61cf..993dfc55 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CreateCertificateRequest.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CreateCertificateRequest.java @@ -2,10 +2,10 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; import java.util.Map; @Data diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/SubjectAlternativeNames.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/SubjectAlternativeNames.java index 489c15c7..bb9b63ac 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/SubjectAlternativeNames.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/SubjectAlternativeNames.java @@ -2,26 +2,14 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; import java.util.Set; -@Data -public class SubjectAlternativeNames { - - @JsonProperty("dns_names") - private final Set dnsNames; - @JsonProperty("emails") - private final Set emails; - @JsonProperty("upns") - private final Set upns; +public record SubjectAlternativeNames(@JsonProperty("dns_names") Set dnsNames, + @JsonProperty("emails") Set emails, + @JsonProperty("upns") Set upns) { @JsonCreator - public SubjectAlternativeNames(@JsonProperty("dns_names") final Set dnsNames, - @JsonProperty("emails") final Set emails, - @JsonProperty("upns") final Set upns) { - this.dnsNames = dnsNames; - this.emails = emails; - this.upns = upns; + public SubjectAlternativeNames { } } diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/X509CertificateModel.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/X509CertificateModel.java index d0b229f3..e90f7b60 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/X509CertificateModel.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/X509CertificateModel.java @@ -2,11 +2,11 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.github.nagyesta.lowkeyvault.service.certificate.impl.KeyUsageEnum; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; import java.util.Set; @Data diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyLifetimeActionModel.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyLifetimeActionModel.java index b6b003b4..4badbaec 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyLifetimeActionModel.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyLifetimeActionModel.java @@ -6,11 +6,10 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.github.nagyesta.lowkeyvault.model.v7_3.key.validator.Restore; import com.github.nagyesta.lowkeyvault.model.v7_3.key.validator.Update; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - @Data @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({"trigger", "action"}) diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyLifetimeActionTriggerModel.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyLifetimeActionTriggerModel.java index c6cc21ea..bbc6e8ba 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyLifetimeActionTriggerModel.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyLifetimeActionTriggerModel.java @@ -36,8 +36,8 @@ public KeyLifetimeActionTriggerModel(@JsonProperty("timeBeforeExpiry") final Per } public KeyLifetimeActionTriggerModel(@NonNull final LifetimeActionTrigger trigger) { - this.triggerType = trigger.getTriggerType(); - this.triggerPeriod = trigger.getTimePeriod(); + this.triggerType = trigger.triggerType(); + this.triggerPeriod = trigger.timePeriod(); } @JsonGetter diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyLifetimeActionTypeModel.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyLifetimeActionTypeModel.java index 5a662edd..70c3b80c 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyLifetimeActionTypeModel.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyLifetimeActionTypeModel.java @@ -6,11 +6,10 @@ import com.github.nagyesta.lowkeyvault.model.v7_3.key.constants.LifetimeActionType; import com.github.nagyesta.lowkeyvault.model.v7_3.key.validator.Restore; import com.github.nagyesta.lowkeyvault.model.v7_3.key.validator.Update; +import jakarta.validation.constraints.NotNull; import lombok.Data; import lombok.NonNull; -import javax.validation.constraints.NotNull; - @Data @JsonInclude(JsonInclude.Include.NON_NULL) public class KeyLifetimeActionTypeModel { diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyRotationPolicyAttributes.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyRotationPolicyAttributes.java index 0cc79008..38ff4aa2 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyRotationPolicyAttributes.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyRotationPolicyAttributes.java @@ -10,10 +10,10 @@ import com.github.nagyesta.lowkeyvault.model.v7_3.key.validator.ExpiryPeriod; import com.github.nagyesta.lowkeyvault.model.v7_3.key.validator.Restore; import com.github.nagyesta.lowkeyvault.model.v7_3.key.validator.Update; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Null; import lombok.Data; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Null; import java.time.OffsetDateTime; import java.time.Period; diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyRotationPolicyModel.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyRotationPolicyModel.java index da6c6874..4b160267 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyRotationPolicyModel.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyRotationPolicyModel.java @@ -6,11 +6,11 @@ import com.github.nagyesta.lowkeyvault.model.v7_3.key.validator.Restore; import com.github.nagyesta.lowkeyvault.model.v7_3.key.validator.Update; import com.github.nagyesta.lowkeyvault.service.key.id.KeyEntityId; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; import lombok.Data; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; import java.net.URI; import java.util.List; diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/RandomBytesRequest.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/RandomBytesRequest.java index 38fab756..f8380e7a 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/RandomBytesRequest.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/RandomBytesRequest.java @@ -2,10 +2,9 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.Min; import lombok.Data; -import javax.validation.constraints.Min; - @Data @JsonInclude(JsonInclude.Include.NON_NULL) public class RandomBytesRequest { diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/validator/ExpiryPeriod.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/validator/ExpiryPeriod.java index b68681eb..8fcf2398 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/validator/ExpiryPeriod.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/validator/ExpiryPeriod.java @@ -1,7 +1,8 @@ package com.github.nagyesta.lowkeyvault.model.v7_3.key.validator; -import javax.validation.Constraint; -import javax.validation.Payload; +import jakarta.validation.Constraint; +import jakarta.validation.Payload; + import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/validator/ExpiryPeriodValidator.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/validator/ExpiryPeriodValidator.java index 2c2e7ef3..453cfb1b 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/validator/ExpiryPeriodValidator.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/validator/ExpiryPeriodValidator.java @@ -2,9 +2,9 @@ import com.github.nagyesta.lowkeyvault.service.key.constants.LifetimeActionTriggerType; import com.github.nagyesta.lowkeyvault.service.key.util.PeriodUtil; +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; import java.time.Period; import java.util.Optional; diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/CertificateLifetimeActionActivity.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/CertificateLifetimeActionActivity.java index e30f8073..e87b0de8 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/CertificateLifetimeActionActivity.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/CertificateLifetimeActionActivity.java @@ -1,9 +1,11 @@ package com.github.nagyesta.lowkeyvault.service.certificate; +import lombok.Getter; import lombok.NonNull; import java.util.Arrays; +@Getter public enum CertificateLifetimeActionActivity { /** * Noop, simulates email notification actions. @@ -27,7 +29,4 @@ public static CertificateLifetimeActionActivity byValue(@NonNull final String va .orElseThrow(() -> new IllegalArgumentException("Unknown lifetime action activity: " + value)); } - public String getValue() { - return value; - } } diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/CertificateLifetimeActionTrigger.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/CertificateLifetimeActionTrigger.java index 23147663..8f15e2d7 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/CertificateLifetimeActionTrigger.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/CertificateLifetimeActionTrigger.java @@ -1,17 +1,10 @@ package com.github.nagyesta.lowkeyvault.service.certificate; -import lombok.EqualsAndHashCode; -import lombok.Getter; import lombok.NonNull; import java.time.OffsetDateTime; -@Getter -@EqualsAndHashCode -public class CertificateLifetimeActionTrigger { - - private final int value; - private final CertificateLifetimeActionTriggerType triggerType; +public record CertificateLifetimeActionTrigger(CertificateLifetimeActionTriggerType triggerType, int value) { public CertificateLifetimeActionTrigger( @NonNull final CertificateLifetimeActionTriggerType triggerType, final int value) { diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/impl/CertAuthorityType.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/impl/CertAuthorityType.java index 591cfc27..00f7dc5d 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/impl/CertAuthorityType.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/impl/CertAuthorityType.java @@ -1,9 +1,11 @@ package com.github.nagyesta.lowkeyvault.service.certificate.impl; import com.github.nagyesta.lowkeyvault.service.certificate.CertificateLifetimeActionActivity; +import lombok.Getter; import java.util.Arrays; +@Getter public enum CertAuthorityType { /** @@ -23,14 +25,6 @@ public enum CertAuthorityType { this.defaultAction = action; } - public String getValue() { - return value; - } - - public CertificateLifetimeActionActivity getDefaultAction() { - return defaultAction; - } - public static CertAuthorityType byValue(final String value) { return Arrays.stream(values()) .filter(c -> c.getValue().equals(value)) diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/impl/CertContentType.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/impl/CertContentType.java index b1e20085..27641a34 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/impl/CertContentType.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/impl/CertContentType.java @@ -6,13 +6,13 @@ import com.github.nagyesta.lowkeyvault.model.v7_2.key.request.JsonWebKeyImportRequest; import com.github.nagyesta.lowkeyvault.service.exception.CryptoException; import com.github.nagyesta.lowkeyvault.service.key.util.KeyGenUtil; +import lombok.Getter; import lombok.NonNull; import org.apache.tomcat.util.codec.binary.Base64; import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey; import org.bouncycastle.openssl.jcajce.JcaPEMWriter; import org.bouncycastle.openssl.jcajce.JcaPKCS8Generator; import org.springframework.util.Assert; -import org.springframework.util.Base64Utils; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -31,6 +31,7 @@ import static com.github.nagyesta.lowkeyvault.model.v7_2.key.constants.KeyType.EC; import static com.github.nagyesta.lowkeyvault.model.v7_2.key.constants.KeyType.RSA; +@Getter public enum CertContentType { /** @@ -71,7 +72,7 @@ public JsonWebKeyImportRequest getKey(@NonNull final String certificateContent, public String asBase64CertificatePackage(@NonNull final Certificate certificate, @NonNull final KeyPair keyPair) throws CryptoException { final byte[] bytes = generateCertificatePackage(certificate, keyPair, DEFAULT_PASSWORD); - return Base64Utils.encodeToString(bytes); + return new Base64().encodeAsString(bytes); } @Override @@ -218,10 +219,6 @@ private static KeyType assumeKeyType(final int size) { this.mimeType = mimeType; } - public String getMimeType() { - return mimeType; - } - public static CertContentType byMimeType(final String mimeType) { return Arrays.stream(values()) .filter(c -> c.getMimeType().equals(mimeType)) diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/impl/CertificateAlgorithm.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/impl/CertificateAlgorithm.java index 8290f8ad..73fc909b 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/impl/CertificateAlgorithm.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/impl/CertificateAlgorithm.java @@ -1,12 +1,14 @@ package com.github.nagyesta.lowkeyvault.service.certificate.impl; import com.github.nagyesta.lowkeyvault.model.v7_2.key.constants.KeyType; +import lombok.Getter; import lombok.NonNull; import java.util.Arrays; import java.util.Optional; import java.util.Set; +@SuppressWarnings("LombokGetterMayBeUsed") public enum CertificateAlgorithm { /** @@ -18,6 +20,7 @@ public enum CertificateAlgorithm { */ EC("SHA256withECDSA", Set.of(KeyType.EC, KeyType.EC_HSM)); + @Getter private final String algorithm; private final Set keyTypes; @@ -26,10 +29,6 @@ public enum CertificateAlgorithm { this.keyTypes = keyTypes; } - public String getAlgorithm() { - return algorithm; - } - public static CertificateAlgorithm forKeyType(@NonNull final KeyType keyType) { final Optional value = Arrays.stream(CertificateAlgorithm.values()) .filter(v -> v.keyTypes.contains(keyType)) diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/impl/CertificateGenerator.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/impl/CertificateGenerator.java index b549bea5..f57ffc80 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/impl/CertificateGenerator.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/certificate/impl/CertificateGenerator.java @@ -44,7 +44,6 @@ public class CertificateGenerator { private static final int NUMBER_OF_BITS_SERIAL = 160; - private static final int NUMBER_OF_BYTES_CID = 20; private final VaultFake vault; private final VersionedKeyEntityId kid; private final SecureRandom secureRandom = new SecureRandom(); @@ -123,7 +122,7 @@ private ExtendedKeyUsage convertUsageExtensions(final ReadOnlyCertificatePolicy .stream() .map(ASN1ObjectIdentifier::new) .map(KeyPurposeId::getInstance) - .collect(Collectors.toList()) + .toList() .toArray(new KeyPurposeId[]{})); } return result; @@ -180,7 +179,7 @@ private GeneralName[] generateSubjectAlternativeNamesArray(final ReadOnlyCertifi .collect(Collectors.toList()); final List subjectAlternativeNames = Stream.of(emails, dnsNames, ips) .flatMap(List::stream) - .collect(Collectors.toList()); + .toList(); return subjectAlternativeNames.toArray(new GeneralName[]{}); } diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/common/impl/ConcurrentVersionedEntityMultiMap.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/common/impl/ConcurrentVersionedEntityMultiMap.java index 46f1f6d9..1289ff21 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/common/impl/ConcurrentVersionedEntityMultiMap.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/common/impl/ConcurrentVersionedEntityMultiMap.java @@ -146,7 +146,7 @@ public void purgeExpired() { final List purgeable = entities.entrySet().stream() .filter(e -> e.getValue().values().stream().anyMatch(ME::isPurgeExpired)) .map(Map.Entry::getKey) - .collect(Collectors.toList()); + .toList(); purgeable.forEach(key -> { entities.remove(key); versions.remove(key); diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/common/impl/KeyVaultLifecycleAwareEntity.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/common/impl/KeyVaultLifecycleAwareEntity.java index c4f12100..d11ecf07 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/common/impl/KeyVaultLifecycleAwareEntity.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/common/impl/KeyVaultLifecycleAwareEntity.java @@ -1,5 +1,6 @@ package com.github.nagyesta.lowkeyvault.service.common.impl; +import lombok.Getter; import org.springframework.lang.NonNull; import org.springframework.util.Assert; @@ -7,6 +8,7 @@ import java.time.ZoneOffset; import java.util.Optional; +@Getter @SuppressWarnings("OptionalUsedAsFieldOrParameterType") public class KeyVaultLifecycleAwareEntity { private OffsetDateTime created; @@ -23,38 +25,18 @@ protected KeyVaultLifecycleAwareEntity() { this.expiry = Optional.empty(); } - public boolean isEnabled() { - return enabled; - } - public void setEnabled(final boolean enabled) { this.enabled = enabled; } - public Optional getNotBefore() { - return notBefore; - } - public void setNotBefore(final OffsetDateTime notBefore) { this.notBefore = Optional.ofNullable(notBefore); } - public Optional getExpiry() { - return expiry; - } - public void setExpiry(final OffsetDateTime expiry) { this.expiry = Optional.ofNullable(expiry); } - public OffsetDateTime getCreated() { - return created; - } - - public OffsetDateTime getUpdated() { - return updated; - } - public void timeShift(final int offsetSeconds) { Assert.isTrue(offsetSeconds > 0, "Offset must be positive."); created = created.minusSeconds(offsetSeconds); diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/KeyLifetimeAction.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/KeyLifetimeAction.java index 5fc25091..93d493d6 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/KeyLifetimeAction.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/KeyLifetimeAction.java @@ -3,23 +3,10 @@ import com.github.nagyesta.lowkeyvault.model.v7_3.key.constants.LifetimeActionType; import lombok.NonNull; -public class KeyLifetimeAction implements LifetimeAction { - - private final LifetimeActionType actionType; - private final LifetimeActionTrigger trigger; +public record KeyLifetimeAction(LifetimeActionType actionType, LifetimeActionTrigger trigger) implements LifetimeAction { public KeyLifetimeAction(@NonNull final LifetimeActionType actionType, @NonNull final LifetimeActionTrigger trigger) { this.actionType = actionType; this.trigger = trigger; } - - @Override - public LifetimeActionType getActionType() { - return actionType; - } - - @Override - public LifetimeActionTrigger getTrigger() { - return trigger; - } } diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/LifetimeAction.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/LifetimeAction.java index 074e59a2..e568b6e3 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/LifetimeAction.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/LifetimeAction.java @@ -4,7 +4,7 @@ public interface LifetimeAction { - LifetimeActionType getActionType(); + LifetimeActionType actionType(); - LifetimeActionTrigger getTrigger(); + LifetimeActionTrigger trigger(); } diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/LifetimeActionTrigger.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/LifetimeActionTrigger.java index 46e57519..a9aaf210 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/LifetimeActionTrigger.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/LifetimeActionTrigger.java @@ -7,9 +7,9 @@ public interface LifetimeActionTrigger { - Period getTimePeriod(); + Period timePeriod(); - LifetimeActionTriggerType getTriggerType(); + LifetimeActionTriggerType triggerType(); boolean shouldTrigger(OffsetDateTime created, OffsetDateTime expiry); diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/impl/EcKeyVaultKeyEntity.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/impl/EcKeyVaultKeyEntity.java index 01bfb04f..9613ab1f 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/impl/EcKeyVaultKeyEntity.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/impl/EcKeyVaultKeyEntity.java @@ -3,6 +3,7 @@ import com.github.nagyesta.lowkeyvault.model.v7_2.key.constants.*; import com.github.nagyesta.lowkeyvault.service.key.ReadOnlyEcKeyVaultKeyEntity; import com.github.nagyesta.lowkeyvault.service.key.id.VersionedKeyEntityId; +import com.github.nagyesta.lowkeyvault.service.key.util.Asn1ConverterUtil; import com.github.nagyesta.lowkeyvault.service.vault.VaultFake; import lombok.extern.slf4j.Slf4j; import org.springframework.lang.NonNull; @@ -100,4 +101,14 @@ public boolean verifySignedBytes(final byte[] digest, final Callable verifyCallable = verifyCallable(digest, signatureAlgorithm, signature, getKey().getPublic()); return doCrypto(verifyCallable, "Cannot verify digest message.", log); } + + @Override + protected byte[] postProcessGeneratedSignature(final byte[] signature) throws Exception { + return Asn1ConverterUtil.convertFromAsn1toRaw(signature, getKeyCurveName().getByteLength()); + } + + @Override + protected byte[] preProcessVerifiableSignature(final byte[] rawSignature) throws Exception { + return Asn1ConverterUtil.convertFromRawToAsn1(rawSignature); + } } diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/impl/KeyLifetimeActionTrigger.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/impl/KeyLifetimeActionTrigger.java index c13a6386..cdddc6e4 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/impl/KeyLifetimeActionTrigger.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/impl/KeyLifetimeActionTrigger.java @@ -8,26 +8,13 @@ import java.time.OffsetDateTime; import java.time.Period; -public class KeyLifetimeActionTrigger implements LifetimeActionTrigger { - - private final Period timePeriod; - private final LifetimeActionTriggerType triggerType; +public record KeyLifetimeActionTrigger(Period timePeriod, LifetimeActionTriggerType triggerType) implements LifetimeActionTrigger { public KeyLifetimeActionTrigger(@NonNull final Period timePeriod, @NonNull final LifetimeActionTriggerType triggerType) { this.timePeriod = timePeriod; this.triggerType = triggerType; } - @Override - public Period getTimePeriod() { - return timePeriod; - } - - @Override - public LifetimeActionTriggerType getTriggerType() { - return triggerType; - } - @Override public boolean shouldTrigger(final OffsetDateTime created, final OffsetDateTime expiry) { return triggerType.shouldTrigger(created, expiry, timePeriod); diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/impl/KeyRotationPolicy.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/impl/KeyRotationPolicy.java index ad40f376..0d3b2e2a 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/impl/KeyRotationPolicy.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/impl/KeyRotationPolicy.java @@ -40,7 +40,7 @@ public boolean isAutoRotate() { @Override public List missedRotations(@NonNull final OffsetDateTime keyCreation) { Assert.isTrue(isAutoRotate(), "Cannot have missed rotations without a \"rotate\" lifetime action."); - final LifetimeActionTrigger trigger = lifetimeActions.get(LifetimeActionType.ROTATE).getTrigger(); + final LifetimeActionTrigger trigger = lifetimeActions.get(LifetimeActionType.ROTATE).trigger(); final OffsetDateTime startPoint = findTriggerTimeOffset(keyCreation, s -> trigger.rotateAfterDays(expiryTime)); return collectMissedTriggerDays(s -> trigger.rotateAfterDays(expiryTime), startPoint); } @@ -53,10 +53,10 @@ public Map getLifetimeActions() { @Override public void validate(final OffsetDateTime latestKeyVersionExpiry) { lifetimeActions.values().forEach(action -> { - final Period triggerPeriod = action.getTrigger().getTimePeriod(); - final LifetimeActionTriggerType triggerType = action.getTrigger().getTriggerType(); + final Period triggerPeriod = action.trigger().timePeriod(); + final LifetimeActionTriggerType triggerType = action.trigger().triggerType(); triggerType.validate(latestKeyVersionExpiry, expiryTime, triggerPeriod); - Assert.isTrue(action.getActionType() != LifetimeActionType.NOTIFY + Assert.isTrue(action.actionType() != LifetimeActionType.NOTIFY || triggerType == LifetimeActionTriggerType.TIME_BEFORE_EXPIRY, "Notify actions cannot be used with time after creation trigger."); }); diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/impl/KeyVaultKeyEntity.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/impl/KeyVaultKeyEntity.java index fdd9c3db..b9fbce56 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/impl/KeyVaultKeyEntity.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/impl/KeyVaultKeyEntity.java @@ -7,6 +7,7 @@ import com.github.nagyesta.lowkeyvault.service.key.ReadOnlyKeyVaultKeyEntity; import com.github.nagyesta.lowkeyvault.service.key.id.VersionedKeyEntityId; import com.github.nagyesta.lowkeyvault.service.vault.VaultFake; +import lombok.Getter; import lombok.NonNull; import org.slf4j.Logger; import org.springframework.util.Assert; @@ -17,7 +18,6 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.Callable; -import java.util.stream.Collectors; /** * Common Key entity base class. @@ -25,8 +25,10 @@ * @param The type of the key. * @param The type of the key parameter. */ +@SuppressWarnings("LombokGetterMayBeUsed") public abstract class KeyVaultKeyEntity extends KeyVaultBaseEntity implements ReadOnlyKeyVaultKeyEntity { + @Getter private final T key; private final S keyParam; private final boolean hsm; @@ -46,10 +48,6 @@ protected KeyVaultKeyEntity(@NonNull final VersionedKeyEntityId id, this.operations = Collections.emptyList(); } - public T getKey() { - return key; - } - protected S getKeyParam() { return keyParam; } @@ -69,7 +67,7 @@ public List getOperations() { } public void setOperations(final List operations) { - final List invalid = operations.stream().filter(this.disallowedOperations()::contains).collect(Collectors.toList()); + final List invalid = operations.stream().filter(this.disallowedOperations()::contains).toList(); Assert.isTrue(invalid.isEmpty(), "Operation not allowed for this key type: " + invalid + "."); this.updatedNow(); this.operations = List.copyOf(operations); @@ -102,17 +100,27 @@ protected Callable signCallable( final Signature sign = signatureAlgorithm.getSignatureInstance(); sign.initSign(privateKey); sign.update(signatureAlgorithm.transformDigest(digest)); - return sign.sign(); + final byte[] signature = sign.sign(); + return postProcessGeneratedSignature(signature); }; } protected Callable verifyCallable( - final byte[] digest, final SignatureAlgorithm signatureAlgorithm, final byte[] signature, final PublicKey publicKey) { + final byte[] digest, final SignatureAlgorithm signatureAlgorithm, final byte[] rawSignature, final PublicKey publicKey) { return () -> { final Signature verify = signatureAlgorithm.getSignatureInstance(); verify.initVerify(publicKey); + final byte[] signature = preProcessVerifiableSignature(rawSignature); verify.update(signatureAlgorithm.transformDigest(digest)); return verify.verify(signature); }; } + + protected byte[] postProcessGeneratedSignature(final byte[] signature) throws Exception { + return signature; + } + + protected byte[] preProcessVerifiableSignature(final byte[] rawSignature) throws Exception { + return rawSignature; + } } diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/util/Asn1ConverterUtil.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/util/Asn1ConverterUtil.java new file mode 100644 index 00000000..c3ecc9a4 --- /dev/null +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/key/util/Asn1ConverterUtil.java @@ -0,0 +1,52 @@ +package com.github.nagyesta.lowkeyvault.service.key.util; + +import org.bouncycastle.asn1.ASN1EncodableVector; +import org.bouncycastle.asn1.ASN1Integer; +import org.bouncycastle.asn1.ASN1Sequence; +import org.bouncycastle.asn1.DERSequence; + +import java.io.IOException; +import java.math.BigInteger; + +public final class Asn1ConverterUtil { + + private Asn1ConverterUtil() { + throw new IllegalCallerException("Utility cannot be instantiated."); + } + + public static byte[] convertFromAsn1toRaw(final byte[] signatureAsn1, final int paramLength) { + // Parse ASN.1 encoded signature + final ASN1Sequence sequence = ASN1Sequence.getInstance(signatureAsn1); + final byte[] rBytes = ((ASN1Integer) sequence.getObjectAt(0)).getValue().toByteArray(); + final byte[] sBytes = ((ASN1Integer) sequence.getObjectAt(1)).getValue().toByteArray(); + + // Concatenate the last paramLength bytes of r and s to get the raw RS signature (add 0 bytes if shorter than paramLength) + final byte[] rawRSSignature = new byte[paramLength * 2]; + mergeInto(rBytes, rawRSSignature, 0, paramLength); + mergeInto(sBytes, rawRSSignature, paramLength, paramLength); + + // Now rawRSSignature contains the converted raw RS signature + return rawRSSignature; + } + + public static byte[] convertFromRawToAsn1(final byte[] signatureRaw) throws IOException { + final int byteLength = signatureRaw.length / 2; + final BigInteger r = new BigInteger(1, signatureRaw, 0, byteLength); + final BigInteger s = new BigInteger(1, signatureRaw, byteLength, byteLength); + + final ASN1EncodableVector sigSequence = new ASN1EncodableVector(); + sigSequence.add(new ASN1Integer(r)); + sigSequence.add(new ASN1Integer(s)); + final DERSequence signature = new DERSequence(sigSequence); + + // Output the ASN.1 encoded signature + return signature.getEncoded(); + } + + private static void mergeInto(final byte[] sourceBytes, final byte[] destination, final int offset, final int paramLength) { + final int copyLength = Math.min(paramLength, sourceBytes.length); + final int startIndex = Math.max(0, sourceBytes.length - paramLength); + System.arraycopy(sourceBytes, startIndex, destination, offset + paramLength - copyLength, copyLength); + } + +} diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/vault/impl/VaultServiceImpl.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/vault/impl/VaultServiceImpl.java index 05267ebb..5b5a3199 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/vault/impl/VaultServiceImpl.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/service/vault/impl/VaultServiceImpl.java @@ -13,7 +13,6 @@ import java.util.concurrent.CopyOnWriteArraySet; import java.util.function.Predicate; import java.util.function.Supplier; -import java.util.stream.Collectors; @Slf4j public class VaultServiceImpl implements VaultService { @@ -55,7 +54,7 @@ public VaultFake create(final URI uri, final RecoveryLevel recoveryLevel, final public List list() { return vaultFakes.stream() .filter(VaultFake::isActive) - .collect(Collectors.toUnmodifiableList()); + .toList(); } @Override @@ -63,7 +62,7 @@ public List listDeleted() { purgeExpired(); return vaultFakes.stream() .filter(VaultFake::isDeleted) - .collect(Collectors.toUnmodifiableList()); + .toList(); } @Override diff --git a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/template/backup/VaultImporter.java b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/template/backup/VaultImporter.java index bca6cb41..85d96593 100644 --- a/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/template/backup/VaultImporter.java +++ b/lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/template/backup/VaultImporter.java @@ -6,14 +6,15 @@ import com.github.nagyesta.lowkeyvault.model.management.VaultBackupListModel; import com.github.nagyesta.lowkeyvault.model.management.VaultBackupModel; import com.github.nagyesta.lowkeyvault.model.management.VaultModel; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.Validator; +import lombok.Getter; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.validation.ConstraintViolation; -import javax.validation.Validator; import java.io.File; import java.io.IOException; import java.net.URI; @@ -29,9 +30,13 @@ public class VaultImporter implements InitializingBean { private final BackupTemplateProcessor backupTemplateProcessor; private final ObjectMapper objectMapper; private final Validator validator; + @Getter private final Map vaults; + @Getter private final Map> keys; + @Getter private final Map> secrets; + @Getter private final Map> certificates; @Autowired @@ -63,22 +68,6 @@ public boolean importFileExists() { return vaultImporterProperties.importFileExists(); } - public Map getVaults() { - return vaults; - } - - public Map> getKeys() { - return keys; - } - - public Map> getSecrets() { - return secrets; - } - - public Map> getCertificates() { - return certificates; - } - @Override public void afterPropertiesSet() { importTemplates(); diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/ResourceUtils.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/ResourceUtils.java index 7c13f7bf..ad5f6db9 100644 --- a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/ResourceUtils.java +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/ResourceUtils.java @@ -28,8 +28,7 @@ public static String loadResourceAsString(final String resource) { public static String loadResourceAsBase64String(final String resource) { final byte[] binaryData = loadResourceAsByteArray(resource); return Optional.ofNullable(binaryData) - .map(Base64::encodeBase64) - .map(base64 -> new String(base64, StandardCharsets.UTF_8)) + .map(binary -> new Base64().encodeAsString(binary)) .orElse(null); } diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/VaultBackupConfiguration.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/VaultBackupConfiguration.java index 5e6024a8..e072d788 100644 --- a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/VaultBackupConfiguration.java +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/VaultBackupConfiguration.java @@ -18,13 +18,13 @@ import com.github.nagyesta.lowkeyvault.template.backup.TimeHelperSource; import com.github.nagyesta.lowkeyvault.template.backup.VaultImporter; import com.github.nagyesta.lowkeyvault.template.backup.VaultImporterProperties; +import jakarta.validation.Validator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Profile; -import javax.validation.Validator; import java.io.File; import java.util.Objects; diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/VaultBackupManagementControllerIntegrationTest.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/VaultBackupManagementControllerIntegrationTest.java index b89e8f93..a668f12f 100644 --- a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/VaultBackupManagementControllerIntegrationTest.java +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/VaultBackupManagementControllerIntegrationTest.java @@ -169,7 +169,7 @@ void testExportShouldExportVaultContentWhenCalled() { final CertificateKeyModel keyProperties = certificate.getPolicy().getKeyProperties(); Assertions.assertEquals(EXPECTED_SUBJECT, x509Properties.getSubject()); Assertions.assertEquals(CertContentType.PKCS12.getMimeType(), secretProperties.getContentType()); - Assertions.assertIterableEquals(Set.of(EXPECTED_SANS), x509Properties.getSubjectAlternativeNames().getDnsNames()); + Assertions.assertIterableEquals(Set.of(EXPECTED_SANS), x509Properties.getSubjectAlternativeNames().dnsNames()); Assertions.assertEquals(EXPECTED_KEY_SIZE, keyProperties.getKeySize()); Assertions.assertEquals(KeyType.RSA, keyProperties.getKeyType()); } diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/common/ControllerRequestMappingTest.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/common/ControllerRequestMappingTest.java new file mode 100644 index 00000000..b2f4baf6 --- /dev/null +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/common/ControllerRequestMappingTest.java @@ -0,0 +1,165 @@ +package com.github.nagyesta.lowkeyvault.controller.common; + +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; +import org.springframework.core.type.filter.AnnotationTypeFilter; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.support.StandardServletEnvironment; + +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +@Slf4j +class ControllerRequestMappingTest { + + @Test + void testControllerEndpointShouldHaveBothMissingAndPresentTrailingSlashWhenAnnotatedWithGetMapping() { + //given + final Map, Map>> results = new HashMap<>(); + + //when + streamAllControllerClasses() + .map(Class::getDeclaredMethods) + .flatMap(Arrays::stream) + .filter(method -> method.isAnnotationPresent(GetMapping.class)) + .forEach(method -> { + final String[] pathMappings = method.getDeclaredAnnotation(GetMapping.class).value(); + results.computeIfAbsent(method.getDeclaringClass(), k -> new HashMap<>()).put(method, Arrays.asList(pathMappings)); + }); + + //then + assertEveryMappingHasBothVersions(results); + } + + @Test + void testControllerEndpointShouldHaveBothMissingAndPresentTrailingSlashWhenAnnotatedWithPostMapping() { + //given + final Map, Map>> results = new HashMap<>(); + + //when + streamAllControllerClasses() + .map(Class::getDeclaredMethods) + .flatMap(Arrays::stream) + .filter(method -> method.isAnnotationPresent(PostMapping.class)) + .forEach(method -> { + final String[] pathMappings = method.getDeclaredAnnotation(PostMapping.class).value(); + results.computeIfAbsent(method.getDeclaringClass(), k -> new HashMap<>()).put(method, Arrays.asList(pathMappings)); + }); + + //then + assertEveryMappingHasBothVersions(results); + } + + @Test + void testControllerEndpointShouldHaveBothMissingAndPresentTrailingSlashWhenAnnotatedWithPutMapping() { + //given + final Map, Map>> results = new HashMap<>(); + + //when + streamAllControllerClasses() + .map(Class::getDeclaredMethods) + .flatMap(Arrays::stream) + .filter(method -> method.isAnnotationPresent(PutMapping.class)) + .forEach(method -> { + final String[] pathMappings = method.getDeclaredAnnotation(PutMapping.class).value(); + results.computeIfAbsent(method.getDeclaringClass(), k -> new HashMap<>()).put(method, Arrays.asList(pathMappings)); + }); + + //then + assertEveryMappingHasBothVersions(results); + } + + @Test + void testControllerEndpointShouldHaveBothMissingAndPresentTrailingSlashWhenAnnotatedWithPatchMapping() { + //given + final Map, Map>> results = new HashMap<>(); + + //when + streamAllControllerClasses() + .map(Class::getDeclaredMethods) + .flatMap(Arrays::stream) + .filter(method -> method.isAnnotationPresent(PatchMapping.class)) + .forEach(method -> { + final String[] pathMappings = method.getDeclaredAnnotation(PatchMapping.class).value(); + results.computeIfAbsent(method.getDeclaringClass(), k -> new HashMap<>()).put(method, Arrays.asList(pathMappings)); + }); + + //then + assertEveryMappingHasBothVersions(results); + } + + @Test + void testControllerEndpointShouldHaveBothMissingAndPresentTrailingSlashWhenAnnotatedWithDeleteMapping() { + //given + final Map, Map>> results = new HashMap<>(); + + //when + streamAllControllerClasses() + .map(Class::getDeclaredMethods) + .flatMap(Arrays::stream) + .filter(method -> method.isAnnotationPresent(DeleteMapping.class)) + .forEach(method -> { + final String[] pathMappings = method.getDeclaredAnnotation(DeleteMapping.class).value(); + results.computeIfAbsent(method.getDeclaringClass(), k -> new HashMap<>()).put(method, Arrays.asList(pathMappings)); + }); + + //then + assertEveryMappingHasBothVersions(results); + } + + @Test + void testControllerEndpointShouldHaveBothMissingAndPresentTrailingSlashWhenAnnotatedWithRequestMapping() { + //given + final Map, Map>> results = new HashMap<>(); + + //when + streamAllControllerClasses() + .map(Class::getDeclaredMethods) + .flatMap(Arrays::stream) + .filter(method -> method.isAnnotationPresent(RequestMapping.class)) + .forEach(method -> { + final String[] pathMappings = method.getDeclaredAnnotation(RequestMapping.class).value(); + results.computeIfAbsent(method.getDeclaringClass(), k -> new HashMap<>()).put(method, Arrays.asList(pathMappings)); + }); + + //then + assertEveryMappingHasBothVersions(results); + } + + private static void assertEveryMappingHasBothVersions(final Map, Map>> results) { + results.forEach((clazz, methodMap) -> { + methodMap.forEach((method, pathMappings) -> { + final String className = clazz.getName(); + final String methodName = method.getName(); + Assertions.assertFalse(pathMappings.isEmpty(), + "Method " + methodName + " should have the default path mappings in " + className + ".\n" + + "expected to have both: {\"\", \"/\"}"); + pathMappings.stream() + .filter(path -> !path.endsWith("/")) + .forEach(path -> { + Assertions.assertTrue(pathMappings.contains(path + "/"), + "Method " + methodName + " should have a pair with trailing slash in " + className + ".\n" + + "expected to have both: {\"" + path + "\", \"" + path + "/\"}\n" + + "in: " + pathMappings + "\n"); + }); + }); + }); + } + + private Stream> streamAllControllerClasses() { + final String packageName = "com.github.nagyesta.lowkeyvault.controller"; + final ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider( + true, new StandardServletEnvironment()); + provider.addIncludeFilter(new AnnotationTypeFilter(RestController.class)); + return provider.findCandidateComponents(packageName).stream() + .map(BeanDefinition::getBeanClassName) + .map(className -> Assertions.assertDoesNotThrow(() -> Class.forName(className))); + } +} diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/v7_2/KeyControllerTest.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/v7_2/KeyControllerTest.java index cf8abd27..1ff7f0ca 100644 --- a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/v7_2/KeyControllerTest.java +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/v7_2/KeyControllerTest.java @@ -195,10 +195,10 @@ void testErrorHandlerConvertsExceptionWhenCaught(final Exception exception, fina Assertions.assertEquals(status, actual.getStatusCode()); final ErrorModel actualBody = actual.getBody(); Assertions.assertNotNull(actualBody); - Assertions.assertNotNull(actualBody.getError()); - Assertions.assertEquals(message, actualBody.getError().getMessage()); - Assertions.assertEquals(exception.getClass().getName(), actualBody.getError().getCode()); - final ErrorMessage actualInnerError = actualBody.getError().getInnerError(); + Assertions.assertNotNull(actualBody.error()); + Assertions.assertEquals(message, actualBody.error().getMessage()); + Assertions.assertEquals(exception.getClass().getName(), actualBody.error().getCode()); + final ErrorMessage actualInnerError = actualBody.error().getInnerError(); if (innerMessage != null) { Assertions.assertNotNull(actualInnerError); Assertions.assertEquals(exception.getCause().getClass().getName(), actualInnerError.getCode()); @@ -222,10 +222,10 @@ void testErrorHandlerConvertsIllegalArgumentExceptionWhenCaught() { Assertions.assertEquals(status, actual.getStatusCode()); final ErrorModel actualBody = actual.getBody(); Assertions.assertNotNull(actualBody); - Assertions.assertNotNull(actualBody.getError()); - Assertions.assertEquals(message, actualBody.getError().getMessage()); - Assertions.assertEquals(exception.getClass().getName(), actualBody.getError().getCode()); - final ErrorMessage actualInnerError = actualBody.getError().getInnerError(); + Assertions.assertNotNull(actualBody.error()); + Assertions.assertEquals(message, actualBody.error().getMessage()); + Assertions.assertEquals(exception.getClass().getName(), actualBody.error().getCode()); + final ErrorMessage actualInnerError = actualBody.error().getInnerError(); Assertions.assertNull(actualInnerError); } diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/v7_3/CertificateControllerIntegrationTest.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/v7_3/CertificateControllerIntegrationTest.java index 695ce082..9ab5fa23 100644 --- a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/v7_3/CertificateControllerIntegrationTest.java +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/v7_3/CertificateControllerIntegrationTest.java @@ -11,6 +11,7 @@ import com.github.nagyesta.lowkeyvault.service.certificate.id.CertificateEntityId; import com.github.nagyesta.lowkeyvault.service.certificate.id.VersionedCertificateEntityId; import com.github.nagyesta.lowkeyvault.service.certificate.impl.CertContentType; +import jakarta.validation.ConstraintViolationException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -22,7 +23,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.ResponseEntity; -import javax.validation.ConstraintViolationException; import java.net.URI; import java.util.*; import java.util.function.Function; diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyBackupRestoreControllerIntegrationTest.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyBackupRestoreControllerIntegrationTest.java index 2d7be1c8..45e76cad 100644 --- a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyBackupRestoreControllerIntegrationTest.java +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyBackupRestoreControllerIntegrationTest.java @@ -159,9 +159,9 @@ void testRestoreEntityShouldRestoreRotationPolicyWhenCalledWithValidInput() { Assertions.assertEquals(EXPIRY_TIME, rotationPolicy.getExpiryTime()); Assertions.assertIterableEquals(Collections.singleton(ROTATE), rotationPolicy.getLifetimeActions().keySet()); final LifetimeAction lifetimeAction = rotationPolicy.getLifetimeActions().get(ROTATE); - Assertions.assertEquals(ROTATE, lifetimeAction.getActionType()); - Assertions.assertEquals(LifetimeActionTriggerType.TIME_AFTER_CREATE, lifetimeAction.getTrigger().getTriggerType()); - Assertions.assertEquals(TRIGGER_TIME, lifetimeAction.getTrigger().getTimePeriod()); + Assertions.assertEquals(ROTATE, lifetimeAction.actionType()); + Assertions.assertEquals(LifetimeActionTriggerType.TIME_AFTER_CREATE, lifetimeAction.trigger().triggerType()); + Assertions.assertEquals(TRIGGER_TIME, lifetimeAction.trigger().timePeriod()); } @Test diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyControllerTest.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyControllerTest.java index 922b8f4a..5e9c2e6b 100644 --- a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyControllerTest.java +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/v7_3/KeyControllerTest.java @@ -197,10 +197,10 @@ void testErrorHandlerConvertsExceptionWhenCaught(final Exception exception, fina Assertions.assertEquals(status, actual.getStatusCode()); final ErrorModel actualBody = actual.getBody(); Assertions.assertNotNull(actualBody); - Assertions.assertNotNull(actualBody.getError()); - Assertions.assertEquals(message, actualBody.getError().getMessage()); - Assertions.assertEquals(exception.getClass().getName(), actualBody.getError().getCode()); - final ErrorMessage actualInnerError = actualBody.getError().getInnerError(); + Assertions.assertNotNull(actualBody.error()); + Assertions.assertEquals(message, actualBody.error().getMessage()); + Assertions.assertEquals(exception.getClass().getName(), actualBody.error().getCode()); + final ErrorMessage actualInnerError = actualBody.error().getInnerError(); if (innerMessage != null) { Assertions.assertNotNull(actualInnerError); Assertions.assertEquals(exception.getCause().getClass().getName(), actualInnerError.getCode()); @@ -224,10 +224,10 @@ void testErrorHandlerConvertsIllegalArgumentExceptionWhenCaught() { Assertions.assertEquals(status, actual.getStatusCode()); final ErrorModel actualBody = actual.getBody(); Assertions.assertNotNull(actualBody); - Assertions.assertNotNull(actualBody.getError()); - Assertions.assertEquals(message, actualBody.getError().getMessage()); - Assertions.assertEquals(exception.getClass().getName(), actualBody.getError().getCode()); - final ErrorMessage actualInnerError = actualBody.getError().getInnerError(); + Assertions.assertNotNull(actualBody.error()); + Assertions.assertEquals(message, actualBody.error().getMessage()); + Assertions.assertEquals(exception.getClass().getName(), actualBody.error().getCode()); + final ErrorMessage actualInnerError = actualBody.error().getInnerError(); Assertions.assertNull(actualInnerError); } diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/filter/CommonAuthHeaderFilterTest.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/filter/CommonAuthHeaderFilterTest.java index 60642046..3b791477 100644 --- a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/filter/CommonAuthHeaderFilterTest.java +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/filter/CommonAuthHeaderFilterTest.java @@ -1,6 +1,10 @@ package com.github.nagyesta.lowkeyvault.filter; import com.github.nagyesta.lowkeyvault.model.common.ApiConstants; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; @@ -15,10 +19,6 @@ import org.springframework.http.HttpHeaders; import org.springframework.util.StringUtils; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.net.URI; import java.util.stream.Stream; diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/mapper/v7_3/key/KeyRotationPolicyV73ModelToEntityConverterTest.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/mapper/v7_3/key/KeyRotationPolicyV73ModelToEntityConverterTest.java index 6d9a7846..3520c147 100644 --- a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/mapper/v7_3/key/KeyRotationPolicyV73ModelToEntityConverterTest.java +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/mapper/v7_3/key/KeyRotationPolicyV73ModelToEntityConverterTest.java @@ -57,9 +57,9 @@ void testConvertShouldConvertValuableFieldsWhenCalledWithValidData() { Assertions.assertEquals(NOW, actual.getUpdatedOn()); Assertions.assertEquals(expiryTime, actual.getExpiryTime()); final LifetimeAction actualNotify = actual.getLifetimeActions().get(LifetimeActionType.NOTIFY); - Assertions.assertEquals(timeBeforeExpiry, actualNotify.getTrigger().getTimePeriod()); - Assertions.assertEquals(LifetimeActionTriggerType.TIME_BEFORE_EXPIRY, actualNotify.getTrigger().getTriggerType()); - Assertions.assertEquals(LifetimeActionType.NOTIFY, actualNotify.getActionType()); + Assertions.assertEquals(timeBeforeExpiry, actualNotify.trigger().timePeriod()); + Assertions.assertEquals(LifetimeActionTriggerType.TIME_BEFORE_EXPIRY, actualNotify.trigger().triggerType()); + Assertions.assertEquals(LifetimeActionType.NOTIFY, actualNotify.actionType()); } @Test @@ -90,9 +90,9 @@ void testConvertShouldUseDefaultsWhenCalledWithMinimalAttributes() { Assertions.assertTrue(actual.getUpdatedOn().isAfter(NOW)); Assertions.assertEquals(expiryTime, actual.getExpiryTime()); final LifetimeAction actualNotify = actual.getLifetimeActions().get(LifetimeActionType.NOTIFY); - Assertions.assertEquals(timeBeforeExpiry, actualNotify.getTrigger().getTimePeriod()); - Assertions.assertEquals(LifetimeActionTriggerType.TIME_BEFORE_EXPIRY, actualNotify.getTrigger().getTriggerType()); - Assertions.assertEquals(LifetimeActionType.NOTIFY, actualNotify.getActionType()); + Assertions.assertEquals(timeBeforeExpiry, actualNotify.trigger().timePeriod()); + Assertions.assertEquals(LifetimeActionTriggerType.TIME_BEFORE_EXPIRY, actualNotify.trigger().triggerType()); + Assertions.assertEquals(LifetimeActionType.NOTIFY, actualNotify.actionType()); } @Test diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/validator/ImportKeyValidatorIntegrationTest.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/validator/ImportKeyValidatorIntegrationTest.java index 9e258764..4359b158 100644 --- a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/validator/ImportKeyValidatorIntegrationTest.java +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/model/v7_2/key/validator/ImportKeyValidatorIntegrationTest.java @@ -4,6 +4,9 @@ import com.github.nagyesta.abortmission.booster.jupiter.annotation.LaunchAbortArmed; import com.github.nagyesta.lowkeyvault.ResourceUtils; import com.github.nagyesta.lowkeyvault.model.v7_2.key.request.ImportKeyRequest; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.Path; +import jakarta.validation.Validator; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -13,9 +16,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; -import javax.validation.ConstraintViolation; -import javax.validation.Path; -import javax.validation.Validator; import java.io.IOException; import java.util.Collections; import java.util.Set; diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateLifetimeActionTriggerModelTest.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateLifetimeActionTriggerModelTest.java index db54f32f..bb0517cd 100644 --- a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateLifetimeActionTriggerModelTest.java +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/model/v7_3/certificate/CertificateLifetimeActionTriggerModelTest.java @@ -94,8 +94,8 @@ void testAsTriggerEntityShouldIdentifyTriggerTypeWhenDaysBeforeExpiryIsSet() { final CertificateLifetimeActionTrigger actual = underTest.asTriggerEntity(); //then - Assertions.assertEquals(DAYS_BEFORE_EXPIRY, actual.getTriggerType()); - Assertions.assertEquals(expectedDays, actual.getValue()); + Assertions.assertEquals(DAYS_BEFORE_EXPIRY, actual.triggerType()); + Assertions.assertEquals(expectedDays, actual.value()); } @Test @@ -109,7 +109,7 @@ void testAsTriggerEntityShouldIdentifyTriggerTypeWhenLifetimePercentageIsSet() { final CertificateLifetimeActionTrigger actual = underTest.asTriggerEntity(); //then - Assertions.assertEquals(LIFETIME_PERCENTAGE, actual.getTriggerType()); - Assertions.assertEquals(expectedDays, actual.getValue()); + Assertions.assertEquals(LIFETIME_PERCENTAGE, actual.triggerType()); + Assertions.assertEquals(expectedDays, actual.value()); } } diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyRotationPolicyModelIntegrationTest.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyRotationPolicyModelIntegrationTest.java index 1bd07345..5a7de3ad 100644 --- a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyRotationPolicyModelIntegrationTest.java +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/KeyRotationPolicyModelIntegrationTest.java @@ -8,6 +8,8 @@ import com.github.nagyesta.lowkeyvault.model.v7_3.key.validator.Restore; import com.github.nagyesta.lowkeyvault.service.key.constants.LifetimeActionTriggerType; import com.github.nagyesta.lowkeyvault.service.key.impl.KeyLifetimeActionTrigger; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.Validator; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -17,8 +19,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; -import javax.validation.ConstraintViolation; -import javax.validation.Validator; import java.io.IOException; import java.net.URI; import java.time.Instant; diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/validator/ExpiryPeriodValidatorTest.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/validator/ExpiryPeriodValidatorTest.java index a66b5bc0..a243d26b 100644 --- a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/validator/ExpiryPeriodValidatorTest.java +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/model/v7_3/key/validator/ExpiryPeriodValidatorTest.java @@ -1,11 +1,11 @@ package com.github.nagyesta.lowkeyvault.model.v7_3.key.validator; +import jakarta.validation.ConstraintValidatorContext; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import javax.validation.ConstraintValidatorContext; import java.time.Period; import java.util.stream.Stream; diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/service/key/KeyLifetimeActionTest.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/service/key/KeyLifetimeActionTest.java index 6f6d1e0a..943b17d7 100644 --- a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/service/key/KeyLifetimeActionTest.java +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/service/key/KeyLifetimeActionTest.java @@ -43,7 +43,7 @@ void testConstructorShouldSetValuesWhenCalledWithValidInput() { final KeyLifetimeAction actual = new KeyLifetimeAction(type, trigger); //then - Assertions.assertEquals(trigger, actual.getTrigger()); - Assertions.assertEquals(type, actual.getActionType()); + Assertions.assertEquals(trigger, actual.trigger()); + Assertions.assertEquals(type, actual.actionType()); } } diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/service/key/impl/KeyRotationPolicyTest.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/service/key/impl/KeyRotationPolicyTest.java index 52a94a2a..31851df0 100644 --- a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/service/key/impl/KeyRotationPolicyTest.java +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/service/key/impl/KeyRotationPolicyTest.java @@ -348,7 +348,7 @@ void testValidateShouldThrowExceptionWhenDataIsInvalid( final KeyLifetimeActionTrigger rotateTrigger = new KeyLifetimeActionTrigger(rotatePeriod, rotateTriggerType); final KeyLifetimeAction rotate = new KeyLifetimeAction(LifetimeActionType.ROTATE, rotateTrigger); final KeyRotationPolicy underTest = new KeyRotationPolicy(UNVERSIONED_KEY_ENTITY_ID_1, expiryPeriod, - Map.of(notify.getActionType(), notify, rotate.getActionType(), rotate)); + Map.of(notify.actionType(), notify, rotate.actionType(), rotate)); //when if (valid) { diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/service/key/util/Asn1ConverterUtilTest.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/service/key/util/Asn1ConverterUtilTest.java new file mode 100644 index 00000000..e3f4f4ed --- /dev/null +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/service/key/util/Asn1ConverterUtilTest.java @@ -0,0 +1,48 @@ +package com.github.nagyesta.lowkeyvault.service.key.util; + +import org.apache.commons.lang3.RandomUtils; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.stream.Stream; + +class Asn1ConverterUtilTest { + + @SuppressWarnings("checkstyle:MagicNumber") + public static Stream validValueProvider() { + return Stream.of(32 * 2, 48 * 2, 66 * 2) + .map(RandomUtils::nextBytes) + .map(Arguments::of); + } + + @Test + void testConstructorShouldThrowExceptionWhenCalled() throws NoSuchMethodException { + //given + final Constructor constructor = Asn1ConverterUtil.class.getDeclaredConstructor(); + constructor.setAccessible(true); + + //when + Assertions.assertThrows(InvocationTargetException.class, constructor::newInstance); + + //then + exception + } + + @ParameterizedTest + @MethodSource("validValueProvider") + void testConvertAsn1toRawShouldReturnOriginalValuesWhenCalledAfterConvertFromRawToAsn1(final byte[] signatureRaw) throws IOException { + //given + final byte[] asn1 = Asn1ConverterUtil.convertFromRawToAsn1(signatureRaw); + + //when + final byte[] raw = Asn1ConverterUtil.convertFromAsn1toRaw(asn1, signatureRaw.length / 2); + + //then + Assertions.assertArrayEquals(signatureRaw, raw); + } +} diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/template/backup/VaultImporterTest.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/template/backup/VaultImporterTest.java index a0686f81..4f02d6d0 100644 --- a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/template/backup/VaultImporterTest.java +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/template/backup/VaultImporterTest.java @@ -2,15 +2,15 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.github.nagyesta.lowkeyvault.model.management.VaultBackupListModel; +import jakarta.validation.Validation; +import jakarta.validation.Validator; +import jakarta.validation.ValidatorFactory; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; import java.io.File; import java.util.stream.Stream; diff --git a/lowkey-vault-client/build.gradle b/lowkey-vault-client/build.gradle index 2f0582a7..12e77a79 100644 --- a/lowkey-vault-client/build.gradle +++ b/lowkey-vault-client/build.gradle @@ -32,9 +32,19 @@ dependencies { testImplementation libs.logback.classic } +java { + sourceCompatibility = JavaVersion.VERSION_11 + toolchain { + languageVersion = JavaLanguageVersion.of(11) + } + withJavadocJar() + withSourcesJar() +} + test { useJUnitPlatform() } + publishing { publications { mavenJava(MavenPublication) { diff --git a/lowkey-vault-client/src/test/java/com/github/nagyesta/lowkeyvault/http/management/impl/LowkeyVaultManagementClientImplTest.java b/lowkey-vault-client/src/test/java/com/github/nagyesta/lowkeyvault/http/management/impl/LowkeyVaultManagementClientImplTest.java index 0c4a2fe4..9b521822 100644 --- a/lowkey-vault-client/src/test/java/com/github/nagyesta/lowkeyvault/http/management/impl/LowkeyVaultManagementClientImplTest.java +++ b/lowkey-vault-client/src/test/java/com/github/nagyesta/lowkeyvault/http/management/impl/LowkeyVaultManagementClientImplTest.java @@ -1,9 +1,6 @@ package com.github.nagyesta.lowkeyvault.http.management.impl; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpMethod; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; +import com.azure.core.http.*; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -13,7 +10,6 @@ import com.github.nagyesta.lowkeyvault.http.management.RecoveryLevel; import com.github.nagyesta.lowkeyvault.http.management.TimeShiftContext; import com.github.nagyesta.lowkeyvault.http.management.VaultModel; -import org.apache.http.HttpHeaders; import org.apache.http.HttpStatus; import org.junit.jupiter.api.*; import org.junit.jupiter.params.ParameterizedTest; @@ -197,7 +193,7 @@ void testCreateVaultShouldTransformInputToModelWhenCalledWithValidInput() throws final HttpRequest request = httpRequestArgumentCaptor.getValue(); Assertions.assertEquals("/management/vault", request.getUrl().getPath()); Assertions.assertEquals(HttpMethod.POST, request.getHttpMethod()); - Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaders.CONTENT_TYPE)); + Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaderName.CONTENT_TYPE)); final String actualBody = new String(Objects.requireNonNull(request.getBody().single().block()).array()); Assertions.assertEquals(JSON, actualBody); verify(response).getStatusCode(); @@ -227,7 +223,7 @@ void testListVaultsShouldReturnVaultsWhenCalled() throws JsonProcessingException final HttpRequest request = httpRequestArgumentCaptor.getValue(); Assertions.assertEquals("/management/vault", request.getUrl().getPath()); Assertions.assertEquals(HttpMethod.GET, request.getHttpMethod()); - Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaders.CONTENT_TYPE)); + Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaderName.CONTENT_TYPE)); verify(response).getStatusCode(); verify(response).getBodyAsString(eq(StandardCharsets.UTF_8)); verify(objectReader).forType(eq(VAULT_MODEL_LIST_TYPE_REF)); @@ -254,7 +250,7 @@ void testListDeletedVaultsShouldReturnVaultsWhenCalled() throws JsonProcessingEx final HttpRequest request = httpRequestArgumentCaptor.getValue(); Assertions.assertEquals("/management/vault/deleted", request.getUrl().getPath()); Assertions.assertEquals(HttpMethod.GET, request.getHttpMethod()); - Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaders.CONTENT_TYPE)); + Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaderName.CONTENT_TYPE)); verify(response).getStatusCode(); verify(response).getBodyAsString(eq(StandardCharsets.UTF_8)); verify(objectReader).forType(eq(VAULT_MODEL_LIST_TYPE_REF)); @@ -280,7 +276,7 @@ void testDeleteShouldReturnBooleanStatusWhenCalled() throws JsonProcessingExcept final HttpRequest request = httpRequestArgumentCaptor.getValue(); Assertions.assertEquals("/management/vault", request.getUrl().getPath()); Assertions.assertEquals(HttpMethod.DELETE, request.getHttpMethod()); - Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaders.CONTENT_TYPE)); + Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaderName.CONTENT_TYPE)); verify(response).getStatusCode(); verify(response).getBodyAsString(eq(StandardCharsets.UTF_8)); verify(objectReader).forType(eq(Boolean.class)); @@ -320,7 +316,7 @@ void testRecoverShouldReturnVaultModelStatusWhenCalled() throws JsonProcessingEx final HttpRequest request = httpRequestArgumentCaptor.getValue(); Assertions.assertEquals("/management/vault/recover", request.getUrl().getPath()); Assertions.assertEquals(HttpMethod.PUT, request.getHttpMethod()); - Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaders.CONTENT_TYPE)); + Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaderName.CONTENT_TYPE)); verify(response).getStatusCode(); verify(response).getBodyAsString(eq(StandardCharsets.UTF_8)); verify(objectReader).forType(eq(VaultModel.class)); @@ -363,7 +359,7 @@ void testAddAliasShouldReturnVaultModelStatusWhenCalled() throws JsonProcessingE + "&baseUri=" + URLEncoder.encode(HTTPS_LOCALHOST, StandardCharsets.UTF_8); Assertions.assertEquals(queryString, request.getUrl().getQuery()); Assertions.assertEquals(HttpMethod.PATCH, request.getHttpMethod()); - Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaders.CONTENT_TYPE)); + Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaderName.CONTENT_TYPE)); verify(response).getStatusCode(); verify(response).getBodyAsString(eq(StandardCharsets.UTF_8)); verify(objectReader).forType(eq(VaultModel.class)); @@ -421,7 +417,7 @@ void testRemoveAliasShouldReturnVaultModelStatusWhenCalled() throws JsonProcessi + "&remove=" + URLEncoder.encode(HTTPS_ALIAS_LOCALHOST, StandardCharsets.UTF_8); Assertions.assertEquals(queryString, request.getUrl().getQuery()); Assertions.assertEquals(HttpMethod.PATCH, request.getHttpMethod()); - Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaders.CONTENT_TYPE)); + Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaderName.CONTENT_TYPE)); verify(response).getStatusCode(); verify(response).getBodyAsString(eq(StandardCharsets.UTF_8)); verify(objectReader).forType(eq(VaultModel.class)); @@ -475,7 +471,7 @@ void testPurgeShouldReturnPurgeStatusWhenCalled() throws JsonProcessingException final HttpRequest request = httpRequestArgumentCaptor.getValue(); Assertions.assertEquals("/management/vault/purge", request.getUrl().getPath()); Assertions.assertEquals(HttpMethod.DELETE, request.getHttpMethod()); - Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaders.CONTENT_TYPE)); + Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaderName.CONTENT_TYPE)); verify(response).getStatusCode(); verify(response).getBodyAsString(eq(StandardCharsets.UTF_8)); verify(objectReader).forType(eq(Boolean.class)); @@ -538,7 +534,7 @@ void testTimeShiftShouldSucceedWhenCalledWithOnlyTime() { Assertions.assertEquals("/management/vault/time/all", request.getUrl().getPath()); Assertions.assertEquals("seconds=86400", request.getUrl().getQuery()); Assertions.assertEquals(HttpMethod.PUT, request.getHttpMethod()); - Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaders.CONTENT_TYPE)); + Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaderName.CONTENT_TYPE)); verify(response).getStatusCode(); verify(response).getBodyAsString(eq(StandardCharsets.UTF_8)); } @@ -564,7 +560,7 @@ void testTimeShiftShouldSucceedWhenCalledWithUriAndTime() { Assertions.assertEquals("/management/vault/time", request.getUrl().getPath()); Assertions.assertEquals("baseUri=http%3A%2F%2Flocalhost&seconds=1", request.getUrl().getQuery()); Assertions.assertEquals(HttpMethod.PUT, request.getHttpMethod()); - Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaders.CONTENT_TYPE)); + Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaderName.CONTENT_TYPE)); verify(response).getStatusCode(); verify(response).getBodyAsString(eq(StandardCharsets.UTF_8)); } @@ -590,7 +586,7 @@ void testTimeShiftShouldSucceedWhenCalledWithTimeAndRegenerateFlag() { Assertions.assertEquals("/management/vault/time/all", request.getUrl().getPath()); Assertions.assertEquals("regenerateCertificates=true&seconds=1", request.getUrl().getQuery()); Assertions.assertEquals(HttpMethod.PUT, request.getHttpMethod()); - Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaders.CONTENT_TYPE)); + Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaderName.CONTENT_TYPE)); verify(response).getStatusCode(); verify(response).getBodyAsString(eq(StandardCharsets.UTF_8)); } @@ -613,7 +609,7 @@ void testExportActiveShouldReturnFullResponseWhenCalledOnRunningServer() { final HttpRequest request = httpRequestArgumentCaptor.getValue(); Assertions.assertEquals("/management/vault/export", request.getUrl().getPath()); Assertions.assertEquals(HttpMethod.GET, request.getHttpMethod()); - Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaders.CONTENT_TYPE)); + Assertions.assertEquals(APPLICATION_JSON, request.getHeaders().getValue(HttpHeaderName.CONTENT_TYPE)); verify(response).getStatusCode(); verify(response).getBodyAsString(eq(StandardCharsets.UTF_8)); } diff --git a/lowkey-vault-docker/README.md b/lowkey-vault-docker/README.md index f5081180..86a6da9a 100644 --- a/lowkey-vault-docker/README.md +++ b/lowkey-vault-docker/README.md @@ -1,7 +1,7 @@ ![LowkeyVault](../.github/assets/LowkeyVault-logo-full.png) [![GitHub license](https://img.shields.io/github/license/nagyesta/lowkey-vault?color=informational)](https://raw.githubusercontent.com/nagyesta/lowkey-vault/main/LICENSE) -[![Java version](https://img.shields.io/badge/Java%20version-11-yellow?logo=java)](https://img.shields.io/badge/Java%20version-11-yellow?logo=java) +[![Java version](https://img.shields.io/badge/Java%20version-17-yellow?logo=java)](https://img.shields.io/badge/Java%20version-17-yellow?logo=java) [![latest-release](https://img.shields.io/github/v/tag/nagyesta/lowkey-vault?color=blue&logo=git&label=releases&sort=semver)](https://github.com/nagyesta/lowkey-vault/releases) [![Docker Hub](https://img.shields.io/docker/v/nagyesta/lowkey-vault?label=docker%20hub&logo=docker&sort=semver)](https://hub.docker.com/r/nagyesta/lowkey-vault) [![Docker Pulls](https://img.shields.io/docker/pulls/nagyesta/lowkey-vault?logo=docker)](https://hub.docker.com/r/nagyesta/lowkey-vault) diff --git a/lowkey-vault-docker/build.gradle b/lowkey-vault-docker/build.gradle index 7e44b2c1..1414b073 100644 --- a/lowkey-vault-docker/build.gradle +++ b/lowkey-vault-docker/build.gradle @@ -11,15 +11,6 @@ repositories { mavenCentral() } -java { - sourceCompatibility = JavaVersion.VERSION_11 - toolchain { - languageVersion = JavaLanguageVersion.of(11) - } - withJavadocJar() - withSourcesJar() -} - group = "${rootProject.group}" dependencies { @@ -36,12 +27,20 @@ dependencies { testImplementation(libs.azure.security.keyvault.certificates) { exclude(group: "io.netty") } - testImplementation libs.bundles.spring.test testImplementation libs.bundles.cucumber testImplementation libs.abort.mission.cucumber testImplementation libs.findbugs.jsr305 } +java { + sourceCompatibility = JavaVersion.VERSION_11 + toolchain { + languageVersion = JavaLanguageVersion.of(11) + } + withJavadocJar() + withSourcesJar() +} + tasks.register('copyAppJar', Copy.class) { inputs.file(rootProject.project(":lowkey-vault-app").tasks.named("bootJar").get().outputs.files.singleFile) outputs.file("${buildDir}/app/lowkey-vault.jar") diff --git a/lowkey-vault-docker/src/docker/Dockerfile b/lowkey-vault-docker/src/docker/Dockerfile index bbba6de9..ceb73b98 100644 --- a/lowkey-vault-docker/src/docker/Dockerfile +++ b/lowkey-vault-docker/src/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM eclipse-temurin:11.0.20_8-jre-alpine@sha256:6a7bdc6f82c73a2fa1c95c5fe7465f8dab63a8973d9eb2c9ad6157db75b9c309 +FROM eclipse-temurin:17.0.8_7-jre-alpine@sha256:956b8bccdb62e0681010a4127e8dba8b9d3f3247dd4004e11e4bdcec71bb7cb8 LABEL maintainer="nagyesta@gmail.com" EXPOSE 8443:8443 ADD lowkey-vault.jar /lowkey-vault.jar diff --git a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/KeyGenUtil.java b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/KeyGenUtil.java index d89c5c67..4f353753 100644 --- a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/KeyGenUtil.java +++ b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/KeyGenUtil.java @@ -2,9 +2,9 @@ import com.azure.security.keyvault.keys.models.KeyCurveName; import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.springframework.lang.NonNull; -import org.springframework.lang.Nullable; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; import java.math.BigInteger; @@ -23,18 +23,18 @@ private KeyGenUtil() { throw new IllegalCallerException("Utility cannot be instantiated."); } - @NonNull + @Nonnull public static SecretKey generateAes(@Nullable final Integer keySize) { final int size = Objects.requireNonNullElse(keySize, 256); return keyGenerator("AES", size).generateKey(); } - @NonNull - public static KeyPair generateEc(@NonNull final KeyCurveName keyCurveName) { + @Nonnull + public static KeyPair generateEc(@Nonnull final KeyCurveName keyCurveName) { return keyPairGenerator("EC", getAlgSpec(keyCurveName)).generateKeyPair(); } - @NonNull + @Nonnull public static KeyPair generateRsa(@Nullable final Integer keySize, @Nullable final BigInteger publicExponent) { final int nonNullKeySize = Objects.requireNonNullElse(keySize, 2048); final BigInteger notNullPublicExponent = Objects.requireNonNullElse(publicExponent, BigInteger.valueOf(65537)); diff --git a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/context/TestContextConfig.java b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/context/TestContextConfig.java index 6dc96a68..9ba5d4bc 100644 --- a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/context/TestContextConfig.java +++ b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/context/TestContextConfig.java @@ -1,11 +1,7 @@ package com.github.nagyesta.lowkeyvault.context; import com.github.nagyesta.lowkeyvault.http.ApacheHttpClientProvider; -import io.cucumber.spring.ScenarioScope; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -@Configuration public class TestContextConfig { /** @@ -25,32 +21,32 @@ public class TestContextConfig { */ public static final String DEFAULT_CONTAINER_URL = "https://" + CONTAINER_HOST + ":" + CONTAINER_PORT; - @Bean - public ApacheHttpClientProvider provider() { - return new ApacheHttpClientProvider(DEFAULT_CONTAINER_URL); + private final CertificateTestContext certificateTestContext; + private final SecretTestContext secretTestContext; + private final ManagementTestContext managementTestContext; + private final KeyTestContext keyTestContext; + + public TestContextConfig() { + final ApacheHttpClientProvider provider = new ApacheHttpClientProvider(DEFAULT_CONTAINER_URL); + managementTestContext = new ManagementTestContext(provider); + keyTestContext = new KeyTestContext(provider); + secretTestContext = new SecretTestContext(provider); + certificateTestContext = new CertificateTestContext(provider); } - @Bean - @ScenarioScope public KeyTestContext keyContext() { - return new KeyTestContext(provider()); + return keyTestContext; } - @Bean - @ScenarioScope public CertificateTestContext certificateContext() { - return new CertificateTestContext(provider()); + return certificateTestContext; } - @Bean - @ScenarioScope public SecretTestContext secretContext() { - return new SecretTestContext(provider()); + return secretTestContext; } - @Bean - @ScenarioScope public ManagementTestContext managementContext() { - return new ManagementTestContext(provider()); + return managementTestContext; } } diff --git a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/parallel/RunParallelCucumberTest.java b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/parallel/RunParallelCucumberTest.java index 5bbc9ba5..e870e181 100644 --- a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/parallel/RunParallelCucumberTest.java +++ b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/parallel/RunParallelCucumberTest.java @@ -1,12 +1,10 @@ package com.github.nagyesta.lowkeyvault.parallel; import com.fasterxml.jackson.databind.ObjectMapper; -import com.github.nagyesta.lowkeyvault.context.TestContextConfig; import com.github.nagyesta.lowkeyvault.http.ApacheHttpClientProvider; -import io.cucumber.spring.CucumberContextConfiguration; +import io.cucumber.picocontainer.PicoFactory; import io.cucumber.testng.AbstractTestNGCucumberTests; import io.cucumber.testng.CucumberOptions; -import org.springframework.context.annotation.Import; import org.testng.annotations.BeforeSuite; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -22,9 +20,8 @@ "classpath:/com/github/nagyesta/lowkeyvault/secrets", "classpath:/com/github/nagyesta/lowkeyvault/certificates"}, plugin = {"com.github.nagyesta.abortmission.booster.cucumber.AbortMissionPlugin", - "html:build/reports/cucumber/cucumber-parallel-report.html"}) -@CucumberContextConfiguration -@Import(value = TestContextConfig.class) + "html:build/reports/cucumber/cucumber-parallel-report.html"}, + objectFactory = PicoFactory.class) @Test(groups = "parallel") public class RunParallelCucumberTest extends AbstractTestNGCucumberTests { diff --git a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/sequential/RunSequentialCucumberTest.java b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/sequential/RunSequentialCucumberTest.java index 9b842dbc..83f28bc0 100644 --- a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/sequential/RunSequentialCucumberTest.java +++ b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/sequential/RunSequentialCucumberTest.java @@ -1,10 +1,8 @@ package com.github.nagyesta.lowkeyvault.sequential; -import com.github.nagyesta.lowkeyvault.context.TestContextConfig; -import io.cucumber.spring.CucumberContextConfiguration; +import io.cucumber.picocontainer.PicoFactory; import io.cucumber.testng.AbstractTestNGCucumberTests; import io.cucumber.testng.CucumberOptions; -import org.springframework.context.annotation.Import; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -15,9 +13,8 @@ "com.github.nagyesta.lowkeyvault.context"}, features = {"classpath:/com/github/nagyesta/lowkeyvault/management"}, plugin = {"com.github.nagyesta.abortmission.booster.cucumber.AbortMissionPlugin", - "html:build/reports/cucumber/cucumber-sequential-report.html"}) -@CucumberContextConfiguration -@Import(value = TestContextConfig.class) + "html:build/reports/cucumber/cucumber-sequential-report.html"}, + objectFactory = PicoFactory.class) @Test(dependsOnGroups = "parallel") public class RunSequentialCucumberTest extends AbstractTestNGCucumberTests { diff --git a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/CertificateStepDefAssertion.java b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/CertificateStepDefAssertion.java index 8ae2a2c9..2a9b1ee3 100644 --- a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/CertificateStepDefAssertion.java +++ b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/CertificateStepDefAssertion.java @@ -8,12 +8,11 @@ import com.github.nagyesta.lowkeyvault.context.CertificateTestContext; import com.github.nagyesta.lowkeyvault.context.KeyTestContext; import com.github.nagyesta.lowkeyvault.context.SecretTestContext; +import com.github.nagyesta.lowkeyvault.context.TestContextConfig; import io.cucumber.java.en.And; import io.cucumber.java.en.Then; import org.apache.commons.codec.binary.Base64; import org.bouncycastle.crypto.CryptoException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.Base64Utils; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -32,18 +31,20 @@ import java.util.Map; import java.util.Objects; +import static java.util.Base64.getMimeDecoder; + public class CertificateStepDefAssertion extends CommonAssertions { private static final String DEFAULT_PASSWORD = ""; - @SuppressWarnings("SpringJavaAutowiredMembersInspection") - @Autowired - private CertificateTestContext context; - @SuppressWarnings("SpringJavaAutowiredMembersInspection") - @Autowired - private SecretTestContext secretContext; - @SuppressWarnings("SpringJavaAutowiredMembersInspection") - @Autowired - private KeyTestContext keyContext; + private final CertificateTestContext context; + private final SecretTestContext secretContext; + private final KeyTestContext keyContext; + + public CertificateStepDefAssertion(final TestContextConfig config) { + this.context = config.certificateContext(); + this.secretContext = config.secretContext(); + this.keyContext = config.keyContext(); + } @Then("the certificate is {enabled}") public void theCertificateIsEnabledStatus(final boolean enabled) { @@ -117,7 +118,7 @@ public void theDownloadedTypeCertificateStoreContentMatchesStoreFromFileNameUsin assertEquals(expectedCertificate, certificate); //compare keys final Key expectedKey = expectedKeyStore.getKey(expectedAlias, password.toCharArray()); - final KeyStore actualKeyStore = getKeyStore(Base64Utils.decodeFromString(value), DEFAULT_PASSWORD); + final KeyStore actualKeyStore = getKeyStore(getMimeDecoder().decode(value), DEFAULT_PASSWORD); final String actualAlias = findAlias(actualKeyStore); final Key actualKey = actualKeyStore.getKey(actualAlias, DEFAULT_PASSWORD.toCharArray()); assertKeyEquals(expectedKey, actualKey); @@ -303,7 +304,7 @@ private X509Certificate getX509Certificate(final CertificateContentType contentT final CertificateFactory fact = CertificateFactory.getInstance("X.509"); certificate = (X509Certificate) fact.generateCertificate(new ByteArrayInputStream(encodedCertificate)); } else { - final byte[] bytes = Base64Utils.decodeFromString(value); + final byte[] bytes = getMimeDecoder().decode(value); final KeyStore keyStore = getKeyStore(bytes, DEFAULT_PASSWORD); final String alias = findAlias(keyStore); certificate = (X509Certificate) keyStore.getCertificate(alias); diff --git a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/CertificatesStepDefs.java b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/CertificatesStepDefs.java index b716b046..9afabb09 100644 --- a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/CertificatesStepDefs.java +++ b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/CertificatesStepDefs.java @@ -5,12 +5,12 @@ import com.github.nagyesta.lowkeyvault.context.CertificateTestContext; import com.github.nagyesta.lowkeyvault.context.KeyTestContext; import com.github.nagyesta.lowkeyvault.context.SecretTestContext; +import com.github.nagyesta.lowkeyvault.context.TestContextConfig; import com.github.nagyesta.lowkeyvault.http.ApacheHttpClientProvider; import com.github.nagyesta.lowkeyvault.http.AuthorityOverrideFunction; import io.cucumber.java.en.And; import io.cucumber.java.en.Given; import io.cucumber.java.en.When; -import org.springframework.beans.factory.annotation.Autowired; import java.io.IOException; import java.util.List; @@ -25,15 +25,15 @@ public class CertificatesStepDefs extends CommonAssertions { public static final int DEFAULT_LIFETIME_PERCENTAGE = 80; - @SuppressWarnings("SpringJavaAutowiredMembersInspection") - @Autowired - private CertificateTestContext context; - @SuppressWarnings("SpringJavaAutowiredMembersInspection") - @Autowired - private SecretTestContext secretContext; - @SuppressWarnings("SpringJavaAutowiredMembersInspection") - @Autowired - private KeyTestContext keyContext; + private final CertificateTestContext context; + private final SecretTestContext secretContext; + private final KeyTestContext keyContext; + + public CertificatesStepDefs(final TestContextConfig config) { + this.context = config.certificateContext(); + this.secretContext = config.secretContext(); + this.keyContext = config.keyContext(); + } @Given("certificate API version {api} is used") public void apiVersionApiIsUsed(final String version) { diff --git a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/KeysStepDefs.java b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/KeysStepDefs.java index 74bcd1cf..95906128 100644 --- a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/KeysStepDefs.java +++ b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/KeysStepDefs.java @@ -6,13 +6,13 @@ import com.azure.security.keyvault.keys.models.*; import com.github.nagyesta.lowkeyvault.KeyGenUtil; import com.github.nagyesta.lowkeyvault.context.KeyTestContext; +import com.github.nagyesta.lowkeyvault.context.TestContextConfig; import com.github.nagyesta.lowkeyvault.http.ApacheHttpClientProvider; import com.github.nagyesta.lowkeyvault.http.AuthorityOverrideFunction; import io.cucumber.java.en.And; import io.cucumber.java.en.Given; import io.cucumber.java.en.When; import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.springframework.beans.factory.annotation.Autowired; import javax.crypto.Cipher; import javax.crypto.SecretKey; @@ -37,9 +37,11 @@ public class KeysStepDefs extends CommonAssertions { private static final BouncyCastleProvider BOUNCY_CASTLE_PROVIDER = new BouncyCastleProvider(); - @SuppressWarnings("SpringJavaAutowiredMembersInspection") - @Autowired - private KeyTestContext context; + private final KeyTestContext context; + + public KeysStepDefs(final TestContextConfig config) { + context = config.keyContext(); + } @Given("key API version {api} is used") public void apiVersionApiIsUsed(final String version) { diff --git a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/KeysStepDefsAssertions.java b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/KeysStepDefsAssertions.java index 6859170f..89f57456 100644 --- a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/KeysStepDefsAssertions.java +++ b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/KeysStepDefsAssertions.java @@ -3,9 +3,9 @@ import com.azure.core.exception.ResourceNotFoundException; import com.azure.security.keyvault.keys.models.*; import com.github.nagyesta.lowkeyvault.context.KeyTestContext; +import com.github.nagyesta.lowkeyvault.context.TestContextConfig; import io.cucumber.java.en.And; import io.cucumber.java.en.Then; -import org.springframework.beans.factory.annotation.Autowired; import java.io.IOException; import java.time.temporal.ChronoUnit; @@ -19,9 +19,11 @@ public class KeysStepDefsAssertions extends CommonAssertions { - @SuppressWarnings("SpringJavaAutowiredMembersInspection") - @Autowired - private KeyTestContext context; + private final KeyTestContext context; + + public KeysStepDefsAssertions(final TestContextConfig config) { + this.context = config.keyContext(); + } @Then("the created key is using EC algorithm with {ecCurveName} curve name and {int} bytes length") public void theCreatedKeyIsUsingEcAlgorithmWithNBytesBytesLength(final KeyCurveName curveName, final int nBytes) { diff --git a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/ManagementStepDefs.java b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/ManagementStepDefs.java index 1a81e159..ec3e448a 100644 --- a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/ManagementStepDefs.java +++ b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/ManagementStepDefs.java @@ -1,6 +1,7 @@ package com.github.nagyesta.lowkeyvault.steps; import com.github.nagyesta.lowkeyvault.context.ManagementTestContext; +import com.github.nagyesta.lowkeyvault.context.TestContextConfig; import com.github.nagyesta.lowkeyvault.http.ApacheHttpClientProvider; import com.github.nagyesta.lowkeyvault.http.AuthorityOverrideFunction; import com.github.nagyesta.lowkeyvault.http.management.RecoveryLevel; @@ -10,7 +11,6 @@ import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import org.springframework.beans.factory.annotation.Autowired; import java.net.URI; import java.time.OffsetDateTime; @@ -20,9 +20,11 @@ public class ManagementStepDefs extends CommonAssertions { - @SuppressWarnings("SpringJavaAutowiredMembersInspection") - @Autowired - private ManagementTestContext context; + private final ManagementTestContext context; + + public ManagementStepDefs(final TestContextConfig config) { + this.context = config.managementContext(); + } @Given("a vault is created with name {name}") public void aVaultIsCreatedWithName(final String vaultName) { diff --git a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/SecretsStepDefs.java b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/SecretsStepDefs.java index 42f60cbd..b57557f9 100644 --- a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/SecretsStepDefs.java +++ b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/SecretsStepDefs.java @@ -5,12 +5,12 @@ import com.azure.security.keyvault.secrets.models.KeyVaultSecret; import com.azure.security.keyvault.secrets.models.SecretProperties; import com.github.nagyesta.lowkeyvault.context.SecretTestContext; +import com.github.nagyesta.lowkeyvault.context.TestContextConfig; import com.github.nagyesta.lowkeyvault.http.ApacheHttpClientProvider; import com.github.nagyesta.lowkeyvault.http.AuthorityOverrideFunction; import io.cucumber.java.en.And; import io.cucumber.java.en.Given; import io.cucumber.java.en.When; -import org.springframework.beans.factory.annotation.Autowired; import java.util.List; import java.util.Map; @@ -23,9 +23,11 @@ public class SecretsStepDefs extends CommonAssertions { - @SuppressWarnings("SpringJavaAutowiredMembersInspection") - @Autowired - private SecretTestContext context; + private final SecretTestContext context; + + public SecretsStepDefs(final TestContextConfig config) { + context = config.secretContext(); + } @Given("secret API version {api} is used") public void apiVersionApiIsUsed(final String version) { diff --git a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/SecretsStepDefsAssertions.java b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/SecretsStepDefsAssertions.java index 0276d5a7..fa2d6d68 100644 --- a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/SecretsStepDefsAssertions.java +++ b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/steps/SecretsStepDefsAssertions.java @@ -2,9 +2,9 @@ import com.azure.core.exception.ResourceNotFoundException; import com.github.nagyesta.lowkeyvault.context.SecretTestContext; +import com.github.nagyesta.lowkeyvault.context.TestContextConfig; import io.cucumber.java.en.And; import io.cucumber.java.en.Then; -import org.springframework.beans.factory.annotation.Autowired; import java.time.temporal.ChronoUnit; import java.util.Collections; @@ -17,9 +17,11 @@ public class SecretsStepDefsAssertions extends CommonAssertions { - @SuppressWarnings("SpringJavaAutowiredMembersInspection") - @Autowired - private SecretTestContext context; + private final SecretTestContext context; + + public SecretsStepDefsAssertions(final TestContextConfig config) { + context = config.secretContext(); + } @Then("the created secret exists with value: {secretValue}") public void theCreatedSecretExists(final String secretValue) { diff --git a/lowkey-vault-testcontainers/build.gradle b/lowkey-vault-testcontainers/build.gradle index 1ec77380..9a2c1fa5 100644 --- a/lowkey-vault-testcontainers/build.gradle +++ b/lowkey-vault-testcontainers/build.gradle @@ -29,12 +29,22 @@ dependencies { testImplementation libs.logback.classic } +java { + sourceCompatibility = JavaVersion.VERSION_11 + toolchain { + languageVersion = JavaLanguageVersion.of(11) + } + withJavadocJar() + withSourcesJar() +} + test { useJUnitPlatform() systemProperty("imageVersion", project.version) mustRunAfter(":lowkey-vault-docker:build") mustRunAfter(":lowkey-vault-docker:test") } + publishing { publications { mavenJava(MavenPublication) {