List of usage examples for io.netty.buffer PooledByteBufAllocator DEFAULT
PooledByteBufAllocator DEFAULT
To view the source code for io.netty.buffer PooledByteBufAllocator DEFAULT.
Click Source Link
From source file:org.apache.qpid.jms.transports.TransportSupportTest.java
License:Apache License
@Test public void testCreateSslEngineFromJksStoreWithExplicitEnabledAndDisabledProtocolsOpenSSL() throws Exception { assumeTrue(OpenSsl.isAvailable());//from w w w . java 2s .c om assumeTrue(OpenSsl.supportsKeyManagerFactory()); // Discover the default enabled protocols TransportOptions options = createJksSslOptions(); SSLEngine directEngine = createOpenSSLEngineDirectly(options); String[] protocols = directEngine.getEnabledProtocols(); assertTrue("There were no initial protocols to choose from!", protocols.length > 1); // Pull out two to enable, and one to disable specifically String protocol1 = protocols[0]; String protocol2 = protocols[1]; String[] enabledProtocols = new String[] { protocol1, protocol2 }; String[] disabledProtocol = new String[] { protocol1 }; String[] remainingProtocols = new String[] { protocol2 }; options.setEnabledProtocols(enabledProtocols); options.setDisabledProtocols(disabledProtocol); SslContext context = TransportSupport.createOpenSslContext(options); SSLEngine engine = TransportSupport.createOpenSslEngine(PooledByteBufAllocator.DEFAULT, null, context, options); // Because Netty cannot currently disable SSLv2Hello in OpenSSL we need to account for it popping up. ArrayList<String> remainingProtocolsList = new ArrayList<>(Arrays.asList(remainingProtocols)); if (!remainingProtocolsList.contains("SSLv2Hello")) { remainingProtocolsList.add(0, "SSLv2Hello"); } remainingProtocols = remainingProtocolsList.toArray(new String[remainingProtocolsList.size()]); // verify the option took effect, that the disabled protocols were removed from the enabled list. assertNotNull(engine); assertEquals("Enabled protocols not as expected", remainingProtocolsList.size(), engine.getEnabledProtocols().length); assertTrue("Enabled protocols not as expected", remainingProtocolsList.containsAll(Arrays.asList(engine.getEnabledProtocols()))); }
From source file:org.apache.qpid.jms.transports.TransportSupportTest.java
License:Apache License
@Test public void testCreateSslEngineFromJksStoreWithExplicitEnabledCiphersOpenSSL() throws Exception { assumeTrue(OpenSsl.isAvailable());/*from w ww .j a v a 2 s. c om*/ assumeTrue(OpenSsl.supportsKeyManagerFactory()); // Discover the default enabled ciphers TransportOptions options = createJksSslOptions(); SSLEngine directEngine = createOpenSSLEngineDirectly(options); String[] ciphers = directEngine.getEnabledCipherSuites(); assertTrue("There were no initial ciphers to choose from!", ciphers.length > 0); // Pull out one to enable specifically String cipher = ciphers[0]; String[] enabledCipher = new String[] { cipher }; options.setEnabledCipherSuites(enabledCipher); SslContext context = TransportSupport.createOpenSslContext(options); SSLEngine engine = TransportSupport.createOpenSslEngine(PooledByteBufAllocator.DEFAULT, null, context, options); // verify the option took effect assertNotNull(engine); assertArrayEquals("Enabled ciphers not as expected", enabledCipher, engine.getEnabledCipherSuites()); }
From source file:org.apache.qpid.jms.transports.TransportSupportTest.java
License:Apache License
@Test public void testCreateSslEngineFromJksStoreWithExplicitDisabledCiphersOpenSSL() throws Exception { assumeTrue(OpenSsl.isAvailable());// w w w .j av a2 s . c o m assumeTrue(OpenSsl.supportsKeyManagerFactory()); // Discover the default enabled ciphers TransportOptions options = createJksSslOptions(); SSLEngine directEngine = createOpenSSLEngineDirectly(options); String[] ciphers = directEngine.getEnabledCipherSuites(); assertTrue("There were no initial ciphers to choose from!", ciphers.length > 0); // Pull out one to disable specifically String[] disabledCipher = new String[] { ciphers[ciphers.length - 1] }; String[] trimmedCiphers = Arrays.copyOf(ciphers, ciphers.length - 1); options.setDisabledCipherSuites(disabledCipher); SslContext context = TransportSupport.createOpenSslContext(options); SSLEngine engine = TransportSupport.createOpenSslEngine(PooledByteBufAllocator.DEFAULT, null, context, options); // verify the option took effect assertNotNull(engine); assertArrayEquals("Enabled ciphers not as expected", trimmedCiphers, engine.getEnabledCipherSuites()); }
From source file:org.apache.qpid.jms.transports.TransportSupportTest.java
License:Apache License
@Test public void testCreateSslEngineFromJksStoreWithExplicitEnabledAndDisabledCiphersOpenSSL() throws Exception { assumeTrue(OpenSsl.isAvailable());//ww w . j a va 2 s . c o m assumeTrue(OpenSsl.supportsKeyManagerFactory()); // Discover the default enabled ciphers TransportOptions options = createJksSslOptions(); SSLEngine directEngine = createOpenSSLEngineDirectly(options); String[] ciphers = directEngine.getEnabledCipherSuites(); assertTrue("There werent enough initial ciphers to choose from!", ciphers.length > 1); // Pull out two to enable, and one to disable specifically String cipher1 = ciphers[0]; String cipher2 = ciphers[1]; String[] enabledCiphers = new String[] { cipher1, cipher2 }; String[] disabledCipher = new String[] { cipher1 }; String[] remainingCipher = new String[] { cipher2 }; options.setEnabledCipherSuites(enabledCiphers); options.setDisabledCipherSuites(disabledCipher); SslContext context = TransportSupport.createOpenSslContext(options); SSLEngine engine = TransportSupport.createOpenSslEngine(PooledByteBufAllocator.DEFAULT, null, context, options); // verify the option took effect, that the disabled ciphers were removed from the enabled list. assertNotNull(engine); assertArrayEquals("Enabled ciphers not as expected", remainingCipher, engine.getEnabledCipherSuites()); }
From source file:org.apache.qpid.jms.transports.TransportSupportTest.java
License:Apache License
@Test public void testCreateSslEngineFromJceksStoreOpenSSL() throws Exception { assumeTrue(OpenSsl.isAvailable());/*from w w w . ja va 2s .c om*/ assumeTrue(OpenSsl.supportsKeyManagerFactory()); TransportOptions options = createJceksSslOptions(); SslContext context = TransportSupport.createOpenSslContext(options); assertNotNull(context); SSLEngine engine = TransportSupport.createOpenSslEngine(PooledByteBufAllocator.DEFAULT, null, context, options); assertNotNull(engine); List<String> engineProtocols = Arrays.asList(engine.getEnabledProtocols()); assertFalse(engineProtocols.isEmpty()); }
From source file:org.apache.qpid.jms.transports.TransportSupportTest.java
License:Apache License
@Test public void testCreateSslEngineFromJceksStoreWithExplicitEnabledProtocolsOpenSSL() throws Exception { assumeTrue(OpenSsl.isAvailable());//from www . j a v a2s.com assumeTrue(OpenSsl.supportsKeyManagerFactory()); // Try and disable all but the one we really want but for now expect that this one plus SSLv2Hello // is going to come back until the netty code can successfully disable them all. TransportOptions options = createJceksSslOptions(ENABLED_PROTOCOLS); SslContext context = TransportSupport.createOpenSslContext(options); assertNotNull(context); SSLEngine engine = TransportSupport.createOpenSslEngine(PooledByteBufAllocator.DEFAULT, null, context, options); assertNotNull(engine); assertArrayEquals("Enabled protocols not as expected", ENABLED_OPENSSL_PROTOCOLS, engine.getEnabledProtocols()); }
From source file:org.apache.qpid.jms.transports.TransportSupportTest.java
License:Apache License
@Test public void testCreateSslEngineWithVerifyHostOpenSSL() throws Exception { assumeTrue(OpenSsl.isAvailable());// ww w .j a v a 2s . c o m assumeTrue(OpenSsl.supportsKeyManagerFactory()); assumeTrue(OpenSsl.supportsHostnameValidation()); TransportOptions options = createJksSslOptions(); options.setVerifyHost(true); SslContext context = TransportSupport.createOpenSslContext(options); assertNotNull(context); SSLEngine engine = TransportSupport.createOpenSslEngine(PooledByteBufAllocator.DEFAULT, null, context, options); assertNotNull(engine); assertEquals("HTTPS", engine.getSSLParameters().getEndpointIdentificationAlgorithm()); }
From source file:org.apache.qpid.jms.transports.TransportSupportTest.java
License:Apache License
@Test public void testCreateSslEngineWithoutVerifyHostOpenSSL() throws Exception { assumeTrue(OpenSsl.isAvailable());/* w w w .j av a 2s . c om*/ assumeTrue(OpenSsl.supportsKeyManagerFactory()); assumeTrue(OpenSsl.supportsHostnameValidation()); TransportOptions options = createJksSslOptions(); options.setVerifyHost(false); SslContext context = TransportSupport.createOpenSslContext(options); assertNotNull(context); SSLEngine engine = TransportSupport.createOpenSslEngine(PooledByteBufAllocator.DEFAULT, null, context, options); assertNotNull(engine); assertNull(engine.getSSLParameters().getEndpointIdentificationAlgorithm()); }
From source file:org.apache.qpid.jms.transports.TransportSupportTest.java
License:Apache License
@Test(timeout = 100000) public void testCreateSslHandlerOpenSSL() throws Exception { assumeTrue(OpenSsl.isAvailable());/*from w w w . ja v a 2 s. c o m*/ assumeTrue(OpenSsl.supportsKeyManagerFactory()); TransportOptions options = new TransportOptions(); options.setUseOpenSSL(true); SslHandler handler = TransportSupport.createSslHandler(PooledByteBufAllocator.DEFAULT, null, options); assertNotNull(handler); assertTrue(handler.engine() instanceof OpenSslEngine); }
From source file:org.apache.qpid.jms.transports.TransportSupportTest.java
License:Apache License
private SSLEngine createOpenSSLEngineDirectly(TransportOptions options) throws Exception { SslContext context = TransportSupport.createOpenSslContext(options); SSLEngine engine = context.newEngine(PooledByteBufAllocator.DEFAULT); return engine; }