本文整理汇总了Java中org.apache.shiro.web.mgt.CookieRememberMeManager类的典型用法代码示例。如果您正苦于以下问题:Java CookieRememberMeManager类的具体用法?Java CookieRememberMeManager怎么用?Java CookieRememberMeManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CookieRememberMeManager类属于org.apache.shiro.web.mgt包,在下文中一共展示了CookieRememberMeManager类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rememberMeManager
import org.apache.shiro.web.mgt.CookieRememberMeManager; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(RememberMeManager.class)
public RememberMeManager rememberMeManager(Cookie cookie) {
CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager();
cookieRememberMeManager.setCookie(cookie);
cookieRememberMeManager.setCipherService(cipherService);
if (shiroCookieProperties.getCipherKey() != null) {
cookieRememberMeManager.setCipherKey(shiroCookieProperties.getCipherKey().getBytes());
} else {
if (shiroCookieProperties.getEncryptionCipherKey() != null) {
cookieRememberMeManager.setEncryptionCipherKey(shiroCookieProperties.getEncryptionCipherKey().getBytes());
}
if (shiroCookieProperties.getDecryptionCipherKey() != null) {
cookieRememberMeManager.setDecryptionCipherKey(shiroCookieProperties.getDecryptionCipherKey().getBytes());
}
}
cookieRememberMeManager.setSerializer(serializer);
return cookieRememberMeManager;
}
示例2: rememberMeManager
import org.apache.shiro.web.mgt.CookieRememberMeManager; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(RememberMeManager.class)
public RememberMeManager rememberMeManager(Cookie cookie) {
CookieRememberMeManager manager = new CookieRememberMeManager();
manager.setCookie(cookie);
manager.setCipherService(cipherService);
if (null != shiroCookieProperties.getCipherKey()) {
manager.setCipherKey(shiroCookieProperties.getCipherKey().getBytes());
} else {
if (null != shiroCookieProperties.getEncryptionCipherKey()) {
manager.setEncryptionCipherKey(shiroCookieProperties.getEncryptionCipherKey().getBytes());
}
if (null != shiroCookieProperties.getDecryptionCipherKey()) {
manager.setDecryptionCipherKey(shiroCookieProperties.getDecryptionCipherKey().getBytes());
}
}
manager.setSerializer(serializer);
return manager;
}
示例3: webSecurityManager
import org.apache.shiro.web.mgt.CookieRememberMeManager; //导入依赖的package包/类
@Bean
public DefaultWebSecurityManager webSecurityManager(Realm realm,
CookieRememberMeManager rememberMeManager,
DefaultWebSessionManager sessionManager,
EhCacheManager ehCacheManager) {
DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
defaultWebSecurityManager.setRealm(realm);
defaultWebSecurityManager.setRememberMeManager(rememberMeManager);
defaultWebSecurityManager.setSessionManager(sessionManager);
defaultWebSecurityManager.setCacheManager(ehCacheManager);
return defaultWebSecurityManager;
}
示例4: SimpleWebSecurityManager
import org.apache.shiro.web.mgt.CookieRememberMeManager; //导入依赖的package包/类
public SimpleWebSecurityManager() {
super();
super.setSubjectDAO(new SubjectDAOImpl());
((DefaultSubjectDAO) this.subjectDAO)
.setSessionStorageEvaluator(new SimpleWebSessionStorageEvaluator());
setSubjectFactory(new DefaultWebSubjectFactory());
setRememberMeManager(new CookieRememberMeManager());
setSessionManager(new ServletContainerSessionManager());
}
示例5: getSecurityManager
import org.apache.shiro.web.mgt.CookieRememberMeManager; //导入依赖的package包/类
/**
* @return the default security manager for this application
*/
@Produces
public WebSecurityManager getSecurityManager() {
if (this.securityManager == null) {
// creates a custom security realm
final AuthorizingRealm realm
= new SecurityRealm(this.accountService);
// instantiate the custom password matcher based on bcrypt
final PasswordMatcher passwordMatcher = new PasswordMatcher();
passwordMatcher.setPasswordService(new BCryptPasswordService());
realm.setCredentialsMatcher(passwordMatcher);
// create the security manager
this.securityManager = new DefaultWebSecurityManager(realm);
// enable the remember me function based on cookies
final CookieRememberMeManager rememberMeManager
= new CookieRememberMeManager();
rememberMeManager.setCipherKey(this.createCypherKey());
this.securityManager.setRememberMeManager(rememberMeManager);
this.securityManager.setCacheManager(new MemoryConstrainedCacheManager());
}
return this.securityManager;
}
示例6: rememberMeManager
import org.apache.shiro.web.mgt.CookieRememberMeManager; //导入依赖的package包/类
@Bean
public CookieRememberMeManager rememberMeManager() {
final CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager();
cookieRememberMeManager.setCipherKey(Base64.decode("ZUdsaGJuSmxibVI2ZHc9PQ=="));
cookieRememberMeManager.setCookie(rememberMeCookie());
return cookieRememberMeManager;
}
示例7: provideRememberMeManager
import org.apache.shiro.web.mgt.CookieRememberMeManager; //导入依赖的package包/类
@Singleton
@Provides
RememberMeManager provideRememberMeManager() {
return new CookieRememberMeManager();
}
示例8: initialize
import org.apache.shiro.web.mgt.CookieRememberMeManager; //导入依赖的package包/类
@Override
public boolean initialize(SilentGo me) throws AppBuildException {
ShiroConfig config = (ShiroConfig) me.getConfig().getConfig(Name);
me.getFactory(CacheFactory.class);
PropKit prop = me.getConfig().getUserProp();
RetryLimitHashedCredentialsMatcher retryLimitHashedCredentialsMatcher = new RetryLimitHashedCredentialsMatcher();
retryLimitHashedCredentialsMatcher.setHashAlgorithmName(prop.getValue(Dict.SHIRO_CREDENTIALS_MATCHER_HASHALGORITHMNAME, "md5"));
retryLimitHashedCredentialsMatcher.setHashIterations(prop.getInt(Dict.SHIRO_CREDENTIALS_MATCHER_HASHITERATIONS, 2));
retryLimitHashedCredentialsMatcher.setStoredCredentialsHexEncoded(prop.getBool(Dict.SHIRO_CREDENTIALS_MATCHER_STOREDCREDENTIALSHEXENCODED, true));
EhCacheManager ehCacheManager = new EhCacheManager();
EhCache cache = (EhCache) me.getConfig().getCacheManager();
ehCacheManager.setCacheManager(cache.getCacheManager());
JavaUuidSessionIdGenerator sessionIdGenerator = new JavaUuidSessionIdGenerator();
SimpleCookie sessionIdCookie = new SimpleCookie(prop.getValue(Dict.SHIRO_SESSION_COOKIENAME, "lc4e"));
sessionIdCookie.setMaxAge(prop.getInt(Dict.SHIRO_SESSION_IDCOOKIE_MAXAGE, -1));
sessionIdCookie.setHttpOnly(prop.getBool(Dict.SHIRO_SESSION_IDCOOKIE_HTTPONLY, true));
SimpleCookie rememberMeCookie = new SimpleCookie(prop.getValue(Dict.SHIRO_SESSION_REMEMBER_COOKIENAME, "rlc4e"));
rememberMeCookie.setHttpOnly(prop.getBool(Dict.SHIRO_SESSION_REMEMBER_ME_HTTPONLY, true));
rememberMeCookie.setMaxAge(prop.getInt(Dict.SHIRO_SESSION_REMEMBER_ME_MAXAGE, 2592000));
CookieRememberMeManager rememberMeManager = new CookieRememberMeManager();
rememberMeManager.setCipherKey(Base64.decode(prop.getValue(Dict.SECURITY_KEY, "4AvVhmFLUs0KTA3Kprsdag==")));
rememberMeManager.setCookie(rememberMeCookie);
EnterpriseCacheSessionDAO sessionDAO = new EnterpriseCacheSessionDAO();
sessionDAO.setActiveSessionsCacheName(prop.getValue(Dict.SHIRO_SESSION_ACTIVE_NAME, "shiro-activeSessionCache"));
sessionDAO.setSessionIdGenerator(sessionIdGenerator);
sessionDAO.setCacheManager(ehCacheManager);
config.getRealm().setCredentialsMatcher(retryLimitHashedCredentialsMatcher);
config.getRealm().setCachingEnabled(false);
config.getRealm().setCacheManager(ehCacheManager);
DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
sessionValidationScheduler = new QuartzSessionValidationScheduler(sessionManager);
sessionValidationScheduler.setSessionValidationInterval(prop.getLong(Dict.SHIRO_SESSION_VALIDATIONINTERVAL, 1800000L));
sessionManager.setGlobalSessionTimeout(prop.getLong(Dict.SHIRO_SESSION_GLOBALSESSIONTIMEOUT, 1800000L));
sessionManager.setSessionDAO(sessionDAO);
sessionManager.setSessionValidationInterval(prop.getLong(Dict.SHIRO_SESSION_VALIDATIONINTERVAL, 360000L));
sessionManager.setSessionValidationScheduler(sessionValidationScheduler);
sessionManager.setSessionIdCookieEnabled(prop.getBool(Dict.SHIRO_SESSION_IDCOOKIEENABLED, true));
sessionManager.setSessionIdCookie(sessionIdCookie);
sessionValidationScheduler.setSessionManager(sessionManager);
defaultWebSecurityManager = new DefaultWebSecurityManager(config.getRealm());
defaultWebSecurityManager.setCacheManager(ehCacheManager);
defaultWebSecurityManager.setRememberMeManager(rememberMeManager);
defaultWebSecurityManager.setSessionManager(sessionManager);
ServletContext servletContext = me.getContext();
ShiroLoader shiroLoader = new ShiroLoader();
shiroLoader.initEnvironment(servletContext);
WebEnvironment environment = (WebEnvironment) servletContext.getAttribute(ShiroLoader.ENVIRONMENT_ATTRIBUTE_KEY);
((MutableWebEnvironment) environment).setWebSecurityManager(defaultWebSecurityManager);
servletContext.setAttribute(ShiroLoader.ENVIRONMENT_ATTRIBUTE_KEY, environment);
return false;
}
示例9: rememberMeManager
import org.apache.shiro.web.mgt.CookieRememberMeManager; //导入依赖的package包/类
@Bean
public CookieRememberMeManager rememberMeManager() {
CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager();
cookieRememberMeManager.setCookie(rememberMeCookie());
return cookieRememberMeManager;
}
示例10: getSecurityManager
import org.apache.shiro.web.mgt.CookieRememberMeManager; //导入依赖的package包/类
/**
* @return the default security manager for this application
*/
@Produces
public WebSecurityManager getSecurityManager() {
if (this.securityManager == null) {
// creates a custom security realm
final AuthorizingRealm realm
= new SecurityRealm(this.accountService);
// instantiate the custom password matcher based on bcrypt
final PasswordMatcher passwordMatcher = new PasswordMatcher();
passwordMatcher.setPasswordService(new BCryptPasswordService());
realm.setCredentialsMatcher(passwordMatcher);
// create the security manager
this.securityManager = new DefaultWebSecurityManager(realm);
// enable the remember me function based on cookies
final CookieRememberMeManager rememberMeManager
= new CookieRememberMeManager();
rememberMeManager.setCipherKey(this.createCypherKey());
this.securityManager.setRememberMeManager(rememberMeManager);
}
return this.securityManager;
}