static Implementation getImplementation(
        String      baseName,
        String      algorithm,
        String      provider)
        throws NoSuchProviderException
    {
        if (provider == null)
        {
            Provider[] prov = Security.getProviders();

            //
            // search every provider looking for the algorithm we want.
            //
            for (int i = 0; i != prov.length; i++)
            {
                //
                // try case insensitive
                //
                Implementation imp = getImplementationFromProvider(baseName, algorithm.toUpperCase(), prov[i]);
                if (imp != null)
                {
                    return imp;
                }

                imp = getImplementationFromProvider(baseName, algorithm, prov[i]);
                if (imp != null)
                {
                    return imp;
                }
            }
        }
        else
        {
            Provider prov = Security.getProvider(provider);

            if (prov == null)
            {
                throw new NoSuchProviderException("Provider " + provider + " not found");
            }

            //
            // try case insensitive
            //
            Implementation imp = getImplementationFromProvider(baseName, algorithm.toUpperCase(), prov);
            if (imp != null)
            {
                return imp;
            }

            return getImplementationFromProvider(baseName, algorithm, prov);
        }

        return null;
    }