证书管理
This commit is contained in:
parent
ba6c06a8b8
commit
5413fa2545
@ -12,4 +12,6 @@ public interface AppCertService {
|
|||||||
Page<CertDTO.ACView> selectPageList(CertDTO.Query query);
|
Page<CertDTO.ACView> selectPageList(CertDTO.Query query);
|
||||||
|
|
||||||
void importCert(CertDTO.ImportCert importCert);
|
void importCert(CertDTO.ImportCert importCert);
|
||||||
|
|
||||||
|
void delete(Long id);
|
||||||
}
|
}
|
||||||
|
@ -173,6 +173,8 @@ public class AppCertServiceImpl implements AppCertService {
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new IllegalArgumentException("证书内容格式错误,无法解析");
|
throw new IllegalArgumentException("证书内容格式错误,无法解析");
|
||||||
}
|
}
|
||||||
|
Assert.isTrue(Objects.equals(signCert.getSubjectX500Principal().getName(), encCert.getSubjectX500Principal().getName()),
|
||||||
|
"证书主题不一致");
|
||||||
PublicKey signPk = signCert.getPublicKey();
|
PublicKey signPk = signCert.getPublicKey();
|
||||||
String signPkHex = BCECUtils.getHexPubKey((BCECPublicKey) signPk);
|
String signPkHex = BCECUtils.getHexPubKey((BCECPublicKey) signPk);
|
||||||
String encPkHex = BCECUtils.getHexPubKey((BCECPublicKey) encCert.getPublicKey());
|
String encPkHex = BCECUtils.getHexPubKey((BCECPublicKey) encCert.getPublicKey());
|
||||||
@ -274,4 +276,25 @@ public class AppCertServiceImpl implements AppCertService {
|
|||||||
return Pair.of(Hex.toHexString(xy), pd);
|
return Pair.of(Hex.toHexString(xy), pd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(Long id) {
|
||||||
|
|
||||||
|
AppCert appCert = appCertMapper.selectById(id);
|
||||||
|
Assert.notNull(appCert, "证书不存在");
|
||||||
|
|
||||||
|
if (appCert.getSingle()) {
|
||||||
|
appCertMapper.deleteById(id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<AppCert> appCerts = appCertMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<AppCert>()
|
||||||
|
.eq(AppCert::getKeyId, appCert.getKeyId())
|
||||||
|
.eq(AppCert::getSubject, appCert.getSubject())
|
||||||
|
|
||||||
|
);
|
||||||
|
appCertMapper.deleteBatchIds(appCerts.stream().map(AppCert::getId).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
package com.sunyard.chsm.controller;
|
package com.sunyard.chsm.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.sunyard.chsm.constant.AuditLogConst;
|
||||||
import com.sunyard.chsm.model.R;
|
import com.sunyard.chsm.model.R;
|
||||||
import com.sunyard.chsm.model.dto.CertDTO;
|
import com.sunyard.chsm.model.dto.CertDTO;
|
||||||
import com.sunyard.chsm.service.AppCertService;
|
import com.sunyard.chsm.service.AppCertService;
|
||||||
|
import com.sunyard.ssp.common.annotation.AuditControllerLog;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@ -53,5 +56,17 @@ public class AppCertController {
|
|||||||
appCertService.importCert(importCert);
|
appCertService.importCert(importCert);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除证书
|
||||||
|
*
|
||||||
|
* @param id id
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
@DeleteMapping
|
||||||
|
@AuditControllerLog(description = "删除证书", operateType = AuditLogConst.DELETE)
|
||||||
|
public R<Void> delete(Long id) {
|
||||||
|
appCertService.delete(id);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user