本文整理汇总了Java中org.apache.shiro.subject.Subject.isRemembered方法的典型用法代码示例。如果您正苦于以下问题:Java Subject.isRemembered方法的具体用法?Java Subject.isRemembered怎么用?Java Subject.isRemembered使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.shiro.subject.Subject
的用法示例。
在下文中一共展示了Subject.isRemembered方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isAccessAllowed
import org.apache.shiro.subject.Subject; //导入方法依赖的package包/类
@Override
protected boolean isAccessAllowed(ServletRequest request,
ServletResponse response, Object mappedValue) {
Subject subject = getSubject(request, response);
// 如果 isAuthenticated 为 false 证明不是登录过的,同时 isRememberd 为true 证明是没登陆直接通过记住我功能进来的
if (!subject.isAuthenticated() && subject.isRemembered()) {
// 获取session的USERSESSION属性来看session是不是空的
if(null == ShiroAuthenticationManager.getSessionAttribute(ShiroUtils.USERSESSION))
{
// 初始化
UserEntity userEntity = (UserEntity) subject.getPrincipal();
ShiroAuthenticationManager.setSessionAttribute(ShiroUtils.USERSESSION, userEntity);
}
}
// 这个方法本来只返回 subject.isAuthenticated() 现在我们加上 subject.isRemembered()
// 让它同时也兼容remember这种情况
return subject.isAuthenticated() || subject.isRemembered();
}
示例2: isAccessAllowed
import org.apache.shiro.subject.Subject; //导入方法依赖的package包/类
@Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
// 是登录页面 则直接返回true
if (isLoginRequest(request, response)) {
return true;
} else {
// 获取主题
Subject subject = getSubject(request, response);
// 如果用户【未认证】 但是用户使用【记住我】功能
if (!subject.isAuthenticated() && subject.isRemembered()) {
// 获取rememberMe的用户名称
Object principal = subject.getPrincipal();
if (null != principal) {
//从session中 获取登录用户信息
//Session session = subject.getSession(true);
//User sessionUser = (User) session.getAttribute(User.SESSION_USER);
//如果session不保存用户信息;则从数据库中获取
//if (sessionUser == null) {
// sessionUser = userService.getUserByName(String.valueOf(principal));
// subject.getSession().setAttribute(User.SESSION_USER, sessionUser);
//}
return true;
}
}
}
return true;
}
示例3: isAccessAllowed
import org.apache.shiro.subject.Subject; //导入方法依赖的package包/类
@Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
HttpServletRequest req = (HttpServletRequest) request;
System.out.println("验证登陆信息==" + req.getRequestURI());
System.out.println("sessionId==" + req.getSession().getId());
Subject currentUser = SecurityUtils.getSubject();
if (null != currentUser) {
if (currentUser.isAuthenticated() || currentUser.isRemembered()) {
return true;
}
}
// 返回false表示不执行后续的过滤器
return false;
}
示例4: isAccessAllowed
import org.apache.shiro.subject.Subject; //导入方法依赖的package包/类
/**
* 判断是否让用户登陆
*/
@Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
Subject subject = getSubject(request, response);
return subject.isAuthenticated() || subject.isRemembered();
}
示例5: init
import org.apache.shiro.subject.Subject; //导入方法依赖的package包/类
@Override
protected void init(VaadinRequest request) {
LOGGER.debug("init - request = " + request);
Subject subject = SecurityUtils.getSubject();
boolean remembered = subject.isRemembered();
if (! (user().isPresent() && remembered)) setContent(login());
setSizeFull();
}
示例6: isAccessAllowed
import org.apache.shiro.subject.Subject; //导入方法依赖的package包/类
@Override
protected boolean isAccessAllowed(ServletRequest req, ServletResponse resp, Object mappedValue) {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) resp;
// 是登录页面 则直接返回true
if (isLoginRequest(request, response)) {
return true;
}
// 获取主题
Subject subject = getSubject(request, response);
//如果用户【已认证】 直接跳过
if (subject.isAuthenticated()) {
return true;
}
// 如果用户【未认证】 但是用户使用【记住我】功能
if (subject.isRemembered()) {
// 获取rememberMe的用户名称
Object principal = subject.getPrincipal();
if (null != principal) {
//从session中 获取登录用户信息
Session session = subject.getSession(true);
MMSnsCommonUserEntity commonUser = (MMSnsCommonUserEntity) session.getAttribute(MMSnsCommonUserEntity.MMSNS_COMMON_USER);
//如果session不保存用户信息;则从数据库中获取
if (commonUser == null) {
List<MMSnsCommonUserEntity> commonUsers = commonUserService.getCommonUserByCondition(principal.toString(), principal.toString(),principal.toString(),null,null);
if (commonUser != null && commonUsers.size() > 0) {
session.setAttribute(MMSnsCommonUserEntity.MMSNS_COMMON_USER, commonUsers.get(0));
}
}
return true;
}
}
return false;
}