Browse Source
Previously a NoSuchBeanDefintionException was thrown when the MethodSecurityExpressionHandler was defined in the parent context. This happened due to trying to work around ordering issues related to SEC-2136 This commit resolves this by not marking the MethodSecurityExpressionHandler bean as lazy unless it exists.pull/80/head
4 changed files with 74 additions and 0 deletions
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
/* |
||||
* Copyright 2002-2014 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.springframework.security.config.method.sec2499; |
||||
|
||||
import org.junit.After; |
||||
import org.junit.Test; |
||||
import org.springframework.context.support.GenericXmlApplicationContext; |
||||
|
||||
/** |
||||
* |
||||
* @author Rob Winch |
||||
* |
||||
*/ |
||||
public class Sec2499Tests { |
||||
private GenericXmlApplicationContext parent; |
||||
|
||||
private GenericXmlApplicationContext child; |
||||
|
||||
@After |
||||
public void cleanup() { |
||||
if(parent != null) { |
||||
parent.close(); |
||||
} |
||||
if(child != null) { |
||||
child.close(); |
||||
} |
||||
} |
||||
|
||||
@Test |
||||
public void methodExpressionHandlerInParentContextLoads() { |
||||
parent = new GenericXmlApplicationContext("org/springframework/security/config/method/sec2499/parent.xml"); |
||||
child = new GenericXmlApplicationContext(); |
||||
child.load("org/springframework/security/config/method/sec2499/child.xml"); |
||||
child.setParent(parent); |
||||
child.refresh(); |
||||
} |
||||
} |
||||
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<b:beans xmlns:b="http://www.springframework.org/schema/beans" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xmlns="http://www.springframework.org/schema/security" |
||||
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd |
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> |
||||
|
||||
<global-method-security pre-post-annotations="enabled"> |
||||
<expression-handler ref="expressionHandler"/> |
||||
</global-method-security> |
||||
|
||||
</b:beans> |
||||
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<beans xmlns="http://www.springframework.org/schema/beans" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> |
||||
|
||||
<bean id="expressionHandler" |
||||
class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler"/> |
||||
|
||||
</beans> |
||||
Loading…
Reference in new issue