Skip to content

Commit 1eccf7d

Browse files
committed
Polishing.
Add since tags, increment license header years, add javadoc. See gh-726 Original pull request: gh-792
1 parent 288871a commit 1eccf7d

File tree

3 files changed

+29
-17
lines changed

3 files changed

+29
-17
lines changed

spring-vault-core/src/main/java/org/springframework/vault/support/VaultTransitContext.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2022 the original author or authors.
2+
* Copyright 2016-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,14 +15,15 @@
1515
*/
1616
package org.springframework.vault.support;
1717

18-
import org.springframework.util.Assert;
19-
2018
import java.util.Arrays;
2119

20+
import org.springframework.util.Assert;
21+
2222
/**
2323
* Transit backend encryption/decryption/rewrapping context.
2424
*
2525
* @author Mark Paluch
26+
* @author Nanne Baars
2627
*/
2728
public class VaultTransitContext {
2829

@@ -93,9 +94,10 @@ public byte[] getNonce() {
9394
}
9495

9596
/**
96-
* @return the version of the key to use for the operation. If not set, uses the
97-
* latest version. Must be greater than or equal to the key's min_encryption_version,
97+
* @return the version of the key to use for the operation. Uses the latest version if
98+
* not set. Must be greater than or equal to the key's {@code min_encryption_version},
9899
* if set.
100+
* @since 3.0.3
99101
*/
100102
public int getKeyVersion() {
101103
return this.keyVersion;
@@ -164,7 +166,16 @@ public VaultTransitRequestBuilder nonce(byte[] nonce) {
164166
return this;
165167
}
166168

169+
/**
170+
* Configure the key version to use. Must be greater than or equal to the key's
171+
* {@code min_encryption_version}. The key version is not used if not set.
172+
* @param keyVersion the key version to be used, must be greater than or equal to
173+
* the key's {@code min_encryption_version}
174+
* @return {@code this} {@link VaultTransitRequestBuilder}.
175+
* @since 3.0.3
176+
*/
167177
public VaultTransitRequestBuilder keyVersion(int keyVersion) {
178+
168179
Assert.isTrue(keyVersion >= 0, "Key version must have a positive value");
169180

170181
this.keyVersion = keyVersion;

spring-vault-core/src/test/java/org/springframework/vault/core/VaultTransitTemplateIntegrationTests.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2022 the original author or authors.
2+
* Copyright 2016-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,6 +15,12 @@
1515
*/
1616
package org.springframework.vault.core;
1717

18+
import java.util.Arrays;
19+
import java.util.Collections;
20+
import java.util.List;
21+
import java.util.stream.IntStream;
22+
import java.util.stream.Stream;
23+
1824
import org.assertj.core.api.Assertions;
1925
import org.junit.jupiter.api.AfterEach;
2026
import org.junit.jupiter.api.BeforeEach;
@@ -23,6 +29,7 @@
2329
import org.junit.jupiter.params.ParameterizedTest;
2430
import org.junit.jupiter.params.provider.Arguments;
2531
import org.junit.jupiter.params.provider.MethodSource;
32+
2633
import org.springframework.beans.factory.annotation.Autowired;
2734
import org.springframework.test.context.ContextConfiguration;
2835
import org.springframework.test.context.junit.jupiter.SpringExtension;
@@ -48,12 +55,6 @@
4855
import org.springframework.vault.util.RequiresVaultVersion;
4956
import org.springframework.vault.util.Version;
5057

51-
import java.util.Arrays;
52-
import java.util.Collections;
53-
import java.util.List;
54-
import java.util.stream.IntStream;
55-
import java.util.stream.Stream;
56-
5758
import static org.assertj.core.api.Assertions.assertThat;
5859
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
5960
import static org.assertj.core.api.Assertions.fail;

spring-vault-core/src/test/java/org/springframework/vault/util/VaultVersionExtension.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class VaultVersionExtension implements ExecutionCondition {
3636
private static final ExtensionContext.Namespace VAULT = ExtensionContext.Namespace.create("vault.version");
3737

3838
private static final ConditionEvaluationResult ENABLED_BY_DEFAULT = ConditionEvaluationResult
39-
.enabled("@VaultVersion is not present");
39+
.enabled("@VaultVersion is not present");
4040

4141
@Override
4242
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
@@ -66,13 +66,13 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con
6666

6767
if (runningVersion.isGreaterThanOrEqualTo(requiredVersion)) {
6868
return ConditionEvaluationResult
69-
.enabled(String.format("Test is enabled, @VaultVersion(%s) is met with Vault running version %s",
70-
requiredVersion, runningVersion));
69+
.enabled(String.format("Test is enabled, @VaultVersion(%s) is met with Vault running version %s",
70+
requiredVersion, runningVersion));
7171
}
7272

7373
return ConditionEvaluationResult
74-
.disabled(String.format("Test is disabled, @VaultVersion(%s) is not met with Vault running version %s",
75-
requiredVersion, runningVersion));
74+
.disabled(String.format("Test is disabled, @VaultVersion(%s) is not met with Vault running version %s",
75+
requiredVersion, runningVersion));
7676
}
7777

7878
if (disabled.isPresent()) {

0 commit comments

Comments
 (0)