Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.security.Provider;
import java.security.Security;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class Main {
  public static void main(String[] argv) throws Exception {
    Set result = new HashSet();
    String serviceType = "KeyFactory";
    Provider[] providers = Security.getProviders();
    for (int i = 0; i < providers.length; i++) {
      Set keys = providers[i].keySet();
      for (Iterator it = keys.iterator(); it.hasNext();) {
        String key = (String) it.next();
        key = key.split(" ")[0];

        if (key.startsWith(serviceType + ".")) {
          result.add(key.substring(serviceType.length() + 1));
        } else if (key.startsWith("Alg.Alias." + serviceType + ".")) {
          result.add(key.substring(serviceType.length() + 11));
        }
      }
    }
    System.out.println(result);
  }

}
[1.2.840.113549.1.3.1, 
OID.1.2.840.113549.1.1, 
1.2.840.113549.1.1, 
OID.1.2.840.113549.1.3.1, 
1.3.14.3.2.12, 
DSA, DiffieHellman, RSA, DH, 1.2.840.10040.4.1]