I am working with some code from back in 2003. There is a reference to the following class:
new com.sun.net.ssl.internal.ssl.Provider()
It is causing an error:
Access restriction: The type Provider is not accessible due to restriction on required library /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre/lib/jsse.jar
Does anyone have any suggestions for a suitable alternative to using this class?
Most of the time, you don't actually need to create or get hold of a provider instance yourself. As the Oracle Providers documentation says:
General purpose applications SHOULD NOT request cryptographic services from specific providers. That is:
getInstance("...", "SunJCE"); // not recommended vs. getInstance("..."); // recommended
In addition, wherever there's an overloaded parameter for the provider, it tends to take either a string or an instance, but the string (name) would probably be more common. (Passing an instance can be useful sometimes, e.g. for some PKCS#11 configurations, but it's unusual.)
The JCA documentation about Providers should be useful.
If you really want to get hold of a specific instance, you can use Security.getProvider(name)
. You'll find the appropriate names in the providers documentation.