From ba4682c0e0b8ed41959e7427ad779e836062dbbe Mon Sep 17 00:00:00 2001 From: Lubos Racansky Date: Thu, 29 Sep 2022 13:48:13 +0200 Subject: [PATCH] Fix #404: Utility classes should not have public constructors https://rules.sonarsource.com/java/RSPEC-1118 --- .../wultra/app/onboardingserver/impl/util/DateUtil.java | 6 +++++- .../app/onboardingserver/impl/util/PowerAuthUtil.java | 8 ++++++-- .../statemachine/util/StateContextUtil.java | 8 ++++++-- .../src/test/java/com/wultra/app/test/TestUtil.java | 8 ++++++-- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/enrollment-server-onboarding/src/main/java/com/wultra/app/onboardingserver/impl/util/DateUtil.java b/enrollment-server-onboarding/src/main/java/com/wultra/app/onboardingserver/impl/util/DateUtil.java index 34e819c60..487723d3c 100644 --- a/enrollment-server-onboarding/src/main/java/com/wultra/app/onboardingserver/impl/util/DateUtil.java +++ b/enrollment-server-onboarding/src/main/java/com/wultra/app/onboardingserver/impl/util/DateUtil.java @@ -27,7 +27,11 @@ * * @author Roman Strobl, roman.strobl@wultra.com */ -public class DateUtil { +public final class DateUtil { + + private DateUtil() { + throw new IllegalStateException("Utility class"); + } /** * Convert expiration time interval to minimal created date used for expiration. diff --git a/enrollment-server-onboarding/src/main/java/com/wultra/app/onboardingserver/impl/util/PowerAuthUtil.java b/enrollment-server-onboarding/src/main/java/com/wultra/app/onboardingserver/impl/util/PowerAuthUtil.java index 254b835cb..bb4e82902 100644 --- a/enrollment-server-onboarding/src/main/java/com/wultra/app/onboardingserver/impl/util/PowerAuthUtil.java +++ b/enrollment-server-onboarding/src/main/java/com/wultra/app/onboardingserver/impl/util/PowerAuthUtil.java @@ -22,11 +22,15 @@ import io.getlime.security.powerauth.rest.api.spring.authentication.PowerAuthApiAuthentication; /** - * PowerAuth utilities + * PowerAuth utilities. * * @author Lukas Lukovsky, lukas.lukovsky@wultra.com */ -public class PowerAuthUtil { +public final class PowerAuthUtil { + + private PowerAuthUtil() { + throw new IllegalStateException("Utility class"); + } /** * Provides context data diff --git a/enrollment-server-onboarding/src/main/java/com/wultra/app/onboardingserver/statemachine/util/StateContextUtil.java b/enrollment-server-onboarding/src/main/java/com/wultra/app/onboardingserver/statemachine/util/StateContextUtil.java index 01323beac..8b45bac1e 100644 --- a/enrollment-server-onboarding/src/main/java/com/wultra/app/onboardingserver/statemachine/util/StateContextUtil.java +++ b/enrollment-server-onboarding/src/main/java/com/wultra/app/onboardingserver/statemachine/util/StateContextUtil.java @@ -27,11 +27,15 @@ import java.util.Map; /** - * State context util + * State context util. * * @author Lukas Lukovsky, lukas.lukovsky@wultra.com */ -public class StateContextUtil { +public final class StateContextUtil { + + private StateContextUtil() { + throw new IllegalStateException("Utility class"); + } public static void setResponseOk(final StateContext context, final Response response) { Preconditions.checkArgument( diff --git a/enrollment-server-onboarding/src/test/java/com/wultra/app/test/TestUtil.java b/enrollment-server-onboarding/src/test/java/com/wultra/app/test/TestUtil.java index e7f130284..59abb8a2d 100644 --- a/enrollment-server-onboarding/src/test/java/com/wultra/app/test/TestUtil.java +++ b/enrollment-server-onboarding/src/test/java/com/wultra/app/test/TestUtil.java @@ -24,11 +24,15 @@ import java.io.InputStream; /** - * Test utilities + * Test utilities. * * @author Lukas Lukovsky, lukas.lukovsky@wultra.com */ -public class TestUtil { +public final class TestUtil { + + private TestUtil() { + throw new IllegalStateException("Utility class"); + } /** * Loads photo from a file