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

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

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

Provider.getName介绍

[英]Returns the name of this provider.
[中]返回此提供程序的名称。

代码示例

代码示例来源:origin: square/okhttp

public static boolean isConscryptPreferred() {
 // mainly to allow tests to run cleanly
 if ("conscrypt".equals(Util.getSystemProperty("okhttp.platform", null))) {
  return true;
 }
 // check if Provider manually installed
 String preferredProvider = Security.getProviders()[0].getName();
 return "Conscrypt".equals(preferredProvider);
}

代码示例来源:origin: apache/geode

private static boolean usesIBMProviders() {
 final Provider[] providers = Security.getProviders();
 for (int index = 0; index < providers.length; ++index) {
  if (!providers[index].getName().toLowerCase().startsWith("ibm")) {
   return false;
  }
 }
 return true;
}

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

/**
   * Returns a string containing a concise, human-readable description of
   * this {@code Service}.
   *
   * @return a printable representation for this {@code Service}.
   */
  @Override
  public String toString() {
    String result = "Provider " + provider.getName() + " Service "
        + type + "." + algorithm + " " + className;
    if (aliases != null) {
      result = result + "\nAliases " + aliases.toString();
    }
    if (attributes != null) {
      result = result + "\nAttributes " + attributes.toString();
    }
    return result;
  }
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

public static boolean isConscryptPreferred() {
 // mainly to allow tests to run cleanly
 if ("conscrypt".equals(Util.getSystemProperty("okhttp.platform", null))) {
  return true;
 }
 // check if Provider manually installed
 String preferredProvider = Security.getProviders()[0].getName();
 return "Conscrypt".equals(preferredProvider);
}

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

/**
 * Removes the provider at the specified 1-based position.
 */
public static synchronized void removeProvider(int providerNumber) {
  Provider p = providers.remove(providerNumber - 1);
  providersNames.remove(p.getName());
  setNeedRefresh();
}

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

SecureRandom rand = SecureRandom.getInstance("SHA1PRNG");
Log.i(TAG, "rand.getProvider(): " + rand.getProvider().getName());

代码示例来源:origin: pentaho/pentaho-kettle

public String getCipherProviderName() {
 return this.cipher.getProvider().getName();
}

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

/**
 * Inserts a provider at a specified 1-based position.
 */
public static synchronized int insertProviderAt(Provider provider, int position) {
  int size = providers.size();
  if ((position < 1) || (position > size)) {
    position = size + 1;
  }
  providers.add(position - 1, provider);
  providersNames.put(provider.getName(), provider);
  setNeedRefresh();
  return position;
}

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

import java.security.Provider;
import java.security.Security;

public class SecurityListings {
  public static void main(String[] args) {
    for (Provider provider : Security.getProviders()) {
      System.out.println("Provider: " + provider.getName());
      for (Provider.Service service : provider.getServices()) {
        System.out.println("  Algorithm: " + service.getAlgorithm());
      }
    }

  }
}

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

Provider[] providers = Security.getProviders();
for (Provider provider : providers) {
  Log.i("CRYPTO","provider: "+provider.getName());
  Set<Provider.Service> services = provider.getServices();
  for (Provider.Service service : services) {
    Log.i("CRYPTO","  algorithm: "+service.getAlgorithm());
  }
}

代码示例来源:origin: Javen205/IJPay

/**
 * 打jre中印算法提供者列表
 */
private static void printProviders() {
  LogUtil.writeLog("Providers List:");
  Provider[] providers = Security.getProviders();
  for (int i = 0; i < providers.length; i++) {
    LogUtil.writeLog(i + 1 + "." + providers[i].getName());
  }
}

代码示例来源:origin: ethereum/ethereumj

/**
 * Generate a new keypair using the given Java Security Provider.
 *
 * All private key operations will use the provider.
 */
public ECKey(Provider provider, SecureRandom secureRandom) {
  this.provider = provider;
  final KeyPairGenerator keyPairGen = ECKeyPairGenerator.getInstance(provider, secureRandom);
  final KeyPair keyPair = keyPairGen.generateKeyPair();
  this.privKey = keyPair.getPrivate();
  final PublicKey pubKey = keyPair.getPublic();
  if (pubKey instanceof BCECPublicKey) {
    pub = ((BCECPublicKey) pubKey).getQ();
  } else if (pubKey instanceof ECPublicKey) {
    pub = extractPublicKey((ECPublicKey) pubKey);
  } else {
    throw new AssertionError(
      "Expected Provider " + provider.getName() +
      " to produce a subtype of ECPublicKey, found " + pubKey.getClass());
  }
}

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

/**
 * Insert the given {@code Provider} at the specified {@code position}. The
 * positions define the preference order in which providers are searched for
 * requested algorithms.
 *
 * @param provider
 *            the provider to insert.
 * @param position
 *            the position (starting from 1).
 * @return the actual position or {@code -1} if the given {@code provider}
 *         was already in the list. The actual position may be different
 *         from the desired position.
 */
public static synchronized int insertProviderAt(Provider provider, int position) {
  // check that provider is not already
  // installed, else return -1; if (position <1) or (position > max
  // position) position = max position + 1; insert provider, shift up
  // one position for next providers; Note: The position is 1-based
  if (getProvider(provider.getName()) != null) {
    return -1;
  }
  int result = Services.insertProviderAt(provider, position);
  renumProviders();
  return result;
}

代码示例来源:origin: aws/aws-sdk-java

if (keyWrapAlgo == null) {
  Provider provider = generator.getProvider();
  String providerName = provider == null ? null : provider.getName();
  involvesBCPublicKey = CryptoRuntime.BOUNCY_CASTLE_PROVIDER.equals(providerName);

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

/**
 * Find a provider service which provides the given service type and algorithm name.
 *
 * If a providerName is specified the match will only be tested against providers with the name specified.
 *
 * @param providerSupplier the provider supplier (must not be {@code null})
 * @param providerName the name of the provider, can be {@code null}
 * @param serviceType the service type (must not be {@code null})
 * @param algorithm the algorithm name (must not be {@code null})
 * @return the provider service, or {@code null} if none is found
 */
public static Provider.Service findProviderService(Supplier<Provider[]> providerSupplier, String providerName, String serviceType, String algorithm) {
  Assert.checkNotNullParam("providerSupplier", providerSupplier);
  Assert.checkNotNullParam("serviceType", serviceType);
  Assert.checkNotNullParam("algorithm", algorithm);
  for (Provider provider : providerSupplier.get()) {
    if (providerName == null || providerName.equals(provider.getName())) {
      Provider.Service providerService = provider.getService(serviceType, algorithm);
      if (providerService != null) {
        return providerService;
      }
    }
  }
  return null;
}

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

private void testBouncyCastleProvider() throws IOException {
  Properties properties = new Properties();
  // Use bouncy castle as first choice of JCE provider.
  properties.setProperty("use.bouncycastle.for.ssl", "true");
  server = getVoldemortServer(properties);
  assertEquals(BouncyCastleProvider.PROVIDER_NAME, Security.getProviders()[0].getName());
}

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

@Test
public void ensureBouncyCastleInstalled() throws CertificateException {
 CertificateFactory factory = CertificateFactory.getInstance("X.509");
 assertThat(factory.getProvider().getName()).isEqualTo(BouncyCastleProvider.PROVIDER_NAME);
}

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

/**
 * Get a {@code CredentialStore} instance.  The returned CredentialStore object will implement the given algorithm.
 *
 * @param algorithm the name of the algorithm
 * @param providerName the name of the provider to use
 * @param providers supplier of provider instances to search
 * @return a {@code CredentialStore} instance
 * @throws NoSuchAlgorithmException if the given algorithm has no available implementations
 * @throws NoSuchProviderException if given provider name cannot match any registered {@link Provider}
 */
public static CredentialStore getInstance(String algorithm, String providerName, Supplier<Provider[]> providers) throws NoSuchAlgorithmException, NoSuchProviderException {
  checkNotNullParam("algorithm", algorithm);
  checkNotNullParam("providerName", providerName);
  checkNotNullParam("providers", providers);
  Provider provider = null;
  for (Provider current : providers.get()) {
    if (providerName.equals(current.getName())) {
      provider = current;
      break;
    }
  }
  if (provider == null) throw new NoSuchProviderException(providerName);
  return getInstance(algorithm, provider);
}

代码示例来源:origin: auth0/java-jwt

@AfterClass
public static void tearDown() throws Exception {
  Security.removeProvider(bcProvider.getName());
}

相关文章