You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
2.0 KiB
Java
53 lines
2.0 KiB
Java
package com.glxp.api;
|
|
|
|
import com.glxp.api.util.RsaUtils;
|
|
import org.springframework.context.ApplicationContextInitializer;
|
|
import org.springframework.context.ConfigurableApplicationContext;
|
|
|
|
import java.io.IOException;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
import java.nio.file.Paths;
|
|
|
|
public class ToolApplicationContextInitializer implements ApplicationContextInitializer {
|
|
|
|
@Override
|
|
public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
|
|
String myKey = RsaUtils.readFileContent("");
|
|
System.out.println(myKey);
|
|
String publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtaHLiDtscnwyee4lG9jC" +
|
|
"8GUEZYIuBoz49W3GSy2LEOVpKRyiQNCjRmybvQS5qKdsb3pV720HQJnv/nQLnsg/" +
|
|
"vWbFc9L09fEeJdDZxQOf8D7CHeVgLd8+fh/GezQCVLijGlbAVORXOrFo5McdyOds" +
|
|
"LJey1x4HxIR13a79JHB7sdve14A2aS6bQ7NPWu8hM9LpJd1hylsXgdBpR+iX3DPF" +
|
|
"eep8Sx8jPnWfUfGF2pDNE3h1uz9RylGBYUz4tDPzz0IXO7vZkyUFXeslzKFDFcmh" +
|
|
"hbn1tobX+al4XvfRpjoCjST2mRfqCt4aNuBDM1LHMzyMBVJpfui91ikLGMgP4Gdf" +
|
|
"swIDAQAB";
|
|
try {
|
|
createTmpDirectoryIfWindows();
|
|
// String result = RsaUtils.publicKeyDecrypt(myKey, publicKey);
|
|
// String hardInfo = MyHardWareUtils.getHardDiskSN();
|
|
// if (!result.equals(hardInfo)) {
|
|
// System.exit(1);
|
|
// }
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
System.exit(1);
|
|
}
|
|
}
|
|
|
|
private void createTmpDirectoryIfWindows() {
|
|
String os = System.getProperty("os.name").toLowerCase();
|
|
if (os.contains("win")) {
|
|
Path path = Paths.get("D:/tmp");
|
|
if (!Files.exists(path)) {
|
|
try {
|
|
Files.createDirectories(path);
|
|
System.out.println("目录创建成功");
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|