use of org.springframework.security.ITargetObject in project spring-security by spring-projects.
the class MethodSecurityInterceptorWithAopConfigTests method securityInterceptorIsAppliedWhenUsedWithAopConfig.
@Test(expected = AuthenticationCredentialsNotFoundException.class)
public void securityInterceptorIsAppliedWhenUsedWithAopConfig() {
setContext("<aop:config>" + " <aop:pointcut id='targetMethods' expression='execution(* org.springframework.security.TargetObject.*(..))'/>" + " <aop:advisor advice-ref='securityInterceptor' pointcut-ref='targetMethods' />" + "</aop:config>" + TARGET_BEAN_AND_INTERCEPTOR + AUTH_PROVIDER_XML + ACCESS_MANAGER_XML);
ITargetObject target = (ITargetObject) appContext.getBean("target");
// Check both against interface and class
try {
target.makeLowerCase("TEST");
fail("AuthenticationCredentialsNotFoundException expected");
} catch (AuthenticationCredentialsNotFoundException expected) {
}
target.makeUpperCase("test");
}
use of org.springframework.security.ITargetObject in project spring-security by spring-projects.
the class MethodSecurityInterceptorWithAopConfigTests method securityInterceptorIsAppliedWhenUsedWithBeanNameAutoProxyCreator.
@Test(expected = AuthenticationCredentialsNotFoundException.class)
public void securityInterceptorIsAppliedWhenUsedWithBeanNameAutoProxyCreator() {
setContext("<b:bean id='autoProxyCreator' class='org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator'>" + " <b:property name='interceptorNames'>" + " <b:list>" + " <b:value>securityInterceptor</b:value>" + " </b:list>" + " </b:property>" + " <b:property name='beanNames'>" + " <b:list>" + " <b:value>target</b:value>" + " </b:list>" + " </b:property>" + " <b:property name='proxyTargetClass' value='false'/>" + "</b:bean>" + TARGET_BEAN_AND_INTERCEPTOR + AUTH_PROVIDER_XML + ACCESS_MANAGER_XML);
ITargetObject target = (ITargetObject) appContext.getBean("target");
try {
target.makeLowerCase("TEST");
fail("AuthenticationCredentialsNotFoundException expected");
} catch (AuthenticationCredentialsNotFoundException expected) {
}
target.makeUpperCase("test");
}
use of org.springframework.security.ITargetObject in project spring-security by spring-projects.
the class MethodSecurityInterceptorTests method createTarget.
private void createTarget(boolean useMock) {
realTarget = useMock ? mock(ITargetObject.class) : new TargetObject();
ProxyFactory pf = new ProxyFactory(realTarget);
pf.addAdvice(interceptor);
advisedTarget = (ITargetObject) pf.getProxy();
}
Aggregations