Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibizlab-boot-starters
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibizlab-boot-starters
提交
3b79c3b6
提交
3b79c3b6
编写于
9月 19, 2022
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提交uaa相关
上级
bfb654c0
变更
7
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
121 行增加
和
5 行删除
+121
-5
IBZUSERServiceImpl.java
...main/java/cn/ibizlab/util/service/IBZUSERServiceImpl.java
+1
-1
CloudTokenUtil.java
...rc/main/java/cn/ibizlab/util/security/CloudTokenUtil.java
+115
-0
UAATokenUtil.java
.../src/main/java/cn/ibizlab/util/security/UAATokenUtil.java
+1
-1
CloudUserService.java
...c/main/java/cn/ibizlab/util/service/CloudUserService.java
+1
-1
IBZUAAUserService.java
.../main/java/cn/ibizlab/util/service/IBZUAAUserService.java
+1
-1
SimpleUserService.java
.../main/java/cn/ibizlab/util/service/SimpleUserService.java
+1
-1
ibzrt_rsa.pub
...boot-starter/src/main/resources/uaa/keypair/ibzrt_rsa.pub
+1
-0
未找到文件。
ibizlab-boot-starter-data/src/main/java/cn/ibizlab/util/service/IBZUSERServiceImpl.java
浏览文件 @
3b79c3b6
...
...
@@ -24,7 +24,7 @@ import org.springframework.util.StringUtils;
* 实体[IBZUSER] 服务对象接口实现
*/
@Service
(
"IBZUSERService"
)
@ConditionalOnExpression
(
"(!${ibiz.enablePermissionValid:false})&&'${ibiz.auth.service:IBZU
SER
Service}'.equals('IBZUSERService')"
)
@ConditionalOnExpression
(
"(!${ibiz.enablePermissionValid:false})&&'${ibiz.auth.service:IBZU
AAUser
Service}'.equals('IBZUSERService')"
)
public
class
IBZUSERServiceImpl
extends
ServiceImpl
<
IBZUSERMapper
,
IBZUSER
>
implements
IBZUSERService
,
AuthenticationUserService
{
@Value
(
"${ibiz.auth.pwencrymode:0}"
)
...
...
ibizlab-boot-starter/src/main/java/cn/ibizlab/util/security/CloudTokenUtil.java
0 → 100644
浏览文件 @
3b79c3b6
package
cn
.
ibizlab
.
util
.
security
;
import
io.jsonwebtoken.Claims
;
import
io.jsonwebtoken.Clock
;
import
io.jsonwebtoken.Jwts
;
import
io.jsonwebtoken.impl.DefaultClock
;
import
lombok.SneakyThrows
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.io.IOUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.stereotype.Component
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.Serializable
;
import
java.nio.charset.Charset
;
import
java.security.KeyFactory
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.PublicKey
;
import
java.security.spec.InvalidKeySpecException
;
import
java.security.spec.X509EncodedKeySpec
;
import
java.util.Date
;
import
java.util.function.Function
;
@Component
@ConditionalOnExpression
(
"'${ibiz.auth.token.util:UAATokenUtil}'.equals('CloudTokenUtil')"
)
public
class
CloudTokenUtil
implements
AuthTokenUtil
,
Serializable
{
private
static
final
long
serialVersionUID
=
-
3301605591108950415L
;
private
Clock
clock
=
DefaultClock
.
INSTANCE
;
@Value
(
"${ibiz.jwt.secret:ibzsecret}"
)
private
String
secret
;
@Value
(
"${ibiz.jwt.expiration:7200000}"
)
private
Long
expiration
;
@Value
(
"${ibiz.jwt.header:Authorization}"
)
private
String
tokenHeader
;
public
String
getUsernameFromToken
(
String
token
)
{
return
getClaimFromToken
(
token
,
Claims:
:
getSubject
);
}
public
Date
getIssuedAtDateFromToken
(
String
token
)
{
return
getClaimFromToken
(
token
,
Claims:
:
getIssuedAt
);
}
public
Date
getExpirationDateFromToken
(
String
token
)
{
return
getClaimFromToken
(
token
,
Claims:
:
getExpiration
);
}
public
<
T
>
T
getClaimFromToken
(
String
token
,
Function
<
Claims
,
T
>
claimsResolver
)
{
final
Claims
claims
=
getAllClaimsFromToken
(
token
);
return
claimsResolver
.
apply
(
claims
);
}
public
Claims
getAllClaimsFromToken
(
String
token
)
{
PublicKey
publicKey
=
getPublicKey
(
getPublicKeyString
());
return
Jwts
.
parser
()
.
setSigningKey
(
publicKey
)
.
parseClaimsJws
(
token
)
.
getBody
();
}
public
String
generateToken
(
UserDetails
userDetails
)
{
return
null
;
}
public
Boolean
validateToken
(
String
token
,
UserDetails
userDetails
)
{
AuthenticationUser
user
=
(
AuthenticationUser
)
userDetails
;
user
.
setToken
(
token
);
final
Date
created
=
getIssuedAtDateFromToken
(
token
);
final
Date
expiration
=
getExpirationDateFromToken
(
token
);
user
.
setExpiration
(
expiration
);
return
!
expiration
.
before
(
clock
.
now
());
}
@SneakyThrows
protected
String
getPublicKeyString
()
{
String
key
=
""
;
String
usrHome
=
System
.
getProperty
(
"user.home"
)
+
"/.ibzrt"
;
File
pubKeyFile
=
new
File
(
usrHome
,
"ibzrt_rsa.pub"
);
if
(!
pubKeyFile
.
exists
())
{
key
=
IOUtils
.
toString
(
this
.
getClass
().
getResourceAsStream
(
"/uaa/keypair/ibzrt_rsa.pub"
));
}
else
{
key
=
IOUtils
.
toString
(
new
FileInputStream
(
pubKeyFile
));
}
return
key
;
}
/**
* 获取PublicKey对象
* @param publicKeyBase64
* @return
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
*/
@SneakyThrows
public
PublicKey
getPublicKey
(
String
publicKeyBase64
)
{
byte
[]
byteKey
=
Base64
.
decodeBase64
(
publicKeyBase64
);
X509EncodedKeySpec
x509EncodedKeySpec
=
new
X509EncodedKeySpec
(
byteKey
);
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
"RSA"
);
return
keyFactory
.
generatePublic
(
x509EncodedKeySpec
);
}
}
ibizlab-boot-starter/src/main/java/cn/ibizlab/util/security/UAATokenUtil.java
浏览文件 @
3b79c3b6
...
...
@@ -23,7 +23,7 @@ import java.util.Date;
import
java.util.function.Function
;
@Component
@ConditionalOnExpression
(
"
${ibiz.enablePermissionValid:false}||
'${ibiz.auth.token.util:UAATokenUtil}'.equals('UAATokenUtil')"
)
@ConditionalOnExpression
(
"'${ibiz.auth.token.util:UAATokenUtil}'.equals('UAATokenUtil')"
)
public
class
UAATokenUtil
implements
AuthTokenUtil
,
Serializable
{
private
static
final
long
serialVersionUID
=
-
3301605591108950415L
;
...
...
ibizlab-boot-starter/src/main/java/cn/ibizlab/util/service/CloudUserService.java
浏览文件 @
3b79c3b6
...
...
@@ -36,7 +36,7 @@ import java.util.*;
@Slf4j
@Service
(
"CloudUserService"
)
@ConditionalOnExpression
(
"
${ibiz.enablePermissionValid:false}&&
'${ibiz.auth.service:IBZUAAUserService}'.equals('CloudUserService')"
)
@ConditionalOnExpression
(
"'${ibiz.auth.service:IBZUAAUserService}'.equals('CloudUserService')"
)
public
class
CloudUserService
extends
IBZUAAUserService
{
@Autowired
...
...
ibizlab-boot-starter/src/main/java/cn/ibizlab/util/service/IBZUAAUserService.java
浏览文件 @
3b79c3b6
...
...
@@ -17,7 +17,7 @@ import org.springframework.stereotype.Service;
* 实体[IBZUSER] 服务对象接口实现
*/
@Service
(
"IBZUAAUserService"
)
@ConditionalOnExpression
(
"
${ibiz.enablePermissionValid:false}&&
'${ibiz.auth.service:IBZUAAUserService}'.equals('IBZUAAUserService')"
)
@ConditionalOnExpression
(
"'${ibiz.auth.service:IBZUAAUserService}'.equals('IBZUAAUserService')"
)
public
class
IBZUAAUserService
implements
AuthenticationUserService
{
@Autowired
...
...
ibizlab-boot-starter/src/main/java/cn/ibizlab/util/service/SimpleUserService.java
浏览文件 @
3b79c3b6
...
...
@@ -18,7 +18,7 @@ import org.springframework.stereotype.Service;
*/
@Primary
@Service
(
"SimpleUserService"
)
@ConditionalOnExpression
(
"(!${ibiz.enablePermissionValid:false})&&'${ibiz.auth.service:IBZU
SER
Service}'.equals('SimpleUserService')"
)
@ConditionalOnExpression
(
"(!${ibiz.enablePermissionValid:false})&&'${ibiz.auth.service:IBZU
AAUser
Service}'.equals('SimpleUserService')"
)
public
class
SimpleUserService
implements
AuthenticationUserService
{
...
...
ibizlab-boot-starter/src/main/resources/uaa/keypair/ibzrt_rsa.pub
0 → 100644
浏览文件 @
3b79c3b6
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCmk8+KYDkf6dEY5XMzNHRK3+GVDc4hPxyXHygyz7u+xrNhCXQytLhnzyNxl/3kcF/S/W02Sbc/bF9n5Eakbd4Fp7DMqU9j/3Dv9hoLUQjx0RQ+wSPg399orBCWejOJA/bcii8PGPSrj9AttGTDA3gq624zGoDDK8EzjOP+HhY81QIDAQAB
\ No newline at end of file
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录