package org.kodejava.security;
import java.security.Provider;
import java.security.Security;
import java.util.Set;
import java.util.HashSet;
public class SecurityProvider {
public static void main(String[] args) {
// Create a set so that we can have a unique results.
Set<String> results = new HashSet<>();
// Returns an array containing all the installed providers.
Provider[] providers = Security.getProviders();
for (Provider provider : providers) {
// Get provider's property keys
Set<Object> keys = provider.keySet();
for (Object key : keys) {
String data = (String) key;
data = data.split(" ")[0];
// Service type started by the "Alg.Alias" string
if (data.startsWith("Alg.Alias")) {
data = data.substring(10);
}
data = data.substring(0, data.indexOf('.'));
results.add(data);
}
}
for (Object object : results) {
System.out.println("Service Type = " + object);
}
}
}
The example result of our code:
Service Type = Policy
Service Type = Configuration
Service Type = AlgorithmParameterGenerator
Service Type = TransformService
Service Type = CertificateFactory
Service Type = KeyInfoFactory
Service Type = CertPathBuilder
Service Type = MessageDigest
Service Type = KeyAgreement
Service Type = SecretKeyFactory
Service Type = KeyGenerator
Service Type = KeyFactory
Service Type = XMLSignatureFactory
Service Type = SaslServerFactory
Service Type = TerminalFactory
Service Type = SecureRandom
Service Type = SaslClientFactory
Service Type = KeyPairGenerator
Service Type = SSLContext
Service Type = KeyStore
Service Type = Mac
Service Type = Provider
Service Type = KeyManagerFactory
Service Type = CertPathValidator
Service Type = Signature
Service Type = TrustManagerFactory
Service Type = Cipher
Service Type = CertStore
Service Type = GssApiMechanism
Service Type = AlgorithmParameters
Latest posts by Wayan (see all)
- How do I get number of each day for a certain month in Java? - September 8, 2024
- How do I get operating system process information using ProcessHandle? - July 22, 2024
- How do I sum a BigDecimal property of a list of objects using Java Stream API? - July 22, 2024