java.security.NoSuchProviderException:没有这样的提供商:SUN
java.security.NoSuchProviderException: no such provider: SUN
我已经使用二维码实现了双重身份验证。我已经使用 GoogleAuth 库完成了它。在我的本地环境中运行起来非常棒,但是当我在 WebSphere 8.5.5 上部署应用程序时,它会抛出此错误:
java.security.NoSuchProviderException: no such provider: SUN
并且GoogleAuth
抛出这个异常:
Could not initialise SecureRandom with the specified provider: SUN.
Another provider can be chosen setting the com.warrenstrange.googleauth.rng.algorithmProvider system property
关于此方法:
private String getRandomNumberAlgorithm()
{
return System.getProperty(RNG_ALGORITHM, DEFAULT_RANDOM_NUMBER_ALGORITHM);
}
我在项目的 GitHub 页面上发现这个 issue 与我的问题非常相似,编写这个库的人在这里解释了这个方法的作用:
The library currently gets a SecureRandom instance using the
SecureRandom#getInstance method and specifying the SHA1PRNG algorithm
and the SUN provider
我知道我必须用另一个使用 System.setProperty("com.warrenstrange.googleauth.rng.algorithmProvider", "property")
的提供程序覆盖 SUN
提供程序,因为系统找不到它,但我不明白为什么会抛出异常。
在我的机器上,我 运行 带有 Java 7 的应用程序和 Websphere 使用相同的版本。区别在于运行s在WebSphere上的应用是用Java6.
编译的
我的问题是:
为什么抛出这个异常? SUN
提供商不是 Java 的一部分吗?
我应该使用哪些其他提供商以及如何使用?
区别在于 SUN
提供程序在某些 WebSphere/Java 版本中默认不可用。您可以检查它是否存在于 WebSphere/AppServer/java/jre/lib/security
目录中的 java.security
文件中。
通过 属性 将 IBMJCE
指定为提供商以使用它而不是 SUN
我已经使用二维码实现了双重身份验证。我已经使用 GoogleAuth 库完成了它。在我的本地环境中运行起来非常棒,但是当我在 WebSphere 8.5.5 上部署应用程序时,它会抛出此错误:
java.security.NoSuchProviderException: no such provider: SUN
并且GoogleAuth
抛出这个异常:
Could not initialise SecureRandom with the specified provider: SUN.
Another provider can be chosen setting the com.warrenstrange.googleauth.rng.algorithmProvider system property
关于此方法:
private String getRandomNumberAlgorithm()
{
return System.getProperty(RNG_ALGORITHM, DEFAULT_RANDOM_NUMBER_ALGORITHM);
}
我在项目的 GitHub 页面上发现这个 issue 与我的问题非常相似,编写这个库的人在这里解释了这个方法的作用:
The library currently gets a SecureRandom instance using the SecureRandom#getInstance method and specifying the SHA1PRNG algorithm and the SUN provider
我知道我必须用另一个使用 System.setProperty("com.warrenstrange.googleauth.rng.algorithmProvider", "property")
的提供程序覆盖 SUN
提供程序,因为系统找不到它,但我不明白为什么会抛出异常。
在我的机器上,我 运行 带有 Java 7 的应用程序和 Websphere 使用相同的版本。区别在于运行s在WebSphere上的应用是用Java6.
我的问题是:
为什么抛出这个异常? SUN
提供商不是 Java 的一部分吗?
我应该使用哪些其他提供商以及如何使用?
区别在于 SUN
提供程序在某些 WebSphere/Java 版本中默认不可用。您可以检查它是否存在于 WebSphere/AppServer/java/jre/lib/security
目录中的 java.security
文件中。
通过 属性 将 IBMJCE
指定为提供商以使用它而不是 SUN