|
@@ -3,18 +3,18 @@ package com.bootdo.system.service.impl;
|
|
|
import com.bootdo.common.utils.IPUtils;
|
|
|
import com.bootdo.system.domain.UserDO;
|
|
|
import com.bootdo.system.domain.UserOnline;
|
|
|
-import com.bootdo.system.domain.UserToken;
|
|
|
import com.bootdo.system.service.SessionService;
|
|
|
import org.apache.shiro.session.Session;
|
|
|
import org.apache.shiro.session.mgt.eis.SessionDAO;
|
|
|
import org.apache.shiro.subject.SimplePrincipalCollection;
|
|
|
import org.apache.shiro.subject.support.DefaultSubjectContext;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.security.Principal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
|
import java.util.List;
|
|
@@ -26,6 +26,7 @@ import java.util.List;
|
|
|
*/
|
|
|
@Service
|
|
|
public class SessionServiceImpl implements SessionService {
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(SessionServiceImpl.class);
|
|
|
private final SessionDAO sessionDAO;
|
|
|
|
|
|
@Value("${api-allow-ip}")
|
|
@@ -39,6 +40,7 @@ public class SessionServiceImpl implements SessionService {
|
|
|
@Override
|
|
|
public List<UserOnline> list(HttpServletRequest request) throws Exception{
|
|
|
String ip = IPUtils.getIpAddr(request);
|
|
|
+ log.info("SessionServiceImpl.list.ip:{0}",ip);
|
|
|
if (!apiAllowIp.contains(ip)) {
|
|
|
throw new Exception("不允许访问");
|
|
|
}
|
|
@@ -91,6 +93,7 @@ public class SessionServiceImpl implements SessionService {
|
|
|
@Override
|
|
|
public boolean forceLogout(String sessionId,HttpServletRequest request) throws Exception {
|
|
|
String ip = IPUtils.getIpAddr(request);
|
|
|
+ log.info("SessionServiceImpl.forceLogout.ip:{0}",ip);
|
|
|
if (!apiAllowIp.contains(ip)) {
|
|
|
throw new Exception("不允许访问");
|
|
|
}
|