Compare commits
3 Commits
c624ff54dd
...
d29aeff221
Author | SHA1 | Date |
---|---|---|
XakepSDK | d29aeff221 | |
d3coder | f669d09da1 | |
d3coder | 176631029d |
|
@ -3,10 +3,10 @@ package pro.gravit.launcher.base.request.auth.password;
|
|||
import pro.gravit.launcher.base.request.auth.AuthRequest;
|
||||
|
||||
public class AuthCodePassword implements AuthRequest.AuthPasswordInterface {
|
||||
public final String code;
|
||||
public final String finalRedirectUri;
|
||||
|
||||
public AuthCodePassword(String code) {
|
||||
this.code = code;
|
||||
public AuthCodePassword(String finalRedirectUri) {
|
||||
this.finalRedirectUri = finalRedirectUri;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package pro.gravit.utils.helper;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
public class QueryHelper {
|
||||
public static Map<String, List<String>> splitQueries(String query) {
|
||||
if (query == null) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<String, List<String>> params = new HashMap<>();
|
||||
String[] split = query.split("&");
|
||||
for (String qParams : split) {
|
||||
String[] splitParams = qParams.split("=");
|
||||
List<String> strings = params.computeIfAbsent(splitParams[0], k -> new ArrayList<>(1));
|
||||
strings.add(splitParams[1]);
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
public static String firstOrNull(String key, Map<String, List<String>> params) {
|
||||
List<String> list = params.getOrDefault(key, Collections.emptyList());
|
||||
if (list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return list.getFirst();
|
||||
}
|
||||
|
||||
|
||||
public static String encodeFormPair(String key, String value) {
|
||||
return URLEncoder.encode(key, StandardCharsets.UTF_8) + "=" + URLEncoder.encode(value, StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue