diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-07-11 21:27:01 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-07-11 21:27:07 -0700 |
commit | de45d40884d58e4d0e2b2a65b8827bb35634894e (patch) | |
tree | 20150907a16553127e3491bb0e314b0af9d4c1e3 /src/main | |
parent | ec21a2b8c2cc6acd6b0872b67aa0daccdb191321 (diff) | |
download | trackermap-server-de45d40884d58e4d0e2b2a65b8827bb35634894e.tar.gz trackermap-server-de45d40884d58e4d0e2b2a65b8827bb35634894e.tar.bz2 trackermap-server-de45d40884d58e4d0e2b2a65b8827bb35634894e.zip |
Support request without auth
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/traccar/sms/HttpSmsClient.java | 13 |
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 |