Bump spring-cloud-starter-openfeign to 4.3.1 (#2898)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2026-01-30 16:38:01 +02:00
committed by GitHub
parent a86be566fc
commit 8cac79f860
6 changed files with 31 additions and 39 deletions

View File

@@ -14,12 +14,9 @@ import java.io.InputStream;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.Random; import java.util.Random;
/** import org.eclipse.hawkbit.repository.test.util.TestdataFactory;
*
*/
public class RandomGeneratedInputStream extends InputStream {
private final Random random = new SecureRandom(); public class RandomGeneratedInputStream extends InputStream {
/** Target size of the stream. */ /** Target size of the stream. */
private final long size; private final long size;
@@ -42,7 +39,6 @@ public class RandomGeneratedInputStream extends InputStream {
index++; index++;
return random.nextInt(255); return TestdataFactory.SECURE_RND.nextInt(255);
} }
} }

View File

@@ -9,8 +9,7 @@
*/ */
package org.eclipse.hawkbit.repository.test.util; package org.eclipse.hawkbit.repository.test.util;
import java.security.SecureRandom; import static org.eclipse.hawkbit.repository.test.util.TestdataFactory.SECURE_RND;
import java.util.Random;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
@@ -24,20 +23,19 @@ public class TargetTestData {
public static final String ATTRIBUTE_VALUE_VALID; public static final String ATTRIBUTE_VALUE_VALID;
static { static {
final Random rand = new SecureRandom(); ATTRIBUTE_KEY_TOO_LONG = generateRandomStringWithLength(Target.CONTROLLER_ATTRIBUTE_MAX_KEY_SIZE + 1);
ATTRIBUTE_KEY_TOO_LONG = generateRandomStringWithLength(Target.CONTROLLER_ATTRIBUTE_MAX_KEY_SIZE + 1, rand); ATTRIBUTE_KEY_VALID = generateRandomStringWithLength(Target.CONTROLLER_ATTRIBUTE_MAX_KEY_SIZE);
ATTRIBUTE_KEY_VALID = generateRandomStringWithLength(Target.CONTROLLER_ATTRIBUTE_MAX_KEY_SIZE, rand); ATTRIBUTE_VALUE_TOO_LONG = generateRandomStringWithLength(Target.CONTROLLER_ATTRIBUTE_MAX_VALUE_SIZE + 1);
ATTRIBUTE_VALUE_TOO_LONG = generateRandomStringWithLength(Target.CONTROLLER_ATTRIBUTE_MAX_VALUE_SIZE + 1, rand); ATTRIBUTE_VALUE_VALID = generateRandomStringWithLength(Target.CONTROLLER_ATTRIBUTE_MAX_VALUE_SIZE);
ATTRIBUTE_VALUE_VALID = generateRandomStringWithLength(Target.CONTROLLER_ATTRIBUTE_MAX_VALUE_SIZE, rand);
} }
private static String generateRandomStringWithLength(final int length, final Random rand) { private static String generateRandomStringWithLength(final int length) {
final StringBuilder randomStringBuilder = new StringBuilder(length); final StringBuilder randomStringBuilder = new StringBuilder(length);
final int lowercaseACode = 97; final int lowercaseACode = 97;
final int lowercaseZCode = 122; final int lowercaseZCode = 122;
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
final char randomCharacter = (char) (rand.nextInt(lowercaseZCode - lowercaseACode + 1) + lowercaseACode); final char randomCharacter = (char) (SECURE_RND.nextInt(lowercaseZCode - lowercaseACode + 1) + lowercaseACode);
randomStringBuilder.append(randomCharacter); randomStringBuilder.append(randomCharacter);
} }
return randomStringBuilder.toString(); return randomStringBuilder.toString();

View File

@@ -93,6 +93,7 @@ public class TestdataFactory {
@SuppressWarnings("java:S2245") // used for tests only, no need of secure random @SuppressWarnings("java:S2245") // used for tests only, no need of secure random
public static final Random RND = new Random(); public static final Random RND = new Random();
public static final SecureRandom SECURE_RND = new SecureRandom();
public static final String VISIBLE_SM_MD_KEY = "visibleMetdataKey"; public static final String VISIBLE_SM_MD_KEY = "visibleMetdataKey";
public static final String VISIBLE_SM_MD_VALUE = "visibleMetdataValue"; public static final String VISIBLE_SM_MD_VALUE = "visibleMetdataValue";
@@ -309,7 +310,7 @@ public class TestdataFactory {
SoftwareModuleManagement.Create.builder() SoftwareModuleManagement.Create.builder()
.type(findOrCreateSoftwareModuleType(SM_TYPE_APP, Integer.MAX_VALUE)) .type(findOrCreateSoftwareModuleType(SM_TYPE_APP, Integer.MAX_VALUE))
.name(prefix + SM_TYPE_APP) .name(prefix + SM_TYPE_APP)
.version(version + "." + new SecureRandom().nextInt(100)) .version(version + "." + SECURE_RND.nextInt(100))
.description(randomDescriptionLong()) .description(randomDescriptionLong())
.vendor(prefix + " vendor Limited, California") .vendor(prefix + " vendor Limited, California")
.build()); .build());
@@ -317,14 +318,14 @@ public class TestdataFactory {
.create(SoftwareModuleManagement.Create.builder() .create(SoftwareModuleManagement.Create.builder()
.type(findOrCreateSoftwareModuleType(SM_TYPE_RT)) .type(findOrCreateSoftwareModuleType(SM_TYPE_RT))
.name(prefix + "app runtime") .name(prefix + "app runtime")
.version(version + "." + new SecureRandom().nextInt(100)) .version(version + "." + SECURE_RND.nextInt(100))
.description(randomDescriptionLong()).vendor(prefix + " vendor GmbH, Stuttgart, Germany") .description(randomDescriptionLong()).vendor(prefix + " vendor GmbH, Stuttgart, Germany")
.build()); .build());
final SoftwareModule osMod = softwareModuleManagement final SoftwareModule osMod = softwareModuleManagement
.create(SoftwareModuleManagement.Create.builder() .create(SoftwareModuleManagement.Create.builder()
.type(findOrCreateSoftwareModuleType(SM_TYPE_OS)) .type(findOrCreateSoftwareModuleType(SM_TYPE_OS))
.name(prefix + " Firmware") .name(prefix + " Firmware")
.version(version + "." + new SecureRandom().nextInt(100)) .version(version + "." + SECURE_RND.nextInt(100))
.description(randomDescriptionLong()).vendor(prefix + " vendor Limited Inc, California") .description(randomDescriptionLong()).vendor(prefix + " vendor Limited Inc, California")
.build()); .build());

View File

@@ -20,7 +20,8 @@ import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType; import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.KeyManagementException; import java.security.KeyManagementException;
import java.security.KeyStore; import java.security.KeyStore;
@@ -263,7 +264,7 @@ public class HawkbitClient {
private Object callMultipartFormDataRequest( private Object callMultipartFormDataRequest(
final Method method, final Object[] args, final Method method, final Object[] args,
final Tenant tenant, final Controller controller, final Tenant tenant, final Controller controller,
final Class<?>[] parameterTypes, final ObjectMapper objectMapper) throws IOException { final Class<?>[] parameterTypes, final ObjectMapper objectMapper) throws URISyntaxException, IOException {
final PostMapping postMapping = method.getAnnotation(PostMapping.class); final PostMapping postMapping = method.getAnnotation(PostMapping.class);
final Annotation[][] parametersAnnotations = method.getParameterAnnotations(); final Annotation[][] parametersAnnotations = method.getParameterAnnotations();
// build path - replace @PathVariables // build path - replace @PathVariables
@@ -275,8 +276,8 @@ public class HawkbitClient {
} }
} }
final HttpURLConnection conn = (HttpURLConnection) new URL( final HttpURLConnection conn = (HttpURLConnection) new URI(
(controller == null ? hawkBitServer.getMgmtUrl() : hawkBitServer.getDdiUrl()) + path).openConnection(); (controller == null ? hawkBitServer.getMgmtUrl() : hawkBitServer.getDdiUrl()) + path).toURL().openConnection();
conn.setRequestMethod("POST"); conn.setRequestMethod("POST");
// deal with authentication - only from headers1 // deal with authentication - only from headers1
@@ -407,15 +408,6 @@ public class HawkbitClient {
return null; return null;
} }
private static final String KEYSTORE_PASSWORD;
static {
final Random random = new SecureRandom();
final byte[] bytes = new byte[16];
random.nextBytes(bytes);
KEYSTORE_PASSWORD = Base64.getEncoder().encodeToString(bytes);
}
private static final Map<HttpClientKey, HttpClientWrapper> HTTP_CLIENTS = new HashMap<>(); private static final Map<HttpClientKey, HttpClientWrapper> HTTP_CLIENTS = new HashMap<>();
private static HttpClient httpClient(final HttpClientKey key) { private static HttpClient httpClient(final HttpClientKey key) {
@@ -430,7 +422,7 @@ public class HawkbitClient {
try { try {
builder.setConnectionManager( builder.setConnectionManager(
PoolingHttpClientConnectionManagerBuilder.create() PoolingHttpClientConnectionManagerBuilder.create()
.setTlsSocketStrategy(getTlsSocketStragegy(key.getClientCertificate(), key.getServerCertificates())) .setTlsSocketStrategy(getTlsSocketStrategy(key.getClientCertificate(), key.getServerCertificates()))
.build()); .build());
} catch (final RuntimeException e) { } catch (final RuntimeException e) {
throw e; throw e;
@@ -448,12 +440,17 @@ public class HawkbitClient {
} }
} }
private static TlsSocketStrategy getTlsSocketStragegy(final Certificate clientCertificate, final X509Certificate[] serverCertificates) private static final Random SECURE_RND = new SecureRandom();
private static TlsSocketStrategy getTlsSocketStrategy(final Certificate clientCertificate, final X509Certificate[] serverCertificates)
throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException, KeyManagementException, CertificateException, throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException, KeyManagementException, CertificateException,
IOException { IOException {
final SSLContextBuilder sslContextBuilder = SSLContextBuilder.create(); final SSLContextBuilder sslContextBuilder = SSLContextBuilder.create();
if (clientCertificate != null) { if (clientCertificate != null) {
sslContextBuilder.loadKeyMaterial(clientCertificate.toKeyStore(KEYSTORE_PASSWORD), KEYSTORE_PASSWORD.toCharArray()); final byte[] bytes = new byte[16];
SECURE_RND.nextBytes(bytes);
final String keystorePassword = Base64.getEncoder().encodeToString(bytes);
sslContextBuilder.loadKeyMaterial(clientCertificate.toKeyStore(keystorePassword), keystorePassword.toCharArray());
} }
if (serverCertificates == null) { if (serverCertificates == null) {
// trust all // trust all

View File

@@ -44,7 +44,7 @@ public class AuthenticationSetupHelper {
private static final String AUTHENTICATION_MODE_HEADER_ENABLED = "authentication.header.enabled"; private static final String AUTHENTICATION_MODE_HEADER_ENABLED = "authentication.header.enabled";
private static final String AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME = "authentication.header.authority"; private static final String AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME = "authentication.header.authority";
private static final Random RND = new SecureRandom(); private static final Random SECURE_RND = new SecureRandom();
@NonNull @NonNull
private final Tenant tenant; private final Tenant tenant;
@@ -53,7 +53,7 @@ public class AuthenticationSetupHelper {
public static String randomToken() { public static String randomToken() {
final byte[] rnd = new byte[24]; final byte[] rnd = new byte[24];
RND.nextBytes(rnd); SECURE_RND.nextBytes(rnd);
return Base64.getEncoder().encodeToString(rnd); return Base64.getEncoder().encodeToString(rnd);
} }

View File

@@ -24,7 +24,7 @@
<name>hawkBit :: SDK :: Parent</name> <name>hawkBit :: SDK :: Parent</name>
<properties> <properties>
<spring-cloud-starter-openfeign.version>4.3.0</spring-cloud-starter-openfeign.version> <spring-cloud-starter-openfeign.version>4.3.1</spring-cloud-starter-openfeign.version>
<openfeign-hc5.version>13.6</openfeign-hc5.version> <openfeign-hc5.version>13.6</openfeign-hc5.version>
<bouncycastle.version>1.83</bouncycastle.version> <bouncycastle.version>1.83</bouncycastle.version>
<java.version>${java.client.version}</java.version> <java.version>${java.client.version}</java.version>