Find correct session state in case the same one is used twice.

The code made the assumption that a session state can be identified by
the unique session ID. However, when multiple identities from the same
device are involved, there are two sessions with the same ID running on
the device.

Hence, a second identifying criteria has to be used to uniquely identify
the correct session. Here, the ID of the group was chosen.
Unfortunately, the session state can not be cached easily anymore
leading to a small performance penalty when getting all messages for the
UI.
This commit is contained in:
Torsten Grote
2016-04-04 12:04:17 -03:00
parent 5ea7ff2857
commit 4b7a32a5ee
4 changed files with 51 additions and 34 deletions

View File

@@ -8,6 +8,7 @@ import org.briarproject.api.db.DbException;
import org.briarproject.api.db.Transaction;
import org.briarproject.api.sync.ClientId;
import org.briarproject.api.sync.Group;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId;
import java.util.Collection;
@@ -26,14 +27,14 @@ public interface IntroductionManager {
/**
* Accept an introduction that had been made
*/
void acceptIntroduction(final SessionId sessionId)
throws DbException, FormatException;
void acceptIntroduction(final ContactId contactId,
final SessionId sessionId) throws DbException, FormatException;
/**
* Decline an introduction that had been made
*/
void declineIntroduction(final SessionId sessionId)
throws DbException, FormatException;
void declineIntroduction(final ContactId contactId,
final SessionId sessionId) throws DbException, FormatException;
/**
* Get all introduction messages for the contact with this contactId
@@ -46,8 +47,8 @@ public interface IntroductionManager {
/** Get the session state for the given session ID */
BdfDictionary getSessionState(Transaction txn, byte[] sessionId)
throws DbException, FormatException;
BdfDictionary getSessionState(Transaction txn, GroupId groupId,
byte[] sessionId) throws DbException, FormatException;
/** Gets the group used for introductions with Contact c */
Group getIntroductionGroup(Contact c);