删除多余代码

pull/305/head^2
RuoYi 6 years ago
parent 8af0afc80d
commit 7329cbdceb

@ -61,7 +61,6 @@
<script th:inline="javascript"> <script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('system:role:edit')}]]; var editFlag = [[${@permission.hasPermi('system:role:edit')}]];
var removeFlag = [[${@permission.hasPermi('system:role:remove')}]]; var removeFlag = [[${@permission.hasPermi('system:role:remove')}]];
var datas = [[${@dict.getType('sys_normal_disable')}]];
var prefix = ctx + "system/role"; var prefix = ctx + "system/role";

@ -93,7 +93,6 @@
var editFlag = [[${@permission.hasPermi('system:user:edit')}]]; var editFlag = [[${@permission.hasPermi('system:user:edit')}]];
var removeFlag = [[${@permission.hasPermi('system:user:remove')}]]; var removeFlag = [[${@permission.hasPermi('system:user:remove')}]];
var resetPwdFlag = [[${@permission.hasPermi('system:user:resetPwd')}]]; var resetPwdFlag = [[${@permission.hasPermi('system:user:resetPwd')}]];
var datas = [[${@dict.getType('sys_normal_disable')}]];
var prefix = ctx + "system/user"; var prefix = ctx + "system/user";
$(function() { $(function() {

@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.framework.shiro.realm.UserRealm; import com.ruoyi.framework.shiro.realm.UserRealm;
import com.ruoyi.framework.shiro.session.OnlineSessionDAO; import com.ruoyi.framework.shiro.session.OnlineSessionDAO;
import com.ruoyi.framework.shiro.session.OnlineSessionFactory; import com.ruoyi.framework.shiro.session.OnlineSessionFactory;
@ -47,10 +48,6 @@ public class ShiroConfig
@Value("${shiro.session.expireTime}") @Value("${shiro.session.expireTime}")
private int expireTime; private int expireTime;
// 相隔多久检查一次session的有效性单位毫秒默认就是10分钟
@Value("${shiro.session.validationInterval}")
private int validationInterval;
// 验证码开关 // 验证码开关
@Value("${shiro.user.captchaEnabled}") @Value("${shiro.user.captchaEnabled}")
private boolean captchaEnabled; private boolean captchaEnabled;
@ -159,44 +156,6 @@ public class ShiroConfig
return sessionFactory; return sessionFactory;
} }
/**
* sessionFactory
*/
@Bean
public SpringSessionValidationScheduler sessionValidationScheduler()
{
SpringSessionValidationScheduler sessionValidationScheduler = new SpringSessionValidationScheduler();
// 相隔多久检查一次session的有效性单位毫秒默认就是10分钟
sessionValidationScheduler.setSessionValidationInterval(validationInterval * 60 * 1000);
// 设置会话验证调度器进行会话验证时的会话管理器
sessionValidationScheduler.setSessionManager(sessionValidationManager());
return sessionValidationScheduler;
}
/**
*
*/
@Bean
public OnlineWebSessionManager sessionValidationManager()
{
OnlineWebSessionManager manager = new OnlineWebSessionManager();
// 加入缓存管理器
manager.setCacheManager(getEhCacheManager());
// 删除过期的session
manager.setDeleteInvalidSessions(true);
// 设置全局session超时时间
manager.setGlobalSessionTimeout(expireTime * 60 * 1000);
// 去掉 JSESSIONID
manager.setSessionIdUrlRewritingEnabled(false);
// 是否定时检查session
manager.setSessionValidationSchedulerEnabled(true);
// 自定义SessionDao
manager.setSessionDAO(sessionDAO());
// 自定义sessionFactory
manager.setSessionFactory(sessionFactory());
return manager;
}
/** /**
* *
*/ */
@ -213,7 +172,7 @@ public class ShiroConfig
// 去掉 JSESSIONID // 去掉 JSESSIONID
manager.setSessionIdUrlRewritingEnabled(false); manager.setSessionIdUrlRewritingEnabled(false);
// 定义要使用的无效的Session定时调度器 // 定义要使用的无效的Session定时调度器
manager.setSessionValidationScheduler(sessionValidationScheduler()); manager.setSessionValidationScheduler(SpringUtils.getBean(SpringSessionValidationScheduler.class));
// 是否定时检查session // 是否定时检查session
manager.setSessionValidationSchedulerEnabled(true); manager.setSessionValidationSchedulerEnabled(true);
// 自定义SessionDao // 自定义SessionDao
@ -227,7 +186,7 @@ public class ShiroConfig
* *
*/ */
@Bean @Bean
public SecurityManager securityManager(UserRealm userRealm) public SecurityManager securityManager(UserRealm userRealm, SpringSessionValidationScheduler springSessionValidationScheduler)
{ {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
// 设置realm. // 设置realm.

@ -9,6 +9,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import com.ruoyi.common.utils.Threads; import com.ruoyi.common.utils.Threads;
/** /**
@ -16,6 +18,7 @@ import com.ruoyi.common.utils.Threads;
* *
* @author ruoyi * @author ruoyi
*/ */
@Component
public class SpringSessionValidationScheduler implements SessionValidationScheduler public class SpringSessionValidationScheduler implements SessionValidationScheduler
{ {
private static final Logger log = LoggerFactory.getLogger(SpringSessionValidationScheduler.class); private static final Logger log = LoggerFactory.getLogger(SpringSessionValidationScheduler.class);
@ -32,36 +35,15 @@ public class SpringSessionValidationScheduler implements SessionValidationSchedu
private volatile boolean enabled = false; private volatile boolean enabled = false;
/** /**
* The session manager used to validate sessions. *
*/ */
@Autowired
@Qualifier("sessionManager")
private ValidatingSessionManager sessionManager; private ValidatingSessionManager sessionManager;
/** // 相隔多久检查一次session的有效性单位毫秒默认就是10分钟
* The session validation interval in milliseconds. @Value("${shiro.session.validationInterval}")
*/ private long sessionValidationInterval;
private long sessionValidationInterval = DEFAULT_SESSION_VALIDATION_INTERVAL;
/**
* Default constructor.
*/
public SpringSessionValidationScheduler()
{
}
/**
* Constructor that specifies the session manager that should be used for validating sessions.
*
* @param sessionManager the <tt>SessionManager</tt> that should be used to validate sessions.
*/
public SpringSessionValidationScheduler(ValidatingSessionManager sessionManager)
{
this.sessionManager = sessionManager;
}
public void setSessionManager(ValidatingSessionManager sessionManager)
{
this.sessionManager = sessionManager;
}
@Override @Override
public boolean isEnabled() public boolean isEnabled()
@ -111,7 +93,7 @@ public class SpringSessionValidationScheduler implements SessionValidationSchedu
sessionManager.validateSessions(); sessionManager.validateSessions();
} }
} }
}, 1000, sessionValidationInterval, TimeUnit.MILLISECONDS); }, 1000, sessionValidationInterval * 60 * 1000, TimeUnit.MILLISECONDS);
this.enabled = true; this.enabled = true;

Loading…
Cancel
Save