So I am looking ways to use a security provider only in the scope of a function. I can already do this by adding these two lines: (assume BouncyCastle is the provider)
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider("BC");
// do some stuff with converter
Security.removeProvider("BC");
So i just want to use BC for JcaPEMKeyConverter and then for the rest use default security provider.
Is there a better way to do this? More elegantly? How about a custom java annotation, is that a good way ?
Thx :)