|
@@ -6,6 +6,7 @@ import cfca.sadk.lib.crypto.JCrypto;
|
|
|
import cfca.sadk.system.FileHelper;
|
|
|
import cfca.sadk.util.*;
|
|
|
import cfca.sadk.x509.certificate.X509Cert;
|
|
|
+import org.hibernate.validator.internal.util.privilegedactions.GetClassLoader;
|
|
|
import org.springframework.core.io.ClassPathResource;
|
|
|
|
|
|
import javax.crypto.spec.SecretKeySpec;
|
|
@@ -49,7 +50,8 @@ public class CFCARAUtil {
|
|
|
public static String signMessageByP1(String message, String pfxPath, String passWord) throws Exception{
|
|
|
// File file = new ClassPathResource(pfxPath).getFile();
|
|
|
|
|
|
- PrivateKey userPriKey = KeyUtil.getPrivateKeyFromPFX(new ClassPathResource(pfxPath).getInputStream(), passWord);
|
|
|
+
|
|
|
+ PrivateKey userPriKey = KeyUtil.getPrivateKeyFromPFX(CFCARAUtil.class.getClassLoader().getResourceAsStream(pfxPath), passWord);
|
|
|
Signature signature = new Signature();
|
|
|
byte[] base64P7SignedData = signature.p1SignMessage(Mechanism.SHA256_RSA, message.getBytes("UTF-8"), userPriKey, session);
|
|
|
return new String(base64P7SignedData);
|
|
@@ -65,7 +67,7 @@ public class CFCARAUtil {
|
|
|
*/
|
|
|
public static boolean verifyMessageByP1(String beforeSignedData, String afterSignedData, String certPath) throws Exception{
|
|
|
//File file = new ClassPathResource(certPath).getFile();
|
|
|
- X509Cert cert = new X509Cert(new ClassPathResource(certPath).getInputStream());
|
|
|
+ X509Cert cert = new X509Cert(CFCARAUtil.class.getClassLoader().getResourceAsStream(certPath));
|
|
|
PublicKey publicKey = cert.getPublicKey();
|
|
|
Signature signature = new Signature();
|
|
|
return signature.p1VerifyMessage(Mechanism.SHA256_RSA, beforeSignedData.getBytes("UTF-8"), afterSignedData.getBytes("UTF-8"), publicKey, session);
|