Polishing.
Add author tags. Update test. Original pull request: gh-476.
This commit is contained in:
@@ -36,6 +36,7 @@ import org.springframework.web.client.HttpStatusCodeException;
|
||||
* Default implementation of {@link VaultPkiOperations}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Alex Antonov
|
||||
*/
|
||||
public class VaultPkiTemplate implements VaultPkiOperations {
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ public abstract class PropertyTransformers {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> transformProperties(
|
||||
Map<String, ? extends Object> input) {
|
||||
return (Map) input;
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.util.Assert;
|
||||
* Request for a Certificate.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Alex Antonov
|
||||
*/
|
||||
public class VaultCertificateRequest {
|
||||
|
||||
@@ -63,9 +64,9 @@ public class VaultCertificateRequest {
|
||||
*/
|
||||
private final boolean excludeCommonNameFromSubjectAltNames;
|
||||
|
||||
VaultCertificateRequest(String commonName, List<String> altNames,
|
||||
List<String> ipSubjectAltNames, List<String> uriSubjectAltNames, @Nullable Duration ttl,
|
||||
boolean excludeCommonNameFromSubjectAltNames) {
|
||||
private VaultCertificateRequest(String commonName, List<String> altNames,
|
||||
List<String> ipSubjectAltNames, List<String> uriSubjectAltNames,
|
||||
@Nullable Duration ttl, boolean excludeCommonNameFromSubjectAltNames) {
|
||||
|
||||
this.commonName = commonName;
|
||||
this.altNames = altNames;
|
||||
@@ -215,6 +216,7 @@ public class VaultCertificateRequest {
|
||||
*
|
||||
* @param uriSubjectAltNames must not be {@literal null}.
|
||||
* @return {@code this} {@link VaultCertificateRequestBuilder}.
|
||||
* @since 2.2
|
||||
*/
|
||||
public VaultCertificateRequestBuilder uriSubjectAltNames(
|
||||
Iterable<String> uriSubjectAltNames) {
|
||||
@@ -230,6 +232,7 @@ public class VaultCertificateRequest {
|
||||
*
|
||||
* @param uriSubjectAltName must not be empty or {@literal null}.
|
||||
* @return {@code this} {@link VaultCertificateRequestBuilder}.
|
||||
* @since 2.2
|
||||
*/
|
||||
public VaultCertificateRequestBuilder withUriSubjectAltName(
|
||||
String uriSubjectAltName) {
|
||||
@@ -341,16 +344,16 @@ public class VaultCertificateRequest {
|
||||
|
||||
List<String> uriSubjectAltNames;
|
||||
switch (this.uriSubjectAltNames.size()) {
|
||||
case 0:
|
||||
uriSubjectAltNames = java.util.Collections.emptyList();
|
||||
break;
|
||||
case 1:
|
||||
uriSubjectAltNames = java.util.Collections
|
||||
.singletonList(this.uriSubjectAltNames.get(0));
|
||||
break;
|
||||
default:
|
||||
uriSubjectAltNames = java.util.Collections
|
||||
.unmodifiableList(new ArrayList<>(this.uriSubjectAltNames));
|
||||
case 0:
|
||||
uriSubjectAltNames = java.util.Collections.emptyList();
|
||||
break;
|
||||
case 1:
|
||||
uriSubjectAltNames = java.util.Collections
|
||||
.singletonList(this.uriSubjectAltNames.get(0));
|
||||
break;
|
||||
default:
|
||||
uriSubjectAltNames = java.util.Collections
|
||||
.unmodifiableList(new ArrayList<>(this.uriSubjectAltNames));
|
||||
}
|
||||
|
||||
return new VaultCertificateRequest(commonName, altNames, ipSubjectAltNames,
|
||||
|
||||
@@ -49,12 +49,14 @@ class VaultCertificateRequestUnitTests {
|
||||
.commonName("hello.com") //
|
||||
.withAltName("alt") //
|
||||
.withIpSubjectAltName("127.0.0.1") //
|
||||
.withUriSubjectAltName("hello.world") //
|
||||
.excludeCommonNameFromSubjectAltNames() //
|
||||
.build();
|
||||
|
||||
assertThat(request.getCommonName()).isEqualTo("hello.com");
|
||||
assertThat(request.getAltNames()).hasSize(1).contains("alt");
|
||||
assertThat(request.getIpSubjectAltNames()).hasSize(1).contains("127.0.0.1");
|
||||
assertThat(request.getIpSubjectAltNames()).containsOnly("127.0.0.1");
|
||||
assertThat(request.getUriSubjectAltNames()).containsOnly("hello.world");
|
||||
assertThat(request.isExcludeCommonNameFromSubjectAltNames()).isTrue();
|
||||
assertThat(request.getCommonName()).isEqualTo("hello.com");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user