package com.zm.blog.config.shiro;
import java.io.Serializable;
import javax.annotation.Resource;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.ValidatingSession;
import org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import com.zm.blog.utils.shiroUtil.SerializableUtils;
public class MySessionDao extends EnterpriseCacheSessionDAO {
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Resource(name = "redisTemplate")
ValueOperations<Object, Object> valOps;
@Override
protected Serializable doCreate(Session session) {
Serializable sessionId = generateSessionId(session);
System.out.println("MySessionDao.doCreate();"+sessionId);
assignSessionId(session, sessionId);
valOps.set(sessionId, SerializableUtils.serialize(session));
return session.getId();
}
@Override
protected Session doReadSession(Serializable sessionId) {
System.out.println("MySessionDao.doReadSession();"+sessionId);
/*if(valOps.get(sessionId).toString().isEmpty())
return null;*/
return SerializableUtils.deserialize(valOps.get("sessionId").toString());
}
@Override
protected void doUpdate(Session session) {
System.out.println("MySessionDao.doUpdate();"+session.getId());
if (session instanceof ValidatingSession && !((ValidatingSession) session).isValid()) {
return;
}
valOps.set(session.getId(),SerializableUtils.serialize(session));
}
@Override
protected void doDelete(Session session) {
System.out.println("MySessionDao.doDelete();");
stringRedisTemplate.delete(session.getId().toString());
}
}
MySessionDao.doCreate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
onStart
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
本次《/blog/login;JSESSIONID=585054a5-e499-4d46-b277-90ac9934934f》请求的处理时间为:0ms
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
2018-01-13 13:11:43.574 DEBUG 6152 --- [p-nio-80-exec-5] c.z.b.m.c.C.getUserByName : ==> Preparing: select * from t_user where username=?
2018-01-13 13:11:43.574 DEBUG 6152 --- [p-nio-80-exec-5] c.z.b.m.c.C.getUserByName : ==> Parameters: admin(String)
2018-01-13 13:11:43.587 DEBUG 6152 --- [p-nio-80-exec-5] c.z.b.m.c.C.getUserByName : <== Total: 1
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
本次《/blog/checkLogin》请求的处理时间为:36ms
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
本次《/blog/》请求的处理时间为:0ms
2018-01-13 13:11:43.642 DEBUG 6152 --- [p-nio-80-exec-8] c.z.b.m.c.CustomUserMapper.getUserRoles : ==> Preparing: SELECT r.id,ur.userid,r.rolename,r.remark,r.createdate,r.updatedate FROM t_role r LEFT JOIN t_userrole ur ON r.id=ur.roleid WHERE ur.userid=?
2018-01-13 13:11:43.642 DEBUG 6152 --- [p-nio-80-exec-8] c.z.b.m.c.CustomUserMapper.getUserRoles : ==> Parameters: 1(String)
2018-01-13 13:11:43.674 DEBUG 6152 --- [p-nio-80-exec-8] c.z.b.m.c.CustomUserMapper.getUserRoles : <== Total: 1
shiro角色:superadmin
2018-01-13 13:11:43.676 DEBUG 6152 --- [p-nio-80-exec-8] c.z.b.m.c.C.getPremission : ==> Preparing: SELECT m.id,m.menuname,m.type,m.url,m.createdate,m.updatedate FROM t_menu m LEFT JOIN t_rolemenu rm ON rm.menuid=m.id WHERE m.type='left-menu'AND rm.roidid=?
2018-01-13 13:11:43.677 DEBUG 6152 --- [p-nio-80-exec-8] c.z.b.m.c.C.getPremission : ==> Parameters: 0(String)
2018-01-13 13:11:43.748 DEBUG 6152 --- [p-nio-80-exec-8] c.z.b.m.c.C.getPremission : <== Total: 30
shiro菜单权限:/blog/system-data
shiro菜单权限:/blog/member-record-share
shiro菜单权限:/blog/system-category
shiro菜单权限:/blog/system-shielding
shiro菜单权限:/blog/feedback-list
shiro菜单权限:/blog/charts-4
shiro菜单权限:/blog/base-resource
shiro菜单权限:/blog/article-list
shiro菜单权限:/blog/picture-list
shiro菜单权限:/blog/product-list
shiro菜单权限:/blog/charts-6
shiro菜单权限:/blog/charts-7
shiro菜单权限:/blog/admin-list
shiro菜单权限:/blog/charts-2
shiro菜单权限:/blog/system-log
shiro菜单权限:/blog/admin-permission
shiro菜单权限:/blog/member-scoreoperation
shiro菜单权限:/blog/product-category
shiro菜单权限:/blog/member-level
shiro菜单权限:/blog/member-list
shiro菜单权限:/blog/product-brand
shiro菜单权限:/blog/member-record-browse
shiro菜单权限:/blog/commons-list
shiro菜单权限:/blog/save-set
shiro菜单权限:/blog/member-record-download
shiro菜单权限:/blog/charts-5
shiro菜单权限:/blog/admin-role
shiro菜单权限:/blog/charts-3
shiro菜单权限:/blog/charts-1
shiro菜单权限:/blog/member-del
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
2018-01-13 13:11:43.923 DEBUG 6152 --- [p-nio-80-exec-7] c.z.b.m.c.CustomUserMapper.getAllNodes : ==> Preparing: SELECT id,pid,url,menuname FROM t_menu WHERE TYPE=? and id!='0' order by orderstring desc
2018-01-13 13:11:43.924 DEBUG 6152 --- [p-nio-80-exec-7] c.z.b.m.c.CustomUserMapper.getAllNodes : ==> Parameters: left-menu(String)
2018-01-13 13:11:43.938 DEBUG 6152 --- [p-nio-80-exec-7] c.z.b.m.c.CustomUserMapper.getAllNodes : <== Total: 40
本次《/blog/leftmenu》请求的处理时间为:22ms
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
本次《/blog/base-resource》请求的处理时间为:1ms
本次《/blog/404》请求的处理时间为:0ms
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
本次《/blog/getUserName》请求的处理时间为:4ms
MySessionDao.doReadSession();C3C91739C36945524CDE58597FB55863
2018-01-13 13:11:46.232 ERROR 6152 --- [p-nio-80-exec-9] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/blog] threw exception [Filtered request failed.] with root cause
java.lang.NullPointerException: null
shiro创建和更新sessionId无问题 。读取的sessionId就和创建更新的id不一致,急........在线等...........