use of org.apache.shiro.web.mgt.DefaultWebSecurityManager in project Ganster-CMS by Gangster-trio.
the class ShiroConfig method securityManager.
@Bean(name = "securityManager")
public SecurityManager securityManager() {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
// 设置realm
securityManager.setRealm(shiroRealm());
return securityManager;
}
use of org.apache.shiro.web.mgt.DefaultWebSecurityManager in project dropwizard-shiro by silb.
the class ShiroBundle method createFilter.
/**
* Create the Shiro filter. Overriding this method allows for complete customization of how Shiro is initialized.
*/
protected Filter createFilter(final T configuration) {
ShiroConfiguration shiroConfig = narrow(configuration);
final IniWebEnvironment shiroEnv = new IniWebEnvironment();
shiroEnv.setConfigLocations(shiroConfig.iniConfigs());
shiroEnv.init();
AbstractShiroFilter shiroFilter = new AbstractShiroFilter() {
@Override
public void init() throws Exception {
Collection<Realm> realms = createRealms(configuration);
WebSecurityManager securityManager = realms.isEmpty() ? shiroEnv.getWebSecurityManager() : new DefaultWebSecurityManager(realms);
setSecurityManager(securityManager);
setFilterChainResolver(shiroEnv.getFilterChainResolver());
}
};
return shiroFilter;
}
use of org.apache.shiro.web.mgt.DefaultWebSecurityManager in project wechat by dllwh.
the class ShiroConfig method securityManager.
/**
* @方法描述 : Shiro安全管理配置
* @return
*/
// @Bean("securityManager")
public DefaultWebSecurityManager securityManager() {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
// 自定义realm
securityManager.setRealm(shiroRealm());
// 自定义缓存实现 使用redis
// securityManager.setCacheManager(cacheManager());
// securityManager.setRememberMeManager(rememberMeManager);
// 自定义session管理 使用redis
securityManager.setSessionManager(sessionManager());
return securityManager;
}
use of org.apache.shiro.web.mgt.DefaultWebSecurityManager in project shiro by apache.
the class SampleShiroServletModule method bindWebSecurityManager.
@Override
protected void bindWebSecurityManager(AnnotatedBindingBuilder<? super WebSecurityManager> bind) {
try {
String cipherKey = loadShiroIni().getSectionProperty("main", "securityManager.rememberMeManager.cipherKey");
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
CookieRememberMeManager rememberMeManager = new CookieRememberMeManager();
rememberMeManager.setCipherKey(Base64.decode(cipherKey));
securityManager.setRememberMeManager(rememberMeManager);
bind.toInstance(securityManager);
} catch (MalformedURLException e) {
// super.bindWebSecurityManager(bind) if you do not need rememberMe functionality
throw new ConfigurationException("securityManager.rememberMeManager.cipherKey must be set in shiro.ini.");
}
}
use of org.apache.shiro.web.mgt.DefaultWebSecurityManager in project shiro by apache.
the class ShiroWebModuleTest method basicInstantiation.
@Test
public void basicInstantiation() {
final ShiroModuleTest.MockRealm mockRealm = createMock(ShiroModuleTest.MockRealm.class);
ServletContext servletContext = createMock(ServletContext.class);
Injector injector = Guice.createInjector(new ShiroWebModule(servletContext) {
@Override
protected void configureShiroWeb() {
bindRealm().to(ShiroModuleTest.MockRealm.class);
expose(SessionManager.class);
}
@Provides
public ShiroModuleTest.MockRealm createRealm() {
return mockRealm;
}
});
// we're not getting a WebSecurityManager here b/c it's not exposed. There didn't seem to be a good reason to
// expose it outside of the Shiro module.
SecurityManager securityManager = injector.getInstance(SecurityManager.class);
assertNotNull(securityManager);
assertTrue(securityManager instanceof WebSecurityManager);
SessionManager sessionManager = injector.getInstance(SessionManager.class);
assertNotNull(sessionManager);
assertTrue(sessionManager instanceof ServletContainerSessionManager);
assertTrue(((DefaultWebSecurityManager) securityManager).getSessionManager() instanceof ServletContainerSessionManager);
}
Aggregations