fix:证书改动
This commit is contained in:
parent
42b4ed1c38
commit
8229b3e44e
@ -28,7 +28,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/crls")
|
||||
@Tag(name = "CRL管理", description = "证书吊销列表导入、吊销明细查询和 CRL 删除接口")
|
||||
@Tag(name = "CRL管理", description = "证书吊销列表导入、吊销明细查询和吊销明细删除接口")
|
||||
public class CrlController {
|
||||
|
||||
private final CrlService crlService;
|
||||
@ -64,9 +64,9 @@ public class CrlController {
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@Operation(summary = "删除CRL", description = "根据 CRL ID 删除 CRL 元数据及其吊销明细。删除后对应吊销记录不再参与证书运行状态判断。")
|
||||
@Operation(summary = "删除CRL吊销明细", description = "根据 CRL 吊销明细 ID 删除单条吊销记录。删除后该吊销记录不再参与证书运行状态判断,CRL 元数据和同一 CRL 下的其他明细不会被删除。")
|
||||
@ReplayProtected
|
||||
@AuditedOperation(module = ModuleCode.KEY, action = ActionType.DELETE, summary = "删除证书吊销列表")
|
||||
@AuditedOperation(module = ModuleCode.KEY, action = ActionType.DELETE, summary = "删除证书吊销明细")
|
||||
@RequireInternalAuth(role = RoleCode.KEY_ADMIN, authLevel = AuthLevel.FULL)
|
||||
public ApiResponse<Void> delete(@Valid @RequestBody IdRequest request) {
|
||||
crlService.delete(request.getId());
|
||||
|
||||
@ -30,16 +30,9 @@ public class Subject {
|
||||
@Schema(description = "组织 O", example = "CISD")
|
||||
private String org;
|
||||
|
||||
@Schema(description = "组织单元 OU", example = "Cert")
|
||||
private String orgUnit;
|
||||
|
||||
@Schema(description = "组织单元 OU 列表,最多支持两个;传入后优先于 orgUnit", example = "[\"Organizational-1\",\"CCFCCB\"]")
|
||||
@Schema(description = "组织单元 OU 列表,最多支持两个", example = "[\"Organizational-1\",\"CCFCCB\"]")
|
||||
private List<String> orgUnits;
|
||||
|
||||
public String getDN() {
|
||||
return toX500Name().toString();
|
||||
}
|
||||
|
||||
public X500Name toX500Name() {
|
||||
Assert.hasText(commonName, "通用名称不能为空");
|
||||
X500NameBuilder builder = new X500NameBuilder(BCStyle.INSTANCE);
|
||||
@ -74,9 +67,6 @@ public class Subject {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (units.isEmpty() && StringUtils.hasText(orgUnit)) {
|
||||
units.add(orgUnit.trim());
|
||||
}
|
||||
Assert.isTrue(units.size() <= 2, "组织单元最多支持2个");
|
||||
return units;
|
||||
}
|
||||
@ -108,7 +98,6 @@ public class Subject {
|
||||
}
|
||||
}
|
||||
if (!orgUnits.isEmpty()) {
|
||||
subject.setOrgUnit(orgUnits.get(0));
|
||||
subject.setOrgUnits(orgUnits);
|
||||
}
|
||||
Assert.hasText(subject.commonName, "通用名称不能为空");
|
||||
|
||||
@ -22,6 +22,8 @@ public interface CrlRepository {
|
||||
Optional<CertificateCrlEntity> findCrlById(Long id);
|
||||
Optional<CertificateCrlEntity> findCrlByFingerprint(String fingerprint);
|
||||
void deleteCrlById(Long id);
|
||||
Optional<CertificateCrlRevokedEntity> findRevokedById(Long id);
|
||||
void deleteRevokedById(Long id);
|
||||
void deleteRevokedByCrlId(Long crlId);
|
||||
Page<CertificateCrlRevokedEntity> pageRevoked(CrlListRequest request);
|
||||
boolean existsRevoked(String issuerDn, String serialNumber);
|
||||
|
||||
@ -123,6 +123,16 @@ public class CrlRepositoryImpl implements CrlRepository {
|
||||
crlMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<CertificateCrlRevokedEntity> findRevokedById(Long id) {
|
||||
return Optional.ofNullable(revokedMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRevokedById(Long id) {
|
||||
revokedMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRevokedByCrlId(Long crlId) {
|
||||
revokedMapper.delete(new LambdaQueryWrapper<CertificateCrlRevokedEntity>()
|
||||
|
||||
@ -300,10 +300,9 @@ public class CrlService {
|
||||
|
||||
@Transactional
|
||||
public void delete(Long id) {
|
||||
crlRepository.findCrlById(id)
|
||||
.orElseThrow(() -> new BizException(ErrorCode.BAD_REQUEST.getCode(), "CRL不存在"));
|
||||
crlRepository.deleteRevokedByCrlId(id);
|
||||
crlRepository.deleteCrlById(id);
|
||||
crlRepository.findRevokedById(id)
|
||||
.orElseThrow(() -> new BizException(ErrorCode.BAD_REQUEST.getCode(), "CRL吊销明细不存在"));
|
||||
crlRepository.deleteRevokedById(id);
|
||||
}
|
||||
|
||||
private int saveRevokedRows(
|
||||
|
||||
@ -38,6 +38,7 @@ import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
class CertSwaggerAnnotationTest {
|
||||
|
||||
@ -108,4 +109,10 @@ class CertSwaggerAnnotationTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void subjectDtoShouldOnlyExposeOrgUnitsForOuValues() throws Exception {
|
||||
assertThrows(NoSuchFieldException.class, () -> Subject.class.getDeclaredField("orgUnit"));
|
||||
assertNotNull(Subject.class.getDeclaredField("orgUnits"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -453,17 +453,19 @@ class CrlServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldDeleteCrlMetadataAndRevokedRows() {
|
||||
void shouldDeleteRevokedDetailByIdWithoutDeletingCrlMetadata() {
|
||||
CrlRepository crlRepository = Mockito.mock(CrlRepository.class);
|
||||
CrlService service = new CrlService(crlRepository, Mockito.mock(CertificateRepository.class), Mockito.mock(TrustedCertService.class));
|
||||
CertificateCrlEntity crl = new CertificateCrlEntity();
|
||||
crl.setId(99L);
|
||||
Mockito.when(crlRepository.findCrlById(99L)).thenReturn(Optional.of(crl));
|
||||
CertificateCrlRevokedEntity revoked = new CertificateCrlRevokedEntity();
|
||||
revoked.setId(99L);
|
||||
revoked.setCrlId(10L);
|
||||
Mockito.when(crlRepository.findRevokedById(99L)).thenReturn(Optional.of(revoked));
|
||||
|
||||
service.delete(99L);
|
||||
|
||||
Mockito.verify(crlRepository).deleteRevokedByCrlId(99L);
|
||||
Mockito.verify(crlRepository).deleteCrlById(99L);
|
||||
Mockito.verify(crlRepository).deleteRevokedById(99L);
|
||||
Mockito.verify(crlRepository, Mockito.never()).deleteRevokedByCrlId(Mockito.anyLong());
|
||||
Mockito.verify(crlRepository, Mockito.never()).deleteCrlById(Mockito.anyLong());
|
||||
}
|
||||
|
||||
private KeyPair sm2KeyPair() throws Exception {
|
||||
|
||||
@ -303,7 +303,7 @@ class EntityServiceTest {
|
||||
private EntityGenP10Request genP10Request(String commonName) {
|
||||
Subject subject = new Subject();
|
||||
subject.setCommonName(commonName);
|
||||
subject.setOrgUnit("Cert");
|
||||
subject.setOrgUnits(List.of("Cert"));
|
||||
subject.setOrg("CISD");
|
||||
subject.setCity("南南市");
|
||||
subject.setProvince("陕西省");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user