use of org.apache.shiro.web.servlet.SimpleCookie in project nutzboot by nutzam.
the class ShiroEnvStarter method getWebSessionManager.
@IocBean(name = "shiroWebSessionManager")
public WebSessionManager getWebSessionManager() {
DefaultWebSessionManager webSessionManager = conf.make(DefaultWebSessionManager.class, "shiro.session.manager.");
// 带缓存的shiro会话
EnterpriseCacheSessionDAO sessionDAO = new EnterpriseCacheSessionDAO();
sessionDAO.setSessionIdGenerator(new UU32SessionIdGenerator());
webSessionManager.setSessionDAO(sessionDAO);
// cookie
conf.putIfAbsent(PROP_SESSION_COOKIE_NAME, "sid");
conf.putIfAbsent(PROP_SESSION_COOKIE_MAXAGE, "946080000");
conf.putIfAbsent(PROP_SESSION_COOKIE_HTTPONLY, "true");
SimpleCookie cookie = conf.make(SimpleCookie.class, "shiro.session.cookie.");
webSessionManager.setSessionIdCookie(cookie);
webSessionManager.setSessionIdCookieEnabled(true);
webSessionManager.setCacheManager(ioc.get(CacheManager.class, "shiroCacheManager"));
return webSessionManager;
}
use of org.apache.shiro.web.servlet.SimpleCookie in project vip by guangdada.
the class ShiroConfig method rememberMeCookie.
/**
* 记住密码Cookie
*/
@Bean
public SimpleCookie rememberMeCookie() {
SimpleCookie simpleCookie = new SimpleCookie("rememberMe");
simpleCookie.setHttpOnly(true);
// 7天
simpleCookie.setMaxAge(7 * 24 * 60 * 60);
return simpleCookie;
}
use of org.apache.shiro.web.servlet.SimpleCookie in project wechat by dllwh.
the class ShiroConfig method rememberMeCookie.
/**
* @方法描述 : 记住我
* @return
*/
public SimpleCookie rememberMeCookie() {
// 这个参数是cookie的名称,对应前端的checkbox的name = rememberMe
SimpleCookie simpleCookie = new SimpleCookie("rememberMe");
// 记住我cookie生效时间30天 ,单位秒;
simpleCookie.setMaxAge(2592000);
return simpleCookie;
}
use of org.apache.shiro.web.servlet.SimpleCookie in project shiro by apache.
the class DefaultWebSessionManager method storeSessionId.
private void storeSessionId(Serializable currentId, HttpServletRequest request, HttpServletResponse response) {
if (currentId == null) {
String msg = "sessionId cannot be null when persisting for subsequent requests.";
throw new IllegalArgumentException(msg);
}
Cookie template = getSessionIdCookie();
Cookie cookie = new SimpleCookie(template);
String idString = currentId.toString();
cookie.setValue(idString);
cookie.saveTo(request, response);
log.trace("Set session ID cookie for session with id {}", idString);
}
use of org.apache.shiro.web.servlet.SimpleCookie in project shiro by apache.
the class AbstractShiroWebConfiguration method buildCookie.
protected Cookie buildCookie(String name, int maxAge, String path, String domain, boolean secure) {
Cookie cookie = new SimpleCookie(name);
cookie.setHttpOnly(true);
cookie.setMaxAge(maxAge);
cookie.setPath(path);
cookie.setDomain(domain);
cookie.setSecure(secure);
return cookie;
}
Aggregations