001package co.codewizards.cloudstore.core.auth;
002
003import java.security.Provider;
004import java.security.Security;
005
006import org.bouncycastle.jce.provider.BouncyCastleProvider;
007
008public final class BouncyCastleRegistrationUtil {
009
010        private BouncyCastleRegistrationUtil() { }
011
012        public static synchronized void registerBouncyCastleIfNeeded() {
013                Provider provider = Security.getProvider("BC");
014                if (provider != null)
015                        return;
016
017                Security.addProvider(new BouncyCastleProvider());
018
019                provider = Security.getProvider("BC");
020                if (provider == null)
021                        throw new IllegalStateException("Registration of BouncyCastleProvider failed!");
022        }
023}