1
0
mirror of synced 2026-08-05 17:57:15 +00:00

Make MIN_SPRING_VERSION Dynamic

Fixes: gh-5065
This commit is contained in:
Rob Winch
2018-03-16 13:53:40 -05:00
parent e86becc151
commit efaf2b080f
3 changed files with 81 additions and 1 deletions
@@ -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");
}
}