whycxzp
2021-01-08 d04fed7dfceee61b5dd6ba10f23ff16c80458f47
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * <b>文件名</b>:ShiroUtil.java
 *
 * 文件描述:
 *
 *
 * 2017-10-11  下午2:28:25
 */
 
package com.whyc.util;
 
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
 
 
/**
 * @Description shiro工具类
 */
public class ShiroUtil {
    
    /**
     * @Description 获得shiro的session
     * @param
     * @return
     */
    public static Session getShiroSession() {
        return SecurityUtils.getSubject().getSession();
    }
    
    /**
     * @Description 获得shiro的sessionId
     * @param
     * @return
     */
    public static String getShiroSessionId() {
        return getShiroSession().getId().toString();
    }
    
    /**
     * @Description 是否登陆
     * @param
     * @return
     */
    public static Boolean isAuthenticated(){
        Subject subject = SecurityUtils.getSubject();
        return subject.isAuthenticated();
    }
 
}