aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/sms
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/sms')
-rw-r--r--src/main/java/org/traccar/sms/HttpSmsClient.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/sms/HttpSmsClient.java b/src/main/java/org/traccar/sms/HttpSmsClient.java
index 8e2b67bf7..c6f3be0f1 100644
--- a/src/main/java/org/traccar/sms/HttpSmsClient.java
+++ b/src/main/java/org/traccar/sms/HttpSmsClient.java
@@ -52,8 +52,10 @@ public class HttpSmsClient implements SmsManager {
if (authorization == null) {
String user = Context.getConfig().getString("sms.http.user");
String password = Context.getConfig().getString("sms.http.password");
- authorization = "Basic "
- + DataConverter.printBase64((user + ":" + password).getBytes(StandardCharsets.UTF_8));
+ if (user != null && password != null) {
+ authorization = "Basic "
+ + DataConverter.printBase64((user + ":" + password).getBytes(StandardCharsets.UTF_8));
+ }
}
template = Context.getConfig().getString("sms.http.template").trim();
if (template.charAt(0) == '{' || template.charAt(0) == '[') {
@@ -80,8 +82,11 @@ public class HttpSmsClient implements SmsManager {
}
private Invocation.Builder getRequestBuilder() {
- return Context.getClient().target(url).request()
- .header(authorizationHeader, authorization);
+ Invocation.Builder builder = Context.getClient().target(url).request();
+ if (authorization != null) {
+ builder = builder.header(authorizationHeader, authorization);
+ }
+ return builder;
}
@Override