Search in sources :

Example 1 with RunAsManagerImpl

use of org.springframework.security.access.intercept.RunAsManagerImpl in project spring-security by spring-projects.

the class GlobalMethodSecurityBeanDefinitionParserTests method runAsManagerIsSetCorrectly.

@Test
public void runAsManagerIsSetCorrectly() throws Exception {
    StaticApplicationContext parent = new StaticApplicationContext();
    MutablePropertyValues props = new MutablePropertyValues();
    props.addPropertyValue("key", "blah");
    parent.registerSingleton("runAsMgr", RunAsManagerImpl.class, props);
    parent.refresh();
    setContext("<global-method-security run-as-manager-ref='runAsMgr'/>" + AUTH_PROVIDER_XML, parent);
    RunAsManagerImpl ram = (RunAsManagerImpl) appContext.getBean("runAsMgr");
    MethodSecurityMetadataSourceAdvisor msi = (MethodSecurityMetadataSourceAdvisor) appContext.getBeansOfType(MethodSecurityMetadataSourceAdvisor.class).values().toArray()[0];
    assertThat(ram).isSameAs(FieldUtils.getFieldValue(msi.getAdvice(), "runAsManager"));
}
Also used : MethodSecurityMetadataSourceAdvisor(org.springframework.security.access.intercept.aopalliance.MethodSecurityMetadataSourceAdvisor) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) MutablePropertyValues(org.springframework.beans.MutablePropertyValues) RunAsManagerImpl(org.springframework.security.access.intercept.RunAsManagerImpl) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 MutablePropertyValues (org.springframework.beans.MutablePropertyValues)1 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)1 RunAsManagerImpl (org.springframework.security.access.intercept.RunAsManagerImpl)1 MethodSecurityMetadataSourceAdvisor (org.springframework.security.access.intercept.aopalliance.MethodSecurityMetadataSourceAdvisor)1