use of com.chao.cloud.common.extra.license.LicenseCheckModel in project chao-cloud by chaojunzi.
the class LicenseController method upload.
@PostMapping(value = "upload")
public Response<LicenseCheckModel> upload(@NotNull MultipartFile licenseFile) {
String ciphertext = null;
try (InputStream in = licenseFile.getInputStream()) {
// 获取密文
ciphertext = IoUtil.readUtf8(in);
Assert.notBlank(ciphertext, "licesne密文解析失败");
// 解析证书内容
String json = config.getRsa().decryptStr(ciphertext, KeyType.PrivateKey);
LicenseCheckModel checkModel = JSONUtil.toBean(json, LicenseCheckModel.class);
return Response.ok(checkModel);
} catch (Exception e) {
throw new BusinessException(StrUtil.format("[证书生成失败! error={},无效的密文:{}]", e.getMessage(), ciphertext));
}
}
Aggregations