Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
shop-Mall
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
licc
shop-Mall
Commits
34ad5d18
Commit
34ad5d18
authored
Mar 04, 2021
by
m1991
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决启动报错
parent
4272103d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
1156 additions
and
1183 deletions
+1156
-1183
pom.xml
pom.xml
+1
-1
FileUploadConfig.java
...ava/cn/wisenergy/common/config/file/FileUploadConfig.java
+0
-29
User.java
...ergy-model/src/main/java/cn/wisenergy/model/app/User.java
+10
-9
ShiroConfig.java
...o/src/main/java/com/project/shiro/config/ShiroConfig.java
+195
-195
AuthenticationFilter.java
...ain/java/com/project/shiro/util/AuthenticationFilter.java
+275
-275
AuthenticationRealm.java
...main/java/com/project/shiro/util/AuthenticationRealm.java
+185
-185
AuthenticationToken.java
...main/java/com/project/shiro/util/AuthenticationToken.java
+41
-41
AuthorizationFilter.java
...main/java/com/project/shiro/util/AuthorizationFilter.java
+47
-47
Principal.java
...shiro/src/main/java/com/project/shiro/util/Principal.java
+38
-38
ShiroRedisCache.java
...in/java/com/project/shiro/util/redis/ShiroRedisCache.java
+175
-175
ShiroRedisCacheManager.java
.../com/project/shiro/util/redis/ShiroRedisCacheManager.java
+59
-59
ShiroRedisSessionDAO.java
...va/com/project/shiro/util/redis/ShiroRedisSessionDAO.java
+129
-129
LoginInterceptor.java
...va/cn/wisenergy/web/sms/interceptor/LoginInterceptor.java
+1
-0
No files found.
pom.xml
View file @
34ad5d18
...
@@ -39,7 +39,7 @@
...
@@ -39,7 +39,7 @@
<module>
wisenergy-model
</module>
<module>
wisenergy-model
</module>
<module>
wisenergy-mapper
</module>
<module>
wisenergy-mapper
</module>
<module>
wisenergy-service
</module>
<module>
wisenergy-service
</module>
<
module>
wisenergy-shiro
</module
>
<
!--<module>wisenergy-shiro</module>--
>
<module>
wisenergy-web-admin
</module>
<module>
wisenergy-web-admin
</module>
</modules>
</modules>
...
...
wisenergy-common/src/main/java/cn/wisenergy/common/config/file/FileUploadConfig.java
deleted
100644 → 0
View file @
4272103d
package
cn
.
wisenergy
.
common
.
config
.
file
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.multipart.MultipartResolver
;
import
org.springframework.web.multipart.commons.CommonsMultipartResolver
;
/**
* 文件上传配置
* @author wyy
* @date 2019-08-22 19:20
*/
@Configuration
public
class
FileUploadConfig
{
/**
* 重新定义文件上传对象【springBoot request转化成MultipartHttpServletRequest】
* @return
*/
@Bean
(
name
=
"multipartResolver"
)
public
MultipartResolver
multipartResolver
()
{
CommonsMultipartResolver
resolver
=
new
CommonsMultipartResolver
();
resolver
.
setDefaultEncoding
(
"UTF-8"
);
resolver
.
setResolveLazily
(
true
);
resolver
.
setMaxInMemorySize
(
40960
);
resolver
.
setMaxUploadSize
(
512
*
1024
*
1024
);
return
resolver
;
}
}
wisenergy-model/src/main/java/cn/wisenergy/model/app/User.java
View file @
34ad5d18
package
cn
.
wisenergy
.
model
.
app
;
package
cn
.
wisenergy
.
model
.
app
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.extension.activerecord.Model
;
import
com.baomidou.mybatisplus.extension.activerecord.Model
;
...
@@ -34,14 +35,14 @@ public class User extends Model<User> implements Serializable{
...
@@ -34,14 +35,14 @@ public class User extends Model<User> implements Serializable{
* 手机号作为用户账号
* 手机号作为用户账号
*/
*/
@ApiModelProperty
(
name
=
"user_id"
,
value
=
"用户主键id"
)
@ApiModelProperty
(
name
=
"user_id"
,
value
=
"用户主键id"
)
@Table
I
d
(
"user_id"
)
@Table
Fiel
d
(
"user_id"
)
private
String
userId
;
private
String
userId
;
/**
/**
* 密码
* 密码
*/
*/
@ApiModelProperty
(
name
=
"password"
,
value
=
"用户密码"
)
@ApiModelProperty
(
name
=
"password"
,
value
=
"用户密码"
)
@Table
I
d
(
"password"
)
@Table
Fiel
d
(
"password"
)
private
String
password
;
private
String
password
;
...
@@ -49,49 +50,49 @@ public class User extends Model<User> implements Serializable{
...
@@ -49,49 +50,49 @@ public class User extends Model<User> implements Serializable{
* 用户会员等级
* 用户会员等级
*/
*/
@ApiModelProperty
(
name
=
"user_level"
,
value
=
"用户会员等级"
)
@ApiModelProperty
(
name
=
"user_level"
,
value
=
"用户会员等级"
)
@Table
I
d
(
"user_level"
)
@Table
Fiel
d
(
"user_level"
)
private
int
userLevel
;
private
int
userLevel
;
/**
/**
* 跨境额度
* 跨境额度
*/
*/
@ApiModelProperty
(
name
=
"cross_border_line"
,
value
=
"跨境额度"
)
@ApiModelProperty
(
name
=
"cross_border_line"
,
value
=
"跨境额度"
)
@Table
I
d
(
"cross_border_line"
)
@Table
Fiel
d
(
"cross_border_line"
)
private
BigDecimal
crossBorderLine
;
private
BigDecimal
crossBorderLine
;
/**
/**
* 身份证号码
* 身份证号码
*/
*/
@ApiModelProperty
(
name
=
"id_card_number"
,
value
=
"身份证号码"
)
@ApiModelProperty
(
name
=
"id_card_number"
,
value
=
"身份证号码"
)
@Table
I
d
(
"id_card_number"
)
@Table
Fiel
d
(
"id_card_number"
)
private
String
idCardNumber
;
private
String
idCardNumber
;
/**
/**
* 粉丝昵称
* 粉丝昵称
*/
*/
@ApiModelProperty
(
name
=
"fans_nickname"
,
value
=
"粉丝昵称"
)
@ApiModelProperty
(
name
=
"fans_nickname"
,
value
=
"粉丝昵称"
)
@Table
I
d
(
"fans_nickname"
)
@Table
Fiel
d
(
"fans_nickname"
)
private
String
fansNickname
;
private
String
fansNickname
;
/**
/**
* 有赞粉丝id,有赞自动生成
* 有赞粉丝id,有赞自动生成
*/
*/
@ApiModelProperty
(
name
=
"fans_id"
,
value
=
"有赞粉丝id,有赞自动生成"
)
@ApiModelProperty
(
name
=
"fans_id"
,
value
=
"有赞粉丝id,有赞自动生成"
)
@Table
I
d
(
"fans_id"
)
@Table
Fiel
d
(
"fans_id"
)
private
String
fansId
;
private
String
fansId
;
/**
/**
* 用户本人邀请码
* 用户本人邀请码
*/
*/
@ApiModelProperty
(
name
=
"invite_code"
,
value
=
"用户本人邀请码"
)
@ApiModelProperty
(
name
=
"invite_code"
,
value
=
"用户本人邀请码"
)
@Table
I
d
(
"invite_code"
)
@Table
Fiel
d
(
"invite_code"
)
private
String
inviteCode
;
private
String
inviteCode
;
/**
/**
* 推荐人邀请码
* 推荐人邀请码
*/
*/
@ApiModelProperty
(
name
=
"be_invited_code"
,
value
=
"推荐人邀请码"
)
@ApiModelProperty
(
name
=
"be_invited_code"
,
value
=
"推荐人邀请码"
)
@Table
I
d
(
"be_invited_code"
)
@Table
Fiel
d
(
"be_invited_code"
)
private
String
beInvitedCode
;
private
String
beInvitedCode
;
/**
/**
...
...
wisenergy-shiro/src/main/java/com/project/shiro/config/ShiroConfig.java
View file @
34ad5d18
This diff is collapsed.
Click to expand it.
wisenergy-shiro/src/main/java/com/project/shiro/util/AuthenticationFilter.java
View file @
34ad5d18
This diff is collapsed.
Click to expand it.
wisenergy-shiro/src/main/java/com/project/shiro/util/AuthenticationRealm.java
View file @
34ad5d18
This diff is collapsed.
Click to expand it.
wisenergy-shiro/src/main/java/com/project/shiro/util/AuthenticationToken.java
View file @
34ad5d18
package
com
.
project
.
shiro
.
util
;
//
package com.project.shiro.util;
//
import
org.apache.shiro.authc.UsernamePasswordToken
;
//
import org.apache.shiro.authc.UsernamePasswordToken;
//
/**
/
//
**
* 登录令牌
//
* 登录令牌
*/
//
*/
public
class
AuthenticationToken
extends
UsernamePasswordToken
{
//
public class AuthenticationToken extends UsernamePasswordToken {
//
private
static
final
long
serialVersionUID
=
4628652632307774263L
;
//
private static final long serialVersionUID = 4628652632307774263L;
//
//验证码ID
//
//验证码ID
private
String
captchaId
;
//
private String captchaId;
//
//验证码
//
//验证码
private
String
captcha
;
//
private String captcha;
//
//ip保留
//
//ip保留
public
AuthenticationToken
(
String
loginName
,
String
password
,
boolean
remeberMe
,
String
ip
,
String
captchaId
,
String
caprcha
)
{
//
public AuthenticationToken(String loginName, String password, boolean remeberMe, String ip, String captchaId, String caprcha) {
super
(
loginName
,
password
,
remeberMe
);
//
super(loginName, password, remeberMe);
this
.
captchaId
=
captchaId
;
//
this.captchaId = captchaId;
this
.
captcha
=
caprcha
;
//
this.captcha = caprcha;
}
//
}
//
public
String
getCaptchaId
()
{
//
public String getCaptchaId() {
return
captchaId
;
//
return captchaId;
}
//
}
//
public
void
setCaptchaId
(
String
captchaId
)
{
//
public void setCaptchaId(String captchaId) {
this
.
captchaId
=
captchaId
;
//
this.captchaId = captchaId;
}
//
}
//
public
String
getCaptcha
()
{
//
public String getCaptcha() {
return
captcha
;
//
return captcha;
}
//
}
//
public
void
setCaptcha
(
String
captcha
)
{
//
public void setCaptcha(String captcha) {
this
.
captcha
=
captcha
;
//
this.captcha = captcha;
}
//
}
//
}
//
}
wisenergy-shiro/src/main/java/com/project/shiro/util/AuthorizationFilter.java
View file @
34ad5d18
package
com
.
project
.
shiro
.
util
;
//
package com.project.shiro.util;
//
import
com.alibaba.fastjson.JSONObject
;
//
import com.alibaba.fastjson.JSONObject;
import
io.swagger.annotations.ResponseHeader
;
//
import io.swagger.annotations.ResponseHeader;
import
org.apache.commons.lang3.StringUtils
;
//
import org.apache.commons.lang3.StringUtils;
import
org.apache.shiro.web.filter.authz.PermissionsAuthorizationFilter
;
//
import org.apache.shiro.web.filter.authz.PermissionsAuthorizationFilter;
//
import
javax.servlet.ServletRequest
;
//
import javax.servlet.ServletRequest;
import
javax.servlet.ServletResponse
;
//
import javax.servlet.ServletResponse;
import
javax.servlet.http.HttpServletRequest
;
//
import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
//
import javax.servlet.http.HttpServletResponse;
import
java.io.IOException
;
//
import java.io.IOException;
import
java.io.PrintWriter
;
//
import java.io.PrintWriter;
//
/**
/
//
**
* @author wyy
//
* @author wyy
* @date 2019-09-14 17:57
//
* @date 2019-09-14 17:57
*/
//
*/
public
class
AuthorizationFilter
extends
PermissionsAuthorizationFilter
{
//
public class AuthorizationFilter extends PermissionsAuthorizationFilter {
/**
//
/**
* shiro认证perms资源失败后回调方法
//
* shiro认证perms资源失败后回调方法
* @param servletRequest
//
* @param servletRequest
* @param servletResponse
//
* @param servletResponse
* @return
//
* @return
* @throws IOException
//
* @throws IOException
*/
//
*/
@Override
//
@Override
protected
boolean
onAccessDenied
(
ServletRequest
servletRequest
,
ServletResponse
servletResponse
)
throws
IOException
{
//
protected boolean onAccessDenied(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException {
HttpServletRequest
httpServletRequest
=
(
HttpServletRequest
)
servletRequest
;
//
HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
HttpServletResponse
httpServletResponse
=
(
HttpServletResponse
)
servletResponse
;
//
HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse;
String
requestedWith
=
httpServletRequest
.
getHeader
(
"X-Requested-With"
);
//
String requestedWith = httpServletRequest.getHeader("X-Requested-With");
if
(
StringUtils
.
isNotEmpty
(
requestedWith
)
&&
StringUtils
.
equals
(
requestedWith
,
"XMLHttpRequest"
))
{
//如果是ajax返回指定格式数据
//
if (StringUtils.isNotEmpty(requestedWith) && StringUtils.equals(requestedWith, "XMLHttpRequest")) {//如果是ajax返回指定格式数据
httpServletResponse
.
setContentType
(
"application/json"
);
//
httpServletResponse.setContentType("application/json");
httpServletResponse
.
setCharacterEncoding
(
"UTF-8"
);
//
httpServletResponse.setCharacterEncoding("UTF-8");
PrintWriter
out
=
httpServletResponse
.
getWriter
();
//
PrintWriter out = httpServletResponse.getWriter();
JSONObject
json
=
new
JSONObject
();
//
JSONObject json = new JSONObject();
json
.
put
(
"result"
,
"success"
);
//
json.put("result", "success");
json
.
put
(
"msg"
,
"登录成功"
);
//
json.put("msg", "登录成功");
out
.
write
(
json
.
toJSONString
());
//
out.write(json.toJSONString());
out
.
flush
();
//
out.flush();
out
.
close
();
//
out.close();
}
else
{
//如果是普通请求进行重定向
//
} else {//如果是普通请求进行重定向
httpServletResponse
.
sendRedirect
(
"/403"
);
//
httpServletResponse.sendRedirect("/403");
}
//
}
return
false
;
//
return false;
}
//
}
}
//
}
wisenergy-shiro/src/main/java/com/project/shiro/util/Principal.java
View file @
34ad5d18
package
com
.
project
.
shiro
.
util
;
//
package com.project.shiro.util;
//
import
java.io.Serializable
;
//
import java.io.Serializable;
//
public
class
Principal
implements
Serializable
{
//
public class Principal implements Serializable {
//
private
static
final
long
serialVersionUID
=
598764316789461315L
;
//
private static final long serialVersionUID = 598764316789461315L;
//
public
Long
id
;
//
public Long id;
//
public
String
loginName
;
//
public String loginName;
//
public
Principal
(
Long
id
,
String
loginName
)
{
//
public Principal(Long id, String loginName) {
this
.
id
=
id
;
//
this.id = id;
this
.
loginName
=
loginName
;
//
this.loginName = loginName;
}
//
}
//
public
Principal
()
{
//
public Principal() {
//
}
//
}
//
public
Long
getId
()
{
//
public Long getId() {
return
id
;
//
return id;
}
//
}
//
public
void
setId
(
Long
id
)
{
//
public void setId(Long id) {
this
.
id
=
id
;
//
this.id = id;
}
//
}
//
public
String
getLoginName
()
{
//
public String getLoginName() {
return
loginName
;
//
return loginName;
}
//
}
//
public
void
setLoginName
(
String
loginName
)
{
//
public void setLoginName(String loginName) {
this
.
loginName
=
loginName
;
//
this.loginName = loginName;
}
//
}
//
}
//
}
wisenergy-shiro/src/main/java/com/project/shiro/util/redis/ShiroRedisCache.java
View file @
34ad5d18
This diff is collapsed.
Click to expand it.
wisenergy-shiro/src/main/java/com/project/shiro/util/redis/ShiroRedisCacheManager.java
View file @
34ad5d18
package
com
.
project
.
shiro
.
util
.
redis
;
//
package com.project.shiro.util.redis;
//
//
import
cn.wisenergy.service.common.utils.redis.RedisClient
;
//
import cn.wisenergy.service.common.utils.redis.RedisClient;
import
cn.wisenergy.service.common.utils.redis.RedisConsts
;
//
import cn.wisenergy.service.common.utils.redis.RedisConsts;
import
org.apache.shiro.cache.Cache
;
//
import org.apache.shiro.cache.Cache;
import
org.apache.shiro.cache.CacheException
;
//
import org.apache.shiro.cache.CacheException;
import
org.apache.shiro.cache.CacheManager
;
//
import org.apache.shiro.cache.CacheManager;
import
org.slf4j.Logger
;
//
import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
//
import org.slf4j.LoggerFactory;
//
import
javax.annotation.Resource
;
//
import javax.annotation.Resource;
import
java.util.concurrent.ConcurrentHashMap
;
//
import java.util.concurrent.ConcurrentHashMap;
import
java.util.concurrent.ConcurrentMap
;
//
import java.util.concurrent.ConcurrentMap;
//
public
class
ShiroRedisCacheManager
implements
CacheManager
{
//
public class ShiroRedisCacheManager implements CacheManager {
//
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ShiroRedisCacheManager
.
class
);
//
private static final Logger logger = LoggerFactory.getLogger(ShiroRedisCacheManager.class);
//
private
final
ConcurrentMap
<
String
,
Cache
>
caches
=
new
ConcurrentHashMap
<
String
,
Cache
>();
//
private final ConcurrentMap<String, Cache> caches = new ConcurrentHashMap<String, Cache>();
//
//注入redisClient实例
//
//注入redisClient实例
@Resource
(
name
=
"redisClient"
)
//
@Resource(name = "redisClient")
private
RedisClient
redisClient
;
//
private RedisClient redisClient;
//
/**
//
/**
* shiro权限缓存前缀
//
* shiro权限缓存前缀
*/
//
*/
private
String
keyPrefix
=
RedisConsts
.
ADMIN_SHIRO_REALM_KEY
;
//
private String keyPrefix = RedisConsts.ADMIN_SHIRO_REALM_KEY;
//
//
@Override
//
@Override
public
<
K
,
V
>
Cache
<
K
,
V
>
getCache
(
String
name
)
throws
CacheException
{
//
public <K, V> Cache<K, V> getCache(String name) throws CacheException {
//
logger
.
debug
(
"获取名称为: "
+
name
+
" 的RedisCache实例"
);
//
logger.debug("获取名称为: " + name + " 的RedisCache实例");
Cache
c
=
caches
.
get
(
keyPrefix
+
name
);
//
Cache c = caches.get(keyPrefix + name);
if
(
c
==
null
)
{
//
if (c == null) {
c
=
new
ShiroRedisCache
<
K
,
V
>(
redisClient
,
keyPrefix
);
//
c = new ShiroRedisCache<K, V>(redisClient, keyPrefix);
caches
.
put
(
keyPrefix
+
name
,
c
);
//
caches.put(keyPrefix + name, c);
}
//
}
return
c
;
//
return c;
}
//
}
//
public
RedisClient
getRedisClient
()
{
//
public RedisClient getRedisClient() {
return
redisClient
;
//
return redisClient;
}
//
}
//
public
void
setRedisClient
(
RedisClient
redisClient
)
{
//
public void setRedisClient(RedisClient redisClient) {
this
.
redisClient
=
redisClient
;
//
this.redisClient = redisClient;
}
//
}
//
public
String
getKeyPrefix
()
{
//
public String getKeyPrefix() {
return
keyPrefix
;
//
return keyPrefix;
}
//
}
//
public
void
setKeyPrefix
(
String
keyPrefix
)
{
//
public void setKeyPrefix(String keyPrefix) {
this
.
keyPrefix
=
keyPrefix
;
//
this.keyPrefix = keyPrefix;
}
//
}
}
//
}
wisenergy-shiro/src/main/java/com/project/shiro/util/redis/ShiroRedisSessionDAO.java
View file @
34ad5d18
package
com
.
project
.
shiro
.
util
.
redis
;
//
package com.project.shiro.util.redis;
//
import
cn.wisenergy.service.common.utils.ByteUtil
;
//
import cn.wisenergy.service.common.utils.ByteUtil;
import
cn.wisenergy.service.common.utils.redis.RedisClient
;
//
import cn.wisenergy.service.common.utils.redis.RedisClient;
import
cn.wisenergy.service.common.utils.redis.RedisConsts
;
//
import cn.wisenergy.service.common.utils.redis.RedisConsts;
import
org.apache.shiro.session.Session
;
//
import org.apache.shiro.session.Session;
import
org.apache.shiro.session.UnknownSessionException
;
//
import org.apache.shiro.session.UnknownSessionException;
import
org.apache.shiro.session.mgt.eis.AbstractSessionDAO
;
//
import org.apache.shiro.session.mgt.eis.AbstractSessionDAO;
import
org.slf4j.Logger
;
//
import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
//
import org.slf4j.LoggerFactory;
//
import
javax.annotation.Resource
;
//
import javax.annotation.Resource;
import
java.io.IOException
;
//
import java.io.IOException;
import
java.io.Serializable
;
//
import java.io.Serializable;
import
java.util.Collection
;
//
import java.util.Collection;
import
java.util.HashSet
;
//
import java.util.HashSet;
import
java.util.Set
;
//
import java.util.Set;
//
public
class
ShiroRedisSessionDAO
extends
AbstractSessionDAO
{
//
public class ShiroRedisSessionDAO extends AbstractSessionDAO {
//
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ShiroRedisSessionDAO
.
class
);
//
private static Logger logger = LoggerFactory.getLogger(ShiroRedisSessionDAO.class);
//
//注入redisClient实例
//
//注入redisClient实例
@Resource
(
name
=
"redisClient"
)
//
@Resource(name = "redisClient")
private
RedisClient
redisClient
;
//
private RedisClient redisClient;
//
/**
//
/**
* shiro-redis的session对象前缀
//
* shiro-redis的session对象前缀
*/
//
*/
//
private
String
keyPrefix
=
RedisConsts
.
ADMIN_SHIRO_SESSION_KEY
;
//
private String keyPrefix = RedisConsts.ADMIN_SHIRO_SESSION_KEY;
//
@Override
//
@Override
public
void
update
(
Session
session
)
throws
UnknownSessionException
{
//
public void update(Session session) throws UnknownSessionException {
this
.
saveSession
(
session
);
//
this.saveSession(session);
}
//
}
//
private
void
saveSession
(
Session
session
)
throws
UnknownSessionException
{
//
private void saveSession(Session session) throws UnknownSessionException {
if
(
session
==
null
||
session
.
getId
()
==
null
)
{
//
if (session == null || session.getId() == null) {
logger
.
error
(
"session or session id is null"
);
//
logger.error("session or session id is null");
return
;
//
return;
}
//
}
this
.
redisClient
.
setAndExpire
(
this
.
getPreStringKey
(
session
.
getId
()),
session
,
RedisConsts
.
ADMIN_SHIRO_SESSION_EXPIRE
);
//
this.redisClient.setAndExpire(this.getPreStringKey(session.getId()), session, RedisConsts.ADMIN_SHIRO_SESSION_EXPIRE);
}
//
}
//
@Override
//
@Override
public
void
delete
(
Session
session
)
{
//
public void delete(Session session) {
if
(
session
==
null
||
session
.
getId
()
==
null
)
{
//
if (session == null || session.getId() == null) {
logger
.
error
(
"session or session id is null"
);
//
logger.error("session or session id is null");
return
;
//
return;
}
//
}
redisClient
.
del
(
getPreStringKey
(
session
.
getId
()));
//
redisClient.del(getPreStringKey(session.getId()));
//
}
//
}
//
@Override
//
@Override
public
Collection
<
Session
>
getActiveSessions
()
{
//
public Collection<Session> getActiveSessions() {
Set
<
Session
>
sessions
=
new
HashSet
<
Session
>();
//
Set<Session> sessions = new HashSet<Session>();
//
Set
<
byte
[]>
keys
=
null
;
//
Set<byte[]> keys = null;
try
{
//
try {
keys
=
redisClient
.
keys
(
ByteUtil
.
objectToBytes
(
this
.
keyPrefix
+
"*"
));
//
keys = redisClient.keys(ByteUtil.objectToBytes(this.keyPrefix + "*"));
}
catch
(
IOException
e
)
{
//
} catch (IOException e) {
e
.
printStackTrace
();
//
e.printStackTrace();
}
//
}
if
(
keys
!=
null
&&
keys
.
size
()
>
0
)
{
//
if (keys != null && keys.size() > 0) {
for
(
byte
[]
key
:
keys
)
{
//
for (byte[] key : keys) {
Session
s
=
null
;
//
Session s = null;
try
{
//
try {
s
=
(
Session
)
ByteUtil
.
bytesToObject
(
redisClient
.
get
(
key
));
//
s = (Session) ByteUtil.bytesToObject(redisClient.get(key));
}
catch
(
IOException
e
)
{
//
} catch (IOException e) {
e
.
printStackTrace
();
//
e.printStackTrace();
}
catch
(
ClassNotFoundException
e
)
{
//
} catch (ClassNotFoundException e) {
e
.
printStackTrace
();
//
e.printStackTrace();
}
//
}
sessions
.
add
(
s
);
//
sessions.add(s);
}
//
}
}
//
}
//
return
sessions
;
//
return sessions;
}
//
}
//
@Override
//
@Override
protected
Serializable
doCreate
(
Session
session
)
{
//
protected Serializable doCreate(Session session) {
Serializable
sessionId
=
this
.
generateSessionId
(
session
);
//
Serializable sessionId = this.generateSessionId(session);
this
.
assignSessionId
(
session
,
sessionId
);
//
this.assignSessionId(session, sessionId);
this
.
saveSession
(
session
);
//
this.saveSession(session);
return
sessionId
;
//
return sessionId;
}
//
}
//
@Override
//
@Override
protected
Session
doReadSession
(
Serializable
sessionId
)
{
//
protected Session doReadSession(Serializable sessionId) {
if
(
sessionId
==
null
)
{
//
if (sessionId == null) {
logger
.
error
(
"session id is null"
);
//
logger.error("session id is null");
return
null
;
//
return null;
}
//
}
//
Session
s
=
(
Session
)
redisClient
.
get
(
this
.
getPreStringKey
(
sessionId
));
//
Session s = (Session) redisClient.get(this.getPreStringKey(sessionId));
return
s
;
//
return s;
}
//
}
//
/**
//
/**
* 获得String类型的key
//
* 获得String类型的key
*
//
*
* @param
//
* @param
* @return
//
* @return
*/
//
*/
private
String
getPreStringKey
(
Serializable
sessionId
)
{
//
private String getPreStringKey(Serializable sessionId) {
String
preKey
=
this
.
keyPrefix
+
sessionId
;
//
String preKey = this.keyPrefix + sessionId;
return
preKey
;
//
return preKey;
}
//
}
//
public
String
getKeyPrefix
()
{
//
public String getKeyPrefix() {
return
keyPrefix
;
//
return keyPrefix;
}
//
}
//
public
void
setKeyPrefix
(
String
keyPrefix
)
{
//
public void setKeyPrefix(String keyPrefix) {
this
.
keyPrefix
=
keyPrefix
;
//
this.keyPrefix = keyPrefix;
}
//
}
//
public
void
setRedisClient
(
RedisClient
redisClient
)
{
//
public void setRedisClient(RedisClient redisClient) {
this
.
redisClient
=
redisClient
;
//
this.redisClient = redisClient;
}
//
}
//
public
RedisClient
getRedisClient
()
{
//
public RedisClient getRedisClient() {
return
redisClient
;
//
return redisClient;
}
//
}
//
}
//
}
wisenergy-web-admin/src/main/java/cn/wisenergy/web/sms/interceptor/LoginInterceptor.java
View file @
34ad5d18
package
cn
.
wisenergy
.
web
.
sms
.
interceptor
;
package
cn
.
wisenergy
.
web
.
sms
.
interceptor
;
import
cn.wisenergy.common.enums.ResultEnum
;
import
cn.wisenergy.common.enums.ResultEnum
;
import
cn.wisenergy.common.utils.Constants
;
import
cn.wisenergy.common.utils.RedisUtils
;
import
cn.wisenergy.common.utils.RedisUtils
;
import
cn.wisenergy.common.utils.ResponseOutput
;
import
cn.wisenergy.common.utils.ResponseOutput
;
import
cn.wisenergy.common.utils.StringUtil
;
import
cn.wisenergy.common.utils.StringUtil
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment