11/*
2- * Copyright 2009-2020 the original author or authors.
2+ * Copyright 2009-2021 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1616
1717package org .springframework .security .config .util ;
1818
19- import java .io .IOException ;
20- import java .io .InputStream ;
21- import java .util .Properties ;
22-
2319import org .springframework .beans .factory .support .DefaultListableBeanFactory ;
2420import org .springframework .context .ApplicationContext ;
2521import org .springframework .context .support .AbstractXmlApplicationContext ;
2622import org .springframework .core .io .Resource ;
27- import org .springframework .security .core .SpringSecurityCoreVersion ;
2823import org .springframework .security .util .InMemoryResource ;
2924
3025/**
3429 */
3530public class InMemoryXmlApplicationContext extends AbstractXmlApplicationContext {
3631
37- private static String getCurrentXSDVersionFromSpringSchemas () {
38- Properties properties = new Properties ();
39- try (InputStream is = SpringSecurityCoreVersion .class .getClassLoader ()
40- .getResourceAsStream ("META-INF/spring.schemas" )) {
41- properties .load (is );
42- }
43- catch (IOException ex ) {
44- throw new RuntimeException ("Could not read 'META-INF/spring.schemas'" , ex );
45- }
46-
47- String inPackageLocation = properties
48- .getProperty ("https://www.springframework.org/schema/security/spring-security.xsd" );
49- String [] parts = inPackageLocation .split ("-" );
50- String currentXSD = parts [parts .length - 1 ];
51- String currentVersion = currentXSD .replace (".xsd" , "" );
52- return currentVersion ;
53- }
54-
5532 static final String BEANS_OPENING = "<b:beans xmlns='http://www.springframework.org/schema/security'\n "
5633 + " xmlns:context='http://www.springframework.org/schema/context'\n "
5734 + " xmlns:b='http://www.springframework.org/schema/beans'\n "
@@ -66,7 +43,7 @@ private static String getCurrentXSDVersionFromSpringSchemas() {
6643 + "http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context-2.5.xsd\n "
6744 + "http://www.springframework.org/schema/security https://www.springframework.org/schema/security/spring-security-" ;
6845 static final String BEANS_CLOSE = "</b:beans>\n " ;
69- static final String SPRING_SECURITY_VERSION = getCurrentXSDVersionFromSpringSchemas ();
46+ static final String SPRING_SECURITY_VERSION = SpringSecurityVersions . getCurrentXsdVersionFromSpringSchemas ();
7047
7148 Resource inMemoryXml ;
7249
0 commit comments