Avoid UnsupportedEncodingException & use const from StandardCharsets (#11948)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
committed by
GitHub
parent
3f54327d5a
commit
167f8ebc49
@@ -12,11 +12,11 @@
|
||||
*/
|
||||
package org.openhab.binding.ipcamera.internal;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
@@ -111,12 +111,7 @@ public class Helper {
|
||||
* @author Matthew Skinner - Initial contribution
|
||||
*/
|
||||
public static String encodeSpecialChars(String text) {
|
||||
String processed = text;
|
||||
try {
|
||||
processed = URLEncoder.encode(text, "UTF-8").replace("+", "%20");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
}
|
||||
return processed;
|
||||
return URLEncoder.encode(text, StandardCharsets.UTF_8).replace("+", "%20");
|
||||
}
|
||||
|
||||
public static String getLocalIpAddress() {
|
||||
|
||||
@@ -14,7 +14,6 @@ package org.openhab.binding.ipcamera.internal.onvif;
|
||||
|
||||
import static org.openhab.binding.ipcamera.internal.IpCameraBindingConstants.*;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
@@ -503,10 +502,9 @@ public class OnvifConnection {
|
||||
try {
|
||||
msgDigest = MessageDigest.getInstance("SHA-1");
|
||||
msgDigest.reset();
|
||||
msgDigest.update(beforeEncryption.getBytes("utf8"));
|
||||
msgDigest.update(beforeEncryption.getBytes(StandardCharsets.UTF_8));
|
||||
encryptedRaw = msgDigest.digest();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
}
|
||||
return Base64.getEncoder().encodeToString(encryptedRaw);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user