在 Equinox 中访问 c​​om.sun.crypto.provider

发布于 2025-01-08 17:10:05 字数 1374 浏览 0 评论 0原文

我正在尝试集成一些依赖于的预先存在的代码 com.sun.crypto.provider.SunJCE 类进入我们基于 Equinox 的 应用程序(版本 3.7.1)。现在我默认知道 com.sun 捆绑包无法访问包,因此我使用以下命令制作了一个片段 扩展框架以导出包的想法。这是它的 清单:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Extension
Bundle-SymbolicName: extension
Bundle-Version: 1.0.0.qualifier
Fragment-Host: system.bundle; extension:=framework
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: com.sun.crypto.provider

线索 1:PDE 标记 Export-Package 行并表示 此插件中不存在 com.sun.crypto.provider。

我创建了一个示例包,它只是实例化有问题的类 在捆绑激活器中。该捆绑包的清单是:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Cryptotest
Bundle-SymbolicName: cryptotest
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: cryptotest.Activator
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.sun.crypto.provider,
 org.osgi.framework;version="1.3.0"

线索 2:PDE 使用访问限制标记实例化。

尽管有两个错误,该项目仍然可以编译,并且我能够 开始调试。启动示例包时,我收到一个类 未发现异常。但是,当我在控制台中执行“packages 0”时,它会出现 Equinox 声称要导出这个包:

com.sun.crypto.provider;
version="0.0.0"<org.eclipse.osgi_3.7.1.R37x_v20110808-1106 [0]>
 cryptotest_1.0.0.qualifier [2] imports

现在,我发现了一个丑陋的解决方法,它似乎在我的最小示例中起作用。它基本上是将 Java 的 jce 提供程序 jar 包装在一个单独的插件中,并将其包含在我的应用程序中,但这似乎是错误的。

有人可以提供一些关于正在发生的事情的见解吗?是 我明显缺少一些东西吗?

I am trying to integrate some pre-existing code that relies on the
com.sun.crypto.provider.SunJCE class into our Equinox based
application (version 3.7.1). Now I know by default the com.sun
packages are not accessible to bundles, so I made a fragment with the
idea of extending the framework to export the package. Here is its
manifest:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Extension
Bundle-SymbolicName: extension
Bundle-Version: 1.0.0.qualifier
Fragment-Host: system.bundle; extension:=framework
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: com.sun.crypto.provider

Clue 1: The PDE marks the Export-Package line and says that
com.sun.crypto.provider does not exist in this plugin.

I created a sample bundle that just instantiates the class in question
in the bundle activator. That bundle's manifest is:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Cryptotest
Bundle-SymbolicName: cryptotest
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: cryptotest.Activator
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.sun.crypto.provider,
 org.osgi.framework;version="1.3.0"

Clue 2: The PDE marks the instantiation with an access restriction.

Despite the two errors, the project does compile and I am able to
start debugging. When starting the sample bundle, I receive a class
not found exception. However, when I do a "packages 0" in the console, it appears
Equinox is claiming to export this package:

com.sun.crypto.provider;
version="0.0.0"<org.eclipse.osgi_3.7.1.R37x_v20110808-1106 [0]>
 cryptotest_1.0.0.qualifier [2] imports

Now, I have found an ugly work around that appears to work in my minimal example. It is to basically wrap Java's jce provider jar in a separate plugin and include that with my application, but that just seems wrong.

Could somebody please provide some insight into what's going on? Is
there something obvious I am missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

可可 2025-01-15 17:10:05

这看起来像是 JVM 中存在的一个包,但仅当在 Sun JVM 上运行时才有效。默认情况下,系统捆绑包不会公开这些内容,因为 OSGi 并非专门为 Sun VM 构建。

但是,您可以指示框架公开此包。为此,您将 org.osgi.framework.system.packages.extra 属性设置为包列表,其中包括您的 com.sun.crypto.provider 包。有多种方法可以做到这一点,但您可以例如使用系统属性启动 Equinox,

-Dorg.osgi.framework.system.packages.extra=com.sun.crypto.provider

顺便说一句,这不是 Equinox 特定的,而是标准的 OSGi 构造。

This looks like a package that is present in your JVM, but only when running on a Sun one. These are not exposed by the system bundle by default, because OSGi is not built solely for Sun VMs.

You can, however, instruct the framework to expose this package. To do so, you set the org.osgi.framework.system.packages.extra property to a list of packages, which includes your com.sun.crypto.provider package. There are several ways to do this, but you could, for instance start Equinox with a system property,

-Dorg.osgi.framework.system.packages.extra=com.sun.crypto.provider

By the way, this is not Equinox-specific, but a standard OSGi-construct.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文