Fix some sonar finings (#1652)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -497,7 +497,6 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInt
|
|||||||
}
|
}
|
||||||
|
|
||||||
final TargetFilterQuery tfq = createSingleTargetFilterQuery(knownName, knownQuery);
|
final TargetFilterQuery tfq = createSingleTargetFilterQuery(knownName, knownQuery);
|
||||||
// set will be implicitly locked
|
|
||||||
final DistributionSet set = testdataFactory.createDistributionSet();
|
final DistributionSet set = testdataFactory.createDistributionSet();
|
||||||
|
|
||||||
// do not provide something about the confirmation
|
// do not provide something about the confirmation
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ public class SetupHelper {
|
|||||||
public static void setupTargetAuthentication(final HawkbitClient hawkbitClient, final Tenant tenant) {
|
public static void setupTargetAuthentication(final HawkbitClient hawkbitClient, final Tenant tenant) {
|
||||||
final MgmtTenantManagementRestApi mgmtTenantManagementRestApi =
|
final MgmtTenantManagementRestApi mgmtTenantManagementRestApi =
|
||||||
hawkbitClient.mgmtService(MgmtTenantManagementRestApi.class, tenant);
|
hawkbitClient.mgmtService(MgmtTenantManagementRestApi.class, tenant);
|
||||||
if (ObjectUtils.isEmpty(tenant.getGatewayToken())) {
|
final String gatewayToken = tenant.getGatewayToken();
|
||||||
|
if (ObjectUtils.isEmpty(gatewayToken)) {
|
||||||
if (!((Boolean) Objects.requireNonNull(mgmtTenantManagementRestApi
|
if (!((Boolean) Objects.requireNonNull(mgmtTenantManagementRestApi
|
||||||
.getTenantConfigurationValue(AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED)
|
.getTenantConfigurationValue(AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED)
|
||||||
.getBody()).getValue())) {
|
.getBody()).getValue())) {
|
||||||
@@ -66,12 +67,12 @@ public class SetupHelper {
|
|||||||
Map.of(AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED, true)
|
Map.of(AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED, true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!tenant.getGatewayToken().equals(
|
if (!gatewayToken.equals(
|
||||||
Objects.requireNonNull(mgmtTenantManagementRestApi
|
Objects.requireNonNull(mgmtTenantManagementRestApi
|
||||||
.getTenantConfigurationValue(AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY)
|
.getTenantConfigurationValue(AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY)
|
||||||
.getBody()).getValue())) {
|
.getBody()).getValue())) {
|
||||||
mgmtTenantManagementRestApi.updateTenantConfiguration(
|
mgmtTenantManagementRestApi.updateTenantConfiguration(
|
||||||
Map.of(AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, tenant.getGatewayToken())
|
Map.of(AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, gatewayToken)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public class DdiController {
|
|||||||
private long overridePollMillis = -1; // -1 means disabled
|
private long overridePollMillis = -1; // -1 means disabled
|
||||||
|
|
||||||
// state
|
// state
|
||||||
|
@SuppressWarnings("java:S3077") // volatile used only for the reference as expected
|
||||||
private volatile ScheduledExecutorService executorService;
|
private volatile ScheduledExecutorService executorService;
|
||||||
private volatile Long currentActionId;
|
private volatile Long currentActionId;
|
||||||
|
|
||||||
|
|||||||
@@ -68,8 +68,9 @@ public interface UpdateHandler {
|
|||||||
private static final String LOG_PREFIX = "[{}:{}] ";
|
private static final String LOG_PREFIX = "[{}:{}] ";
|
||||||
|
|
||||||
private static final String DOWNLOAD_LOG_MESSAGE = "Download ";
|
private static final String DOWNLOAD_LOG_MESSAGE = "Download ";
|
||||||
|
private static final String EXPECTED = "(Expected: ";
|
||||||
private static final String BUT_GOT_LOG_MESSAGE = " but got: ";
|
private static final String BUT_GOT_LOG_MESSAGE = " but got: ";
|
||||||
private static final int MINIMUM_TOKENLENGTH_FOR_HINT = 6;
|
private static final int MINIMUM_TOKEN_LENGTH_FOR_HINT = 6;
|
||||||
|
|
||||||
private final DdiController ddiController;
|
private final DdiController ddiController;
|
||||||
|
|
||||||
@@ -239,7 +240,7 @@ public interface UpdateHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (response.getEntity().getContentLength() != size) {
|
if (response.getEntity().getContentLength() != size) {
|
||||||
throw new IllegalArgumentException("Wrong content length " + "(Expected: " + size + BUT_GOT_LOG_MESSAGE + response.getEntity()
|
throw new IllegalArgumentException("Wrong content length " + EXPECTED + size + BUT_GOT_LOG_MESSAGE + response.getEntity()
|
||||||
.getContentLength() + ")!");
|
.getContentLength() + ")!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +285,7 @@ public interface UpdateHandler {
|
|||||||
return "<EMPTY!>";
|
return "<EMPTY!>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetToken.length() <= MINIMUM_TOKENLENGTH_FOR_HINT) {
|
if (targetToken.length() <= MINIMUM_TOKEN_LENGTH_FOR_HINT) {
|
||||||
return "***";
|
return "***";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,16 +326,14 @@ public interface UpdateHandler {
|
|||||||
public void read(final byte[] buff, final int len) {
|
public void read(final byte[] buff, final int len) {
|
||||||
read += len;
|
read += len;
|
||||||
if (read > size) {
|
if (read > size) {
|
||||||
throw new SecurityException("Size mismatch: read more " +
|
throw new SecurityException("Size mismatch: read more " + EXPECTED + size + BUT_GOT_LOG_MESSAGE + read + ")!");
|
||||||
"(Expected: " + size + BUT_GOT_LOG_MESSAGE + read + ")!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() {
|
public void validate() {
|
||||||
if (read != size) {
|
if (read != size) {
|
||||||
throw new SecurityException("Size mismatch " +
|
throw new SecurityException("Size mismatch " + EXPECTED + size + BUT_GOT_LOG_MESSAGE + read + ")!");
|
||||||
"(Expected: " + size + BUT_GOT_LOG_MESSAGE + read + ")!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -360,8 +359,7 @@ public interface UpdateHandler {
|
|||||||
final String actual = BaseEncoding.base16().lowerCase().encode(messageDigest.digest());
|
final String actual = BaseEncoding.base16().lowerCase().encode(messageDigest.digest());
|
||||||
if (!actual.equals(expected)) {
|
if (!actual.equals(expected)) {
|
||||||
throw new SecurityException(
|
throw new SecurityException(
|
||||||
messageDigest.getAlgorithm() + " hash mismatch " +
|
messageDigest.getAlgorithm() + " hash mismatch " + EXPECTED + expected + BUT_GOT_LOG_MESSAGE + actual + ")!");
|
||||||
"(Expected: " + expected + BUT_GOT_LOG_MESSAGE + actual + ")!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user