Example usage for java.security Provider keySet

List of usage examples for java.security Provider keySet

Introduction

In this page you can find the example usage for java.security Provider keySet.

Prototype

@Override
public Set<Object> keySet() 

Source Link

Document

Returns an unmodifiable Set view of the property keys contained in this provider.

Usage

From source file:MainClass.java

public static void main(String[] args) {
    Provider provider = Security.getProvider("BC");

    Iterator it = provider.keySet().iterator();

    while (it.hasNext()) {
        String entry = (String) it.next();
        if (entry.startsWith("Alg.Alias.")) {
            entry = entry.substring("Alg.Alias.".length());
        }/*from w  w  w .  ja v  a2  s.  c om*/
        System.out.println(entry);
    }
}

From source file:Main.java

public static void main(String[] args) {
    Set<Object> result = new HashSet<Object>();
    Provider[] providers = Security.getProviders();
    for (Provider provider : providers) {
        Set<Object> keys = provider.keySet();
        for (Object key : keys) {
            String data = (String) key;
            data = data.split(" ")[0];
            if (data.startsWith("Alg.Alias")) {
                data = data.substring(10);
            }//w  ww  . j  a  va 2s . c om
            data = data.substring(0, data.indexOf('.'));
            result.add(data);
        }
    }
    for (Object o : result) {
        System.out.println("Service Type = " + o);
    }
}

From source file:com.adaptris.security.util.SecurityUtil.java

public static String getAlgorithms() {
    initialise();// w  ww . j ava  2s  . co  m
    StringBuffer sb = new StringBuffer("Security Algorithms available");
    for (Provider provider : Security.getProviders()) {
        sb.append("\nProvider : " + provider.toString() + "\n");

        Object[] objs = provider.keySet().toArray();
        Arrays.sort(objs);
        for (Object o : objs) {
            sb.append(o.toString() + ", ");
        }
    }
    return sb.toString();
}

From source file:net.sf.jsignpdf.Signer.java

/**
 * Writes info about security providers to the {@link Logger} instance. The
 * log-level for messages is TRACE./*from   w w  w .j a  va  2 s .  c om*/
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
private static void traceInfo() {
    if (LOGGER.isTraceEnabled()) {
        try {
            Provider[] aProvider = Security.getProviders();
            for (int i = 0; i < aProvider.length; i++) {
                Provider provider = aProvider[i];
                LOGGER.trace(
                        "Provider " + (i + 1) + " : " + provider.getName() + " " + provider.getInfo() + " :");
                List keyList = new ArrayList(provider.keySet());
                try {
                    Collections.sort(keyList);
                } catch (Exception e) {
                    LOGGER.trace("Provider's properties keys can't be sorted", e);
                }
                Iterator keyIterator = keyList.iterator();
                while (keyIterator.hasNext()) {
                    String key = (String) keyIterator.next();
                    LOGGER.trace(key + ": " + provider.getProperty(key));
                }
                LOGGER.trace("------------------------------------------------");
            }
        } catch (Exception e) {
            LOGGER.trace("Listing security providers failed", e);
        }
    }
}

From source file:org.texai.x509.X509Utils.java

/** Logs the capabilities of the cryptography providers.
 * @param providerString the provider identifier
 *//*from   w  ww . ja v a2  s . c o m*/
public static void logProviderCapabilities(final String providerString) {
    //Preconditions
    assert providerString != null : "providerString must not be null";
    assert !providerString.isEmpty() : "providerString must not be empty";

    final Provider provider = Security.getProvider(providerString);

    final Iterator<Object> propertyKey_iter = provider.keySet().iterator();

    LOGGER.info("cryptography provider " + providerString + " capabilities ...");
    final List<String> propertyStrings = new ArrayList<>();
    while (propertyKey_iter.hasNext()) {
        String propertyString = (String) propertyKey_iter.next();
        if (propertyString.startsWith("Alg.Alias.")) {
            // this indicates the entry refers to another entry
            propertyString = propertyString.substring("Alg.Alias.".length());
        }
        propertyStrings.add(propertyString);
    }
    Collections.sort(propertyStrings);
    for (final String propertyString : propertyStrings) {
        final String factoryClass = propertyString.substring(0, propertyString.indexOf('.'));
        final String name = propertyString.substring(factoryClass.length() + 1);
        LOGGER.info("  " + factoryClass + ": " + name);
    }
}