JCE algorithms in Browser : Algorithms « Security « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JavaFX
25.JDK 6
26.JDK 7
27.JNDI LDAP
28.JPA
29.JSP
30.JSTL
31.Language Basics
32.Network Protocol
33.PDF RTF
34.Reflection
35.Regular Expressions
36.Scripting
37.Security
38.Servlets
39.Spring
40.Swing Components
41.Swing JFC
42.SWT JFace Eclipse
43.Threads
44.Tiny Application
45.Velocity
46.Web Services SOA
47.XML
Java » Security » Algorithms 




JCE algorithms in Browser
JCE algorithms in Browser
 
import java.awt.Dimension;
import java.security.Provider;
import java.security.Security;
import java.util.HashSet;
import java.util.Set;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeSelectionModel;

public class ListAlgorithmsBC extends JFrame {
  private void getNodes(DefaultMutableTreeNode providerNode, Provider provider,
      Set<Provider.Service> used, String title, String target) {
    DefaultMutableTreeNode node = new DefaultMutableTreeNode(title);
    for (Provider.Service service : provider.getServices()) {
      if (!used.contains(service&& target.equalsIgnoreCase(service.getType())) {
        used.add(service);
        DefaultMutableTreeNode algNode = new DefaultMutableTreeNode(service.getAlgorithm());
        node.add(algNode);
        algNode.add(new DefaultMutableTreeNode("class : " + service.getClassName()));
      }
    }
    if (node.getChildCount() != 0) {
      providerNode.add(node);
    }
  }

  private ListAlgorithmsBC() {
    super("JCE Algorithms");
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    DefaultMutableTreeNode root = new DefaultMutableTreeNode("Providers");
    DefaultTreeModel treeModel = new DefaultTreeModel(root);
    for (Provider provider : java.security.Security.getProviders()) {
      DefaultMutableTreeNode providerNode = new DefaultMutableTreeNode(provider);
      root.add(providerNode);
      Set<Provider.Service> used = new HashSet<Provider.Service>();

      getNodes(providerNode, provider, used, "Cipher""cipher");
      getNodes(providerNode, provider, used, "Key Agreement""keyagreement");
      getNodes(providerNode, provider, used, "Key Generator""keygenerator");
      getNodes(providerNode, provider, used, "Key Pair Generator""keypairgenerator");
      getNodes(providerNode, provider, used, "Key Factory""keyfactory");
      getNodes(providerNode, provider, used, "Secret Key Factory""secretkeyfactory");
      getNodes(providerNode, provider, used, "Mac""mac");
      getNodes(providerNode, provider, used, "Message Digest""messagedigest");
      getNodes(providerNode, provider, used, "Signature""signature");
      getNodes(providerNode, provider, used, "Algorithm Paramater""algorithmparameters");
      getNodes(providerNode, provider, used, "Algorithm Paramater Generator",
          "algorithmparametergenerator");
      getNodes(providerNode, provider, used, "Key Store""keystore");
      getNodes(providerNode, provider, used, "Secure Random""securerandom");
      getNodes(providerNode, provider, used, "Certificate Factory""certificatefactory");
      getNodes(providerNode, provider, used, "Certificate Store""certstore");
      getNodes(providerNode, provider, used, "Key Manager Factory""KeyManagerFactory");
      getNodes(providerNode, provider, used, "Trust Manager Factory""TrustManagerFactory");
      getNodes(providerNode, provider, used, "SSL Context""SSLContext");
      getNodes(providerNode, provider, used, "Sasl Server Factory""SaslServerFactory");
      getNodes(providerNode, provider, used, "Sasl Client Factory""SaslClientFactory");
      {
        DefaultMutableTreeNode node = new DefaultMutableTreeNode("Other");
        for (Provider.Service service : provider.getServices()) {
          if (!used.contains(service)) {
            DefaultMutableTreeNode serviceNode = new DefaultMutableTreeNode(service.getType()
                " : " + service.getAlgorithm());
            node.add(serviceNode);
            serviceNode.add(new DefaultMutableTreeNode("class : " + service.getClassName()));
          }
        }
        if (node.getChildCount() != 0)
          providerNode.add(node);
      }
    }

    JTree tree = new JTree(treeModel);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setEditable(false);
    JScrollPane pane = new JScrollPane(tree);
    pane.setPreferredSize(new Dimension(200200));

    getContentPane().add(pane);

    pack();
  }

  public static void main(String[] args) {
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    new ListAlgorithmsBC().setVisible(true);
  }
}

           
         
  














Related examples in the same category
1.What is in bouncycastle (bouncy castle)
2.Listing All Available Cryptographic Services
3.Return the available implementations for a service type
4.Get cryptographic security providers
5.Generating a Parameter Set for the Diffie-Hellman Key Agreement Algorithm
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.