Hello,
I have just wired up Shiro using Spring JavaConfig (no xml - Spring
3.0.1)...
This is how it looks:
NOTE: Change the realm to your own - I just have a simple PIN based security
realm for my app
If anyone spots any issues/improvements let me know
@Configuration
public class SecurityConfig {
@Bean
public PinAccountRealm pinAccountRealm(){
return new PinAccountRealm();
}
@Bean
public SecurityManager securityManager(){
DefaultSecurityManager securityManager = new
DefaultSecurityManager();
securityManager.setRealm(pinAccountRealm());
return securityManager;
}
@Bean
public LifecycleBeanPostProcessor lifecycleBeanPostProcessor(){
return new LifecycleBeanPostProcessor();
}
@Bean
public MethodInvokingFactoryBean methodInvokingFactoryBean(){
MethodInvokingFactoryBean methodInvokingFactoryBean = new
MethodInvokingFactoryBean();
methodInvokingFactoryBean.setStaticMethod("org.apache.shiro.SecurityUtils.setSecurityManager");
methodInvokingFactoryBean.setArguments(new
Object[]{securityManager()});
return methodInvokingFactoryBean;
}
@Bean
@DependsOn(value="lifecycleBeanPostProcessor")
public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator(){
return new DefaultAdvisorAutoProxyCreator();
}
@Bean
public AuthorizationAttributeSourceAdvisor
authorizationAttributeSourceAdvisor(){
AuthorizationAttributeSourceAdvisor
authorizationAttributeSourceAdvisor =
new AuthorizationAttributeSourceAdvisor();
authorizationAttributeSourceAdvisor.setSecurityManager(securityManager());
return authorizationAttributeSourceAdvisor;
}
--
View this message in context:
http://n2.nabble.com/Spring-JavaConfig-tp4704383p4704383.html
Sent from the Shiro User mailing list archive at Nabble.com.