Skip to content

Commit 86ab317

Browse files
committed
Remove use of StandardCharsets due to incompatibility with older Java versions (<10)
1 parent 0fa5d4e commit 86ab317

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/java/cz/smarteon/loxone/message/EncryptedCommand.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import cz.smarteon.loxone.app.MiniserverType;
44
import org.jetbrains.annotations.NotNull;
55

6+
import java.io.UnsupportedEncodingException;
67
import java.net.URLEncoder;
7-
import java.nio.charset.StandardCharsets;
88
import java.util.function.Function;
99

1010
import static java.util.Objects.requireNonNull;
@@ -82,7 +82,7 @@ public static EncryptedCommand<Token> getToken(final @NotNull String tokenHash,
8282
final @NotNull Function<String, String> encryptor) {
8383
final String cmd = "jdev/sys/gettoken/"
8484
+ requireNonNull(tokenHash, "tokenHash can't be null") + "/"
85-
+ requireNonNull(user, "user can't be null") + "/"
85+
+ requireNonNull(user, "user can't be null") + "/" +
8686
+ requireNonNull(permissionType, "permissionType can't be null").getId() + "/"
8787
+ requireNonNull(clientUuid, "clientUuid can't be null") + "/"
8888
+ requireNonNull(clientInfo, "clientInfo can't be null");
@@ -105,6 +105,10 @@ public static EncryptedCommand<Token> refreshToken(final String tokenHash, final
105105
}
106106

107107
private static String encodeUrl(String toEncode) {
108-
return URLEncoder.encode(toEncode, StandardCharsets.UTF_8);
108+
try {
109+
return URLEncoder.encode(toEncode, "UTF-8");
110+
} catch (UnsupportedEncodingException e) {
111+
throw new IllegalStateException("UTF-8 encoding should be present everywhere", e);
112+
}
109113
}
110114
}

0 commit comments

Comments
 (0)