private static void validateFormatOfCertificates(final Connection connection, final DittoHeaders dittoHeaders) { final Optional<String> trustedCertificates = connection.getTrustedCertificates(); final Optional<Credentials> credentials = connection.getCredentials(); // check if there are certificates to check if (trustedCertificates.isPresent() || credentials.isPresent()) { credentials.orElseGet(ClientCertificateCredentials::empty) .accept(SSLContextCreator.fromConnection(connection, dittoHeaders)); } }
private static void validateFormatOfCertificates(final Connection connection, final DittoHeaders dittoHeaders) { final Optional<String> trustedCertificates = connection.getTrustedCertificates(); final Optional<Credentials> credentials = connection.getCredentials(); // check if there are certificates to check if (trustedCertificates.isPresent() || credentials.isPresent()) { credentials.orElseGet(ClientCertificateCredentials::empty) .accept(SSLContextCreator.fromConnection(connection, dittoHeaders)); } }
private MqttConnectionSettings applySSLSocketFactory(final Connection connection, final MqttConnectionSettings connectionSettings, final DittoHeaders dittoHeaders) { final SSLContextCreator sslContextCreator = connection.isValidateCertificates() ? SSLContextCreator.fromConnection(connection, dittoHeaders) : SSLContextCreator.withTrustManager(ACCEPT_ANY_TRUST_MANAGER, dittoHeaders); final Credentials clientCredentials = connection.getCredentials().orElseGet(ClientCertificateCredentials::empty); final SSLContext sslContext = clientCredentials.accept(sslContextCreator); return SocketFactoryExtension.withSocketFactory(connectionSettings, sslContext.getSocketFactory()); }
private MqttConnectionSettings applySSLSocketFactory(final Connection connection, final MqttConnectionSettings connectionSettings, final DittoHeaders dittoHeaders) { final SSLContextCreator sslContextCreator = connection.isValidateCertificates() ? SSLContextCreator.fromConnection(connection, dittoHeaders) : SSLContextCreator.withTrustManager(ACCEPT_ANY_TRUST_MANAGER, dittoHeaders); final Credentials clientCredentials = connection.getCredentials().orElseGet(ClientCertificateCredentials::empty); final SSLContext sslContext = clientCredentials.accept(sslContextCreator); return SocketFactoryExtension.withSocketFactory(connectionSettings, sslContext.getSocketFactory()); }
/** * Returns a new {@code ConnectionBuilder} object. * * @param connection the connection to use for initializing the builder. * @return new instance of {@code ImmutableConnectionBuilder}. * @throws NullPointerException if {@code connection} is {@code null}. */ public static ConnectionBuilder getBuilder(final Connection connection) { checkNotNull(connection, "Connection"); return new Builder(connection.getConnectionType()) .id(connection.getId()) .connectionStatus(connection.getConnectionStatus()) .credentials(connection.getCredentials().orElse(null)) .uri(connection.getUri()) .trustedCertificates(connection.getTrustedCertificates().orElse(null)) .failoverEnabled(connection.isFailoverEnabled()) .validateCertificate(connection.isValidateCertificates()) .processorPoolSize(connection.getProcessorPoolSize()) .sources(connection.getSources()) .targets(connection.getTargets()) .clientCount(connection.getClientCount()) .specificConfig(connection.getSpecificConfig()) .mappingContext(connection.getMappingContext().orElse(null)) .name(connection.getName().orElse(null)) .tags(connection.getTags()); }
/** * Returns a new {@code ConnectionBuilder} object. * * @param connection the connection to use for initializing the builder. * @return new instance of {@code ImmutableConnectionBuilder}. * @throws NullPointerException if {@code connection} is {@code null}. */ public static ConnectionBuilder getBuilder(final Connection connection) { checkNotNull(connection, "Connection"); return new Builder(connection.getConnectionType()) .id(connection.getId()) .connectionStatus(connection.getConnectionStatus()) .credentials(connection.getCredentials().orElse(null)) .uri(connection.getUri()) .trustedCertificates(connection.getTrustedCertificates().orElse(null)) .failoverEnabled(connection.isFailoverEnabled()) .validateCertificate(connection.isValidateCertificates()) .processorPoolSize(connection.getProcessorPoolSize()) .sources(connection.getSources()) .targets(connection.getTargets()) .clientCount(connection.getClientCount()) .specificConfig(connection.getSpecificConfig()) .mappingContext(connection.getMappingContext().orElse(null)) .name(connection.getName().orElse(null)) .tags(connection.getTags()); }