fix
This commit is contained in:
parent
dc349561bf
commit
90750ac3b9
@ -67,7 +67,8 @@ public class CommonCertUtils extends GMBaseUtil {
|
||||
}
|
||||
|
||||
public static PKCS10CertificationRequest createCSR(X500Name subject, BCECPublicKey pubKey, PrivateKey priKey) throws OperatorCreationException {
|
||||
PKCS10CertificationRequestBuilder csrBuilder = new JcaPKCS10CertificationRequestBuilder(subject, pubKey);
|
||||
SM2PublicKey sm2SubPub = new SM2PublicKey(pubKey.getAlgorithm(), pubKey);
|
||||
PKCS10CertificationRequestBuilder csrBuilder = new JcaPKCS10CertificationRequestBuilder(subject, sm2SubPub);
|
||||
ContentSigner signerBuilder = new JcaContentSignerBuilder("SM3withSM2")
|
||||
.setProvider(BouncyCastleProvider.PROVIDER_NAME).build(priKey);
|
||||
return csrBuilder.build(signerBuilder);
|
||||
|
@ -0,0 +1,44 @@
|
||||
package com.sunyard.chsm.utils.gm.cert;
|
||||
|
||||
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
|
||||
import org.bouncycastle.asn1.ASN1OctetString;
|
||||
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
|
||||
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
|
||||
import org.bouncycastle.asn1.x9.X9ECPoint;
|
||||
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers;
|
||||
import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey;
|
||||
import org.bouncycastle.jcajce.provider.asymmetric.util.KeyUtil;
|
||||
|
||||
public class SM2PublicKey extends BCECPublicKey {
|
||||
public static final ASN1ObjectIdentifier ID_SM2_PUBKEY_PARAM = new ASN1ObjectIdentifier("1.2.156.10197.1.301");
|
||||
|
||||
private boolean withCompression;
|
||||
|
||||
public SM2PublicKey(BCECPublicKey key) {
|
||||
super(key.getAlgorithm(), key);
|
||||
this.withCompression = false;
|
||||
}
|
||||
|
||||
public SM2PublicKey(String algorithm, BCECPublicKey key) {
|
||||
super(algorithm, key);
|
||||
this.withCompression = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getEncoded() {
|
||||
ASN1OctetString p = ASN1OctetString.getInstance(
|
||||
new X9ECPoint(getQ(), withCompression).toASN1Primitive());
|
||||
|
||||
// stored curve is null if ImplicitlyCa
|
||||
SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(
|
||||
new AlgorithmIdentifier(X9ObjectIdentifiers.id_ecPublicKey, ID_SM2_PUBKEY_PARAM),
|
||||
p.getOctets());
|
||||
|
||||
return KeyUtil.getEncodedSubjectPublicKeyInfo(info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPointFormat(String style) {
|
||||
withCompression = !("UNCOMPRESSED".equalsIgnoreCase(style));
|
||||
}
|
||||
}
|
@ -27,10 +27,12 @@ import com.sunyard.ssp.utils.PageUtil;
|
||||
import com.sunyard.ssp.utils.ResultUtil;
|
||||
import com.sunyard.ssp.utils.SecurityUtil;
|
||||
import com.sunyard.ssp.utils.UsernameUtil;
|
||||
import com.sunyard.ssp.vo.ScUserVo;
|
||||
import com.sunyard.ssp.vo.SearchVo;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
@ -444,9 +446,11 @@ public class ScUserController {
|
||||
|
||||
@RequestMapping(value = "/admin/add", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "添加用户")
|
||||
public Result<Object> regist(@ModelAttribute("user") @Validated ScUser u,
|
||||
public Result<Object> regist(@ModelAttribute("user") @Validated ScUserVo uv,
|
||||
@RequestParam(required = false) Long[] roleIds) {
|
||||
try {
|
||||
ScUser u = new ScUser();
|
||||
BeanUtils.copyProperties(uv, u);
|
||||
u.setPassUpdateTime(LocalDateTime.now());
|
||||
userService.regist(u, roleIds);
|
||||
} catch (Exception e) {
|
||||
@ -457,16 +461,18 @@ public class ScUserController {
|
||||
|
||||
@RequestMapping(value = "/admin/init", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "初始化admin")
|
||||
public Result<Object> init(@ModelAttribute("user") @Validated ScUser u,
|
||||
public Result<Object> init(@ModelAttribute("user") @Validated ScUserVo uv,
|
||||
@RequestParam(required = false) Long[] roleIds) {
|
||||
try {
|
||||
ScUser u = new ScUser();
|
||||
BeanUtils.copyProperties(uv, u);
|
||||
u.setPassUpdateTime(LocalDateTime.now());
|
||||
userService.regist(u, roleIds);
|
||||
return new ResultUtil<Object>().setData(u.getId(),"添加成功");
|
||||
} catch (Exception e) {
|
||||
userService.remove(new QueryWrapper<>());
|
||||
return new ResultUtil<Object>().setErrorMsg(e.getMessage());
|
||||
}
|
||||
return new ResultUtil<Object>().setData(u.getId(),"添加成功");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/admin/disable/{userId}", method = RequestMethod.POST)
|
||||
|
@ -3,7 +3,9 @@ package com.sunyard.ssp.modules.user.utils.validator;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.sunyard.ssp.modules.user.entity.ScUser;
|
||||
import com.sunyard.ssp.modules.user.service.IScUserService;
|
||||
import com.sunyard.ssp.vo.ScUserVo;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.Errors;
|
||||
@ -26,13 +28,19 @@ public class UserValidator implements Validator {
|
||||
@Override
|
||||
public boolean supports(Class<?> aClass) {
|
||||
|
||||
return ScUser.class.equals(aClass);
|
||||
return ScUser.class.equals(aClass) || ScUserVo.class.equals(aClass);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void validate(Object o, Errors errors) {
|
||||
ScUser user = (ScUser) o;
|
||||
ScUser user;
|
||||
if (o instanceof ScUserVo) {
|
||||
user = new ScUser();
|
||||
BeanUtils.copyProperties(o, user);
|
||||
} else {
|
||||
user = (ScUser) o;
|
||||
}
|
||||
if (user.getId() != null) {
|
||||
//编辑
|
||||
ScUser origin = userService.getById(user.getId());
|
||||
|
@ -0,0 +1,58 @@
|
||||
package com.sunyard.ssp.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author liulu
|
||||
* @since 2024/11/15
|
||||
*/
|
||||
@Data
|
||||
public class ScUserVo {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 真实姓名
|
||||
*/
|
||||
private String realname;
|
||||
|
||||
/**
|
||||
* 组织机构id
|
||||
*/
|
||||
private Long organizationId;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String tel;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
/**
|
||||
* 状态:0:可用 1:不可用
|
||||
*/
|
||||
private Integer status;
|
||||
private Integer positionId;
|
||||
private LocalDateTime updateTime;
|
||||
private LocalDateTime passUpdateTime;
|
||||
private Integer sex;
|
||||
private String avatar;
|
||||
private String uPublickey;
|
||||
private String positionName;
|
||||
private String departmentTitle;
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user