java.security.NoSuchProviderException: no such provider: SUN

Viewed 7360

I have implemented two factor authentication with QR code. I've done it using GoogleAuth library. In my local environment works like a charm but when I deploy the application on WebSphere 8.5.5 it throws this error:

java.security.NoSuchProviderException: no such provider: SUN

And GoogleAuth throw this exception:

Could not initialise SecureRandom with the specified provider: SUN. 
Another provider can be chosen setting the com.warrenstrange.googleauth.rng.algorithmProvider system property

on this method:

private String getRandomNumberAlgorithm()
{
    return System.getProperty(RNG_ALGORITHM, DEFAULT_RANDOM_NUMBER_ALGORITHM);
}

I found this issue on project's GitHub page that is very similar to my problem and here the guy who wrote this library explaines what this method does:

The library currently gets a SecureRandom instance using the SecureRandom#getInstance method and specifying the SHA1PRNG algorithm and the SUN provider

I understood that I have to override SUN provider with another one using System.setProperty("com.warrenstrange.googleauth.rng.algorithmProvider", "property"), because the system can't find it, but I don't understand why is throwing the exception. On my machine I run the application with Java 7 and Websphere uses the same version. The difference is the application that runs on WebSphere is compiled with Java 6.

My questions are:

Why is throwing this exception? Isn't SUN provider part of Java?

What other provider should I use and how?

1 Answers
Related