Skip to content

Commit d8a7b05

Browse files
committed
Polishing.
Add since and author tags. Remove unused imports. Reorder methods. See gh-745 Original pull request: gh-791
1 parent 253e866 commit d8a7b05

File tree

4 files changed

+38
-26
lines changed

4 files changed

+38
-26
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
import java.nio.charset.Charset;
1919
import java.util.Arrays;
20-
import java.util.Base64;
2120
import java.util.Objects;
21+
2222
import org.springframework.util.Assert;
2323

2424
/**
@@ -27,6 +27,7 @@
2727
*
2828
* @author Praveendra Singh
2929
* @author Mark Paluch
30+
* @author Nanne Baars
3031
* @since 1.1
3132
*/
3233
public class Plaintext {

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* @author Luander Ribeiro
2525
* @author Mark Paluch
2626
* @author My-Lan Aragon
27+
* @author Nanne Baars
2728
* @since 2.0
2829
*/
2930
public class VaultSignRequest {
@@ -101,6 +102,7 @@ public String getAlgorithm() {
101102

102103
/**
103104
* @return true if the input is already hashed.
105+
* @since 3.1
104106
*/
105107
public boolean isPrehashed() {
106108
return this.prehashed;
@@ -148,6 +150,19 @@ public VaultSignRequestBuilder hashAlgorithm(String hashAlgorithm) {
148150
return this;
149151
}
150152

153+
/**
154+
* Set to {@literal true} when the input is already hashed. If the key type is
155+
* {@literal rsa-2048}, {@literal rsa-3072}, or {@literal rsa-4096} then specify
156+
* the algorithm used to hash the input through {@link #hashAlgorithm(String)}.
157+
* @param prehashed whether the input is already hashed.
158+
* @return {@code this} {@link VaultSignRequestBuilder}.
159+
* @since 3.1
160+
*/
161+
public VaultSignRequestBuilder prehashed(boolean prehashed) {
162+
this.prehashed = prehashed;
163+
return this;
164+
}
165+
151166
/**
152167
* Configure the signature algorithm to be used for the operation when using an
153168
* RSA key.
@@ -177,24 +192,13 @@ public VaultSignRequestBuilder algorithm(String algorithm) {
177192
return signatureAlgorithm(algorithm);
178193
}
179194

180-
/**
181-
* Set to true when the input is already hashed. If the key type is rsa-2048,
182-
* rsa-3072 or rsa-4096, then the algorithm used to hash the input should be
183-
* indicated by the hash_algorithm parameter.
184-
* @param prehashed whether the input is already hashed
185-
* @return {@code this} {@link VaultSignRequestBuilder}.
186-
*/
187-
public VaultSignRequestBuilder prehashed(boolean prehashed) {
188-
this.prehashed = prehashed;
189-
return this;
190-
}
191-
192195
/**
193196
* Build a new {@link VaultSignRequest} instance. Requires
194197
* {@link #plaintext(Plaintext)} to be configured.
195198
* @return a new {@link VaultSignRequest}.
196199
*/
197200
public VaultSignRequest build() {
201+
198202
Assert.notNull(this.plaintext, "Plaintext input must not be null");
199203

200204
return new VaultSignRequest(this.plaintext, this.hashAlgorithm, this.signatureAlgorithm, this.prehashed);

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package org.springframework.vault.support;
1717

18-
import org.checkerframework.checker.units.qual.A;
1918
import org.springframework.lang.Nullable;
2019
import org.springframework.util.Assert;
2120

@@ -26,6 +25,7 @@
2625
* @author Mark Paluch
2726
* @author My-Lan Aragon
2827
* @author James Luke
28+
* @author Nanne Baars
2929
* @since 2.0
3030
*/
3131
public class VaultSignatureVerificationRequest {
@@ -141,7 +141,8 @@ public String getAlgorithm() {
141141
}
142142

143143
/**
144-
* @return true if the input is already hashed.
144+
* @return {@literal true} if the input is already hashed.
145+
* @since 3.1
145146
*/
146147
public boolean isPrehashed() {
147148
return this.prehashed;
@@ -226,6 +227,19 @@ public VaultSignatureVerificationRequestBuilder hashAlgorithm(String hashAlgorit
226227
return this;
227228
}
228229

230+
/**
231+
* Set to {@literal true} when the input is already hashed. If the key type is
232+
* {@literal rsa-2048}, {@literal rsa-3072}, or {@literal rsa-4096} then specify
233+
* the algorithm used to hash the input through {@link #hashAlgorithm(String)}.
234+
* @param prehashed whether the input is already hashed.
235+
* @return {@code this} {@link VaultSignatureVerificationRequestBuilder}.
236+
* @since 3.1
237+
*/
238+
public VaultSignatureVerificationRequestBuilder prehashed(boolean prehashed) {
239+
this.prehashed = prehashed;
240+
return this;
241+
}
242+
229243
/**
230244
* Configure the signature algorithm to be used for the operation when using an
231245
* RSA key.
@@ -243,11 +257,6 @@ public VaultSignatureVerificationRequestBuilder signatureAlgorithm(String signat
243257
return this;
244258
}
245259

246-
public VaultSignatureVerificationRequestBuilder prehashed(boolean prehashed) {
247-
this.prehashed = prehashed;
248-
return this;
249-
}
250-
251260
/**
252261
* Configure the algorithm to be used for the operation.
253262
* @param algorithm Specify the algorithm to be used for the operation. Supported

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,20 @@
1515
*/
1616
package org.springframework.vault.core;
1717

18-
import static org.assertj.core.api.Assertions.assertThat;
19-
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
20-
import static org.assertj.core.api.Assertions.fail;
21-
2218
import java.util.Arrays;
2319
import java.util.Collections;
2420
import java.util.List;
2521
import java.util.stream.IntStream;
2622
import java.util.stream.Stream;
27-
import org.assertj.core.api.Assertions;
23+
2824
import org.junit.jupiter.api.AfterEach;
2925
import org.junit.jupiter.api.BeforeEach;
3026
import org.junit.jupiter.api.Test;
3127
import org.junit.jupiter.api.extension.ExtendWith;
3228
import org.junit.jupiter.params.ParameterizedTest;
3329
import org.junit.jupiter.params.provider.Arguments;
3430
import org.junit.jupiter.params.provider.MethodSource;
31+
3532
import org.springframework.beans.factory.annotation.Autowired;
3633
import org.springframework.test.context.ContextConfiguration;
3734
import org.springframework.test.context.junit.jupiter.SpringExtension;
@@ -57,7 +54,6 @@
5754
import org.springframework.vault.util.RequiresVaultVersion;
5855
import org.springframework.vault.util.Version;
5956

60-
import static org.assertj.core.api.Assertions.*;
6157
import static org.assertj.core.api.Assertions.assertThat;
6258
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
6359
import static org.assertj.core.api.Assertions.fail;
@@ -812,6 +808,7 @@ void signWithCustomAlgorithmShouldCreateSignature() {
812808
@Test
813809
@RequiresVaultVersion(SIGN_VERIFY_INTRODUCED_IN_VERSION)
814810
void signAndVerifyWithPrehashedInput() {
811+
815812
String keyName = createEcdsaP256Key();
816813
Plaintext plaintext = Plaintext.of("P8m2iUWdc4+MiKOkiqnjNUIBa3pAUuABqqU2/KdIE8s=");
817814
VaultSignRequest signRequest = VaultSignRequest.builder()
@@ -836,6 +833,7 @@ void signAndVerifyWithPrehashedInput() {
836833
@Test
837834
@RequiresVaultVersion(SIGN_VERIFY_INTRODUCED_IN_VERSION)
838835
void signWithPrehashedAndVerifyWithoutShouldFail() {
836+
839837
String keyName = createEcdsaP256Key();
840838
Plaintext plaintext = Plaintext.of("P8m2iUWdc4+MiKOkiqnjNUIBa3pAUuABqqU2/KdIE8s=");
841839
VaultSignRequest signRequest = VaultSignRequest.builder()

0 commit comments

Comments
 (0)