本文整理了Java中java.security.Provider.keySet()
方法的一些代码示例,展示了Provider.keySet()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Provider.keySet()
方法的具体详情如下:
包路径:java.security.Provider
类名称:Provider
方法名:keySet
[英]Returns an unmodifiable Set view of the property keys contained in this provider.
[中]返回此提供程序中包含的属性键的不可修改的集合视图。
代码示例来源:origin: wildfly/wildfly
private static <T> Iterator<T> getFactories(Class<T> type, ClassLoader classLoader, boolean includeGlobal) {
Set<T> factories = new LinkedHashSet<>();
final ServiceLoader<T> loader = ServiceLoader.load(type, classLoader);
for (T factory : loader) {
factories.add(factory);
}
if (includeGlobal) {
Set<String> loadedClasses = new HashSet<>();
final String filter = type.getSimpleName() + ".";
Provider[] providers = Security.getProviders();
for (Provider currentProvider : providers) {
final ClassLoader cl = currentProvider.getClass().getClassLoader();
currentProvider.keySet().stream().filter(currentKey -> currentKey instanceof String && ((String)currentKey).startsWith(filter)
&& ((String)currentKey).indexOf(' ') < 0).forEach(currentKey -> {
String className=currentProvider.getProperty((String)currentKey);
if(className != null && loadedClasses.add(className)) {
try {
factories.add(Class.forName(className, true, cl).asSubclass(type).newInstance());
} catch(ClassNotFoundException | ClassCastException | InstantiationException | IllegalAccessException e) {
}
}
});
}
}
return factories.iterator();
}
代码示例来源:origin: wildfly/wildfly
for (Object currentKey : currentProvider.keySet()) {
if (currentKey instanceof String &&
((String) currentKey).startsWith(filter) &&
代码示例来源:origin: stackoverflow.com
for (Provider p : Security.getProviders()) {
for (Object o : p.keySet()) {
System.out.println(o);
}
}
代码示例来源:origin: stackoverflow.com
Provider[] providers = Security.getProviders();
for (Provider provider : providers) {
for (Object entry : provider.keySet()) {
String name = String.valueOf(entry);
if (name.startsWith("Cipher")) {
Log.d("Cipher", "Supports: " + name.substring(7));
}
}
}
代码示例来源:origin: stackoverflow.com
Provider[] providers = Security.getProviders();
for (Provider provider : providers) {
for (Object entry : provider.keySet()) {
String name = String.valueOf(entry);
if (name.startsWith("Cipher")) {
Log.d("Cipher", "Supports: " + name.substring(7));
}
}
}
代码示例来源:origin: com.puresoltechnologies.commons/misc
public static String[] getCryptoImpls() {
Set<String> result = new HashSet<String>();
for (Provider provider : Security.getProviders()) {
for (Object providerKey : provider.keySet()) {
String key = providerKey.toString();
key = key.split(" ")[0];
result.add(key);
}
}
return result.toArray(new String[result.size()]);
}
代码示例来源:origin: com.puresoltechnologies.commons/os
public static String[] getCryptoImpls() {
Set<String> result = new HashSet<String>();
for (Provider provider : Security.getProviders()) {
for (Object providerKey : provider.keySet()) {
String key = providerKey.toString();
key = key.split(" ")[0];
result.add(key);
}
}
return result.toArray(new String[result.size()]);
}
代码示例来源:origin: com.puresoltechnologies.commons/misc
public static String[] getServiceTypes() {
Set<String> result = new HashSet<String>();
for (Provider provider : Security.getProviders()) {
for (Object providerKey : provider.keySet()) {
String key = providerKey.toString();
key = key.split(" ")[0];
if (key.startsWith("Alg.Alias.")) {
key = key.substring(10);
}
int ix = key.indexOf('.');
result.add(key.substring(0, ix));
}
}
return result.toArray(new String[result.size()]);
}
代码示例来源:origin: org.apache.wss4j/wss4j-ws-security-common
public Set<Object> keySet() {
Provider p = getProvider();
if (p != null) {
return p.keySet();
} else {
return Collections.emptySet();
}
}
代码示例来源:origin: com.puresoltechnologies.commons/os
public static String[] getServiceTypes() {
Set<String> result = new HashSet<String>();
for (Provider provider : Security.getProviders()) {
for (Object providerKey : provider.keySet()) {
String key = providerKey.toString();
key = key.split(" ")[0];
if (key.startsWith("Alg.Alias.")) {
key = key.substring(10);
}
int ix = key.indexOf('.');
result.add(key.substring(0, ix));
}
}
return result.toArray(new String[result.size()]);
}
代码示例来源:origin: com.puresoltechnologies.commons/misc
public static String[] getCryptoImpls(String serviceType) {
Set<String> result = new HashSet<String>();
for (Provider provider : Security.getProviders()) {
for (Object providerKey : provider.keySet()) {
String key = providerKey.toString();
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));
}
}
}
return result.toArray(new String[result.size()]);
}
代码示例来源:origin: com.puresoltechnologies.commons/os
public static String[] getCryptoImpls(String serviceType) {
Set<String> result = new HashSet<String>();
for (Provider provider : Security.getProviders()) {
for (Object providerKey : provider.keySet()) {
String key = providerKey.toString();
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));
}
}
}
return result.toArray(new String[result.size()]);
}
代码示例来源:origin: stackoverflow.com
public static void main(final String[] args) {
final Provider[] providers = Security.getProviders();
for (int i = 0; i < providers.length; i++) {
final String name = providers[i].getName();
final double version = providers[i].getVersion();
System.out.println("Provider[" + i + "]:: " + name + " " + version);
if (args.length > 0) {
final Iterator it = providers[i].keySet().iterator();
while (it.hasNext()) {
final String element = (String) it.next();
if (element.toLowerCase().startsWith(args[0].toLowerCase())
|| args[0].equals("-all"))
System.out.println("\t" + element);
}
}
}
}
代码示例来源:origin: facebook/nailgun
/**
* Provides a list of algorithms for the specified service (which, for our purposes, is
* "MessageDigest".
*
* <p>This method was only very slightly adapted (to use a TreeSet) from the Java Almanac at
* http://javaalmanac.com/egs/java.security/ListServices.html
*
* @param serviceType The name of the service we're looking for. It's "MessageDigest"
*/
private static Set getCryptoImpls(String serviceType) {
Set result = new TreeSet();
// All all providers
Provider[] providers = Security.getProviders();
for (int i = 0; i < providers.length; i++) {
// Get services provided by each provider
Set keys = providers[i].keySet();
for (Object okey : providers[i].keySet()) {
String key = (String) okey;
key = key.split(" ")[0];
if (key.startsWith(serviceType + ".")) {
result.add(key.substring(serviceType.length() + 1));
} else if (key.startsWith("Alg.Alias." + serviceType + ".")) {
// This is an alias
result.add(key.substring(serviceType.length() + 11));
}
}
}
return result;
}
代码示例来源:origin: org.sonatype.nexus/nexus-ldap-common
/**
* This method returns the available implementations for a service type
*/
public static String[] getCryptoImpls(String serviceType) {
Set<String> result = new HashSet<String>();
// All all providers
Provider[] providers = Security.getProviders();
for (int i = 0; i < providers.length; i++) {
// Get services provided by each provider
Set<Object> keys = providers[i].keySet();
for (Iterator<Object> 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 + ".")) {
// This is an alias
result.add(key.substring(serviceType.length() + 11));
}
}
}
return result.toArray(new String[result.size()]);
}
}
代码示例来源:origin: org.sonatype.nexus/nexus-ldap-common
/**
* Exploratory part. This method returns all available services types
*/
public static String[] getServiceTypes() {
Set<String> result = new HashSet<String>();
// All all providers
Provider[] providers = Security.getProviders();
for (int i = 0; i < providers.length; i++) {
// Get services provided by each provider
Set<Object> keys = providers[i].keySet();
for (Iterator<Object> it = keys.iterator(); it.hasNext(); ) {
String key = (String) it.next();
key = key.split(" ")[0];
if (key.startsWith("Alg.Alias.")) {
// Strip the alias
key = key.substring(10);
}
int ix = key.indexOf('.');
result.add(key.substring(0, ix));
}
}
return result.toArray(new String[result.size()]);
}
代码示例来源:origin: org.sonatype.nexus.plugins.ldap/ldap-common
/**
* Exploratory part. This method returns all available services types
*/
public static String[] getServiceTypes()
{
Set<String> result = new HashSet<String>();
// All all providers
Provider[] providers = Security.getProviders();
for ( int i = 0; i < providers.length; i++ )
{
// Get services provided by each provider
Set<Object> keys = providers[i].keySet();
for ( Iterator<Object> it = keys.iterator(); it.hasNext(); )
{
String key = (String) it.next();
key = key.split( " " )[0];
if ( key.startsWith( "Alg.Alias." ) )
{
// Strip the alias
key = key.substring( 10 );
}
int ix = key.indexOf( '.' );
result.add( key.substring( 0, ix ) );
}
}
return result.toArray( new String[result.size()] );
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
private static <T> Iterator<T> getFactories(Class<T> type, ClassLoader classLoader, boolean includeGlobal) {
Set<T> factories = new LinkedHashSet<>();
final ServiceLoader<T> loader = ServiceLoader.load(type, classLoader);
for (T factory : loader) {
factories.add(factory);
}
if (includeGlobal) {
Set<String> loadedClasses = new HashSet<>();
final String filter = type.getSimpleName() + ".";
Provider[] providers = Security.getProviders();
for (Provider currentProvider : providers) {
final ClassLoader cl = currentProvider.getClass().getClassLoader();
currentProvider.keySet().stream().filter(currentKey -> currentKey instanceof String && ((String)currentKey).startsWith(filter)
&& ((String)currentKey).indexOf(' ') < 0).forEach(currentKey -> {
String className=currentProvider.getProperty((String)currentKey);
if(className != null && loadedClasses.add(className)) {
try {
factories.add(Class.forName(className, true, cl).asSubclass(type).newInstance());
} catch(ClassNotFoundException | ClassCastException | InstantiationException | IllegalAccessException e) {
}
}
});
}
}
return factories.iterator();
}
代码示例来源:origin: org.infinispan/infinispan-commons
for (Provider currentProvider : providers) {
final ClassLoader cl = currentProvider.getClass().getClassLoader();
for (Object currentKey : currentProvider.keySet()) {
if (currentKey instanceof String &&
((String) currentKey).startsWith(filter) &&
代码示例来源:origin: stackoverflow.com
import java.security.Provider;
import java.security.Security;
import java.util.Arrays;
public class ShowCryptoProviders
{
private static final String EOL = System.getProperty("line.separator");
public static void main(final String[] args)
{
final Provider[] providers = Security.getProviders();
final Boolean verbose = Arrays.asList(args).contains("-v");
for (final Provider p : providers)
{
System.out.format("%s %s%s", p.getName(), p.getVersion(), EOL);
for (final Object o : p.keySet())
{
if (verbose)
{
System.out.format("\t%s : %s%s", o, p.getProperty((String)o), EOL);
}
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!