ban掉restful-fast-request--api-buddy的验证服务器ip

This commit is contained in:
novice.li 2024-01-16 23:11:24 +08:00
parent a8b6a9129e
commit 0714d4a122
3 changed files with 29 additions and 7 deletions

View file

@ -13,14 +13,12 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import win.novice.li.model.License;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.security.*;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
@RestController
@ -33,8 +31,6 @@ public class LicenseController {
@PostMapping("/generateLicense")
@SneakyThrows
public Map<String, Object> generateLicense(@RequestBody @Validated License license) {
Map<String, Object> ans = new HashMap<>();
String licenseId = generateLicenseId();
license.setLicenseId(licenseId);
@ -42,7 +38,6 @@ public class LicenseController {
byte[] licensePartBytes = licensePart.getBytes(StandardCharsets.UTF_8);
String licensePartBase64 = Base64.getEncoder().encodeToString(licensePartBytes);
Signature signature = Signature.getInstance("SHA1withRSA");
signature.initSign(PRIVATE_KEY);
signature.update(licensePartBytes);
@ -51,8 +46,7 @@ public class LicenseController {
String result = licenseId + "-" + licensePartBase64 + "-" + sigResultsBase64 + "-" + Base64.getEncoder().encodeToString(CRT.getEncoded());
ans.put("license",result);
return ans;
return Map.of("license", result);
}