當前位置: 首頁>>代碼示例>>Java>>正文


Java InsecureTrustManagerFactory.INSTANCE屬性代碼示例

本文整理匯總了Java中io.netty.handler.ssl.util.InsecureTrustManagerFactory.INSTANCE屬性的典型用法代碼示例。如果您正苦於以下問題:Java InsecureTrustManagerFactory.INSTANCE屬性的具體用法?Java InsecureTrustManagerFactory.INSTANCE怎麽用?Java InsecureTrustManagerFactory.INSTANCE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在io.netty.handler.ssl.util.InsecureTrustManagerFactory的用法示例。


在下文中一共展示了InsecureTrustManagerFactory.INSTANCE屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: trustManager

private static TrustManagerFactory trustManager(NetworkSslConfig cfg, ResourceService resources) throws GeneralSecurityException,
    IOException, ResourceLoadingException {
    if (cfg.getTrustStorePath() == null || cfg.getTrustStorePath().isEmpty()) {
        return InsecureTrustManagerFactory.INSTANCE;
    } else {
        TrustManagerFactory factory;

        if (cfg.getTrustStoreAlgorithm() == null || cfg.getTrustStoreAlgorithm().isEmpty()) {
            factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
        } else {
            factory = TrustManagerFactory.getInstance(cfg.getTrustStoreAlgorithm());
        }

        KeyStore store = keyStore(cfg.getTrustStorePath(), cfg.getTrustStorePassword(), cfg.getTrustStoreType(), resources);

        factory.init(store);

        return factory;
    }
}
 
開發者ID:hekate-io,項目名稱:hekate,代碼行數:20,代碼來源:NettySslUtils.java

示例2: HttpClient

public HttpClient(String uri, boolean useInsecureTrustManagerFactory)
		throws URISyntaxException, UnsupportedOperationException {
	trustManagerFactory = useInsecureTrustManagerFactory ? InsecureTrustManagerFactory.INSTANCE : null;

	bootstrap = new Bootstrap();

	httpRequest = new HttpRequest(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri));

	if (!httpRequest().uriObject().getScheme().equalsIgnoreCase("http")
			&& !httpRequest().uriObject().getScheme().equalsIgnoreCase("https")) {
		String message = "HTTP(S) is supported only.";
		logger.error(message);
		throw new UnsupportedOperationException(message);
	}
}
 
開發者ID:anyflow,項目名稱:lannister,代碼行數:15,代碼來源:HttpClient.java

示例3: MqttClient

public MqttClient(String uri, boolean useInsecureTrustManagerFactory) throws URISyntaxException {
	this.bootstrap = new Bootstrap();
	this.uri = new URI(uri);
	this.trustManagerFactory = useInsecureTrustManagerFactory ? InsecureTrustManagerFactory.INSTANCE : null;
	this.sharedObject = new SharedObject();
	this.options = new ConnectOptions();
	this.currentMessageId = 0;
}
 
開發者ID:anyflow,項目名稱:lannister,代碼行數:8,代碼來源:MqttClient.java

示例4: initializeTrustManagerFactory

public TrustManagerFactory initializeTrustManagerFactory() throws DrillException {
  TrustManagerFactory tmf;
  KeyStore ts = null;
  //Support Windows/MacOs system trust store
  try {
    String trustStoreType = getTrustStoreType();
    if ((isWindows || isMacOs) && useSystemTrustStore()) {
      // This is valid for MS-Windows and MacOs
      logger.debug("Initializing System truststore.");
      ts = KeyStore.getInstance(!trustStoreType.isEmpty() ? trustStoreType : KeyStore.getDefaultType());
      ts.load(null, null);
    } else if (!getTrustStorePath().isEmpty()) {
        // if truststore is not provided then we will use the default. Note that the default depends on
        // the TrustManagerFactory that in turn depends on the Security Provider.
        // Use null as the truststore which will result in the default truststore being picked up
        logger.debug("Initializing truststore {}.", getTrustStorePath());
        ts = KeyStore.getInstance(!trustStoreType.isEmpty() ? trustStoreType : KeyStore.getDefaultType());
        InputStream tsStream = new FileInputStream(getTrustStorePath());
        ts.load(tsStream, getTrustStorePassword().toCharArray());
    } else {
      logger.debug("Initializing default truststore.");
    }
    if (disableCertificateVerification()) {
      tmf = InsecureTrustManagerFactory.INSTANCE;
    } else {
      tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
    }
    tmf.init(ts);
  } catch (Exception e) {
    // Catch any SSL initialization Exceptions here and abort.
    throw new DrillException(
        new StringBuilder()
            .append("Exception while initializing the truststore: [")
            .append(e.getMessage())
            .append("]. ")
            .toString(), e);
  }
  return tmf;
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:39,代碼來源:SSLConfig.java

示例5: ClientBuilderFactory

@Inject
public ClientBuilderFactory(
    MeterRegistry meterRegistry,
    Tracing tracing,
    Optional<SelfSignedCertificate> selfSignedCertificate,
    Optional<TrustManagerFactory> caTrustManager,
    ServerConfig serverConfig) {
  this.tracing = tracing;
  final TrustManagerFactory trustManagerFactory;
  if (serverConfig.isDisableClientCertificateVerification()) {
    logger.warn("Disabling client SSL verification. This should only happen on local!");
    trustManagerFactory = InsecureTrustManagerFactory.INSTANCE;
  } else if (caTrustManager.isPresent()) {
    trustManagerFactory = caTrustManager.get();
  } else {
    trustManagerFactory = null;
  }

  final Consumer<SslContextBuilder> clientCertificateCustomizer;
  if (selfSignedCertificate.isPresent()) {
    SelfSignedCertificate certificate = selfSignedCertificate.get();
    clientCertificateCustomizer =
        sslContext -> sslContext.keyManager(certificate.certificate(), certificate.privateKey());
  } else if (serverConfig.getTlsCertificatePath().isEmpty()
      || serverConfig.getTlsPrivateKeyPath().isEmpty()) {
    throw new IllegalStateException(
        "No TLS configuration provided, Curiostack does not support clients without TLS "
            + "certificates. Use gradle-curio-cluster-plugin to set up a namespace and TLS.");
  } else {
    clientCertificateCustomizer =
        sslContext ->
            sslContext.keyManager(
                new File(serverConfig.getTlsCertificatePath()),
                new File(serverConfig.getTlsPrivateKeyPath()));
  }

  final Consumer<SslContextBuilder> clientTlsCustomizer;
  if (trustManagerFactory != null) {
    clientTlsCustomizer =
        sslContext -> {
          clientCertificateCustomizer.accept(sslContext);
          sslContext.trustManager(trustManagerFactory);
        };
  } else {
    clientTlsCustomizer = clientCertificateCustomizer;
  }
  clientFactory =
      new ClientFactoryBuilder()
          .sslContextCustomizer(clientTlsCustomizer)
          .meterRegistry(meterRegistry)
          .build();
}
 
開發者ID:curioswitch,項目名稱:curiostack,代碼行數:52,代碼來源:ClientBuilderFactory.java


注:本文中的io.netty.handler.ssl.util.InsecureTrustManagerFactory.INSTANCE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。