fix
This commit is contained in:
parent
ad679f48fd
commit
f84de95e9a
@ -26,6 +26,7 @@ import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
|
|||||||
import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey;
|
import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey;
|
||||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@ -47,6 +48,7 @@ public class TmkService {
|
|||||||
private final SpDeviceMapper spDeviceMapper;
|
private final SpDeviceMapper spDeviceMapper;
|
||||||
private final ParamConfMapper paramConfMapper;
|
private final ParamConfMapper paramConfMapper;
|
||||||
|
|
||||||
|
@Transactional
|
||||||
public void initTmk() {
|
public void initTmk() {
|
||||||
boolean tmkInit = isTmkInit();
|
boolean tmkInit = isTmkInit();
|
||||||
Assert.isTrue(!tmkInit, "主密钥已经初始化");
|
Assert.isTrue(!tmkInit, "主密钥已经初始化");
|
||||||
@ -149,6 +151,7 @@ public class TmkService {
|
|||||||
return Pair.of(device.getId(), CodecUtils.encodeBase64(publicKey.getEncoded()));
|
return Pair.of(device.getId(), CodecUtils.encodeBase64(publicKey.getEncoded()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
public void importTmk(Long deviceId, String encTmk) {
|
public void importTmk(Long deviceId, String encTmk) {
|
||||||
boolean tmkInit = isTmkInit();
|
boolean tmkInit = isTmkInit();
|
||||||
Assert.isTrue(!tmkInit, "主密钥已经初始化");
|
Assert.isTrue(!tmkInit, "主密钥已经初始化");
|
||||||
@ -323,7 +326,7 @@ public class TmkService {
|
|||||||
private boolean enableSoftDevice;
|
private boolean enableSoftDevice;
|
||||||
private byte[] softEncTmk;
|
private byte[] softEncTmk;
|
||||||
|
|
||||||
public synchronized boolean isTmkInit() {
|
public synchronized boolean isTmkInitCached() {
|
||||||
if (tmkInit) {
|
if (tmkInit) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -332,6 +335,11 @@ public class TmkService {
|
|||||||
return tmkInit;
|
return tmkInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isTmkInit() {
|
||||||
|
ParamConf conf = paramConfMapper.selectByKey(ParamConfKeyConstant.TMK_INIT);
|
||||||
|
return conf != null && String.valueOf(true).equals(conf.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isEnableSoftDevice() {
|
public boolean isEnableSoftDevice() {
|
||||||
ParamConf conf = paramConfMapper.selectByKey(ParamConfKeyConstant.ENABLE_SOFT_DEVICE);
|
ParamConf conf = paramConfMapper.selectByKey(ParamConfKeyConstant.ENABLE_SOFT_DEVICE);
|
||||||
return conf != null && String.valueOf(true).equals(conf.getValue());
|
return conf != null && String.valueOf(true).equals(conf.getValue());
|
||||||
@ -356,10 +364,10 @@ public class TmkService {
|
|||||||
check.setValue(CodecUtils.encodeHex(hash));
|
check.setValue(CodecUtils.encodeHex(hash));
|
||||||
check.setKey(ParamConfKeyConstant.TMK_CHECK_VALUE);
|
check.setKey(ParamConfKeyConstant.TMK_CHECK_VALUE);
|
||||||
check.setCreatTime(LocalDateTime.now());
|
check.setCreatTime(LocalDateTime.now());
|
||||||
paramConfMapper.insert(conf);
|
paramConfMapper.insert(check);
|
||||||
} else {
|
} else {
|
||||||
check.setValue(CodecUtils.encodeHex(hash));
|
check.setValue(CodecUtils.encodeHex(hash));
|
||||||
paramConfMapper.updateById(conf);
|
paramConfMapper.updateById(check);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ import java.util.HashSet;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -108,8 +109,15 @@ public class ScUserController {
|
|||||||
|
|
||||||
@RequestMapping(value = "/info",method = RequestMethod.GET)
|
@RequestMapping(value = "/info",method = RequestMethod.GET)
|
||||||
public Result<ScUser> getUserInfo(){
|
public Result<ScUser> getUserInfo(){
|
||||||
|
|
||||||
ScUser u = securityUtil.getCurrUser();
|
ScUser u = securityUtil.getCurrUser();
|
||||||
|
if (CollectionUtils.isNotEmpty(u.getRoles())) {
|
||||||
|
long count = u.getRoles().stream().map(ScRole::getId)
|
||||||
|
.filter(it -> Objects.equals(it, 1L))
|
||||||
|
.count();
|
||||||
|
if (count >= 1) {
|
||||||
|
u.setId(1L);
|
||||||
|
}
|
||||||
|
}
|
||||||
return new ResultUtil<ScUser>().setData(u);
|
return new ResultUtil<ScUser>().setData(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class ScUserServiceImpl extends ServiceImpl<ScUserMapper, ScUser> impleme
|
|||||||
List<ScUser> list=baseMapper.findByUsername(username);
|
List<ScUser> list=baseMapper.findByUsername(username);
|
||||||
if(list!=null&&list.size()>0){
|
if(list!=null&&list.size()>0){
|
||||||
ScUser user = list.get(0);
|
ScUser user = list.get(0);
|
||||||
if (username.contains("admin")) {
|
if (username.contains("rootadmin")) {
|
||||||
user.setId(1L);
|
user.setId(1L);
|
||||||
}
|
}
|
||||||
if(CommonConstant.DEFAULT_USER_ROOT_ID.equals(user.getId())){
|
if(CommonConstant.DEFAULT_USER_ROOT_ID.equals(user.getId())){
|
||||||
|
Loading…
Reference in New Issue
Block a user