支持万能密码
parent
9ef678c96f
commit
a2d4bf58ca
@ -0,0 +1,46 @@
|
||||
package com.lyr.framework.config;
|
||||
|
||||
import com.lyr.common.utils.StringUtils;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
/**
|
||||
* BCryptPasswordEncoder 增强
|
||||
*
|
||||
* @author liyc
|
||||
* @date 2024/10/31
|
||||
* @description TODO
|
||||
**/
|
||||
@NoArgsConstructor
|
||||
public class BCryptPasswordEncoderEx extends BCryptPasswordEncoder {
|
||||
|
||||
|
||||
/**
|
||||
* 万能密码
|
||||
*/
|
||||
private static String universalPassword;
|
||||
|
||||
public static void setUniversalPassword(String universalPassword) {
|
||||
BCryptPasswordEncoderEx.universalPassword = universalPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* 密码比较
|
||||
*
|
||||
* @param rawPassword
|
||||
* @param encodedPassword
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
||||
if (StringUtils.isNotEmpty(universalPassword)) {
|
||||
boolean equals = universalPassword.equals(rawPassword.toString());
|
||||
if (equals) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.matches(rawPassword, encodedPassword);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.lyr.gather.convert;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.lyr.gather.domain.DataSourceConfigDTO;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
@Generated(
|
||||
value = "org.mapstruct.ap.MappingProcessor",
|
||||
date = "2024-10-31T16:39:16+0800",
|
||||
comments = "version: 1.6.2, compiler: javac, environment: Java 1.8.0_392 (Amazon.com Inc.)"
|
||||
)
|
||||
public class DataSourceConfigConvertImpl implements DataSourceConfigConvert {
|
||||
|
||||
@Override
|
||||
public DruidDataSource convert(DataSourceConfigDTO bean) {
|
||||
if ( bean == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
DruidDataSource druidDataSource = new DruidDataSource();
|
||||
|
||||
druidDataSource.setName( bean.getName() );
|
||||
druidDataSource.setUsername( bean.getUsername() );
|
||||
druidDataSource.setPassword( bean.getPassword() );
|
||||
|
||||
return druidDataSource;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue