java.security.Provider.getProperty()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中java.security.Provider.getProperty()方法的一些代码示例,展示了Provider.getProperty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Provider.getProperty()方法的具体详情如下:
包路径:java.security.Provider
类名称:Provider
方法名:getProperty

Provider.getProperty介绍

[英]Returns the property with the specified key in the provider properties. The name is not case-sensitive.
[中]返回具有提供程序属性中指定键的属性。名称不区分大小写。

代码示例

代码示例来源:origin: robovm/robovm

/**
 * Returns the property with the specified key in the provider properties.
 * The name is not case-sensitive.
 */
private String getPropertyIgnoreCase(String key) {
  String res = getProperty(key);
  if (res != null) {
    return res;
  }
  for (Enumeration<?> e = propertyNames(); e.hasMoreElements(); ) {
    String propertyName = (String) e.nextElement();
    if (key.equalsIgnoreCase(propertyName)) {
      return getProperty(propertyName);
    }
  }
  return null;
}

代码示例来源: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: robovm/robovm

/**
 * Returns value for the specified algorithm with the specified name.
 *
 * @param algName
 *            the name of the algorithm.
 * @param propName
 *            the name of the property.
 * @return value of the property.
 * @deprecated Use {@link AlgorithmParameters} and {@link KeyFactory} instead.
 */
@Deprecated
public static String getAlgorithmProperty(String algName, String propName) {
  if (algName == null || propName == null) {
    return null;
  }
  String prop = "Alg." + propName + "." + algName;
  Provider[] providers = getProviders();
  for (Provider provider : providers) {
    for (Enumeration e = provider.propertyNames(); e.hasMoreElements(); ) {
      String propertyName = (String) e.nextElement();
      if (propertyName.equalsIgnoreCase(prop)) {
        return provider.getProperty(propertyName);
      }
    }
  }
  return null;
}

代码示例来源:origin: wildfly/wildfly

((String) currentKey).startsWith(filter) &&
  ((String) currentKey).indexOf(' ') < 0) {
String className = currentProvider.getProperty((String) currentKey);
if (className != null && loadedClasses.add(className)) {
  try {

代码示例来源:origin: syncany/syncany

@Test 
  public void listCryptoSettingsAvailable() {
    logger.log(Level.INFO, "Listing security providers and properties:");
    
    for (Provider provider: Security.getProviders()) {
      logger.log(Level.INFO, "- Provider '"+provider.getName()+"' ");
      
      List<String> propertyNames = new ArrayList<String>();
      propertyNames.addAll(provider.stringPropertyNames());
      
      Collections.sort(propertyNames);
      
      for (String key : propertyNames) {
        logger.log(Level.INFO, "   "+provider.getName()+" / "+key+" = "+provider.getProperty(key));
      }
    }
  }        
}

代码示例来源:origin: stackoverflow.com

import java.security.*;

for (Provider provider: Security.getProviders()) {
 System.out.println(provider.getName());
 for (String key: provider.stringPropertyNames())
  System.out.println("\t" + key + "\t" + provider.getProperty(key));
}

代码示例来源:origin: stackoverflow.com

for (Provider provider: Security.getProviders()) {
 System.out.println(provider.getName());
 for (String key: provider.stringPropertyNames())
  System.out.println("\t" + key + "\t" + provider.getProperty(key));
}

代码示例来源:origin: ibinti/bugvm

/**
 * Returns the property with the specified key in the provider properties.
 * The name is not case-sensitive.
 */
private String getPropertyIgnoreCase(String key) {
  String res = getProperty(key);
  if (res != null) {
    return res;
  }
  for (Enumeration<?> e = propertyNames(); e.hasMoreElements(); ) {
    String propertyName = (String) e.nextElement();
    if (key.equalsIgnoreCase(propertyName)) {
      return getProperty(propertyName);
    }
  }
  return null;
}

代码示例来源:origin: MobiVM/robovm

/**
 * Returns the property with the specified key in the provider properties.
 * The name is not case-sensitive.
 */
private String getPropertyIgnoreCase(String key) {
  String res = getProperty(key);
  if (res != null) {
    return res;
  }
  for (Enumeration<?> e = propertyNames(); e.hasMoreElements(); ) {
    String propertyName = (String) e.nextElement();
    if (key.equalsIgnoreCase(propertyName)) {
      return getProperty(propertyName);
    }
  }
  return null;
}

代码示例来源:origin: org.apache.wss4j/wss4j-ws-security-common

public String getProperty(String key) {
  Provider p = getProvider();
  if (p != null) {
    return p.getProperty(key);
  } else {
    return null;
  }
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * Returns the property with the specified key in the provider properties.
 * The name is not case-sensitive.
 */
private String getPropertyIgnoreCase(String key) {
  String res = getProperty(key);
  if (res != null) {
    return res;
  }
  for (Enumeration<?> e = propertyNames(); e.hasMoreElements(); ) {
    String propertyName = (String) e.nextElement();
    if (key.equalsIgnoreCase(propertyName)) {
      return getProperty(propertyName);
    }
  }
  return null;
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * Returns the property with the specified key in the provider properties.
 * The name is not case-sensitive.
 */
private String getPropertyIgnoreCase(String key) {
  String res = getProperty(key);
  if (res != null) {
    return res;
  }
  for (Enumeration<?> e = propertyNames(); e.hasMoreElements(); ) {
    String propertyName = (String) e.nextElement();
    if (key.equalsIgnoreCase(propertyName)) {
      return getProperty(propertyName);
    }
  }
  return null;
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Returns the property with the specified key in the provider properties.
 * The name is not case-sensitive.
 */
private String getPropertyIgnoreCase(String key) {
  String res = getProperty(key);
  if (res != null) {
    return res;
  }
  for (Enumeration<?> e = propertyNames(); e.hasMoreElements(); ) {
    String propertyName = (String) e.nextElement();
    if (key.equalsIgnoreCase(propertyName)) {
      return getProperty(propertyName);
    }
  }
  return null;
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * Returns the property with the specified key in the provider properties.
 * The name is not case-sensitive.
 */
private String getPropertyIgnoreCase(String key) {
  String res = getProperty(key);
  if (res != null) {
    return res;
  }
  for (Enumeration<?> e = propertyNames(); e.hasMoreElements(); ) {
    String propertyName = (String) e.nextElement();
    if (key.equalsIgnoreCase(propertyName)) {
      return getProperty(propertyName);
    }
  }
  return null;
}

代码示例来源:origin: kaikramer/keystore-explorer

private String getAlgorithmClass(String algorithm, String serviceType, Provider provider) {
  /*
   * Looking for the property name that matches
   * "<service type>.<algorithm>". The value of the property is the class
   * name
   */
  String match = serviceType + "." + algorithm;
  for (Enumeration<?> names = provider.propertyNames(); names.hasMoreElements();) {
    String key = (String) names.nextElement();
    if (key.equals(match)) {
      return provider.getProperty(key);
    }
  }
  return null;
}

代码示例来源:origin: kaikramer/keystore-explorer

private String[] getAlgorithmAliases(String algorithm, String serviceType, Provider provider) {
  /*
   * Looking to match property names with key "Alg.Alias.<service type>."
   * and value of algorithm. The alias is the text following the '.' in
   * the property name. Return in alpha order
   */
  String matchAlias = "Alg.Alias." + serviceType + ".";
  ArrayList<String> aliasList = new ArrayList<String>();
  for (Enumeration<?> names = provider.propertyNames(); names.hasMoreElements();) {
    String key = (String) names.nextElement();
    if (provider.getProperty(key).equals(algorithm)) {
      if (key.startsWith(matchAlias)) {
        String alias = key.substring(matchAlias.length());
        aliasList.add(alias);
      }
    }
  }
  String[] aliases = aliasList.toArray(new String[aliasList.size()]);
  Arrays.sort(aliases);
  return aliases;
}

代码示例来源: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);
        }
      }
    }
  }
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-util

public String getSigAlgName()
{
  Provider[] provs = Security.getProviders();
  //
  // search every provider looking for a real algorithm
  //
  for (int i = 0; i != provs.length; i++)
  {
    String algName = provs[i].getProperty("Alg.Alias.Signature." + this.getSigAlgOID());
    if ( algName != null )
    {
      return algName;
    }
  }
  return this.getSigAlgOID();
}

代码示例来源:origin: org.apache.geronimo.framework/geronimo-crypto

public String getSigAlgName()
{
  Provider[] provs = Security.getProviders();
  //
  // search every provider looking for a real algorithm
  //
  for (int i = 0; i != provs.length; i++)
  {
    String algName = provs[i].getProperty("Alg.Alias.Signature." + this.getSigAlgOID());
    if ( algName != null )
    {
      return algName;
    }
  }
  return this.getSigAlgOID();
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-util

/**
 * return a more "meaningful" representation for the signature algorithm used in
 * the certficate.
 */
public String getSigAlgName()
{
  Provider[] provs = Security.getProviders();
  //
  // search every provider looking for a real algorithm
  //
  for (int i = 0; i != provs.length; i++)
  {
    String algName = provs[i].getProperty("Alg.Alias.Signature." + this.getSigAlgOID());
    if (algName != null)
    {
      return algName;
    }
  }
  return this.getSigAlgOID();
}

相关文章