use of org.thingsboard.rule.engine.credentials.BasicCredentials in project thingsboard by thingsboard.
the class TbHttpClient method prepareHeaders.
private HttpHeaders prepareHeaders(TbMsg msg) {
HttpHeaders headers = new HttpHeaders();
config.getHeaders().forEach((k, v) -> headers.add(TbNodeUtils.processPattern(k, msg), TbNodeUtils.processPattern(v, msg)));
ClientCredentials credentials = config.getCredentials();
if (CredentialsType.BASIC == credentials.getType()) {
BasicCredentials basicCredentials = (BasicCredentials) credentials;
String authString = basicCredentials.getUsername() + ":" + basicCredentials.getPassword();
String encodedAuthString = new String(Base64.encodeBase64(authString.getBytes(StandardCharsets.UTF_8)));
headers.add("Authorization", "Basic " + encodedAuthString);
}
return headers;
}
use of org.thingsboard.rule.engine.credentials.BasicCredentials in project thingsboard by thingsboard.
the class TbMqttNode method prepareMqttClientConfig.
protected void prepareMqttClientConfig(MqttClientConfig config) throws SSLException {
ClientCredentials credentials = this.mqttNodeConfiguration.getCredentials();
if (credentials.getType() == CredentialsType.BASIC) {
BasicCredentials basicCredentials = (BasicCredentials) credentials;
config.setUsername(basicCredentials.getUsername());
config.setPassword(basicCredentials.getPassword());
}
}
Aggregations