private static Set getCryptoImpls ( String serviceType ) { Set result = new TreeSet ( ) ; // All all providers Provider [ ] providers = Security . getProviders ( ) ; for ( int i = 0 ; i < providers . length ; i ++ ) { // Get services provided by each provider Set keys = providers [ i ] . keySet ( ) ; for ( Object okey : providers [ i ] . keySet ( ) ) { String key = ( String ) okey ; key = key . split ( " " ) [ 0 ] ; if ( key . startsWith ( serviceType + "." ) ) { result . add ( key . substring ( serviceType . length ( ) + 1 ) ) ; } else if ( key . startsWith ( "Alg.Alias." + serviceType + "." ) ) { // This is an alias result . add ( key . substring ( serviceType . length ( ) + 11 ) ) ; } } } return result ; }
Provides a list of algorithms for the specified service ( which for our purposes is MessageDigest .