import org.asamk.signal.manager.storage.SignalAccount;
import org.asamk.signal.manager.storage.identities.TrustNewIdentity;
import org.asamk.signal.manager.util.KeyUtils;
+import org.asamk.signal.manager.util.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.whispersystems.libsignal.util.KeyHelper;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
-import java.util.Locale;
public class RegistrationManager implements Closeable {
public void register(boolean voiceVerification, String captcha) throws IOException, CaptchaRequiredException {
final ServiceResponse<RequestVerificationCodeResponse> response;
if (voiceVerification) {
- response = accountManager.requestVoiceVerificationCode(getDefaultLocale(),
+ response = accountManager.requestVoiceVerificationCode(Utils.getDefaultLocale(),
Optional.fromNullable(captcha),
Optional.absent(),
Optional.absent());
}
}
- private Locale getDefaultLocale() {
- final var locale = Locale.getDefault();
- try {
- Locale.LanguageRange.parse(locale.getLanguage() + "-" + locale.getCountry());
- } catch (IllegalArgumentException e) {
- logger.debug("Invalid locale, ignoring: {}", locale);
- return null;
- }
-
- return locale;
- }
-
public Manager verifyAccount(
String verificationCode, String pin
) throws IOException, PinLockedException, IncorrectPinException {
import java.util.Date;
import java.util.HashSet;
import java.util.List;
-import java.util.Locale;
import java.util.Objects;
import java.util.Set;
}
private SignalServiceProfile retrieveProfileSync(String username) throws IOException {
- final var locale = Locale.getDefault();
+ final var locale = Utils.getDefaultLocale();
return dependencies.getMessageReceiver().retrieveProfileByUsername(username, Optional.absent(), locale);
}
var profileService = dependencies.getProfileService();
Single<ServiceResponse<ProfileAndCredential>> responseSingle;
- final var locale = Locale.getDefault();
+ final var locale = Utils.getDefaultLocale();
try {
responseSingle = profileService.getProfile(address, profileKey, unidentifiedAccess, requestType, locale);
} catch (NoClassDefFoundError e) {
package org.asamk.signal.manager.util;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.whispersystems.libsignal.IdentityKey;
import org.whispersystems.libsignal.fingerprint.Fingerprint;
import org.whispersystems.libsignal.fingerprint.NumericFingerprintGenerator;
import java.io.InputStream;
import java.net.URLConnection;
import java.nio.file.Files;
+import java.util.Locale;
public class Utils {
+ private final static Logger logger = LoggerFactory.getLogger(Utils.class);
+
public static String getFileMimeType(File file, String defaultMimeType) throws IOException {
var mime = Files.probeContentType(file.toPath());
if (mime == null) {
theirId,
theirIdentityKey);
}
+
+ public static Locale getDefaultLocale() {
+ final var locale = Locale.getDefault();
+ try {
+ Locale.LanguageRange.parse(locale.getLanguage() + "-" + locale.getCountry());
+ } catch (IllegalArgumentException e) {
+ logger.debug("Invalid locale, ignoring: {}", locale);
+ return null;
+ }
+
+ return locale;
+ }
}