Make MIN_SPRING_VERSION Dynamic
Fixes: gh-5065
This commit is contained in:
+21
-1
@@ -20,6 +20,9 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.SpringVersion;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Internal class used for checking version compatibility in a deployed application.
|
||||
*
|
||||
@@ -40,7 +43,7 @@ public class SpringSecurityCoreVersion {
|
||||
*/
|
||||
public static final long SERIAL_VERSION_UID = 510L;
|
||||
|
||||
static final String MIN_SPRING_VERSION = "5.0.4.RELEASE";
|
||||
static final String MIN_SPRING_VERSION = getSpringVersion();
|
||||
|
||||
static {
|
||||
performVersionChecks();
|
||||
@@ -64,6 +67,9 @@ public class SpringSecurityCoreVersion {
|
||||
* @param minSpringVersion
|
||||
*/
|
||||
private static void performVersionChecks(String minSpringVersion) {
|
||||
if (minSpringVersion == null) {
|
||||
return;
|
||||
}
|
||||
// Check Spring Compatibility
|
||||
String springVersion = SpringVersion.getVersion();
|
||||
String version = getVersion();
|
||||
@@ -95,4 +101,18 @@ public class SpringSecurityCoreVersion {
|
||||
}
|
||||
return Boolean.getBoolean(DISABLE_CHECKS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the spring version or null if it cannot be found.
|
||||
* @return
|
||||
*/
|
||||
private static String getSpringVersion() {
|
||||
Properties properties = new Properties();
|
||||
try {
|
||||
properties.load(SpringSecurityCoreVersion.class.getClassLoader().getResourceAsStream("META-INF/spring-security.versions"));
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
return properties.getProperty("org.springframework:spring-core");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user