Implement Dbus setPin and removePin (#733)

and update documentation
This commit is contained in:
John Freed 2021-09-21 22:26:26 +02:00 committed by GitHub
parent 6c29d90503
commit d622967192
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 0 deletions

View file

@ -18,6 +18,7 @@ import org.asamk.signal.manager.groups.NotAGroupMemberException;
import org.asamk.signal.manager.storage.identities.IdentityInfo;
import org.asamk.signal.util.ErrorUtils;
import org.asamk.signal.util.Util;
import org.freedesktop.dbus.exceptions.DBusExecutionException;
import org.whispersystems.libsignal.util.Pair;
import org.whispersystems.libsignal.util.guava.Optional;
@ -25,6 +26,7 @@ import org.whispersystems.signalservice.api.groupsv2.GroupLinkNotActiveException
import org.whispersystems.signalservice.api.messages.SendMessageResult;
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
import org.whispersystems.signalservice.api.util.InvalidNumberException;
import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException;
import java.io.File;
import java.io.IOException;
@ -413,6 +415,28 @@ public class DbusSignalImpl implements Signal {
}
}
@Override
public void removePin() {
try {
m.setRegistrationLockPin(Optional.absent());
} catch (UnauthenticatedResponseException e) {
throw new Error.Failure("Remove pin failed with unauthenticated response: " + e.getMessage());
} catch (IOException e) {
throw new Error.Failure("Remove pin error: " + e.getMessage());
}
}
@Override
public void setPin(String registrationLockPin) {
try {
m.setRegistrationLockPin(Optional.of(registrationLockPin));
} catch (UnauthenticatedResponseException e) {
throw new Error.Failure("Set pin error failed with unauthenticated response: " + e.getMessage());
} catch (IOException e) {
throw new Error.Failure("Set pin error: " + e.getMessage());
}
}
// Provide option to query a version string in order to react on potential
// future interface changes
@Override