|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2015 the original author or authors. |
| 2 | + * Copyright 2002-2020 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
16 | 16 |
|
17 | 17 | package org.springframework.security.web.context.support;
|
18 | 18 |
|
19 |
| -import java.util.Enumeration; |
20 |
| - |
21 | 19 | import javax.servlet.ServletContext;
|
22 | 20 |
|
23 | 21 | import org.springframework.util.Assert;
|
@@ -48,32 +46,11 @@ public abstract class SecurityWebApplicationContextUtils extends WebApplicationC
|
48 | 46 | * @see ServletContext#getAttributeNames()
|
49 | 47 | */
|
50 | 48 | public static WebApplicationContext findRequiredWebApplicationContext(ServletContext servletContext) {
|
51 |
| - WebApplicationContext webApplicationContext = compatiblyFindWebApplicationContext(servletContext); |
| 49 | + WebApplicationContext webApplicationContext = findWebApplicationContext(servletContext); |
52 | 50 | Assert.state(webApplicationContext != null,
|
53 | 51 | "No WebApplicationContext found: no ContextLoaderListener registered?");
|
54 | 52 | return webApplicationContext;
|
55 | 53 | }
|
56 | 54 |
|
57 |
| - /** |
58 |
| - * Copy of {@link #findWebApplicationContext(ServletContext)} for compatibility with |
59 |
| - * spring framework 4.1.x. |
60 |
| - * @see #findWebApplicationContext(ServletContext) |
61 |
| - */ |
62 |
| - private static WebApplicationContext compatiblyFindWebApplicationContext(ServletContext sc) { |
63 |
| - WebApplicationContext webApplicationContext = getWebApplicationContext(sc); |
64 |
| - if (webApplicationContext == null) { |
65 |
| - Enumeration<String> attrNames = sc.getAttributeNames(); |
66 |
| - while (attrNames.hasMoreElements()) { |
67 |
| - String attrName = attrNames.nextElement(); |
68 |
| - Object attrValue = sc.getAttribute(attrName); |
69 |
| - if (attrValue instanceof WebApplicationContext) { |
70 |
| - Assert.state(webApplicationContext == null, "No unique WebApplicationContext found: more than one " |
71 |
| - + "DispatcherServlet registered with publishContext=true?"); |
72 |
| - webApplicationContext = (WebApplicationContext) attrValue; |
73 |
| - } |
74 |
| - } |
75 |
| - } |
76 |
| - return webApplicationContext; |
77 |
| - } |
78 | 55 |
|
79 | 56 | }
|
0 commit comments