org.apache.shiro.mgt.DefaultSubjectDAO Java Examples
The following examples show how to use
org.apache.shiro.mgt.DefaultSubjectDAO.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShiroAuthConfig.java From Moss with Apache License 2.0 | 6 votes |
@Bean("securityManager") public DefaultWebSecurityManager getManager(UserService userService) { DefaultWebSecurityManager manager = new DefaultWebSecurityManager(); List<Realm> realms = Lists.newArrayList(); realms.add(new DBRealm(userService)); manager.setRealms(realms); /* * 关闭shiro自带的session,详情见文档 * http://shiro.apache.org/session-management.html#SessionManagement-StatelessApplications%28Sessionless%29 */ DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO(); DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator(); defaultSessionStorageEvaluator.setSessionStorageEnabled(false); subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator); manager.setSubjectDAO(subjectDAO); return manager; }
Example #2
Source File: ShiroConfig.java From web-flash with MIT License | 6 votes |
@Bean("securityManager") public DefaultWebSecurityManager getManager(ApiRealm realm) { DefaultWebSecurityManager manager = new DefaultWebSecurityManager(); // 使用自己的realm manager.setRealm(realm); /* * 关闭shiro自带的session,详情见文档 * http://shiro.apache.org/session-management.html#SessionManagement-StatelessApplications%28Sessionless%29 */ DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO(); DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator(); defaultSessionStorageEvaluator.setSessionStorageEnabled(false); subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator); manager.setSubjectDAO(subjectDAO); return manager; }
Example #3
Source File: ShiroConfig.java From flash-waimai with MIT License | 6 votes |
@Bean("securityManager") public DefaultWebSecurityManager getManager(ApiRealm realm) { DefaultWebSecurityManager manager = new DefaultWebSecurityManager(); // 使用自己的realm manager.setRealm(realm); /* * 关闭shiro自带的session,详情见文档 * http://shiro.apache.org/session-management.html#SessionManagement-StatelessApplications%28Sessionless%29 */ DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO(); DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator(); defaultSessionStorageEvaluator.setSessionStorageEnabled(false); subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator); manager.setSubjectDAO(subjectDAO); return manager; }
Example #4
Source File: ShiroManager.java From shiro-spring-boot-starter with Apache License 2.0 | 6 votes |
@Bean(name = "securityManager") @ConditionalOnMissingBean public DefaultSecurityManager securityManager(CacheManager shiroCacheManager) { DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager(); // 用自己的Factory实现替换默认 // 用于关闭session功能 dwsm.setSubjectFactory(new StatelessSubjectFactory()); dwsm.setSessionManager(defaultSessionManager()); // 关闭session存储 ((DefaultSessionStorageEvaluator) ((DefaultSubjectDAO)dwsm.getSubjectDAO()).getSessionStorageEvaluator()).setSessionStorageEnabled(false); // <!-- 用户授权/认证信息Cache, 采用EhCache 缓存 --> dwsm.setCacheManager(shiroCacheManager); SecurityUtils.setSecurityManager(dwsm); return dwsm; }
Example #5
Source File: ShiroConfig.java From fastdep with Apache License 2.0 | 5 votes |
/** * securityManager * * @param authorizingRealm AuthorizingRealm bean * @return securityManager */ @Bean("securityManager") @ConditionalOnMissingBean(SecurityManager.class) public DefaultWebSecurityManager getManager(AuthorizingRealm authorizingRealm) { DefaultWebSecurityManager manager = new DefaultWebSecurityManager(); manager.setRealm(authorizingRealm); DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO(); DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator(); defaultSessionStorageEvaluator.setSessionStorageEnabled(false); subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator); manager.setSubjectDAO(subjectDAO); return manager; }
Example #6
Source File: ShiroConfiguration.java From watchdog-framework with MIT License | 5 votes |
@Bean public SecurityManager securityManager(RedisCacheManager RedisCacheManager){ DefaultWebSecurityManager manager = new DefaultWebSecurityManager(); manager.setRealm(myRealm()); manager.setCacheManager(RedisCacheManager); /* * 关闭session存储,禁用Session作为存储策略的实现, * 但它没有完全地禁用Session所以需要配合SubjectFactory中的context.setSessionCreationEnabled(false) */ //manager.setSessionManager(sessionManager()); ((DefaultSessionStorageEvaluator) ((DefaultSubjectDAO)manager.getSubjectDAO()) .getSessionStorageEvaluator()).setSessionStorageEnabled(false); manager.setSubjectFactory(new AgileSubjectFactory()); return manager; }
Example #7
Source File: TapestryRealmSecurityManager.java From tapestry-security with Apache License 2.0 | 5 votes |
public TapestryRealmSecurityManager(Authenticator authenticator, SubjectFactory subjectFactory, RememberMeManager rememberMeManager, final Collection<Realm> realms) { super(); authenticator.setRealms(realms); setAuthenticator(authenticator); ((DefaultSubjectDAO) this.subjectDAO).setSessionStorageEvaluator(new DefaultWebSessionStorageEvaluator()); setSubjectFactory(subjectFactory); setRememberMeManager(rememberMeManager); setSessionManager(new ServletContainerSessionManager()); setRealms(realms); }
Example #8
Source File: SecurityGuiceConfigurer.java From seed with Mozilla Public License 2.0 | 5 votes |
public void configure(Binder binder) { // Subject SecurityConfig.SubjectConfig subjectConfig = securityConfig.subject(); Optional.ofNullable(subjectConfig.getContext()).ifPresent(c -> binder.bind(SubjectContext.class).to(c)); Optional.ofNullable(subjectConfig.getFactory()).ifPresent(f -> binder.bind(SubjectFactory.class).to(f)); Class<? extends SubjectDAO> subjectDao = subjectConfig.getDao(); binder.bind(SubjectDAO.class).to(subjectDao != null ? subjectDao : DefaultSubjectDAO.class); // Authentication SecurityConfig.AuthenticationConfig authenticationConfig = securityConfig.authentication(); binder.bind(Authenticator.class).to(authenticationConfig.getAuthenticator()); binder.bind(AuthenticationStrategy.class).to(authenticationConfig.getStrategy()); binder.bind(CredentialsMatcher.class).to(authenticationConfig.getCredentialsMatcher()); // Cache configuration SecurityConfig.CacheConfig cacheConfig = securityConfig.cache(); binder.bind(CacheManager.class).to(cacheConfig.getManager()); // Sessions SecurityConfig.SessionConfig sessionConfig = securityConfig.sessions(); binder.bind(SessionStorageEvaluator.class).to(sessionConfig.getStorageEvaluator()); Optional.ofNullable(sessionConfig.getValidationScheduler()) .ifPresent(s -> binder.bind(SessionValidationScheduler.class).to(s)); binder.bindConstant() .annotatedWith(Names.named("shiro.sessionValidationInterval")) .to(sessionConfig.getValidationInterval() * 1000); binder.bindConstant() .annotatedWith(Names.named("shiro.globalSessionTimeout")) .to(sessionConfig.getTimeout() * 1000); }
Example #9
Source File: ShiroConfig.java From spring-boot-plus with Apache License 2.0 | 4 votes |
@Bean public DefaultSubjectDAO subjectDAO() { DefaultSubjectDAO defaultSubjectDAO = new DefaultSubjectDAO(); defaultSubjectDAO.setSessionStorageEvaluator(sessionStorageEvaluator()); return defaultSubjectDAO; }