/** * @throws KeyManagementException * @tests javax.net.ssl.SSLContext#createSSLEngine() */ @TestTargetNew( level = TestLevel.SUFFICIENT, notes = "UnsupportedOperationException checking missed", method = "createSSLEngine", args = {} ) public void test_createSSLEngine() throws KeyManagementException { if (!DEFSupported) fail(NotSupportMsg); SSLContextSpi spi = new MySSLContextSpi(); SSLContext sslContext = new MySslContext(spi, defaultProvider, defaultProtocol); sslContext.init(null, null, new SecureRandom()); SSLEngine sslEngine = sslContext.createSSLEngine(); assertNotNull("SSL engine is null", sslEngine); }
/** * @throws KeyManagementException * @tests javax.net.ssl.SSLContext#createSSLEngine(java.lang.String, int) */ @TestTargetNew( level = TestLevel.SUFFICIENT, notes = "UnsupportedOperationException checking missed", method = "createSSLEngine", args = {java.lang.String.class, int.class} ) public void test_createSSLEngineLjava_lang_StringI() throws KeyManagementException { if (!DEFSupported) fail(NotSupportMsg); SSLContextSpi spi = new MySSLContextSpi(); SSLContext sslContext = new MySslContext(spi, defaultProvider, defaultProtocol); sslContext.init(null, null, new SecureRandom()); SSLEngine sslEngine = sslContext.createSSLEngine("www.fortify.net", 80); assertNotNull("SSL engine is null", sslEngine); }
/** * @throws NoSuchAlgorithmException * @throws NoSuchProviderException * @tests javax.net.ssl.SSLContext#getProvider() */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "getProvider", args = {} ) public void test_getProvider() throws NoSuchAlgorithmException, NoSuchProviderException { if (!DEFSupported) fail(NotSupportMsg); SSLContextSpi spi = new MySSLContextSpi(); SSLContext sslContext = new MySslContext(spi, defaultProvider, defaultProtocol); assertEquals("Incorrect provider", defaultProvider, sslContext.getProvider()); sslContext = SSLContext.getInstance(defaultProtocol, defaultProvider); assertEquals("Incorrect provider", defaultProvider, sslContext.getProvider()); sslContext = SSLContext.getInstance(defaultProtocol, defaultProviderName); assertEquals("Incorrect provider", defaultProvider, sslContext.getProvider()); }
/** * @tests javax.net.ssl.SSLContextSpi#SSLContextSpi() */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "SSLContextSpi", args = {} ) public void test_Constructor() { try { SSLContextSpiImpl ssl = new SSLContextSpiImpl(); assertTrue(ssl instanceof SSLContextSpi); } catch (Exception e) { fail("Unexpected exception " + e.toString()); } }
/** * @throws NoSuchAlgorithmException * @throws NoSuchProviderException * @tests javax.net.ssl.SSLContext#getProtocol() */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "getProtocol", args = {} ) public void test_getProtocol() throws NoSuchAlgorithmException, NoSuchProviderException { if (!DEFSupported) fail(NotSupportMsg); SSLContextSpi spi = new MySSLContextSpi(); SSLContext sslContext = new MySslContext(spi, defaultProvider, defaultProtocol); assertEquals("Incorrect protocol", defaultProtocol, sslContext.getProtocol()); sslContext = new MySslContext(spi, defaultProvider, null); assertNull("Incorrect protocol", sslContext.getProtocol()); sslContext = SSLContext.getInstance(defaultProtocol); assertEquals("Incorrect protocol", defaultProtocol, sslContext.getProtocol()); sslContext = SSLContext.getInstance(defaultProtocol, defaultProvider); assertEquals("Incorrect protocol", defaultProtocol, sslContext.getProtocol()); sslContext = SSLContext.getInstance(defaultProtocol, defaultProviderName); assertEquals("Incorrect protocol", defaultProtocol, sslContext.getProtocol()); }
private X509TrustManager getX509TrustManager( Lookup<ConnectionSocketFactory> socketFactoryRegistry) { ConnectionSocketFactory connectionSocketFactory = socketFactoryRegistry .lookup("https"); SSLSocketFactory sslSocketFactory = getField(connectionSocketFactory, "socketfactory"); SSLContextSpi sslContext = getField(sslSocketFactory, "context"); return getField(sslContext, "trustManager"); }
/** * Constructs a new instance of the preferred {@link SSLContextSpi}. */ public static SSLContextSpi newPreferredSSLContextSpi() { checkAvailability(); return OpenSSLContextImpl.getPreferred(); }
TealessSSLContext(SSLContextSpi sslContextSpi, Provider provider, String s) { super(sslContextSpi, provider, s); }
public static SSLContext create(SSLContextSpi sslContextSpi, Provider provider, String s) { return new TealessSSLContext(sslContextSpi, provider, s); }
/** * @throws NoSuchAlgorithmException * @throws KeyStoreException * @throws FileNotFoundException * @throws KeyManagementException * @tests javax.net.ssl.SSLContext# * init(javax.net.ssl.KeyManager[], javax.net.ssl.TrustManager[], * java.security.SecureRandom) */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "init", args = {javax.net.ssl.KeyManager[].class, javax.net.ssl.TrustManager[].class, java.security.SecureRandom.class} ) public void test_init$Ljavax_net_ssl_KeyManager$Ljavax_net_ssl_TrustManagerLjava_security_SecureRandom() throws Exception { if (!DEFSupported) fail(NotSupportMsg); SSLContextSpi spi = new MySSLContextSpi(); SSLContext sslContext = new MySslContext(spi, defaultProvider, defaultProtocol); try { sslContext.createSSLEngine(); fail("Expected RuntimeException was not thrown"); } catch (RuntimeException rte) { // expected } try { sslContext.init(null, null, null); fail("KeyManagementException wasn't thrown"); } catch (KeyManagementException kme) { //expected } try { String tAlg = TrustManagerFactory.getDefaultAlgorithm(); String kAlg = KeyManagerFactory.getDefaultAlgorithm(); if (tAlg == null) fail("TrustManagerFactory default algorithm is not defined"); if (kAlg == null) fail("KeyManagerFactory default algorithm is not defined"); KeyManagerFactory kmf = KeyManagerFactory.getInstance(kAlg); kmf.init(null, new char[11]); TrustManagerFactory tmf = TrustManagerFactory.getInstance(tAlg); KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); tmf.init(ks); TrustManager[] tms = tmf.getTrustManagers(); sslContext.init(kmf.getKeyManagers(), tms, new SecureRandom()); } catch (Exception e) { System.out.println("EE = " + e); } }
public MySslContext(SSLContextSpi spi, Provider prov, String alg) { super(spi, prov, alg); }
public MySSLContext(SSLContextSpi spi, Provider prov, String alg) { super(spi, prov, alg); }
private X509TrustManager getX509TrustManager(Lookup<ConnectionSocketFactory> socketFactoryRegistry) { ConnectionSocketFactory connectionSocketFactory = (ConnectionSocketFactory)socketFactoryRegistry.lookup("https"); SSLSocketFactory sslSocketFactory = (SSLSocketFactory)this.getField(connectionSocketFactory, "socketfactory"); SSLContextSpi sslContext = (SSLContextSpi)this.getField(sslSocketFactory, "context"); return (X509TrustManager)this.getField(sslContext, "trustManager"); }
public mySSLContext(SSLContextSpi spi, Provider prov, String alg) { super(spi, prov, alg); }