List the available algorithm names for ciphers, key agreement, macs, message digests and signatures : Providers « Security « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Collections Data Structure
8. Database SQL JDBC
9. Design Pattern
10. Development Class
11. Email
12. Event
13. File Input Output
14. Game
15. Hibernate
16. J2EE
17. J2ME
18. JDK 6
19. JSP
20. JSTL
21. Language Basics
22. Network Protocol
23. PDF RTF
24. Regular Expressions
25. Security
26. Servlets
27. Spring
28. Swing Components
29. Swing JFC
30. SWT JFace Eclipse
31. Threads
32. Tiny Application
33. Velocity
34. Web Services SOA
35. XML
Microsoft Office Word 2007 Tutorial
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Java » Security » ProvidersScreenshots 
List the available algorithm names for ciphers, key agreement, macs, message digests and signatures

/*
Ciphers:
            None available.
KeyAgreeents:
            None available.
Macs:
            None available.
MessageDigests:
            SHA-512
            SHA1
            MD2
            SHA
            SHA ImplementedIn
            SHA-256
            MD5 ImplementedIn
            SHA-1
            MD5
            SHA-384
Signatures:
            OID.1.2.840.10040.4.3
            OID.1.2.840.113549.1.1.4
            SHA384withRSA
            1.3.14.3.2.29
            SHA512withRSA SupportedKeyClasses
            SHA/DSA
            SHA1withDSA KeySize
            NONEwithDSA SupportedKeyClasses
            OID.1.2.840.113549.1.1.5
            SHA512withRSA
            MD5withRSA
            DSS
            OID.1.2.840.113549.1.1.11
            SHA384withRSA SupportedKeyClasses
            SHA1withRSA
            MD5withRSA SupportedKeyClasses
            NONEwithDSA
            1.2.840.113549.1.1.4
            MD5andSHA1withRSA
            1.2.840.113549.1.1.11
            OID.1.2.840.113549.1.1.13
            1.3.14.3.2.27
            1.2.840.10040.4.3
            SHA256withRSA
            MD2withRSA SupportedKeyClasses
            1.2.840.113549.1.1.2
            1.2.840.113549.1.1.12
            RawDSA
            SHA1withDSA
            SHA1/DSA
            MD2withRSA
            1.3.14.3.2.13
            SHAwithDSA
            DSAWithSHA1
            1.2.840.113549.1.1.13
            OID.1.3.14.3.2.29
            SHA1withDSA ImplementedIn
            SHA256withRSA SupportedKeyClasses
            SHA1withDSA SupportedKeyClasses
            DSA
            1.2.840.113549.1.1.5
            SHA-1/DSA
            SHA1withRSA SupportedKeyClasses
            OID.1.2.840.113549.1.1.12
            OID.1.2.840.113549.1.1.2
 */
import java.security.Provider;
import java.security.Security;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class ListAlgorithms {
  public static void printSet(String setName, Set algorithms) {
    System.out.println(setName + ":");
    if (algorithms.isEmpty()) {
      System.out.println("            None available.");
    else {
      Iterator it = algorithms.iterator();
      while (it.hasNext()) {
        String name = (Stringit.next();

        System.out.println("            " + name);
      }
    }
  }

  public static void main(String[] args) {
    Provider[] providers = Security.getProviders();
    Set<String> ciphers = new HashSet<String>();
    Set<String> keyAgreements = new HashSet<String>();
    Set<String> macs = new HashSet<String>();
    Set<String> messageDigests = new HashSet<String>();
    Set<String> signatures = new HashSet<String>();

    for (int i = 0; i != providers.length; i++) {
      Iterator it = providers[i].keySet().iterator();

      while (it.hasNext()) {
        String entry = (Stringit.next();

        if (entry.startsWith("Alg.Alias.")) {
          entry = entry.substring("Alg.Alias.".length());
        }

        if (entry.startsWith("Cipher.")) {
          ciphers.add(entry.substring("Cipher.".length()));
        else if (entry.startsWith("KeyAgreement.")) {
          keyAgreements.add(entry.substring("KeyAgreement.".length()));
        else if (entry.startsWith("Mac.")) {
          macs.add(entry.substring("Mac.".length()));
        else if (entry.startsWith("MessageDigest.")) {
          messageDigests.add(entry.substring("MessageDigest.".length()));
        else if (entry.startsWith("Signature.")) {
          signatures.add(entry.substring("Signature.".length()));
        }
      }
    }

    printSet("Ciphers", ciphers);
    printSet("KeyAgreeents", keyAgreements);
    printSet("Macs", macs);
    printSet("MessageDigests", messageDigests);
    printSet("Signatures", signatures);
  }
}

           
       
Related examples in the same category
1. List All Provider And Its Algorithms
w__w___w._j__a__v__a2s___._c_o_m__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.