Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/main/java/cz/smarteon/loxone/message/EncryptedCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import cz.smarteon.loxone.app.MiniserverType;
import org.jetbrains.annotations.NotNull;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.function.Function;

import static java.util.Objects.requireNonNull;
Expand Down Expand Up @@ -82,7 +82,7 @@ public static EncryptedCommand<Token> getToken(final @NotNull String tokenHash,
final @NotNull Function<String, String> encryptor) {
final String cmd = "jdev/sys/gettoken/"
+ requireNonNull(tokenHash, "tokenHash can't be null") + "/"
+ requireNonNull(user, "user can't be null") + "/"
+ requireNonNull(user, "user can't be null") + "/" +
+ requireNonNull(permissionType, "permissionType can't be null").getId() + "/"
+ requireNonNull(clientUuid, "clientUuid can't be null") + "/"
+ requireNonNull(clientInfo, "clientInfo can't be null");
Expand All @@ -105,6 +105,10 @@ public static EncryptedCommand<Token> refreshToken(final String tokenHash, final
}

private static String encodeUrl(String toEncode) {
return URLEncoder.encode(toEncode, StandardCharsets.UTF_8);
try {
return URLEncoder.encode(toEncode, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("UTF-8 encoding should be present everywhere", e);
}
}
}
Loading