|
|
|
@ -17,8 +17,6 @@ package org.thingsboard.rule.engine.rest; |
|
|
|
|
|
|
|
import io.netty.channel.EventLoopGroup; |
|
|
|
import io.netty.channel.nio.NioEventLoopGroup; |
|
|
|
import io.netty.handler.ssl.SslContext; |
|
|
|
import io.netty.handler.ssl.SslContextBuilder; |
|
|
|
import lombok.Data; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.codec.binary.Base64; |
|
|
|
@ -47,7 +45,6 @@ import org.thingsboard.rule.engine.api.TbNodeException; |
|
|
|
import org.thingsboard.rule.engine.api.TbRelationTypes; |
|
|
|
import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
|
|
|
import org.thingsboard.rule.engine.credentials.BasicCredentials; |
|
|
|
import org.thingsboard.rule.engine.credentials.CertPemCredentials; |
|
|
|
import org.thingsboard.rule.engine.credentials.ClientCredentials; |
|
|
|
import org.thingsboard.rule.engine.credentials.CredentialsType; |
|
|
|
import org.thingsboard.server.common.msg.TbMsg; |
|
|
|
@ -141,7 +138,7 @@ public class TbHttpClient { |
|
|
|
} else { |
|
|
|
this.eventLoopGroup = new NioEventLoopGroup(); |
|
|
|
Netty4ClientHttpRequestFactory nettyFactory = new Netty4ClientHttpRequestFactory(this.eventLoopGroup); |
|
|
|
nettyFactory.setSslContext(getSslContext(config.getCredentials())); |
|
|
|
nettyFactory.setSslContext(config.getCredentials().initSslContext()); |
|
|
|
nettyFactory.setReadTimeout(config.getReadTimeoutMs()); |
|
|
|
httpClient = new AsyncRestTemplate(nettyFactory); |
|
|
|
} |
|
|
|
@ -150,18 +147,6 @@ public class TbHttpClient { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private SslContext getSslContext(ClientCredentials credentials) throws SSLException { |
|
|
|
switch (credentials.getType()) { |
|
|
|
case ANONYMOUS: |
|
|
|
case BASIC: |
|
|
|
return SslContextBuilder.forClient().build(); |
|
|
|
case CERT_PEM: |
|
|
|
return credentials.initSslContext(); |
|
|
|
default: |
|
|
|
throw new IllegalArgumentException("[" + credentials.getType() + "] is not supported!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void checkSystemProxyProperties() throws TbNodeException { |
|
|
|
boolean useHttpProxy = !StringUtils.isEmpty(System.getProperty("http.proxyHost")) && !StringUtils.isEmpty(System.getProperty("http.proxyPort")); |
|
|
|
boolean useHttpsProxy = !StringUtils.isEmpty(System.getProperty("https.proxyHost")) && !StringUtils.isEmpty(System.getProperty("https.proxyPort")); |
|
|
|
|