diff --git a/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/serverconnection/impl/HttpTransportImpl.java b/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/serverconnection/impl/HttpTransportImpl.java index ff8adab9bef..306853e73ff 100644 --- a/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/serverconnection/impl/HttpTransportImpl.java +++ b/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/serverconnection/impl/HttpTransportImpl.java @@ -43,7 +43,6 @@ import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; -import org.apache.commons.lang3.StringUtils; import org.openhab.binding.digitalstrom.internal.lib.config.Config; import org.openhab.binding.digitalstrom.internal.lib.manager.ConnectionManager; import org.openhab.binding.digitalstrom.internal.lib.serverconnection.HttpTransport; @@ -334,7 +333,12 @@ public class HttpTransportImpl implements HttpTransport { } private boolean checkNeededSessionToken(String request) { - String functionName = StringUtils.substringAfterLast(StringUtils.substringBefore(request, "?"), "/"); + String requestFirstPart = request; + int indexOfSeparator = request.indexOf("?"); + if (indexOfSeparator >= 0) { + requestFirstPart = request.substring(0, request.indexOf("?")); + } + String functionName = requestFirstPart.substring(requestFirstPart.lastIndexOf("/") + 1); return !DsAPIImpl.METHODS_MUST_NOT_BE_LOGGED_IN.contains(functionName); } @@ -347,8 +351,13 @@ public class HttpTransportImpl implements HttpTransport { correctedRequest = correctedRequest + "?" + ParameterKeys.TOKEN + "=" + sessionToken; } } else { - correctedRequest = StringUtils.replaceOnce(correctedRequest, StringUtils.substringBefore( - StringUtils.substringAfter(correctedRequest, ParameterKeys.TOKEN + "="), "&"), sessionToken); + String strippedRequest = correctedRequest + .substring(correctedRequest.indexOf(ParameterKeys.TOKEN + "=") + ParameterKeys.TOKEN.length() + 1); + int indexOfSeparator = strippedRequest.indexOf("&"); + if (indexOfSeparator >= 0) { + strippedRequest = strippedRequest.substring(0, indexOfSeparator); + } + correctedRequest = correctedRequest.replaceFirst(strippedRequest, sessionToken); } return correctedRequest; }