use of java.security.NoSuchProviderException in project torodb by torodb.
the class MongoClientConfigurationFactory method getMongoClientConfiguration.
public static MongoClientConfiguration getMongoClientConfiguration(AbstractReplication replication) {
HostAndPort syncSource = HostAndPort.fromString(replication.getSyncSource()).withDefaultPort(27017);
MongoClientConfiguration.Builder mongoClientConfigurationBuilder = new MongoClientConfiguration.Builder(syncSource);
Ssl ssl = replication.getSsl();
mongoClientConfigurationBuilder.setSslEnabled(ssl.getEnabled());
if (ssl.getEnabled()) {
try {
mongoClientConfigurationBuilder.setSslAllowInvalidHostnames(ssl.getAllowInvalidHostnames());
TrustManager[] tms = getTrustManagers(ssl);
KeyManager[] kms = getKeyManagers(ssl);
SSLContext sslContext;
if (ssl.getFipsMode()) {
sslContext = SSLContext.getInstance("TLS", "SunPKCS11-NSS");
} else {
sslContext = SSLContext.getInstance("TLS");
}
sslContext.init(kms, tms, null);
mongoClientConfigurationBuilder.setSocketFactory(sslContext.getSocketFactory());
} catch (CertificateException | KeyManagementException | KeyStoreException | UnrecoverableKeyException | NoSuchProviderException | NoSuchAlgorithmException | IOException exception) {
throw new SystemException(exception);
}
}
Auth auth = replication.getAuth();
if (auth.getMode().isEnabled()) {
MongoAuthenticationConfiguration mongoAuthenticationConfiguration = getMongoAuthenticationConfiguration(auth, ssl);
mongoClientConfigurationBuilder.addAuthenticationConfiguration(mongoAuthenticationConfiguration);
}
return mongoClientConfigurationBuilder.build();
}
use of java.security.NoSuchProviderException in project j2objc by google.
the class AlgorithmParametersTest method test_getInstanceLjava_lang_StringLjava_lang_String.
/**
* java.security.AlgorithmParameters#getInstance(String, String)
*/
public void test_getInstanceLjava_lang_StringLjava_lang_String() {
String[] alg = { "", "qwertyu", "!@#$%^&*()" };
String[] prv = { "", null };
String[] prv1 = { "1234567890", "qwertyu", "!@#$%^&*()" };
try {
AlgorithmParameters ap = AlgorithmParameters.getInstance("ABC", "MyProvider");
checkUnititialized(ap);
ap.init(new byte[6]);
checkAP(ap, p);
} catch (Exception e) {
fail("Unexpected exception");
}
for (int i = 0; i < alg.length; i++) {
try {
AlgorithmParameters ap = AlgorithmParameters.getInstance(alg[i], "MyProvider");
fail("NoSuchAlgorithmException was not thrown for parameter " + alg[i]);
} catch (NoSuchAlgorithmException nsae) {
//expected
} catch (Exception e) {
fail("Incorrect exception " + e + " was thrown for " + alg[i]);
}
}
for (int i = 0; i < prv.length; i++) {
try {
AlgorithmParameters ap = AlgorithmParameters.getInstance("ABC", prv[i]);
fail("IllegalArgumentException was not thrown for parameter " + prv[i]);
} catch (IllegalArgumentException iae) {
//expected
} catch (Exception e) {
fail("Incorrect exception " + e + " was thrown for " + prv[i]);
}
}
for (int i = 0; i < prv1.length; i++) {
try {
AlgorithmParameters ap = AlgorithmParameters.getInstance("ABC", prv1[i]);
fail("NoSuchProviderException was not thrown for parameter " + prv1[i]);
} catch (NoSuchProviderException nspe) {
//expected
} catch (Exception e) {
fail("Incorrect exception " + e + " was thrown for " + prv1[i]);
}
}
}
use of java.security.NoSuchProviderException in project zaproxy by zaproxy.
the class SSLContextManager method initMSCAPI.
public int initMSCAPI() throws KeyStoreException, NoSuchProviderException, IOException, NoSuchAlgorithmException, CertificateException {
try {
if (!isProviderAvailable("msks")) {
return -1;
}
Provider mscapi = (Provider) Class.forName("se.assembla.jce.provider.ms.MSProvider").newInstance();
Security.addProvider(mscapi);
// init the key store
KeyStore ks = KeyStore.getInstance("msks", "assembla");
ks.load(null, null);
return addKeyStore(ks, "Microsoft CAPI Store", null);
} catch (Exception e) {
log.error("Error instantiating the MSCAPI provider: " + e.getMessage(), e);
return -1;
}
}
use of java.security.NoSuchProviderException in project XobotOS by xamarin.
the class JDKKeyStore method decodeCertificate.
private Certificate decodeCertificate(DataInputStream dIn) throws IOException {
String type = dIn.readUTF();
byte[] cEnc = new byte[dIn.readInt()];
dIn.readFully(cEnc);
try {
CertificateFactory cFact = CertificateFactory.getInstance(type, BouncyCastleProvider.PROVIDER_NAME);
ByteArrayInputStream bIn = new ByteArrayInputStream(cEnc);
return cFact.generateCertificate(bIn);
} catch (NoSuchProviderException ex) {
throw new IOException(ex.toString());
} catch (CertificateException ex) {
throw new IOException(ex.toString());
}
}
use of java.security.NoSuchProviderException in project zaproxy by zaproxy.
the class RelaxedX509TrustManager method getTunnelSSLSocketFactory.
// ZAP: added new ServerSocketFaktory with support of dynamic SSL certificates
public SSLSocketFactory getTunnelSSLSocketFactory(String hostname) {
// KeyStore ks;
try {
SSLContext ctx = SSLContext.getInstance(SSL);
// Normally "SunX509", "IbmX509"...
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
SslCertificateService scs = CachedSslCertifificateServiceImpl.getService();
KeyStore ks = scs.createCertForHost(hostname);
kmf.init(ks, SslCertificateService.PASSPHRASE);
java.security.SecureRandom x = new java.security.SecureRandom();
x.setSeed(System.currentTimeMillis());
ctx.init(kmf.getKeyManagers(), null, x);
SSLSocketFactory tunnelSSLFactory = createDecoratedServerSslSocketFactory(ctx.getSocketFactory());
return tunnelSSLFactory;
} catch (NoSuchAlgorithmException | KeyStoreException | CertificateException | UnrecoverableKeyException | KeyManagementException | InvalidKeyException | NoSuchProviderException | SignatureException | IOException e) {
// friendly way?
throw new RuntimeException(e);
}
}
Aggregations