本文整理了Java中java.security.Security.addProvider()
方法的一些代码示例,展示了Security.addProvider()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Security.addProvider()
方法的具体详情如下:
包路径:java.security.Security
类名称:Security
方法名:addProvider
[英]Adds the given provider to the collection of providers at the next available position.
[中]将给定的提供程序添加到下一个可用位置的提供程序集合中。
代码示例来源:origin: floragunncom/search-guard
@Override
public Object run() {
if(Security.getProvider("BC") == null) {
Security.addProvider(new BouncyCastleProvider());
}
return null;
}
});
代码示例来源:origin: igniterealtime/Openfire
/** Installs the required security provider(s) */
private synchronized void initialize()
{
if (!isInitialized)
{
try
{
Security.addProvider(new BouncyCastleProvider());
isInitialized = true;
}
catch (Throwable t)
{
log.warn("JCE provider failure; unable to load BC", t);
}
}
}
代码示例来源:origin: gocd/gocd
public X509CertificateGenerator() {
Security.addProvider(new BouncyCastleProvider());
this.keyStoreManager = new KeyStoreManager();
}
代码示例来源:origin: stackoverflow.com
Security.addProvider(new BouncyCastleProvider());
String data = "hello world";
MessageDigest mda = MessageDigest.getInstance("SHA-512", "BC");
byte [] digesta = mda.digest(data.getBytes());
MessageDigest mdb = MessageDigest.getInstance("SHA-512", "BC");
byte [] digestb = mdb.digest(data.getBytes());
System.out.println(MessageDigest.isEqual(digesta, digestb));
System.out.println(Hex.encodeHex(digesta));
代码示例来源:origin: apache/nifi
/**
* Initializes the encryptor with a {@link KeyProvider}.
*
* @param keyProvider the key provider which will be responsible for accessing keys
* @throws KeyManagementException if there is an issue configuring the key provider
*/
@Override
public void initialize(KeyProvider keyProvider) throws KeyManagementException {
this.keyProvider = keyProvider;
if (this.aesKeyedCipherProvider == null) {
this.aesKeyedCipherProvider = new AESKeyedCipherProvider();
}
if (Security.getProvider("BC") == null) {
Security.addProvider(new BouncyCastleProvider());
}
}
代码示例来源:origin: testcontainers/testcontainers-java
@Override
public EventLoopGroup init(Bootstrap bootstrap, final DockerClientConfig dockerClientConfig) {
EventLoopGroup nioEventLoopGroup = new NioEventLoopGroup(0, createThreadFactory());
// TODO do we really need BouncyCastle?
Security.addProvider(new BouncyCastleProvider());
ChannelFactory<NioSocketChannel> factory = () -> configure(new NioSocketChannel());
bootstrap.group(nioEventLoopGroup).channelFactory(factory)
.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(final SocketChannel channel) throws Exception {
channel.pipeline().addLast(new HttpClientCodec());
channel.pipeline().addLast(new HttpContentDecompressor());
}
});
return nioEventLoopGroup;
}
代码示例来源:origin: Javen205/IJPay
/**
* 添加签名,验签,加密算法提供者
*/
private static void addProvider(){
if (Security.getProvider("BC") == null) {
LogUtil.writeLog("add BC provider");
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
} else {
Security.removeProvider("BC"); //解决eclipse调试时tomcat自动重新加载时,BC存在不明原因异常的问题。
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
LogUtil.writeLog("re-add BC provider");
}
printSysInfo();
}
代码示例来源:origin: docker-java/docker-java
@Override
public EventLoopGroup init(Bootstrap bootstrap, final DockerClientConfig dockerClientConfig) {
EventLoopGroup nioEventLoopGroup = new NioEventLoopGroup(0, new DefaultThreadFactory(threadPrefix));
InetAddress addr = InetAddress.getLoopbackAddress();
final SocketAddress proxyAddress = new InetSocketAddress(addr, 8008);
Security.addProvider(new BouncyCastleProvider());
ChannelFactory<NioSocketChannel> factory = new ChannelFactory<NioSocketChannel>() {
@Override
public NioSocketChannel newChannel() {
return configure(new NioSocketChannel());
}
};
bootstrap.group(nioEventLoopGroup).channelFactory(factory)
.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(final SocketChannel channel) throws Exception {
// channel.pipeline().addLast(new
// HttpProxyHandler(proxyAddress));
channel.pipeline().addLast(new HttpClientCodec());
channel.pipeline().addLast(new HttpContentDecompressor());
}
});
return nioEventLoopGroup;
}
代码示例来源:origin: docker-java/docker-java
@Override
public SSLContext getSSLContext() {
boolean certificatesExist = CertificateUtils.verifyCertificatesExist(dockerCertPath);
if (certificatesExist) {
try {
Security.addProvider(new BouncyCastleProvider());
String caPemPath = dockerCertPath + File.separator + "ca.pem";
String keyPemPath = dockerCertPath + File.separator + "key.pem";
String certPemPath = dockerCertPath + File.separator + "cert.pem";
String keypem = new String(Files.readAllBytes(Paths.get(keyPemPath)));
String certpem = new String(Files.readAllBytes(Paths.get(certPemPath)));
String capem = new String(Files.readAllBytes(Paths.get(caPemPath)));
String kmfAlgorithm = AccessController.doPrivileged(getSystemProperty("ssl.keyManagerFactory.algorithm",
KeyManagerFactory.getDefaultAlgorithm()));
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(kmfAlgorithm);
keyManagerFactory.init(CertificateUtils.createKeyStore(keypem, certpem), "docker".toCharArray());
String tmfAlgorithm = AccessController.doPrivileged(getSystemProperty("ssl.trustManagerFactory.algorithm",
TrustManagerFactory.getDefaultAlgorithm()));
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(tmfAlgorithm);
trustManagerFactory.init(CertificateUtils.createTrustStore(capem));
SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null);
return sslContext;
} catch (Exception e) {
throw new DockerClientException(e.getMessage(), e);
}
}
return null;
}
代码示例来源:origin: Pay-Group/best-pay-sdk
Security.addProvider(new BouncyCastleProvider());
SecretKeySpec aesKey = new SecretKeySpec(DigestUtils.md5Hex(key).toLowerCase().getBytes(), ALGORITHM);
Cipher cipher = null;
代码示例来源:origin: apache/zookeeper
@BeforeClass
public static void createKeyPair() throws Exception {
Security.addProvider(new BouncyCastleProvider());
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA", BouncyCastleProvider.PROVIDER_NAME);
keyPairGenerator.initialize(4096);
keyPair = keyPairGenerator.genKeyPair();
}
代码示例来源:origin: apache/zookeeper
@BeforeClass
public static void setUpBaseClass() throws Exception {
Security.addProvider(new BouncyCastleProvider());
cachedTestContexts = new HashMap<>();
tempDir = ClientBase.createEmptyTestDir();
}
代码示例来源:origin: Graylog2/graylog2-server
public static void main(String[] args) {
final CliBuilder<CliCommand> builder = Cli.<CliCommand>builder("graylog")
.withDescription("Open source, centralized log management")
.withDefaultCommand(CliCommandHelp.class)
.withCommands(ImmutableSet.of(
ShowVersion.class,
CliCommandHelp.class));
// add rest from classpath
final ServiceLoader<CliCommandsProvider> commandsProviders = ServiceLoader.load(CliCommandsProvider.class);
for (CliCommandsProvider provider : commandsProviders) {
provider.addTopLevelCommandsOrGroups(builder);
}
final Cli<CliCommand> cli = builder.build();
final Runnable command = cli.parse(args);
// Explicitly register Bouncy Castle as security provider.
// This allows us to use more key formats than with JCE
Security.addProvider(new BouncyCastleProvider());
command.run();
}
}
代码示例来源:origin: cloudfoundry/uaa
@BeforeClass
public static void addBCProvider() throws Exception {
try {
Security.addProvider(new BouncyCastleProvider());
} catch (SecurityException e) {
e.printStackTrace();
System.err.println("Ignoring provider error, may already be added.");
}
}
代码示例来源:origin: stackoverflow.com
Security.addProvider(new BouncyCastleProvider());
代码示例来源:origin: apache/nifi
@BeforeClass
public static void setUpOnce() throws Exception {
Security.addProvider(new BouncyCastleProvider());
}
代码示例来源:origin: apache/nifi
@BeforeClass
public static void setUpOnce() throws Exception {
Security.addProvider(new BouncyCastleProvider());
}
代码示例来源:origin: cloudfoundry/uaa
@BeforeClass
public static void addBCProvider() throws Exception {
try {
Security.addProvider(new BouncyCastleProvider());
} catch (SecurityException e) {
e.printStackTrace();
System.err.println("Ignoring provider error, may already be added.");
}
}
代码示例来源:origin: apache/nifi
@Before
public void setUp() {
Security.addProvider(new BouncyCastleProvider());
}
代码示例来源:origin: cloudfoundry/uaa
@BeforeClass
public static void addProvider() throws Exception {
Security.addProvider(new BouncyCastleProvider());
}
内容来源于网络,如有侵权,请联系作者删除!