/**
* 验证是否登陆
*
* org.apache.shiro.subject.support.DefaultSubjectContext_AUTHENTICATED_SESSION_KEY ; true
* org.apache.shiro.subject.support.DefaultSubjectContext_PRINCIPALS_SESSION_KEY ; com.hncxhd.bywl.entity.manual.UserInfo@533752b2
*/
public boolean isAuthenticated(String sessionID,HttpServletRequest request,HttpServletResponse response){
boolean status = false;
SessionKey key = new WebSessionKey(sessionID,request,response);
try{
Session se = SecurityUtils.getSecurityManager().getSession(key);
Object obj = se.getAttribute(DefaultSubjectContext.AUTHENTICATED_SESSION_KEY);
if(obj != null){
status = (Boolean) obj;
}
}catch(Exception e){
e.printStackTrace();
}finally{
Session se = null;
Object obj = null;
}
return status;
}
/**
* 获取用户登录信息
*
*/org.apache.shiro.subject.support.DefaultSubjectContext_PRINCIPALS_SESSION_KEY ; com.hncxhd.bywl.entity.manual.UserInfo@533752b2
*/
public UserInfo getUserInfo(String sessionID,HttpServletRequest request,HttpServletResponse response){
boolean status = false;
SessionKey key = new WebSessionKey(sessionID,request,response);
try{
Session se = SecurityUtils.getSecurityManager().getSession(key);
Object obj = se.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
//org.apache.shiro.subject.SimplePrincipalCollection cannot be cast to com.hncxhd.bywl.entity.manual.UserInfo
SimplePrincipalCollection coll = (SimplePrincipalCollection) obj;
return (UserInfo)coll.getPrimaryPrincipal();
}catch(Exception e){
e.printStackTrace();
}finally{
}
return null;
}
shiro – Erhalten Sie Benutzerinformationen und bestimmen Sie anhand der JSESSIONID, ob Sie sich anmelden möchten
Je suppose que tu aimes
Origine blog.csdn.net/qq_41848006/article/details/130090802
conseillé
Classement