Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzuaa
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzuaa
提交
8b2279cf
提交
8b2279cf
编写于
12月 28, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
转接sysuser
上级
1e5ba661
变更
2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
13 行增加
和
21 行删除
+13
-21
LdapUserService.java
.../ibizlab/core/uaa/extensions/service/LdapUserService.java
+6
-11
UAAUserService.java
...n/ibizlab/core/uaa/extensions/service/UAAUserService.java
+7
-10
未找到文件。
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/extensions/service/LdapUserService.java
浏览文件 @
8b2279cf
package
cn
.
ibizlab
.
core
.
uaa
.
extensions
.
service
;
package
cn
.
ibizlab
.
core
.
uaa
.
extensions
.
service
;
import
cn.ibizlab.core.uaa.domain.SysUser
;
import
cn.ibizlab.core.uaa.service.impl.SysUserServiceImpl
;
import
cn.ibizlab.util.client.IBZOUFeignClient
;
import
cn.ibizlab.util.client.IBZOUFeignClient
;
import
cn.ibizlab.util.domain.IBZUSER
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
cn.ibizlab.util.mapper.IBZUSERMapper
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
cn.ibizlab.util.service.AuthenticationUserService
;
import
cn.ibizlab.util.service.AuthenticationUserService
;
import
cn.ibizlab.util.service.IBZUSERService
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.ldap.core.LdapTemplate
;
import
org.springframework.ldap.core.LdapTemplate
;
...
@@ -26,7 +22,6 @@ import org.springframework.security.core.GrantedAuthority;
...
@@ -26,7 +22,6 @@ import org.springframework.security.core.GrantedAuthority;
import
org.springframework.security.core.authority.AuthorityUtils
;
import
org.springframework.security.core.authority.AuthorityUtils
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
...
@@ -40,7 +35,7 @@ import java.util.*;
...
@@ -40,7 +35,7 @@ import java.util.*;
@Slf4j
@Slf4j
@Service
(
"LdapUserService"
)
@Service
(
"LdapUserService"
)
@ConditionalOnExpression
(
"'${ibiz.auth.service:SimpleUserService}'.equals('LdapUserService')"
)
@ConditionalOnExpression
(
"'${ibiz.auth.service:SimpleUserService}'.equals('LdapUserService')"
)
public
class
LdapUserService
extends
S
erviceImpl
<
IBZUSERMapper
,
IBZUSER
>
implements
IBZUSERService
,
AuthenticationUserService
{
public
class
LdapUserService
extends
S
ysUserServiceImpl
implements
AuthenticationUserService
{
@Value
(
"${ibiz.auth.pwencrymode:0}"
)
@Value
(
"${ibiz.auth.pwencrymode:0}"
)
private
int
pwencrymode
;
private
int
pwencrymode
;
...
@@ -51,7 +46,7 @@ public class LdapUserService extends ServiceImpl<IBZUSERMapper, IBZUSER> impleme
...
@@ -51,7 +46,7 @@ public class LdapUserService extends ServiceImpl<IBZUSERMapper, IBZUSER> impleme
public
AuthenticationUser
loadUserByUsername
(
String
username
)
{
public
AuthenticationUser
loadUserByUsername
(
String
username
)
{
if
(
StringUtils
.
isEmpty
(
username
))
if
(
StringUtils
.
isEmpty
(
username
))
throw
new
UsernameNotFoundException
(
"用户名为空"
);
throw
new
UsernameNotFoundException
(
"用户名为空"
);
QueryWrapper
<
IBZUSER
>
conds
=
new
QueryWrapper
<
IBZUSER
>();
QueryWrapper
<
SysUser
>
conds
=
new
QueryWrapper
<
SysUser
>();
String
[]
data
=
username
.
split
(
"[|]"
);
String
[]
data
=
username
.
split
(
"[|]"
);
String
loginname
=
""
;
String
loginname
=
""
;
String
domains
=
""
;
String
domains
=
""
;
...
@@ -63,7 +58,7 @@ public class LdapUserService extends ServiceImpl<IBZUSERMapper, IBZUSER> impleme
...
@@ -63,7 +58,7 @@ public class LdapUserService extends ServiceImpl<IBZUSERMapper, IBZUSER> impleme
conds
.
eq
(
"loginname"
,
loginname
);
conds
.
eq
(
"loginname"
,
loginname
);
if
(!
StringUtils
.
isEmpty
(
domains
))
if
(!
StringUtils
.
isEmpty
(
domains
))
conds
.
eq
(
"domains"
,
domains
);
conds
.
eq
(
"domains"
,
domains
);
IBZUSER
user
=
this
.
getOne
(
conds
);
SysUser
user
=
this
.
getOne
(
conds
);
if
(
user
==
null
)
{
if
(
user
==
null
)
{
throw
new
UsernameNotFoundException
(
"用户"
+
username
+
"未找到"
);
throw
new
UsernameNotFoundException
(
"用户"
+
username
+
"未找到"
);
}
else
{
}
else
{
...
@@ -136,7 +131,7 @@ public class LdapUserService extends ServiceImpl<IBZUSERMapper, IBZUSER> impleme
...
@@ -136,7 +131,7 @@ public class LdapUserService extends ServiceImpl<IBZUSERMapper, IBZUSER> impleme
}
}
public
AuthenticationUser
createUserDetails
(
IBZUSER
user
)
{
public
AuthenticationUser
createUserDetails
(
SysUser
user
)
{
AuthenticationUser
userdatail
=
new
AuthenticationUser
();
AuthenticationUser
userdatail
=
new
AuthenticationUser
();
CachedBeanCopier
.
copy
(
user
,
userdatail
);
CachedBeanCopier
.
copy
(
user
,
userdatail
);
if
(
userdatail
.
getSuperuser
()
==
1
)
{
if
(
userdatail
.
getSuperuser
()
==
1
)
{
...
...
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/extensions/service/UAAUserService.java
浏览文件 @
8b2279cf
package
cn
.
ibizlab
.
core
.
uaa
.
extensions
.
service
;
package
cn
.
ibizlab
.
core
.
uaa
.
extensions
.
service
;
import
cn.ibizlab.core.uaa.domain.SysUser
;
import
cn.ibizlab.core.uaa.service.impl.SysUserServiceImpl
;
import
cn.ibizlab.util.client.IBZOUFeignClient
;
import
cn.ibizlab.util.client.IBZOUFeignClient
;
import
cn.ibizlab.util.service.AuthenticationUserService
;
import
cn.ibizlab.util.service.AuthenticationUserService
;
import
cn.ibizlab.util.service.IBZUSERService
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.authority.AuthorityUtils
;
import
org.springframework.security.core.authority.AuthorityUtils
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
cn.ibizlab.util.mapper.IBZUSERMapper
;
import
cn.ibizlab.util.domain.IBZUSER
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -32,7 +28,7 @@ import java.util.Set;
...
@@ -32,7 +28,7 @@ import java.util.Set;
* 实体[IBZUSER] 服务对象接口实现
* 实体[IBZUSER] 服务对象接口实现
*/
*/
@Service
(
"UAAUserService"
)
@Service
(
"UAAUserService"
)
public
class
UAAUserService
extends
S
erviceImpl
<
IBZUSERMapper
,
IBZUSER
>
implements
IBZUSERService
,
AuthenticationUserService
{
public
class
UAAUserService
extends
S
ysUserServiceImpl
implements
AuthenticationUserService
{
@Value
(
"${ibiz.auth.pwencrymode:0}"
)
@Value
(
"${ibiz.auth.pwencrymode:0}"
)
private
int
pwencrymode
;
private
int
pwencrymode
;
...
@@ -41,7 +37,7 @@ public class UAAUserService extends ServiceImpl<IBZUSERMapper, IBZUSER> implemen
...
@@ -41,7 +37,7 @@ public class UAAUserService extends ServiceImpl<IBZUSERMapper, IBZUSER> implemen
public
AuthenticationUser
loadUserByUsername
(
String
username
)
{
public
AuthenticationUser
loadUserByUsername
(
String
username
)
{
if
(
StringUtils
.
isEmpty
(
username
))
if
(
StringUtils
.
isEmpty
(
username
))
throw
new
UsernameNotFoundException
(
"用户名为空"
);
throw
new
UsernameNotFoundException
(
"用户名为空"
);
QueryWrapper
<
IBZUSER
>
conds
=
new
QueryWrapper
<
IBZUSER
>();
QueryWrapper
<
SysUser
>
conds
=
new
QueryWrapper
<
SysUser
>();
String
[]
data
=
username
.
split
(
"[|]"
);
String
[]
data
=
username
.
split
(
"[|]"
);
String
loginname
=
""
;
String
loginname
=
""
;
String
domains
=
""
;
String
domains
=
""
;
...
@@ -53,7 +49,7 @@ public class UAAUserService extends ServiceImpl<IBZUSERMapper, IBZUSER> implemen
...
@@ -53,7 +49,7 @@ public class UAAUserService extends ServiceImpl<IBZUSERMapper, IBZUSER> implemen
conds
.
eq
(
"loginname"
,
loginname
);
conds
.
eq
(
"loginname"
,
loginname
);
if
(!
StringUtils
.
isEmpty
(
domains
))
if
(!
StringUtils
.
isEmpty
(
domains
))
conds
.
eq
(
"domains"
,
domains
);
conds
.
eq
(
"domains"
,
domains
);
IBZUSER
user
=
this
.
getOne
(
conds
);
SysUser
user
=
this
.
getOne
(
conds
);
if
(
user
==
null
)
{
if
(
user
==
null
)
{
throw
new
UsernameNotFoundException
(
"用户"
+
username
+
"未找到"
);
throw
new
UsernameNotFoundException
(
"用户"
+
username
+
"未找到"
);
}
}
...
@@ -89,9 +85,10 @@ public class UAAUserService extends ServiceImpl<IBZUSERMapper, IBZUSER> implemen
...
@@ -89,9 +85,10 @@ public class UAAUserService extends ServiceImpl<IBZUSERMapper, IBZUSER> implemen
}
}
public
AuthenticationUser
createUserDetails
(
IBZUSER
user
)
{
public
AuthenticationUser
createUserDetails
(
SysUser
user
)
{
AuthenticationUser
userdatail
=
new
AuthenticationUser
();
AuthenticationUser
userdatail
=
new
AuthenticationUser
();
CachedBeanCopier
.
copy
(
user
,
userdatail
);
CachedBeanCopier
.
copy
(
user
,
userdatail
);
userdatail
.
setSuperuser
(
user
.
getSuperuser
());
if
(
userdatail
.
getSuperuser
()==
1
){
if
(
userdatail
.
getSuperuser
()==
1
){
userdatail
.
setAuthorities
(
AuthorityUtils
.
createAuthorityList
(
"ROLE_SUPERADMIN"
));
userdatail
.
setAuthorities
(
AuthorityUtils
.
createAuthorityList
(
"ROLE_SUPERADMIN"
));
}
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录