解决 "Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.bouncycastle.math.ec.ECPoint$Fp.<init>(Lorg/bouncycastle/math/ec/ECCurve;Lorg/bouncycastle/math/ec/ECFieldElement;Lorg/bouncycastle/math/ec/ECFieldElement;)V from class com.essc.support.hsmsoft.sm2.Sm2Factory" 错误
该报错是因为在com.essc.support.hsmsoft.sm2.Sm2Factory类中尝试访问org.bouncycastle.math.ec.ECPoint$Fp类的构造函数,但是该构造函数被认为是非法访问。可能的原因是版本不兼容,或者有多个版本的jar包冲突。要解决这个问题,可以尝试升级或降级bouncycastle的版本,或者排除冲突的jar包。
package com.esscard.ipgs;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.esscard.ipgs.dto.ykt.ElectronicCard; import com.esscard.ipgs.util.SM4Util; import com.esscard.ipgs.util.SkgHttpUtil; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication @ComponentScan(basePackages ={"com.esscard"}) public class IpgsApplication {
public static final String SM4KEY = 'd0d60b458d151763f52d28feda1df2de';//按接入分配
public static final String SM4IV = '1920ad759ba84cad06da7c5043ccbd68';//固定为1920ad759ba84cad06da7c5043ccbd68
public static final String MYPRIVATEKEY = '15580cf6fdb5ba4242d390dfb233fc9a5ef5f4dd9f2d7d6fc3334ffedeaab078';//按接入分配
public static final String SBKURL = 'https://223.4.79.119:13335/ykt/sbkService';
public static void main(String[] args) {
//SpringApplication.run(IpgsApplication.class, args);
ElectronicCard electronicCard = new ElectronicCard();
electronicCard.setAAB300('测试');
electronicCard.setMSGNO('7492');
electronicCard.setBUSITYPE('01');
//sm4加密
electronicCard.setQRCODE(SM4Util.SM4encrypt('63749829', SM4KEY,SM4IV));
electronicCard.setAAB301('330100');
electronicCard.setBAZ411('39232408234');
electronicCard.setSCENE('0');
electronicCard.setINTERFACECODE( 'dzsbksmjx');
JSONObject encodeElectronicCard = JSON.parseObject(JSON.toJSONString(electronicCard));
//sm2签名
encodeElectronicCard.put('SIGNATURE', SM4Util.sign(encodeElectronicCard,MYPRIVATEKEY));
JSONObject jsonObject = SkgHttpUtil.doSkgPostJson('https://223.4.79.119:13335/ykt/sbkService', encodeElectronicCard.toJSONString());
//sm4解密
jsonObject.put('data',SM4Util.SM4decrypt(jsonObject.getString('data'),SM4KEY,SM4IV));
System.out.println(jsonObject);
}
}
(Lorg/bouncycastle/math/ec/ECCurve;Lorg/bouncycastle/math/ec/ECFieldElement;Lorg/bouncycastle/math/ec/ECFieldElement;)V from class com.essc.support.hsmsoft.sm2.Sm2Factory" 错误" title="解决 "Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.bouncycastle.math.ec.ECPoint$Fp.原文地址: https://www.cveoy.top/t/topic/nAAg 著作权归作者所有。请勿转载和采集!