Skip to content

Commit

Permalink
v1.1 (build 217)
Browse files Browse the repository at this point in the history
  • Loading branch information
finiasz committed Oct 25, 2023
1 parent 3a37281 commit 7735490
Show file tree
Hide file tree
Showing 47 changed files with 1,632 additions and 436 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Build 217 (1.1)
2023-10-24

- Fixes for various protocols in some multi-device corner cases
- Support for "write only" WebDAV automatic backup server (PUT permission is sufficient)
- Possibility to push settings configuration links through an MDM
- Possibility to push a WebDAV automatic backup configuration through an MDM and to enable Olvid backup key escrow on this WebDAV server

# Build 216 (1.0)
2023-10-10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,10 @@ public boolean isPrefixedBy(AdministratorsChain prefix) {
return true;
}

public boolean isChainCreatedBy(Identity identity) {
return blocks.length > 0 && blocks[0].isSignatureValid(new Identity[]{identity});
}
// no longer used, but could be useful one day!
// public boolean isChainCreatedBy(Identity identity) {
// return blocks.length > 0 && blocks[0].isSignatureValid(new Identity[]{identity});
// }

private AdministratorsChain(UID groupUid, Block[] blocks, boolean integrityWasChecked) {
this.groupUid = groupUid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3252,6 +3252,17 @@ public GroupV2.IdentifierVersionAndKeys[] getServerGroupsV2IdentifierVersionAndK
return ContactGroupV2.getServerGroupsV2IdentifierVersionAndKeysForContact(wrapSession(session), ownedIdentity, contactIdentity);
}


@Override
public GroupV2.IdentifierVersionAndKeys[] getAllServerGroupsV2IdentifierVersionAndKeys(Session session, Identity ownedIdentity) throws Exception {
if (ownedIdentity == null) {
throw new Exception();
}

return ContactGroupV2.getAllServerGroupsV2IdentifierVersionAndKeys(wrapSession(session), ownedIdentity);
}


@Override
public GroupV2.IdentifierAndAdminStatus[] getServerGroupsV2IdentifierAndMyAdminStatusForContact(Session session, Identity ownedIdentity, Identity contactIdentity) throws Exception {
if (ownedIdentity == null || contactIdentity == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ public static GroupV2.IdentifierVersionAndKeys[] getServerGroupsV2IdentifierVers

while (res.next()) {
byte[] groupUid = res.getBytes("uid");
String serverUld = res.getString("url");
String serverUrl = res.getString("url");
byte[] serializedContactPermissions = res.getBytes("perms");
int version = res.getInt(ContactGroupV2.VERSION);

Expand All @@ -1117,7 +1117,48 @@ public static GroupV2.IdentifierVersionAndKeys[] getServerGroupsV2IdentifierVers


list.add(new GroupV2.IdentifierVersionAndKeys(
new GroupV2.Identifier(new UID(groupUid), serverUld, GroupV2.Identifier.CATEGORY_SERVER),
new GroupV2.Identifier(new UID(groupUid), serverUrl, GroupV2.Identifier.CATEGORY_SERVER),
version,
blobKeys
));
}
return list.toArray(new GroupV2.IdentifierVersionAndKeys[0]);
}
}
}

public static GroupV2.IdentifierVersionAndKeys[] getAllServerGroupsV2IdentifierVersionAndKeys(IdentityManagerSession identityManagerSession, Identity ownedIdentity) throws SQLException {
try (PreparedStatement statement = identityManagerSession.session.prepareStatement(
"SELECT * FROM " + ContactGroupV2.TABLE_NAME +
" WHERE " + ContactGroupV2.CATEGORY + " = " + GroupV2.Identifier.CATEGORY_SERVER +
" AND " + ContactGroupV2.OWNED_IDENTITY + " = ?;"
)) {
statement.setBytes(1, ownedIdentity.getBytes());
try (ResultSet res = statement.executeQuery()) {
ArrayList<GroupV2.IdentifierVersionAndKeys> list = new ArrayList<>();

while (res.next()) {
byte[] groupUid = res.getBytes(ContactGroupV2.GROUP_UID);
String serverUrl = res.getString(ContactGroupV2.SERVER_URL);
int version = res.getInt(ContactGroupV2.VERSION);
byte[] bytesMainSeed = res.getBytes(ContactGroupV2.BLOB_MAIN_SEED);
byte[] bytesVersionSeed = res.getBytes(ContactGroupV2.BLOB_VERSION_SEED);
ServerAuthenticationPrivateKey serverAuthenticationPrivateKey = null;
byte[] bytesGroupAdminKey = res.getBytes(ContactGroupV2.GROUP_ADMIN_SERVER_AUTHENTICATION_PRIVATE_KEY); // this is non-null only when I am admin
if (bytesGroupAdminKey != null) {
try {
serverAuthenticationPrivateKey = (ServerAuthenticationPrivateKey) new Encoded(bytesGroupAdminKey).decodePrivateKey();
} catch (Exception ignored) { }
}

GroupV2.BlobKeys blobKeys = new GroupV2.BlobKeys(
new Seed(bytesMainSeed),
new Seed(bytesVersionSeed),
serverAuthenticationPrivateKey);


list.add(new GroupV2.IdentifierVersionAndKeys(
new GroupV2.Identifier(new UID(groupUid), serverUrl, GroupV2.Identifier.CATEGORY_SERVER),
version,
blobKeys
));
Expand All @@ -1127,6 +1168,7 @@ public static GroupV2.IdentifierVersionAndKeys[] getServerGroupsV2IdentifierVers
}
}


public static GroupV2.IdentifierAndAdminStatus[] getServerGroupsV2IdentifierAndMyAdminStatusForContact(IdentityManagerSession identityManagerSession, Identity ownedIdentity, Identity contactIdentity) throws SQLException {
try (PreparedStatement statement = identityManagerSession.session.prepareStatement(
"SELECT * FROM (SELECT " + ContactGroupV2Member.GROUP_UID + " AS uid, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ public interface IdentityDelegate {
boolean getGroupV2AdminStatus(Session session, Identity ownedIdentity, GroupV2.Identifier groupIdentifier) throws Exception;
List<ObvGroupV2> getObvGroupsV2ForOwnedIdentity(Session session, Identity ownedIdentity) throws Exception;
GroupV2.IdentifierVersionAndKeys[] getServerGroupsV2IdentifierVersionAndKeysForContact(Session session, Identity ownedIdentity, Identity contactIdentity) throws Exception;
GroupV2.IdentifierVersionAndKeys[] getAllServerGroupsV2IdentifierVersionAndKeys(Session session, Identity ownedIdentity) throws Exception;
GroupV2.IdentifierAndAdminStatus[] getServerGroupsV2IdentifierAndMyAdminStatusForContact(Session session, Identity ownedIdentity, Identity contactIdentity) throws Exception;
void initiateGroupV2BatchKeysResend(UID currentDeviceUid, Identity contactIdentity, UID contactDeviceUid);
void forcefullyRemoveMemberOrPendingFromNonAdminGroupV2(Session session, Identity ownedIdentity, GroupV2.Identifier groupIdentifier, Identity contactIdentity) throws SQLException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ public class RegisterServerPushNotificationsCoordinator implements RegisterServe
private final ExponentialBackoffRepeatingScheduler<Identity> scheduler;
private final NoDuplicateOperationQueue registerPushNotificationOperationQueue;

private final HashSet<Identity> awaitingServerSessionOperations;
private final Object awaitingServerSessionOperationsLock;
private final ServerSessionCreatedNotificationListener serverSessionCreatedNotificationListener;

private final HashMap<UID, IdentityAndUid> androidIdentityMaskingUids;
Expand All @@ -80,8 +78,6 @@ public RegisterServerPushNotificationsCoordinator(FetchManagerSessionFactory fet
registerPushNotificationOperationQueue.execute(1, "Engine-RegisterServerPushNotificationsCoordinator");

scheduler = new ExponentialBackoffRepeatingScheduler<>();
awaitingServerSessionOperations = new HashSet<>();
awaitingServerSessionOperationsLock = new Object();

androidIdentityMaskingUids = new HashMap<>();

Expand Down Expand Up @@ -174,7 +170,6 @@ public void onCancelCallback(Operation operation) {
}
switch (rfc) {
case RegisterPushNotificationOperation.RFC_INVALID_SERVER_SESSION: {
waitForServerSession(ownedIdentity);
createServerSessionDelegate.createServerSession(ownedIdentity);
break;
}
Expand All @@ -194,12 +189,6 @@ public void onCancelCallback(Operation operation) {
}
}

private void waitForServerSession(Identity identity) {
synchronized (awaitingServerSessionOperationsLock) {
awaitingServerSessionOperations.add(identity);
}
}

@Override
public void registerServerPushNotification(Identity identity) {
queueNewRegisterPushNotificationOperation(identity);
Expand Down Expand Up @@ -270,13 +259,9 @@ public void callback(String notificationName, HashMap<String, Object> userInfo)
if (!(identityObject instanceof Identity)) {
return;
}
Identity identity = (Identity) identityObject;
synchronized (awaitingServerSessionOperationsLock) {
if (awaitingServerSessionOperations.contains(identity)) {
awaitingServerSessionOperations.remove(identity);
queueNewRegisterPushNotificationOperation(identity);
}
}

// alway do a register after a new client session, we no longer keep a list a awaiting identities
queueNewRegisterPushNotificationOperation((Identity) identityObject);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ public void callback(String notificationName, HashMap<String, Object> userInfo)
for (ChannelCreationProtocolInstance channelCreationProtocolInstance: channelCreationProtocolInstances) {
abortProtocol(protocolManagerSession.session, channelCreationProtocolInstance.getProtocolInstanceUid(), ownedIdentity);
}
protocolManagerSession.session.commit();
}
// To improve: delete any other protocol related to this contact
} catch (Exception e) {
Expand Down
Loading

0 comments on commit 7735490

Please sign in to comment.