Hide utility class constructors
Update all utility classes so that they have a private constructor. This prevents users from accidentally creating an instance, when they should just use the static methods directly. Issue gh-8945
This commit is contained in:
@@ -22,6 +22,9 @@ import org.springframework.expression.Expression;
|
||||
|
||||
public final class ExpressionUtils {
|
||||
|
||||
private ExpressionUtils() {
|
||||
}
|
||||
|
||||
public static boolean evaluateAsBoolean(Expression expr, EvaluationContext ctx) {
|
||||
try {
|
||||
return expr.getValue(ctx, Boolean.class);
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.util.Assert;
|
||||
* @author Josh Cummings
|
||||
* @since 5.2
|
||||
*/
|
||||
public class RsaKeyConverters {
|
||||
public final class RsaKeyConverters {
|
||||
|
||||
private static final String DASHES = "-----";
|
||||
|
||||
@@ -50,6 +50,9 @@ public class RsaKeyConverters {
|
||||
|
||||
private static final String X509_PEM_FOOTER = DASHES + "END PUBLIC KEY" + DASHES;
|
||||
|
||||
private RsaKeyConverters() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a {@link Converter} for converting a PEM-encoded PKCS#8 RSA Private Key
|
||||
* into a {@link RSAPrivateKey}.
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.core.SpringVersion;
|
||||
* @author Luke Taylor
|
||||
* @author Rob Winch
|
||||
*/
|
||||
public class SpringSecurityCoreVersion {
|
||||
public final class SpringSecurityCoreVersion {
|
||||
|
||||
private static final String DISABLE_CHECKS = SpringSecurityCoreVersion.class.getName().concat(".DISABLE_CHECKS");
|
||||
|
||||
@@ -50,6 +50,9 @@ public class SpringSecurityCoreVersion {
|
||||
performVersionChecks();
|
||||
}
|
||||
|
||||
private SpringSecurityCoreVersion() {
|
||||
}
|
||||
|
||||
public static String getVersion() {
|
||||
Package pkg = SpringSecurityCoreVersion.class.getPackage();
|
||||
return (pkg != null ? pkg.getImplementationVersion() : null);
|
||||
|
||||
@@ -29,10 +29,13 @@ import org.springframework.security.core.Authentication;
|
||||
* @author Rob Winch
|
||||
* @since 5.0
|
||||
*/
|
||||
public class ReactiveSecurityContextHolder {
|
||||
public final class ReactiveSecurityContextHolder {
|
||||
|
||||
private static final Class<?> SECURITY_CONTEXT_KEY = SecurityContext.class;
|
||||
|
||||
private ReactiveSecurityContextHolder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@code Mono<SecurityContext>} from Reactor {@link Context}
|
||||
* @return the {@code Mono<SecurityContext>}
|
||||
|
||||
@@ -29,6 +29,9 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public final class FieldUtils {
|
||||
|
||||
private FieldUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to locate the specified field on the class.
|
||||
* @param clazz the class definition containing the field
|
||||
|
||||
@@ -35,6 +35,9 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public final class MethodInvocationUtils {
|
||||
|
||||
private MethodInvocationUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a <code>MethodInvocation</code> for specified <code>methodName</code> on
|
||||
* the passed object, using the <code>args</code> to locate the method.
|
||||
|
||||
Reference in New Issue
Block a user