Avoid UnsupportedEncodingException & use const from StandardCharsets (#11948)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp
2022-01-03 16:05:08 +01:00
committed by GitHub
parent 3f54327d5a
commit 167f8ebc49
52 changed files with 180 additions and 414 deletions

View File

@@ -12,7 +12,6 @@
*/
package org.openhab.binding.zoneminder.internal.handler;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
@@ -61,14 +60,8 @@ public class ZmAuth {
logger.debug("ZmAuth: Authorization is enabled");
usingAuthorization = true;
isAuthorized = false;
String encodedUser = null;
String encodedPass = null;
try {
encodedUser = URLEncoder.encode(user, StandardCharsets.UTF_8.name());
encodedPass = URLEncoder.encode(pass, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
logger.warn("ZmAuth: Unable to encode user name and password");
}
String encodedUser = URLEncoder.encode(user, StandardCharsets.UTF_8);
String encodedPass = URLEncoder.encode(pass, StandardCharsets.UTF_8);
authContent = encodedUser == null ? ""
: String.format("user=%s&pass=%s&stateful=1", encodedUser, encodedPass);
}