当前位置: 首页 > 知识库问答 >
问题:

如何通过使用BouncyCastle的客户端maven插件构建本机映像

邬楚青
2023-03-14

我正在开发一个java Gluon项目,该项目使用面向桌面、iOS和Android的maven客户端插件构建。我现在试图添加对使用BouncyCastle进行加密的内部java库的依赖。

通过mvn净javafx: run执行代码会产生一个功能应用程序,可以很好地执行所有加密。

运行mvn清洁客户端:构建-Pios客户端:运行-Pios在iOS上运行应用程序,但抛出java.security.NoSuch算法异常:没有这样的算法:当我们的库尝试生成密码时,提供者BC的AES多次。

我尝试过的事情:

  • 添加<代码>

系统信息:

  • MacOS 10.15.5
  • IntelliJ IDEA Ultimate 2020.2.2
  • java版本:openjdk version“11.0.8”2020-07-14 openjdk Runtime Environment GraalVM CE 20.2.0(build 11.0.8 10-jvmci-20.2-b03)
    openjdk 64位服务器VM GraalVM CE 20.2.0(build 11.0.8 10-jvmci-20.2-b03,混合模式,共享)

编辑(20年9月29日):

将AES添加到反射列表似乎让我更进一步,但我仍然遇到安全错误:

[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] Fatal error: javax.crypto.JceSecurity.getCodeBase(Class) is reached at runtime. This should not happen. The contents of JceSecurity.verificationResults are computed and cached at image build time. Try enabling all security services with --enable-all-security-services.
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] JavaFrameAnchor dump:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   No anchors
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] TopFrame info:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   TotalFrameSize in CodeInfoTable 32
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] VMThreads info:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   VMThread 0000000283fa1ba0  STATUS_IN_NATIVE  java.lang.Thread@0x116001028
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   VMThread 0000000283fa0f70  STATUS_IN_NATIVE  java.lang.Thread@0x115b043d0
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   VMThread 0000000283fa0ea0  STATUS_IN_JAVA (safepoints disabled)  java.lang.Thread@0x115a02e10
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   VMThread 0000000283fa0dd0  STATUS_IN_NATIVE  java.lang.Thread@0x107ce30a0
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] VM Thread State for current thread 0000000283fa0ea0:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   0 (8 bytes): com.oracle.svm.jni.JNIThreadLocalEnvironment.jniFunctions = (bytes) 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     0000000283fa0ea0: 00000001070a6c88
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   8 (32 bytes): com.oracle.svm.core.genscavenge.ThreadLocalAllocation.regularTLAB = (bytes) 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     0000000283fa0ea8: 0000000116600000 0000000116700000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     0000000283fa0eb8: 000000011660b960 0000000000000000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   40 (8 bytes): com.oracle.svm.core.heap.NoAllocationVerifier.openVerifiers = (Object) null
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   48 (8 bytes): com.oracle.svm.core.jdk.IdentityHashCodeSupport.hashCodeGeneratorTL = (Object) java.util.SplittableRandom  0000000115b04600
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   56 (8 bytes): com.oracle.svm.core.snippets.ExceptionUnwind.currentException = (Object) null
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   64 (8 bytes): com.oracle.svm.core.thread.JavaThreads.currentThread = (Object) java.lang.Thread  0000000115a02e10
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   72 (8 bytes): com.oracle.svm.core.thread.ThreadingSupportImpl.activeTimer = (Object) null
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   80 (8 bytes): com.oracle.svm.jni.JNIObjectHandles.handles = (Object) com.oracle.svm.core.handles.ThreadLocalHandles  0000000115b02360
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   88 (8 bytes): com.oracle.svm.jni.JNIThreadLocalPendingException.pendingException = (Object) null
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   96 (8 bytes): com.oracle.svm.jni.JNIThreadLocalPinnedObjects.pinnedObjectsListHead = (Object) null
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   104 (8 bytes): com.oracle.svm.jni.JNIThreadOwnedMonitors.ownedMonitors = (Object) null
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   112 (8 bytes): com.oracle.svm.core.genscavenge.ThreadLocalAllocation.freeList = (Word) 0  0000000000000000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   120 (8 bytes): com.oracle.svm.core.graal.snippets.StackOverflowCheckImpl.stackBoundaryTL = (Word) 1  0000000000000001
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   128 (8 bytes): com.oracle.svm.core.stack.JavaFrameAnchors.lastAnchor = (Word) 0  0000000000000000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   136 (8 bytes): com.oracle.svm.core.thread.VMThreads.IsolateTL = (Word) 94598687557484880  0150150150150150
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   144 (8 bytes): com.oracle.svm.core.thread.VMThreads.OSThreadHandleTL = (Word) 6105214976  000000016be63000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   152 (8 bytes): com.oracle.svm.core.thread.VMThreads.OSThreadIdTL = (Word) 6105214976  000000016be63000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   160 (8 bytes): com.oracle.svm.core.thread.VMThreads.nextTL = (Word) 10804137424  0000000283fa0dd0
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   168 (4 bytes): com.oracle.svm.core.graal.snippets.StackOverflowCheckImpl.yellowZoneStateTL = (int) -16843010  fefefefe
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   172 (4 bytes): com.oracle.svm.core.snippets.ImplicitExceptions.implicitExceptionsAreFatal = (int) 0  00000000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   176 (4 bytes): com.oracle.svm.core.thread.Safepoint.safepointRequested = (int) 2147255657  7ffc8569
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   180 (4 bytes): com.oracle.svm.core.thread.ThreadingSupportImpl.currentPauseDepth = (int) 0  00000000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   184 (4 bytes): com.oracle.svm.core.thread.VMThreads$ActionOnTransitionToJavaSupport.actionTL = (int) 0  00000000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   188 (4 bytes): com.oracle.svm.core.thread.VMThreads$StatusSupport.safepointsDisabledTL = (int) 1  00000001
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   192 (4 bytes): com.oracle.svm.core.thread.VMThreads$StatusSupport.statusTL = (int) 1  00000001
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] VMOperation dump:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   No VMOperation in progress
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] Dump Counters:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] Raw Stacktrace:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   000000016be62ba0: 000000011660b940 0000000000000000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   000000016be62bb0: 000000016be62be0 00000001045c4a48
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   000000016be62bc0: 0000000283fa0f60 000000011660b4e0
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   000000016be62bd0: 000000011660b4e0 000000011660b940
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   000000016be62be0: 000000016be62c40 000000010569556c
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   000000016be62bf0: 000000016be62c40 0000000107351138
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   000000016be62c00: 0000000107d0be88 0000000107d0be48
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   000000016be62c10: 0000000107351040 0000000115b11578
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] Stacktrace Stage 0:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62ba0 IP 00000001045ec738  FrameSize 32
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62bc0 IP 00000001045c4a48  FrameSize 48
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62bf0 IP 000000010569556c  FrameSize 96
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62c50 IP 0000000105695144  FrameSize 64
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62c90 IP 00000001056990f8  FrameSize 48
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62cc0 IP 000000010452012c  FrameSize 176
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62d70 IP 000000010451fbd8  FrameSize 48
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 0000000  SP 000000016be62f20 IP 0000000104fa6b2c  FrameSize 32
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62f40 IP 00000001045e4a10  FrameSize 80
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62f90 IP 00000001045a9c9c  FrameSize 64
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] Stacktrace Stage 1:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62ba0 IP 00000001045ec738  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62bc0 IP 00000001045c4a48  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62bf0 IP 000000010569556c  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62c50 IP 0000000105695144  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62c90 IP 00000001056990f8  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62cc0 IP 000000010452012c  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62d70 IP 000000010451fbd8  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62da0 IP 0000000104826860  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62e80 IP 00000001048230b4  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62ee0 IP 0000000104822718  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62f20 IP 0000000104fa6b2c  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62f40 IP 00000001045e4a10  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62f90 IP 00000001045a9c9c  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] Stacktrace Stage 2:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62ba0 IP 00000001045ec738  [image code] com.oracle.svm.core.jdk.VMErrorSubstitutions.shutdown(VMErrorSubstitutions.java:96)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62ba0 IP 00000001045ec738  [image code] com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:75)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62bc0 IP 00000001045c4a48  [image code] com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:59)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62bc0 IP 00000001045c4a48  [image code] com.oracle.svm.core.jdk.JceSecurityUtil.shouldNotReach(SecuritySubstitutions.java:387)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62bf0 IP 000000010569556c  [image code] javax.crypto.JceSecurity.getCodeBase(JceSecurity.java:351)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62bf0 IP 000000010569556c  [image code] javax.crypto.JceSecurity.getVerificationResult(JceSecurity.java:216)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62c50 IP 0000000105695144  [image code] javax.crypto.JceSecurity.getInstance(JceSecurity.java:141)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62c90 IP 00000001056990f8  [image code] javax.crypto.KeyGenerator.getInstance(KeyGenerator.java:326)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62cc0 IP 000000010452012c  [image code] com.gluonapplication.GluonApplication.securityTest(GluonApplication.java:85)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62d70 IP 000000010451fbd8  [image code] com.gluonapplication.GluonApplication.init(GluonApplication.java:45)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62da0 IP 0000000104826860  [image code] com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:824)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62e80 IP 00000001048230b4  [image code] com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62ee0 IP 0000000104822718  [image code] com.sun.javafx.application.LauncherImpl$$Lambda$6b52b8b751707d234c1e536df5c7bfccab052d36.run(Unknown Source)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62f20 IP 0000000104fa6b2c  [image code] java.lang.Thread.run(Thread.java:834)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62f40 IP 00000001045e4a10  [image code] com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:517)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62f90 IP 00000001045a9c9c  [image code] com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62f90 IP 00000001045a9c9c  [image code] com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(IsolateEnterStub.java:0)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] [Native image heap boundaries: 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   ReadOnly Primitives: 0x106054008 .. 0x1070a4940
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   ReadOnly References: 0x1070a4978 .. 0x1076e01a8
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   ReadOnly Relocatables: 0x0 .. 0x0
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   Writable Primitives: 0x107730000 .. 0x107cd4ba0
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   Writable References: 0x107cd4bb8 .. 0x10838c328
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   Writable Huge: 0x0 .. 0x0
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   ReadOnly Huge: 0x0 .. 0x0]
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] [Heap:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   [Young generation: 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     [Eden: 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]       [edenSpace:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]         aligned: 0/0 unaligned: 0/0]]
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     [Survivors: 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]       ]]
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   [Old generation: 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     [oldFromSpace:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]       aligned: 0/0 unaligned: 0/0]
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     [oldToSpace:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]       aligned: 0/0 unaligned: 0/0]
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     ]
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   [Unused:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     aligned: 0/0]]
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] Fatal error: javax.crypto.JceSecurity.getCodeBase(Class) is reached at runtime. This should not happen. The contents of JceSecurity.verificationResults are computed and cached at image build time. Try enabling all security services with --enable-all-security-services.
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] Process 1187 exited with status = 99 (0x00000063) 
[Tue Sep 29 11:01:06 EDT 2020][INFO] result = true

正如这里讨论的,这可能是GraalVM的一个已知问题

下面是我pom文件中的插件配置:

            <plugin>
                <groupId>com.gluonhq</groupId>
                <artifactId>client-maven-plugin</artifactId>
                <version>${client.plugin.version}</version>
                <configuration>
                    <target>${client.target}</target>
                    <nativeImageArgs>-J-Djava.security.properties=java.security.overrides</nativeImageArgs>
                    <nativeImageArgs>--enable-all-security-services</nativeImageArgs>
                    <attachList>
                        <list>display</list>
                        <list>lifecycle</list>
                        <list>statusbar</list>
                        <list>storage</list>
                    </attachList>
                    <bundlesList>
                        <list>com.gluonapplication.views.primary</list>
                        <list>com.gluonapplication.views.secondary</list>
                    </bundlesList>
                    <reflectionList>
                        <list>com.gluonapplication.views.PrimaryPresenter</list>
                        <list>com.gluonapplication.views.SecondaryPresenter</list>
                        <list>org.bouncycastle.jcajce.provider.symmetric.AES$Mappings</list>
                    </reflectionList>
                    <mainClass>${mainClassName}</mainClass>
                </configuration>
            </plugin>

以及我为在此处共享代码而构建的示例应用程序的源代码(基于gluon插件的自动生成应用程序设置):

public class GluonApplication extends MobileApplication {

    private Provider provider;
    private static final String CIPHER_ALGORITHM = "AES";
    private static final String KEYPAIR_GENERATOR_ALGORITHM = "RSA";
    private static final String KEY_GENERATOR_ALGORITHM = "AES";
    private static final String KEY_FACTORY_ALGORITHM = "RSA";
    private static final String KEY_STORE_TYPE = "PKCS12";
    private static final String SIGNATURE_ALGORITHM = "SHA256withRSA";
    private static final String HASH_ALGORITHM = "PBKDF2WithHmacSHA256";
    private static final String TEMPORAL_KEY_ALGORITHM = "RSA";
    private static final int AES_KEY_SIZE = 256;
    private static final int RSA_KEY_SIZE = 2048;
    private File KEY_STORE_FILE;
    private static final String KEY_STORE_NAME = "keyStore";
    private static final String KEY_STORE_DIRECTORY_NAME = "security";
    private final KeyGenerator[] keyGenerators = new KeyGenerator[TOTAL_CIPHER_UNITS];
    private final Cipher[] temporalKeyEncrypters = new Cipher[TOTAL_CIPHER_UNITS];
    private final Cipher[] temporalKeyDecrypters = new Cipher[TOTAL_CIPHER_UNITS];
    private final Cipher[] payloadEncrypters = new Cipher[TOTAL_CIPHER_UNITS];
    private final Cipher[] payloadDecrypters = new Cipher[TOTAL_CIPHER_UNITS];
    private final KeyFactory[] keyFactories = new KeyFactory[TOTAL_CIPHER_UNITS];
    private final Signature[] signers = new Signature[TOTAL_CIPHER_UNITS];
    private static final int TOTAL_CIPHER_UNITS = 14;

    @Override
    public void init() {
        securityTest();
        AppViewManager.registerViewsAndDrawer(this);
    }

    @Override
    public void postInit(Scene scene) {
        Swatch.BLUE.assignTo(scene);

        scene.getStylesheets().add(GluonApplication.class.getResource("style.css").toExternalForm());
        ((Stage) scene.getWindow()).getIcons().add(new Image(GluonApplication.class.getResourceAsStream("/icon.png")));
    }

    public static void main(String args[]) {
        launch(args);
    }

    private void securityTest() {
        Security.removeProvider("BC");
        // also remove not sufficient AndroidOpenSSL provider for X.509 - most likely only needed if BouncyCastleJsseProvider is used
        Security.removeProvider("AndroidOpenSSL");
        // touch the internal Providers class to trigger the static provider loading
        // see http://androidxref.com/9.0.0_r3/xref/libcore/ojluni/src/main/java/sun/security/jca/Providers.java#SYSTEM_BOUNCY_CASTLE_PROVIDER
        try {
            Class.forName("sun.security.jca.Providers");
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(String.format("%s to patch not found.", "sun.security.jca.Providers"), e);
        }
        provider = new BouncyCastleProvider();

        Security.insertProviderAt(provider, 0);

        final File keyStoreDirectory = new File(System.getProperty("user.home"), KEY_STORE_DIRECTORY_NAME);
        // make sure that the path to the directory
        keyStoreDirectory.mkdirs();
        // create the key store file object
        KEY_STORE_FILE = new File(keyStoreDirectory, KEY_STORE_NAME);

        for (int i = 0; i < TOTAL_CIPHER_UNITS; i++) {
            try {
                // we init the key generator with the AES key size
                keyGenerators[i] = KeyGenerator.getInstance(KEY_GENERATOR_ALGORITHM, provider);
                keyGenerators[i].init(AES_KEY_SIZE);
                temporalKeyEncrypters[i] = Cipher.getInstance(TEMPORAL_KEY_ALGORITHM, provider);
                temporalKeyDecrypters[i] = Cipher.getInstance(TEMPORAL_KEY_ALGORITHM, provider);
                payloadEncrypters[i] = Cipher.getInstance(CIPHER_ALGORITHM, provider);
                payloadDecrypters[i] = Cipher.getInstance(CIPHER_ALGORITHM, provider);
                keyFactories[i] = KeyFactory.getInstance(KEY_FACTORY_ALGORITHM, provider);
                signers[i] = Signature.getInstance(SIGNATURE_ALGORITHM, provider);
            } catch (NoSuchPaddingException | NoSuchAlgorithmException ex) {
                ex.printStackTrace();
            }
        }
    }
}

共有1个答案

井宪
2023-03-14

如果您发布代码和完整的堆栈跟踪就更好了。

您可以查看此问题以及此解决方案。

通常从堆栈跟踪中,您可以检查BC源代码,然后您将能够找到需要为反射添加的类。

我遇到过很多情况,错误消息没有显示与反射相关的内容,但事实上,它是由反射引起的。

 类似资料:
  • 然而,我正试图使它在Windows10中工作,但没能做到。Windows 10中的等价物是什么?

  • 我试图使用maven插件为maven java项目添加一个源文件夹到Eclipse。 从http://mojo.codehaus.org/build-helper-maven-plugin/usage.html上的文档来看,这应该是正确的吧?文件夹target/sources/mygeneratedfiles存在。

  • 我需要在eclipse中使用with swagger codegen插件(用于maven)生成服务器存根代码。你能帮我怎么做吗?以及需要什么配置(在pom.xml中)。

  • 问题内容: 在我的文件中,我尝试实现一些映射,其中使用不同的分析器将属于一种类型的一个字段索引到其余字段。 目前,yaml文件具有以下结构: 这不会将自定义分析器应用于标题字段,因此我希望有人可以为我指出将自定义分析器应用于各个字段的正确方向? 问题答案: 我在ml中回答了这个问题: 如果您使用的是Java,则不必使用yml文件。您可以,但不必。 如果您使用的是Spring,则可以查看ES spr

  • 我正在使用GraalVm 21.0.0.2的native-image-maven-plugin为JavaFX应用程序创建一个本机映像。当我尝试在构建成功结束后执行它时,我得到以下错误: 我很感激你能给我的任何帮助。