java.security.Security.insertProviderAt()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(528)

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

Security.insertProviderAt介绍

[英]Insert the given Provider at the specified position. The positions define the preference order in which providers are searched for requested algorithms.
[中]在指定位置插入给定的提供程序。这些位置定义了在提供者中搜索请求算法的优先顺序。

代码示例

代码示例来源:origin: looly/hutool

/**
 * 增加加密解密的算法提供者,默认优先使用,例如:
 * 
 * <pre>
 * addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
 * </pre>
 * 
 * @param provider 算法提供者
 * @since 4.1.22
 */
public static void addProvider(Provider provider) {
  Security.insertProviderAt(provider, 0);
}

代码示例来源:origin: looly/hutool

/**
 * 增加加密解密的算法提供者,默认优先使用,例如:
 * 
 * <pre>
 * addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
 * </pre>
 * 
 * @param provider 算法提供者
 * @since 4.1.22
 */
public static void addProvider(Provider provider) {
  Security.insertProviderAt(provider, 0);
}

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

/**
 * Adds the given {@code provider} to the collection of providers at the
 * next available position.
 *
 * @param provider
 *            the provider to be added.
 * @return the actual position or {@code -1} if the given {@code provider}
 *         was already in the list.
 */
public static int addProvider(Provider provider) {
  return insertProviderAt(provider, 0);
}

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

static {
  Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1);
}

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

public static void useBouncyCastle() {
    Security.insertProviderAt(new BouncyCastleProvider(), 1);
  }
}

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

public static void main(String[] args) {
 //System.setProperty("javax.net.debug", "ssl:handshake:verbose");
 Security.insertProviderAt(Conscrypt.newProviderBuilder().provideTrustManager().build(), 1);
 System.out.println(
   "Running tests using " + Platform.get() + " " + System.getProperty("java.vm.version"));
 // https://github.com/tlswg/tls13-spec/wiki/Implementations
 List<String> urls =
   Arrays.asList("https://enabled.tls13.com", "https://www.howsmyssl.com/a/check",
     "https://tls13.cloudflare.com", "https://www.allizom.org/robots.txt",
     "https://tls13.crypto.mozilla.org/", "https://tls.ctf.network/robots.txt",
     "https://rustls.jbp.io/", "https://h2o.examp1e.net", "https://mew.org/",
     "https://tls13.baishancloud.com/", "https://tls13.akamai.io/", "https://swifttls.org/",
     "https://www.googleapis.com/robots.txt", "https://graph.facebook.com/robots.txt",
     "https://api.twitter.com/robots.txt", "https://connect.squareup.com/robots.txt");
 System.out.println("TLS1.3+TLS1.2");
 testClient(urls, buildClient(ConnectionSpec.RESTRICTED_TLS));
 System.out.println("\nTLS1.3 only");
 testClient(urls, buildClient(TLS_13));
 System.out.println("\nTLS1.3 then fallback");
 testClient(urls, buildClient(TLS_13, TLS_12));
}

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

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

public class WindowsSecureRandom extends Provider {
  private static final String MSCAPI = "sun.security.mscapi.PRNG";

  private WindowsSecureRandom() {
    super("WindowsSecureRandom Provider", 1.0, null);
    putService(new Service(this, "SecureRandom", "Windows-PRNG", MSCAPI, null, null));
  }

  public static void register() {
    if (System.getProperty("os.name").contains("Windows")) {
      try {
        Class.forName(MSCAPI);
        Security.insertProviderAt(new WindowsSecureRandom(), 1);
      } catch (ClassNotFoundException e) {
        // Fallback to default implementation
      }
    }
  }
}

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

@BeforeClass
public static void setUp() throws Exception {
  //Set BC as the preferred bcProvider
  Security.insertProviderAt(bcProvider, 1);
}

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

Security.insertProviderAt(new BouncyCastleProvider(), 1);

代码示例来源:origin: AsamK/signal-cli

public static void main(String[] args) {
  // Register our own security provider
  Security.insertProviderAt(new SecurityProvider(), 1);
  Security.addProvider(new BouncyCastleProvider());
  Namespace ns = parseArgs(args);
  if (ns == null) {
    System.exit(1);
  }
  int res = handleCommands(ns);
  System.exit(res);
}

代码示例来源:origin: i2p/i2p.i2p

/**
   *  Install the I2PProvider.
   *  Harmless to call multiple times.
   *  @since 0.9.25
   */
  public static void addProvider() {
    synchronized(I2PProvider.class) {
      if (!_installed) {
        try {
          Provider us = new I2PProvider();
          // put ours ahead of BC, if installed, because our ElGamal
          // implementation may not be fully compatible with BC
          Provider[] provs = Security.getProviders();
          for (int i = 0; i < provs.length; i++) {
            if (provs[i].getName().equals("BC")) {
              Security.insertProviderAt(us, i);
              _installed = true;
              return;
            }
          }
          Security.addProvider(us);
          _installed = true;
        } catch (SecurityException se) {
          System.out.println("WARN: Could not install I2P provider: " + se);
        }
      }
    }
  }
}

代码示例来源:origin: syncthing/syncthing-android

|| (!LinuxPRNGSecureRandomProvider.class.equals(
  secureRandomProviders[0].getClass()))) {
Security.insertProviderAt(new LinuxPRNGSecureRandomProvider(), 1);

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

Security.insertProviderAt(new BouncyCastleProvider(), 1);

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

/**
 * Adds the given {@code provider} to the collection of providers at the
 * next available position.
 *
 * @param provider
 *            the provider to be added.
 * @return the actual position or {@code -1} if the given {@code provider}
 *         was already in the list.
 */
public static int addProvider(Provider provider) {
  return insertProviderAt(provider, 0);
}

代码示例来源:origin: org.wildfly.openssl/wildfly-openssl

public static synchronized void registerFirst() {
    if (!registered) {
      registered = true;
      Security.insertProviderAt(INSTANCE, 1);
    }
  }
}

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

/**
 * Adds the given {@code provider} to the collection of providers at the
 * next available position.
 *
 * @param provider
 *            the provider to be added.
 * @return the actual position or {@code -1} if the given {@code provider}
 *         was already in the list.
 */
public static int addProvider(Provider provider) {
  return insertProviderAt(provider, 0);
}

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

/**
 * Adds the given {@code provider} to the collection of providers at the
 * next available position.
 *
 * @param provider
 *            the provider to be added.
 * @return the actual position or {@code -1} if the given {@code provider}
 *         was already in the list.
 */
public static int addProvider(Provider provider) {
  return insertProviderAt(provider, 0);
}

代码示例来源:origin: org.wildfly.openssl/wildfly-openssl-java

public static synchronized void registerFirst() {
    if (!registered) {
      registered = true;
      Security.insertProviderAt(INSTANCE, 1);
    }
  }
}

代码示例来源:origin: io.cloudslang.content/score-ssh

protected boolean addSecurityProvider() {
  boolean providerAdded = false;
  Provider provider = Security.getProvider("BC");
  if (provider == null) {
    providerAdded = true;
    Security.insertProviderAt(new BouncyCastleProvider(), 2);
  }
  return providerAdded;
}

代码示例来源:origin: org.robolectric/robolectric

Security.insertProviderAt(new BouncyCastleProvider(), 1);

相关文章