コード例 #1
0
 @Test
 public void testSSLConfig() {
   SSLConfig sslConfig = config.getNetworkConfig().getSSLConfig();
   assertNotNull(sslConfig);
   assertFalse(sslConfig.isEnabled());
   assertEquals(DummySSLContextFactory.class.getName(), sslConfig.getFactoryClassName());
   assertEquals(sslContextFactory, sslConfig.getFactoryImplementation());
 }
コード例 #2
0
  private SocketChannelWrapperFactory initSocketChannel(ClientNetworkConfig networkConfig) {
    // ioService.getSSLConfig(); TODO
    SSLConfig sslConfig = networkConfig.getSSLConfig();

    if (sslConfig != null && sslConfig.isEnabled()) {
      LOGGER.info("SSL is enabled");
      return new SSLSocketChannelWrapperFactory(sslConfig);
    } else {
      return new DefaultSocketChannelWrapperFactory();
    }
  }
コード例 #3
0
 SSLSocketChannelWrapperFactory(SSLConfig sslConfig) {
   //            if (CipherHelper.isSymmetricEncryptionEnabled(ioService)) {
   //                throw new RuntimeException("SSL and SymmetricEncryption cannot be both
   // enabled!");
   //            }
   SSLContextFactory sslContextFactoryObject =
       (SSLContextFactory) sslConfig.getFactoryImplementation();
   try {
     String factoryClassName = sslConfig.getFactoryClassName();
     if (sslContextFactoryObject == null && factoryClassName != null) {
       sslContextFactoryObject =
           (SSLContextFactory) Class.forName(factoryClassName).newInstance();
     }
     if (sslContextFactoryObject == null) {
       sslContextFactoryObject = new BasicSSLContextFactory();
     }
     sslContextFactoryObject.init(sslConfig.getProperties());
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
   sslContextFactory = sslContextFactoryObject;
 }