Java Code Examples for org.apache.shiro.web.servlet.SimpleCookie#setHttpOnly()

The following examples show how to use org.apache.shiro.web.servlet.SimpleCookie#setHttpOnly() . 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: ShiroConfig.java    From springboot-learn with MIT License 5 votes vote down vote up
/**
 * cookie 属性设置
 */
public SimpleCookie rememberMeCookie() {
    SimpleCookie cookie = new SimpleCookie("rememberMe");
    cookie.setDomain("");
    cookie.setPath("/");
    cookie.setHttpOnly(true);
    cookie.setMaxAge(30 * 24 * 60 * 60);
    return cookie;
}
 
Example 2
Source File: ShiroConfig.java    From EasyReport with Apache License 2.0 5 votes vote down vote up
@Bean
public SimpleCookie rememberMeCookie() {
    final SimpleCookie simpleCookie = new SimpleCookie("rememberMe");
    simpleCookie.setHttpOnly(true);
    simpleCookie.setMaxAge(259200);
    return simpleCookie;
}
 
Example 3
Source File: SecurityConfiguration.java    From java-platform with Apache License 2.0 5 votes vote down vote up
@Bean
public Cookie rememberMeCookie() {
	SimpleCookie cookie = new SimpleCookie("rememberMe");
	cookie.setHttpOnly(true);
	cookie.setMaxAge(31536000);
	return cookie;
}
 
Example 4
Source File: ShiroAutoConfiguration.java    From utils with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(Cookie.class)
public Cookie rememberMeCookie() {
    SimpleCookie cookie = new SimpleCookie();

    cookie.setName(authFilterProperties.getRememberMeParamName());
    cookie.setMaxAge(shiroCookieProperties.getMaxAge());
    cookie.setValue(shiroCookieProperties.getValue());
    cookie.setVersion(shiroCookieProperties.getVersion());
    cookie.setHttpOnly(shiroCookieProperties.isHttpOnly());
    cookie.setSecure(shiroCookieProperties.isSecure());

    return cookie;
}
 
Example 5
Source File: ShiroConfig.java    From yyblog with MIT License 5 votes vote down vote up
@Bean
public SimpleCookie rememberMeCookie(){
    //这个参数是cookie的名称,对应前端的checkbox的name = rememberMe
    SimpleCookie simpleCookie = new SimpleCookie("rememberMe");
    //如果httyOnly设置为true,则客户端不会暴露给客户端脚本代码,使用HttpOnly cookie有助于减少某些类型的跨站点脚本攻击;
    simpleCookie.setHttpOnly(true);
    //记住我cookie生效时间,默认30天 ,单位秒:60 * 60 * 24 * 30
    simpleCookie.setMaxAge(259200);
    return simpleCookie;
}
 
Example 6
Source File: ShiroConfig.java    From mysiteforme with Apache License 2.0 5 votes vote down vote up
@Bean
public SimpleCookie rememberMeCookie(){
    //这个参数是cookie的名称,对应前端的checkbox的name = rememberMe
    SimpleCookie cookie = new SimpleCookie("rememberMe");
    cookie.setHttpOnly(true);
    //记住我有效期长达30天
    cookie.setMaxAge(2592000);
    return cookie;
}
 
Example 7
Source File: ShiroConfig.java    From LuckyFrameWeb with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * cookie 属性设置
 */
public SimpleCookie rememberMeCookie()
{
    SimpleCookie cookie = new SimpleCookie("rememberMe");
    cookie.setDomain(domain);
    cookie.setPath(path);
    cookie.setHttpOnly(httpOnly);
    cookie.setMaxAge(maxAge * 24 * 60 * 60);
    return cookie;
}
 
Example 8
Source File: ShiroConfig.java    From RuoYi with Apache License 2.0 5 votes vote down vote up
/**
 * cookie 属性设置
 */
private SimpleCookie rememberMeCookie() {
    SimpleCookie cookie = new SimpleCookie("rememberMe");
    cookie.setDomain(domain);
    cookie.setPath(path);
    cookie.setHttpOnly(httpOnly);
    cookie.setMaxAge(maxAge * 24 * 60 * 60);
    return cookie;
}
 
Example 9
Source File: ShiroConfig.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
/**
 * 设置rememberMe  Cookie 7天
 * @return
 */
@Bean(name="simpleCookie")
public SimpleCookie getSimpleCookie(){
    SimpleCookie simpleCookie = new SimpleCookie();
    simpleCookie.setName("rememberMe");
    simpleCookie.setHttpOnly(true);
    simpleCookie.setMaxAge(7*24*60*60);
    return simpleCookie ;
}
 
Example 10
Source File: ShiroConfig.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * cookie 属性设置
 */
public SimpleCookie rememberMeCookie()
{
    SimpleCookie cookie = new SimpleCookie("rememberMe");
    cookie.setDomain(domain);
    cookie.setPath(path);
    cookie.setHttpOnly(httpOnly);
    cookie.setMaxAge(maxAge * 24 * 60 * 60);
    return cookie;
}
 
Example 11
Source File: ShiroConfig.java    From WebStack-Guns with MIT License 5 votes vote down vote up
/**
 * 记住密码Cookie
 */
@Bean
public SimpleCookie rememberMeCookie() {
    SimpleCookie simpleCookie = new SimpleCookie("rememberMe");
    simpleCookie.setHttpOnly(true);
    simpleCookie.setMaxAge(7 * 24 * 60 * 60);//7天
    return simpleCookie;
}
 
Example 12
Source File: AuthConfig.java    From v-mock with MIT License 5 votes vote down vote up
/**
 * cookie 属性设置
 */
public SimpleCookie rememberMeCookie() {
    SimpleCookie cookie = new SimpleCookie("rememberMe");
    cookie.setPath("/");
    cookie.setHttpOnly(true);
    cookie.setMaxAge(30 * 24 * 60 * 60);
    return cookie;
}
 
Example 13
Source File: ShiroConfig.java    From ruoyiplus with MIT License 5 votes vote down vote up
/**
 * cookie 属性设置
 */
public SimpleCookie rememberMeCookie()
{
    SimpleCookie cookie = new SimpleCookie("rememberMe");
    cookie.setDomain(domain);
    cookie.setPath(path);
    cookie.setHttpOnly(httpOnly);
    cookie.setMaxAge(maxAge * 24 * 60 * 60);
    return cookie;
}
 
Example 14
Source File: FormAuthenticationFilter.java    From frpMgr with MIT License 5 votes vote down vote up
/**
 * 构造方法
 */
public FormAuthenticationFilter() {
	super();
	rememberUserCodeCookie = new SimpleCookie(DEFAULT_REMEMBER_USERCODE_PARAM);
	rememberUserCodeCookie.setHttpOnly(true);
       rememberUserCodeCookie.setMaxAge(Cookie.ONE_YEAR);
}
 
Example 15
Source File: ShiroConfig.java    From MeetingFilm with Apache License 2.0 5 votes vote down vote up
/**
 * 记住密码Cookie
 */
@Bean
public SimpleCookie rememberMeCookie() {
    SimpleCookie simpleCookie = new SimpleCookie("rememberMe");
    simpleCookie.setHttpOnly(true);
    simpleCookie.setMaxAge(7 * 24 * 60 * 60);//7天
    return simpleCookie;
}
 
Example 16
Source File: ShiroConfig.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
/**
 * 设置rememberMe  Cookie 7天
 * @return
 */
@Bean(name="simpleCookie")
public SimpleCookie getSimpleCookie(){
    SimpleCookie simpleCookie = new SimpleCookie();
    simpleCookie.setName("rememberMe");
    simpleCookie.setHttpOnly(true);
    simpleCookie.setMaxAge(7*24*60*60);
    return simpleCookie ;
}
 
Example 17
Source File: ShiroConfig.java    From erp-framework with MIT License 5 votes vote down vote up
/**
 * cookie对象,通过登录界面的记住我
 * @return
 */
@Bean
public SimpleCookie rememberMeCookie(){
    //这个参数是cookie的名称,对应前端的checkbox的name = rememberMe
    SimpleCookie cookie = new SimpleCookie("rememberMe");

    //setcookie的httponly属性如果设为true的话,会增加对xss防护的安全系数。它有以下特点:
    //setcookie()的第七个参数
    //设为true后,只能通过http访问,javascript无法访问
    //防止xss读取cookie
    cookie.setHttpOnly(true);
    //记住我有效期长达30天
    cookie.setMaxAge(2592000);
    return cookie;
}