java.security.NoSuchProviderException:没有这样的提供者:SUN

ami*_*zer 3 java websphere google-authenticator

我已经使用二维码实现了两因素身份验证。我已经使用GoogleAuth库完成了它。在我的本地环境中,效果非常好,但是当我在 WebSphere 8.5.5 上部署应用程序时,它会抛出以下错误:

java.security.NoSuchProviderException: no such provider: SUN
Run Code Online (Sandbox Code Playgroud)

GoogleAuth抛出这个异常:

Could not initialise SecureRandom with the specified provider: SUN. 
Another provider can be chosen setting the com.warrenstrange.googleauth.rng.algorithmProvider system property
Run Code Online (Sandbox Code Playgroud)

关于这个方法:

private String getRandomNumberAlgorithm()
{
    return System.getProperty(RNG_ALGORITHM, DEFAULT_RANDOM_NUMBER_ALGORITHM);
}
Run Code Online (Sandbox Code Playgroud)

我在项目的 GitHub 页面上发现了这个问题,它与我的问题非常相似,编写这个库的人在这里解释了这个方法的作用:

该库当前使用 SecureRandom#getInstance 方法并指定 SHA1PRNG 算法和 SUN 提供程序获取 SecureRandom 实例

我知道我必须SUN使用另一个提供者来覆盖提供者System.setProperty("com.warrenstrange.googleauth.rng.algorithmProvider", "property"),因为系统找不到它,但我不明白为什么会抛出异常。在我的机器上,我使用 Java 7 运行应用程序,Websphere 使用相同的版本。不同之处在于WebSphere 上运行的应用程序是用Java 6 编译的。

我的问题是:

为什么会抛出这个异常?Provider不是SUNJava 的一部分吗?

我应该使用哪些其他提供商以及如何使用?

Gas*_*Gas 5

不同之处在于,SUN默认情况下,某些 WebSphere/Java 版本中提供程序不可用。您可以检查它是否存在于目录java.security中的文件中WebSphere/AppServer/java/jre/lib/security

通过该属性指定IBMJCE为提供者以使用它而不是SUN