提交 97b40b75 编写于 作者: sq3536's avatar sq3536

init

上级 458512de
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
<artifactId>ibizlab-util</artifactId> <artifactId>ibizlab-util</artifactId>
<name>ibizlab-util</name> <name>ibizlab-util</name>
<description>ibizlab-util</description> <description>ibizlab-util</description>
<version>1.0.2</version> <version>1.0.3</version>
<!-- Spring Boot --> <!-- Spring Boot -->
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version> <version>2.2.5.RELEASE</version>
</parent> </parent>
<properties> <properties>
...@@ -45,8 +45,9 @@ ...@@ -45,8 +45,9 @@
<!--baomidou-jobs定时服务 --> <!--baomidou-jobs定时服务 -->
<baomidou-jobs.version>1.0.3</baomidou-jobs.version> <baomidou-jobs.version>1.0.3</baomidou-jobs.version>
<oracle.version>19.8.0.0</oracle.version> <ojdbc.version>19.8.0.0</ojdbc.version>
<postgresql.version>42.2.6</postgresql.version> <postgresql.version>42.2.10</postgresql.version>
<mysql.version>8.0.19</mysql.version>
<flowable-modeler.version>6.4.2</flowable-modeler.version> <flowable-modeler.version>6.4.2</flowable-modeler.version>
</properties> </properties>
...@@ -178,12 +179,12 @@ ...@@ -178,12 +179,12 @@
<dependency> <dependency>
<groupId>com.oracle.database.jdbc</groupId> <groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId> <artifactId>ojdbc8</artifactId>
<version>${oracle.version}</version> <version>${ojdbc.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.oracle.database.nls</groupId> <groupId>com.oracle.database.nls</groupId>
<artifactId>orai18n</artifactId> <artifactId>orai18n</artifactId>
<version>${oracle.version}</version> <version>${ojdbc.version}</version>
</dependency> </dependency>
<!-- PostgreSQL驱动包 --> <!-- PostgreSQL驱动包 -->
<dependency> <dependency>
...@@ -195,6 +196,13 @@ ...@@ -195,6 +196,13 @@
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
<exclusions>
<exclusion>
<artifactId>protobuf-java</artifactId>
<groupId>com.google.protobuf</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
</dependencies> </dependencies>
......
package cn.ibizlab.util.service;
import cn.ibizlab.util.domain.IBZUSER;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* 实体[IBZUSER] 服务对象接口实现
*/
public interface IBZUSERService extends IService<IBZUSER> {
}
\ No newline at end of file
package cn.ibizlab.util.service;
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.errors.BadRequestAlertException;
import cn.ibizlab.util.helper.CachedBeanCopier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
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.StringUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.security.core.authority.AuthorityUtils;
/**
* 实体[IBZUSER] 服务对象接口实现
*/
@Service("IBZUSERService")
@ConditionalOnExpression("(!${ibiz.enablePermissionValid:false})&&'${ibiz.auth.service:IBZUAAUserService}'.equals('IBZUSERService')")
public class IBZUSERServiceImpl extends ServiceImpl<IBZUSERMapper, IBZUSER> implements IBZUSERService,AuthenticationUserService{
@Value("${ibiz.auth.pwencrymode:0}")
private int pwencrymode;
@Override
public AuthenticationUser loadUserByUsername(String username) {
if(StringUtils.isEmpty(username)) {
throw new UsernameNotFoundException("用户名为空");
}
QueryWrapper<IBZUSER> conds = new QueryWrapper<IBZUSER>();
String[] data = username.split("[|]");
String loginname = "";
String domains = "";
if(data.length>0) {
loginname = data[0].trim();
}
if(data.length>1) {
domains = data[1].trim();
}
if(!StringUtils.isEmpty(loginname)) {
conds.eq("loginname",loginname);
}
if(!StringUtils.isEmpty(domains)) {
conds.eq("domains",domains);
}
IBZUSER user = this.getOne(conds);
if (user == null) {
throw new UsernameNotFoundException("用户" + username + "未找到");
}
else {
user.setUsername(username);
return createUserDetails(user);
}
}
@Override
public AuthenticationUser loadUserByLogin(String username, String password){
AuthenticationUser authuserdetail = loadUserByUsername(username);
if(pwencrymode == 1){
password = DigestUtils.md5DigestAsHex(password.getBytes());
}
else if(pwencrymode == 2){
password = DigestUtils.md5DigestAsHex(String.format("%1$s||%2$s", username, password).getBytes());
}
if(!authuserdetail.getPassword().equals(password)) {
throw new BadRequestAlertException("用户名密码错误","IBZUSER",username);
}
return authuserdetail;
}
public void resetByUsername(String username) {
}
public AuthenticationUser createUserDetails(IBZUSER user) {
AuthenticationUser userdatail = new AuthenticationUser();
CachedBeanCopier.copy(user,userdatail);
if(userdatail.getSuperuser() == 1){
userdatail.setAuthorities(AuthorityUtils.createAuthorityList("ROLE_SUPERADMIN"));
}
return userdatail;
}
}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册