Remove deprecated API.

See #666
This commit is contained in:
Mark Paluch
2021-09-27 14:46:28 +02:00
parent 276c0e14fb
commit e25423716c
19 changed files with 29 additions and 390 deletions

View File

@@ -64,40 +64,6 @@ public class LoginToken extends VaultToken {
return of(token, Duration.ZERO);
}
/**
* Create a new {@link LoginToken} with a {@code leaseDurationSeconds}.
* @param token must not be {@literal null}.
* @param leaseDurationSeconds the lease duration in seconds, must not be negative.
* @return the created {@link VaultToken}
* @deprecated since 2.0, use {@link #of(char[], Duration)} for time unit safety.
*/
@Deprecated
public static LoginToken of(String token, long leaseDurationSeconds) {
Assert.hasText(token, "Token must not be empty");
Assert.isTrue(leaseDurationSeconds >= 0, "Lease duration must not be negative");
return of(token.toCharArray(), Duration.ofSeconds(leaseDurationSeconds));
}
/**
* Create a new {@link LoginToken} with a {@code leaseDurationSeconds}.
* @param token must not be {@literal null}.
* @param leaseDurationSeconds the lease duration in seconds, must not be negative.
* @return the created {@link VaultToken}
* @since 1.1
* @deprecated since 2.0, use {@link #of(char[], Duration)} for time unit safety.
*/
@Deprecated
public static LoginToken of(char[] token, long leaseDurationSeconds) {
Assert.notNull(token, "Token must not be null");
Assert.isTrue(token.length > 0, "Token must not be empty");
Assert.isTrue(leaseDurationSeconds >= 0, "Lease duration must not be negative");
return new LoginToken(token, Duration.ofSeconds(leaseDurationSeconds), false);
}
/**
* Create a new {@link LoginToken} with a {@code leaseDurationSeconds}.
* @param token must not be {@literal null}.
@@ -116,42 +82,6 @@ public class LoginToken extends VaultToken {
return new LoginToken(token, leaseDuration, false);
}
/**
* Create a new renewable {@link LoginToken} with a {@code leaseDurationSeconds}.
* @param token must not be {@literal null}.
* @param leaseDurationSeconds the lease duration in seconds, must not be negative.
* @return the created {@link VaultToken}
* @deprecated since 2.0, use {@link #renewable(char[], Duration)} for time unit
* safety.
*/
@Deprecated
public static LoginToken renewable(String token, long leaseDurationSeconds) {
Assert.hasText(token, "Token must not be empty");
Assert.isTrue(leaseDurationSeconds >= 0, "Lease duration must not be negative");
return renewable(token.toCharArray(), Duration.ofSeconds(leaseDurationSeconds));
}
/**
* Create a new renewable {@link LoginToken} with a {@code leaseDurationSeconds}.
* @param token must not be {@literal null}.
* @param leaseDurationSeconds the lease duration in seconds, must not be negative.
* @return the created {@link VaultToken}
* @since 2.0
* @deprecated since 2.0, use {@link #renewable(char[], Duration)} for time unit
* safety.
*/
@Deprecated
public static LoginToken renewable(char[] token, long leaseDurationSeconds) {
Assert.notNull(token, "Token must not be null");
Assert.isTrue(token.length > 0, "Token must not be empty");
Assert.isTrue(leaseDurationSeconds >= 0, "Lease duration must not be negative");
return new LoginToken(token, Duration.ofSeconds(leaseDurationSeconds), true);
}
/**
* Create a new renewable {@link LoginToken} with a {@code leaseDurationSeconds}.
* @param token must not be {@literal null}.

View File

@@ -158,7 +158,8 @@ public class PcfAuthentication implements ClientAuthentication, AuthenticationSt
private static String doSign(byte[] message, String instanceKeyPem) throws CryptoException {
RSAPrivateKeySpec privateKey = PemObject.fromKey(instanceKeyPem).getRSAKeySpec();
RSAPrivateKeySpec privateKey = PemObject.fromKey(instanceKeyPem)
.getRSAPrivateKeySpec();
PSSSigner signer = new PSSSigner(new RSAEngine(), new SHA256Digest(), SALT_LENGTH);
signer.init(true, new RSAKeyParameters(true, privateKey.getModulus(), privateKey.getPrivateExponent()));

View File

@@ -116,7 +116,7 @@ public class WebClientBuilder {
Assert.notNull(httpConnector, "ClientHttpConnector must not be null");
return requestFactory(() -> httpConnector);
return httpConnectorFactory(() -> httpConnector);
}
/**
@@ -134,19 +134,6 @@ public class WebClientBuilder {
return this;
}
/**
* Set the {@link Supplier} of {@link ClientHttpConnector} that should be called each
* time we {@link #build()} a new {@link WebClient} instance.
* @param httpConnector the supplier for the HTTP connector.
* @return {@code this} {@link WebClientBuilder}.
* @deprecated since 2.2.1 as the name is wrong, use
* {@link #httpConnectorFactory(Supplier)}
*/
@Deprecated
public WebClientBuilder requestFactory(Supplier<ClientHttpConnector> httpConnector) {
return httpConnectorFactory(httpConnector);
}
/**
* Add a default header that will be set if not already present on the outgoing
* {@link HttpRequest}.

View File

@@ -1,47 +0,0 @@
/*
* Copyright 2017-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.vault.config;
import org.springframework.http.client.reactive.ClientHttpConnector;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.vault.support.ClientOptions;
import org.springframework.vault.support.SslConfiguration;
/**
* Factory for {@link ClientHttpConnector} that supports
* {@link ReactorClientHttpConnector}.
*
* @author Mark Paluch
* @since 2.0
* @deprecated since 2.2, use
* {@link org.springframework.vault.client.ClientHttpConnectorFactory} as the
* functionality was moved to the {@code org.springframework.vault.client} package.
*/
@Deprecated
public class ClientHttpConnectorFactory {
/**
* Create a {@link ClientHttpConnector} for the given {@link ClientOptions} and
* {@link SslConfiguration}.
* @param options must not be {@literal null}
* @param sslConfiguration must not be {@literal null}
* @return a new {@link ClientHttpConnector}.
*/
public static ClientHttpConnector create(ClientOptions options, SslConfiguration sslConfiguration) {
return org.springframework.vault.client.ClientHttpConnectorFactory.create(options, sslConfiguration);
}
}

View File

@@ -1,47 +0,0 @@
/*
* Copyright 2016-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.vault.config;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.vault.support.ClientOptions;
import org.springframework.vault.support.SslConfiguration;
/**
* Factory for {@link ClientHttpRequestFactory} that supports Apache HTTP Components,
* OkHttp, Netty and the JDK HTTP client (in that order). This factory configures a
* {@link ClientHttpRequestFactory} depending on the available dependencies.
*
* @author Mark Paluch
* @deprecated since 2.2, use
* {@link org.springframework.vault.client.ClientHttpRequestFactoryFactory} as the
* functionality was moved to the {@code org.springframework.vault.client} package.
*/
@Deprecated
public class ClientHttpRequestFactoryFactory {
/**
* Create a {@link ClientHttpRequestFactory} for the given {@link ClientOptions} and
* {@link SslConfiguration}.
* @param options must not be {@literal null}
* @param sslConfiguration must not be {@literal null}
* @return a new {@link ClientHttpRequestFactory}. Lifecycle beans must be initialized
* after obtaining.
*/
public static ClientHttpRequestFactory create(ClientOptions options, SslConfiguration sslConfiguration) {
return org.springframework.vault.client.ClientHttpRequestFactoryFactory.create(options, sslConfiguration);
}
}

View File

@@ -275,18 +275,6 @@ public class LeaseAwareVaultPropertySource extends EnumerablePropertySource<Vaul
return this.propertyTransformer.transformProperties(properties);
}
/**
* Utility method converting a {@code String/Object} map to a flat
* {@code String/String} map. Nested objects are represented with property paths.
* @param data the map
* @return the flattened map.
* @deprecated since 2.0, use {@link #flattenMap(Map)} to retain JSON data types.
*/
@Deprecated
protected Map<String, String> toStringMap(Map<String, Object> data) {
return JsonMapFlattener.flattenToStringMap(data);
}
/**
* Utility method converting a {@code String/Object} map to a flat
* {@code String/Object} map. Nested objects are represented with property path keys.

View File

@@ -232,18 +232,6 @@ public class VaultPropertySource extends EnumerablePropertySource<VaultOperation
return this.propertyTransformer.transformProperties(properties);
}
/**
* Utility method converting a {@code String/Object} map to a flat
* {@code String/String} map.
* @param data the map
* @return the flattened map.
* @deprecated since 2.0, use {@link #flattenMap(Map)} to retain JSON data types.
*/
@Deprecated
protected Map<String, String> toStringMap(Map<String, Object> data) {
return JsonMapFlattener.flattenToStringMap(data);
}
/**
* Utility method converting a {@code String/Object} map to a flat
* {@code String/Object} map. Nested objects are represented with property path keys.

View File

@@ -61,24 +61,6 @@ public enum LeaseEndpoints {
}
},
/**
* Alias for {@link #Leases}.
* @deprecated since 2.3, use {@link #Leases} instead.
*/
@Deprecated
SysLeases {
@Override
public void revoke(Lease lease, RestOperations operations) {
Leases.revoke(lease, operations);
}
@Override
public Lease renew(Lease lease, RestOperations operations) {
return Leases.renew(lease, operations);
}
},
/**
* Sys/lease endpoints for Vault 0.8 and higher ({@literal /sys/leases/…}) that uses
* the {@literal /sys/leases/revoke} endpoint when revoking leases.

View File

@@ -203,18 +203,6 @@ public class SecretLeaseContainer extends SecretLeaseEventPublisher implements I
this.leaseEndpoints = leaseEndpoints;
}
/**
* Sets the amount of seconds that is at least required before renewing a lease.
* {@code minRenewalSeconds} prevents renewals from happening too often.
* @param minRenewalSeconds number of seconds that is at least required before
* renewing a {@link Lease}, must not be negative.
* @deprecated since 2.0, use {@link #setMinRenewal(Duration)} for time unit safety.
*/
@Deprecated
public void setMinRenewalSeconds(int minRenewalSeconds) {
setMinRenewal(Duration.ofSeconds(minRenewalSeconds));
}
/**
* Sets the amount {@link Duration} that is at least required before renewing a lease.
* {@code minRenewal} prevents renewals from happening too often.
@@ -230,19 +218,6 @@ public class SecretLeaseContainer extends SecretLeaseEventPublisher implements I
this.minRenewal = minRenewal;
}
/**
* Set the expiry threshold. A {@link Lease} is renewed the given seconds before it
* expires.
* @param expiryThresholdSeconds number of seconds before {@link Lease} expiry, must
* not be negative.
* @deprecated since 2.0, use {@link #setExpiryThreshold(Duration)} for time unit
* safety.
*/
@Deprecated
public void setExpiryThresholdSeconds(int expiryThresholdSeconds) {
setExpiryThreshold(Duration.ofSeconds(expiryThresholdSeconds));
}
/**
* Set the expiry threshold. A {@link Lease} is renewed the given time before it
* expires.

View File

@@ -44,23 +44,6 @@ public class Lease {
this.renewable = renewable;
}
/**
* Create a new {@link Lease}.
* @param leaseId must not be empty or {@literal null}.
* @param leaseDurationSeconds the lease duration in seconds, must not be negative.
* @param renewable {@literal true} if this lease is renewable.
* @return the created {@link Lease}
* @deprecated since 2.0, use {@link #of(String, Duration, boolean)} for time unit
* safety.
*/
@Deprecated
public static Lease of(String leaseId, long leaseDurationSeconds, boolean renewable) {
Assert.isTrue(leaseDurationSeconds >= 0, "Lease duration must not be negative");
return of(leaseId, Duration.ofSeconds(leaseDurationSeconds), renewable);
}
/**
* Create a new {@link Lease}.
* @param leaseId must not be empty or {@literal null}.
@@ -78,22 +61,6 @@ public class Lease {
return new Lease(leaseId, leaseDuration, renewable);
}
/**
* Create a new non-renewable {@link Lease}, without a {@code leaseId} and specified
* duration.
* @param leaseDuration the lease duration in seconds, must not be negative.
* @return the created {@link Lease}
* @since 1.1
* @deprecated since 2.0, use {@link #fromTimeToLive(Duration)} for time unit safety.
*/
@Deprecated
public static Lease fromTimeToLive(long leaseDuration) {
Assert.isTrue(leaseDuration >= 0, "Lease duration must not be negative");
return new Lease(null, Duration.ofSeconds(leaseDuration), false);
}
/**
* Create a new non-renewable {@link Lease}, without a {@code leaseId} and specified
* duration.

View File

@@ -46,20 +46,6 @@ public class ClientOptions {
this(Duration.ofSeconds(5), Duration.ofSeconds(15));
}
/**
* Create new {@link ClientOptions}.
* @param connectionTimeout connection timeout in {@link TimeUnit#MILLISECONDS}, must
* not be negative.
* @param readTimeout read timeout in {@link TimeUnit#MILLISECONDS}, must not be
* negative.
* @deprecated since 2.0, use {@link #ClientOptions(Duration, Duration)} for time unit
* safety.
*/
@Deprecated
public ClientOptions(int connectionTimeout, int readTimeout) {
this(Duration.ofMillis(connectionTimeout), Duration.ofMillis(readTimeout));
}
/**
* Create new {@link ClientOptions}.
* @param connectionTimeout connection timeout, must not be {@literal null}.

View File

@@ -195,17 +195,6 @@ public class PemObject {
return PemObjectType.PUBLIC_KEY == this.objectType || PemObjectType.RSA_PUBLIC_KEY == this.objectType;
}
/**
* Retrieve a {@link RSAPrivateCrtKeySpec}.
* @return the {@link RSAPrivateCrtKeySpec}.
* @deprecated since 2.3. Use {@link #getRSAPrivateKeySpec()} instead that uses an
* improved name to indicate what the method is supposed to return.
*/
@Deprecated
public RSAPrivateCrtKeySpec getRSAKeySpec() {
return getRSAPrivateKeySpec();
}
/**
* Retrieve a {@link X509Certificate}.
* @return the {@link X509Certificate}.

View File

@@ -450,18 +450,6 @@ public class SslConfiguration {
return this.keyStoreConfiguration.getResource();
}
/**
* @return the key store password or {@literal null} if not configured.
* @deprecated Since 1.1, use {@link KeyStoreConfiguration#getStorePassword()} to
* prevent {@link String} interning and retaining passwords represented as String
* longer from GC than necessary.
*/
@Deprecated
@Nullable
public String getKeyStorePassword() {
return stringOrNull(this.keyStoreConfiguration.getStorePassword());
}
/**
* @return the key store configuration.
* @since 1.1
@@ -512,18 +500,6 @@ public class SslConfiguration {
return this.trustStoreConfiguration.getResource();
}
/**
* @return the trust store password or {@literal null} if not configured.
* @deprecated Since 1.1, use {@link KeyStoreConfiguration#getStorePassword()} to
* prevent {@link String} interning and retaining passwords represented as String
* longer from GC than necessary.
*/
@Deprecated
@Nullable
public String getTrustStorePassword() {
return stringOrNull(this.trustStoreConfiguration.getStorePassword());
}
/**
* @return the trust store configuration.
* @since 1.1

View File

@@ -314,21 +314,6 @@ public class VaultCertificateRequest {
return this;
}
/**
* Configure a TTL.
* @param ttl the time to live, in seconds, must not be negative.
* @return {@code this} {@link VaultCertificateRequestBuilder}.
* @deprecated since 2.0, use {@link #ttl(Duration)} for time unit safety.
*/
@Deprecated
public VaultCertificateRequestBuilder ttl(int ttl) {
Assert.isTrue(ttl > 0, "TTL must not be negative");
this.ttl = Duration.ofSeconds(ttl);
return this;
}
/**
* Configure a TTL.
* @param ttl the time to live, must not be negative.

View File

@@ -302,17 +302,6 @@ public class VaultTokenRequest {
return this;
}
/**
* Configure a TTL (seconds) for the token.
* @param ttl the time to live in seconds, must not be negative.
* @return {@code this} {@link VaultTokenRequestBuilder}.
* @deprecated since 2.0, use {@link #ttl(Duration)} for time unit safety.
*/
@Deprecated
public VaultTokenRequestBuilder ttl(long ttl) {
return ttl(ttl, TimeUnit.SECONDS);
}
/**
* Configure a TTL (seconds) for the token.
* @param ttl the time to live, must not be negative.
@@ -344,21 +333,6 @@ public class VaultTokenRequest {
return this;
}
/**
* Configure the explicit maximum TTL (seconds) for the token. This maximum token
* TTL cannot be changed later, and unlike with normal tokens, updates to the
* system/mount max TTL value will have no effect at renewal time - the token will
* never be able to be renewed or used past the value set at issue time.
* @param explicitMaxTtl the time to live in seconds, must not be negative.
* @return {@code this} {@link VaultTokenRequestBuilder}.
* @deprecated since 2.0, use {@link #explicitMaxTtl(Duration)} for time unit
* safety.
*/
@Deprecated
public VaultTokenRequestBuilder explicitMaxTtl(long explicitMaxTtl) {
return explicitMaxTtl(explicitMaxTtl, TimeUnit.SECONDS);
}
/**
* Configure the explicit maximum TTL for the token. This maximum token TTL cannot
* be changed later, and unlike with normal tokens, updates to the system/mount

View File

@@ -19,16 +19,15 @@ import org.junit.jupiter.api.Test;
import org.springframework.core.NestedRuntimeException;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.vault.client.ClientHttpRequestFactoryFactory;
import org.springframework.vault.client.VaultClients;
import org.springframework.vault.config.ClientHttpRequestFactoryFactory;
import org.springframework.vault.support.ClientOptions;
import org.springframework.vault.support.VaultToken;
import org.springframework.vault.util.Settings;
import org.springframework.vault.util.TestRestTemplateFactory;
import org.springframework.web.client.RestTemplate;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.*;
/**
* Integration tests for {@link ClientCertificateAuthentication} using

View File

@@ -15,9 +15,11 @@
*/
package org.springframework.vault.authentication;
import java.time.Duration;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.*;
/**
* Unit tests for {@link LoginToken}.
@@ -30,16 +32,19 @@ class LoginTokenUnitTests {
void shouldConstructLoginToken() {
assertThat(LoginToken.of("token")).isInstanceOf(LoginToken.class);
assertThat(LoginToken.of("token", 1)).isInstanceOf(LoginToken.class);
assertThat(LoginToken.renewable("token", 1)).isInstanceOf(LoginToken.class);
assertThat(LoginToken.of("token".toCharArray(), Duration.ofSeconds(1))).isInstanceOf(LoginToken.class);
assertThat(LoginToken.renewable("token".toCharArray(), Duration.ofSeconds(1))).isInstanceOf(LoginToken.class);
}
@Test
void toStringShouldPrintFields() {
assertThat(LoginToken.of("token").toString()).isEqualTo("LoginToken [renewable=false, leaseDuration=PT0S]");
assertThat(LoginToken.of("token", 1).toString()).isEqualTo("LoginToken [renewable=false, leaseDuration=PT1S]");
assertThat(LoginToken.renewable("token", 1).toString())
assertThat(LoginToken.of("token")
.toString()).isEqualTo("LoginToken [renewable=false, leaseDuration=PT0S]");
assertThat(LoginToken.of("token".toCharArray(), Duration.ofSeconds(1)).toString())
.isEqualTo("LoginToken [renewable=false, leaseDuration=PT1S]");
assertThat(LoginToken.renewable("token".toCharArray(), Duration.ofSeconds(1))
.toString())
.isEqualTo("LoginToken [renewable=true, leaseDuration=PT1S]");
}

View File

@@ -89,16 +89,21 @@ class EnvironmentVaultConfigurationUnitTests {
SslConfiguration sslConfiguration = this.configuration.sslConfiguration();
assertThat(sslConfiguration.getKeyStore()).isInstanceOf(ClassPathResource.class);
assertThat(sslConfiguration.getKeyStorePassword()).isEqualTo("key store password");
assertThat(new String(sslConfiguration.getKeyStoreConfiguration()
.getStorePassword()))
.isEqualTo("key store password");
assertThat(sslConfiguration.getTrustStore()).isInstanceOf(ClassPathResource.class);
assertThat(sslConfiguration.getTrustStorePassword()).isEqualTo("trust store password");
assertThat(new String(sslConfiguration.getTrustStoreConfiguration()
.getStorePassword()))
.isEqualTo("trust store password");
assertThat(sslConfiguration.getEnabledProtocols()).containsExactly("TLSv1.2", "TLSv1.1");
assertThat(sslConfiguration.getEnabledCipherSuites()).containsExactly("TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256");
this.configurableEnvironment.getPropertySources().remove(propertySource.getName());
this.configurableEnvironment.getPropertySources()
.remove(propertySource.getName());
}
}

View File

@@ -34,13 +34,9 @@ import org.springframework.http.ResponseEntity;
import org.springframework.vault.core.lease.domain.Lease;
import org.springframework.web.client.RestOperations;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
/**
* Unit tests for {@link LeaseEndpoints}.
@@ -119,7 +115,7 @@ public class LeaseEndpointsUnitTests {
when(oldLease.getLeaseId()).thenReturn("old_lease");
when(oldLease.getLeaseDuration()).thenReturn(Duration.ofSeconds(70));
Lease renewedLease = LeaseEndpoints.SysLeases.renew(oldLease, restOperations);
Lease renewedLease = LeaseEndpoints.Leases.renew(oldLease, restOperations);
verify(restOperations).exchange(eq("sys/leases/renew"), eq(HttpMethod.PUT), httpEntityCaptor.capture(),
eq(Map.class));
@@ -141,7 +137,7 @@ public class LeaseEndpointsUnitTests {
when(oldLease.getLeaseId()).thenReturn("old_lease");
LeaseEndpoints.SysLeases.revoke(oldLease, restOperations);
LeaseEndpoints.Leases.revoke(oldLease, restOperations);
verify(restOperations).exchange(eq("sys/leases/revoke"), eq(HttpMethod.PUT), httpEntityCaptor.capture(),
eq(Map.class), eq("old_lease"));