List of usage examples for java.security Provider getServices
public synchronized Set<Service> getServices()
From source file:jef.tools.security.EncrypterUtil.java
/** * ????// ww w .j a v a 2s .c o m * * @param type * @return */ public static Service[] getSupportedAlgorithm(AlgorithmType type) { List<Service> list = new ArrayList<Service>(); for (Provider p : Security.getProviders()) { for (Service s : p.getServices()) { if (type == null || s.getType().equals(type.name())) { list.add(s); } } } return list.toArray(new Service[0]); }
From source file:jef.tools.security.EncrypterUtil.java
/** * ???/* ww w . jav a 2 s .c o m*/ * * @param name * @return * @throws Exception */ @SuppressWarnings("unchecked") public static Service[] getAlgorithmService(String name) throws Exception { List<Service> list = new ArrayList<Service>(); MethodEx m = BeanUtils.getCompatibleMethod(Service.class, "getAliases"); for (Provider p : Security.getProviders()) { for (Service s : p.getServices()) { boolean flag = false; if (s.getAlgorithm().equalsIgnoreCase(name)) { flag = true; } else { List<String> aliases = ((List<String>) m.invoke(s)); for (String alias : aliases) { if (alias.equalsIgnoreCase(name)) { flag = true; break; } } } if (flag) { list.add(s); } } } return list.toArray(new Service[0]); }
From source file:ListAlgorithmsBC.java
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);//from w ww. java2s . c o m DefaultMutableTreeNode algNode = new DefaultMutableTreeNode(service.getAlgorithm()); node.add(algNode); algNode.add(new DefaultMutableTreeNode("class : " + service.getClassName())); } } if (node.getChildCount() != 0) { providerNode.add(node); } }
From source file:eu.europa.esig.dss.DSSUtils.java
/** * This method lists all defined security providers. *///ww w . j a v a 2 s.com public static void printSecurityProvides() { final Provider[] providers = Security.getProviders(); for (final Provider provider : providers) { System.out.println("PROVIDER: " + provider.getName()); final Set<Provider.Service> services = provider.getServices(); for (final Provider.Service service : services) { System.out.println("\tALGORITHM: " + service.getAlgorithm() + " / " + service.getType() + " / " + service.getClassName()); } } }
From source file:at.tfr.securefs.Configuration.java
@PostConstruct public void init() { if (log.isDebugEnabled()) { for (Provider p : Security.getProviders()) { try { log.debug("Provider: " + p.getClass() + ", Name=" + p.getName() + ", Info=" + p.getInfo()); final Set<Service> services = p.getServices(); if (services == null) { log.debug("Provider has no services: " + p); } else { for (Service s : services) { log.debug("Service: " + s.getClassName() + ", " + s.getAlgorithm() + ", "); }/*from w ww .ja v a 2 s.c om*/ } } catch (Throwable t) { log.info("cannot print info: Provider=" + p + " : " + t, t); } } } loadSecureFsProperties(true); keyAlgorithm = secConfig.getString(SECUREFS_SERVER_PFX + KEY_ALGORITHM, keyAlgorithm); log.info("KeyAlgorithm = " + keyAlgorithm); keyStrength = secConfig.getInt(SECUREFS_SERVER_PFX + KEY_STRENGTH, keyStrength); log.info("KeyStrength = " + keyStrength); iterationCount = secConfig.getInt(SECUREFS_SERVER_PFX + ITERATION_COUNT, iterationCount); log.info("IterationCount = " + iterationCount); cipherAlgorithm = secConfig.getString(SECUREFS_SERVER_PFX + CIPHER_ALGORITHM, cipherAlgorithm); log.info("CipherAlgorithm = " + cipherAlgorithm); paddingCipherAlgorithm = secConfig.getString(SECUREFS_SERVER_PFX + PADDING_CIPHER_ALGORITHM, paddingCipherAlgorithm); log.info("PaddingCipherAlgorithm = " + paddingCipherAlgorithm); salt = secConfig.getString(SECUREFS_SERVER_PFX + SALT, salt); log.info("Salt = " + salt); cacheName = secConfig.getString(SECUREFS_SERVER_PFX + CACHE_NAME, cacheName); log.info("CacheName = " + cacheName); restrictedToBasePath = secConfig.getBoolean(SECUREFS_SERVER_PFX + RESTRICTED_TO_BASE_PATH, restrictedToBasePath); log.info("RestrictedToBasePath = " + restrictedToBasePath); preProcessing = secConfig.getBoolean(SECUREFS_SERVER_PFX + PRE_PROCESSING, preProcessing); log.info("PreProcessing = " + preProcessing); test = secConfig.getBoolean(SECUREFS_SERVER_PFX + TEST, test); log.info("Test = " + test); try { String basePathProp = secConfig.getString(SECUREFS_SERVER_PFX + BASE_PATH); if (StringUtils.isNotBlank(basePathProp)) { basePath = Paths.get(basePathProp); } else { basePath = Files.createTempDirectory(SECUREFS); } log.info("BasePath = " + basePath); revokedKeysPath = basePath.resolve(REVOKED_KEYS); } catch (Exception e) { log.warn("cannot open BasePath", e); } try { String tmpPathProp = secConfig.getString(SECUREFS_SERVER_PFX + TMP_PATH); String jbossTmpPathProp = System.getProperty(JBOSS_SERVER_TEMP_DIR); if (StringUtils.isNotBlank(tmpPathProp)) { tmpPath = Paths.get(tmpPathProp); } else if (StringUtils.isNotBlank(jbossTmpPathProp)) { tmpPath = Files.createDirectories(Paths.get(jbossTmpPathProp, SECUREFS)); } else { tmpPath = Files.createTempDirectory(SECUREFS); } log.info("TmpPath = " + tmpPath); } catch (Exception e) { log.warn("cannot open TmpPath", e); } try { schemaPath = Paths.get(secConfig.getString(SECUREFS_SERVER_PFX + SCHEMA_PATH, "/tmp")); log.info("SchemaPath = " + schemaPath); } catch (Exception e) { log.warn("cannot open SchemaPath", e); } try { log.info("ServiceModules : names=" + getServiceModules()); getModuleConfigurations().stream().peek((m) -> log.info("\t" + m)); } catch (Exception e) { log.warn("cannot read ServiceModules", e); } }
From source file:ListAlgorithmsBC.java
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);//from w w w .jav a 2s. co m 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(200, 200)); getContentPane().add(pane); pack(); }
From source file:test.be.fedict.eid.applet.RSATest.java
@Test public void testListSecurityProviders() throws Exception { Provider[] providers = Security.getProviders(); for (Provider provider : providers) { LOG.debug("provider name: " + provider.getName()); LOG.debug("provider info: " + provider.getInfo()); Set<Service> services = provider.getServices(); for (Service service : services) { LOG.debug("\tservice type: " + service.getType()); LOG.debug("\tservice algo: " + service.getAlgorithm()); }/* ww w. j a v a2s . c om*/ } }