Created
December 3, 2013 21:59
-
-
Save venuatu/7778186 to your computer and use it in GitHub Desktop.
Get jvm security algorithms (from a scala (2.10) script)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.language.postfixOps | |
object Main { | |
def getProviders(): Map[String, Seq[String]] = { | |
import scala.collection.JavaConversions._ | |
import java.security._ | |
Security.getProviders().map{ provider => | |
val name = provider.getName | |
name -> (provider.getServices.toList.map{ service => | |
def getAttr(service: Provider.Service, attr: String): Array[String] = { | |
val ret = service.getAttribute(attr); if (ret == null) Array("") else ret.split('|') } | |
getAttr(service, "SupportedModes").map{ mode => | |
getAttr(service, "SupportedPaddings").map{ padding => | |
s"${service.getAlgorithm}/${mode}/${padding}" | |
} | |
} flatten | |
} flatten) | |
} toMap | |
} | |
def main(args: Array[String]): Unit = { | |
var matchers = args.map{_.toUpperCase} | |
for ((provider, algorithms) <- getProviders) { | |
println(provider) | |
for (algorithm <- algorithms) { | |
if (matchers.length == 0 || | |
matchers.forall(algorithm.toUpperCase.contains(_))) | |
println(" " + algorithm) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment