shiro组件类移到shiro包下
This commit is contained in:
parent
0a9e4a2587
commit
6242bab855
|
@ -1,8 +1,11 @@
|
|||
package com.zheng.upms.server.interceptor;
|
||||
|
||||
import com.zheng.upms.dao.model.UpmsUser;
|
||||
import com.zheng.upms.server.controller.manage.UpmsOrganizationController;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
|
@ -13,7 +16,9 @@ import javax.servlet.http.HttpServletResponse;
|
|||
* 登录信息拦截器
|
||||
* Created by shuzheng on 2017/2/11.
|
||||
*/
|
||||
public class UpmsLoginInterceptor extends HandlerInterceptorAdapter {
|
||||
public class UpmsInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
private static Logger _log = LoggerFactory.getLogger(UpmsInterceptor.class);
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
|
@ -1,29 +0,0 @@
|
|||
package com.zheng.upms.server.listener;
|
||||
|
||||
import org.apache.shiro.session.Session;
|
||||
import org.apache.shiro.session.SessionListener;
|
||||
|
||||
/**
|
||||
* Created by shuzheng on 2017/2/12.
|
||||
*/
|
||||
public class ShiroSessionListener implements SessionListener {
|
||||
|
||||
@Override
|
||||
public void onStart(Session session) {
|
||||
System.out.println(session.toString());
|
||||
System.out.println("会话创建:" + session.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop(Session session) {
|
||||
System.out.println(session.toString());
|
||||
System.out.println("会话停止:" + session.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExpiration(Session session) {
|
||||
System.out.println(session.toString());
|
||||
System.out.println("会话过期:" + session.getId());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.zheng.upms.server.realm;
|
||||
package com.zheng.upms.server.shiro.realm;
|
||||
|
||||
import com.zheng.common.util.MD5Util;
|
||||
import com.zheng.upms.dao.model.UpmsPermission;
|
||||
|
@ -40,7 +40,6 @@ public class UpmsRealm extends AuthorizingRealm {
|
|||
*/
|
||||
@Override
|
||||
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
|
||||
// 当前用户
|
||||
UpmsUser upmsUser = (UpmsUser) principalCollection.getPrimaryPrincipal();
|
||||
|
||||
// 当前用户所有权限
|
||||
|
@ -75,13 +74,13 @@ public class UpmsRealm extends AuthorizingRealm {
|
|||
UpmsUser upmsUser = upmsUserService.selectFirstByExample(upmsUserExample);
|
||||
|
||||
if (null == upmsUser) {
|
||||
throw new UnknownAccountException("帐号不存在!");
|
||||
throw new UnknownAccountException();
|
||||
}
|
||||
if (!upmsUser.getPassword().equals(MD5Util.MD5(password + upmsUser.getSalt()))) {
|
||||
throw new IncorrectCredentialsException("密码错误!");
|
||||
throw new IncorrectCredentialsException();
|
||||
}
|
||||
if (upmsUser.getLocked() == 1) {
|
||||
throw new LockedAccountException("账号已被锁定!");
|
||||
throw new LockedAccountException();
|
||||
}
|
||||
|
||||
return new SimpleAuthenticationInfo(upmsUser, password, getName());
|
|
@ -1,17 +0,0 @@
|
|||
package com.zheng.upms.server.util;
|
||||
|
||||
/**
|
||||
* Created by shuzheng on 2017/1/19.
|
||||
*/
|
||||
public class SystemConstant {
|
||||
|
||||
public static final int SUCCESS = 10000; // 成功
|
||||
|
||||
public static final int NO_USERNAME = 10001; // 帐号为空
|
||||
public static final int NO_PASSWORD = 10002; // 密码为空
|
||||
public static final int ERROR_ACCOUNT = 10003; // 帐号或密码错误
|
||||
public static final int ERROR_USERNAME = 10004; // 帐号不存在
|
||||
public static final int ERROR_PASSWORD = 10005; // 密码错误
|
||||
public static final int INVALID_ACCOUNT = 10006; // 帐号被封
|
||||
|
||||
}
|
|
@ -16,7 +16,7 @@
|
|||
<!-- 获取登录信息 -->
|
||||
<mvc:interceptor>
|
||||
<mvc:mapping path="/manage/**"/>
|
||||
<bean class="com.zheng.upms.server.interceptor.UpmsLoginInterceptor"></bean>
|
||||
<bean class="com.zheng.upms.server.interceptor.UpmsInterceptor"></bean>
|
||||
</mvc:interceptor>
|
||||
</mvc:interceptors>
|
||||
|
||||
|
|
Loading…
Reference in New Issue