| | |
| | | |
| | | package com.whyc.util; |
| | | |
| | | import com.mysql.cj.core.util.StringUtils; |
| | | import com.whyc.constant.SuperConstant; |
| | | import com.whyc.pojo.User; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.apache.shiro.session.Session; |
| | | import org.apache.shiro.subject.Subject; |
| | | import org.apache.shiro.util.ThreadContext; |
| | | |
| | | |
| | | /** |
| | |
| | | return subject.isAuthenticated(); |
| | | } |
| | | |
| | | public static User getUser() { |
| | | if (!isNullOrEmpty(ThreadContext.getSubject()) && !isNullOrEmpty(SecurityUtils.getSubject().getPrincipal())) { |
| | | return (User) SecurityUtils.getSubject().getPrincipal(); |
| | | }else { |
| | | return new User(0,"none"); |
| | | } |
| | | } |
| | | |
| | | public static boolean isNullOrEmpty(Object obj) { |
| | | if (obj == null || "".equals(obj)) { |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | } |