Client createClient(final ClientId clientId, final VerificationKey verificationKey) { final Client client = new Client(); client.setComparisonIdentities(new ArrayList<>()); client.setDeviceToken(clientId.getClient()); final PublicKeys publicKeys = new PublicKeys(); publicKeys.setVerification(verificationKey); final EncryptionKey encryptionKey = new EncryptionKey(); encryptionKey.setAlgorithm(EncryptionAlgorithm.RSA2048); final ByteBuffer b = ByteBuffer.wrap("".getBytes()); b.mark(); encryptionKey.setBuffer(b); publicKeys.setEncryption(encryptionKey); client.setKeys(publicKeys); final UserAgent userAgent = new UserAgent(); userAgent.setPlatform(""); userAgent.setVersion(""); client.setUserAgent(userAgent); return client; }
Base1() throws GoraException, NoSuchAlgorithmException { final ByteBuffer b0 = ByteBuffer.wrap("0".getBytes()); b0.mark(); e0 = new com.kareebo.contacts.thrift.EncryptionKey( b0, com.kareebo.contacts.thrift.EncryptionAlgorithm.RSA2048); final User user0 = userDatastore.get(clientId.getUser()); final Map<CharSequence, Client> clients0 = user0.getClients(); clients0.values().iterator().next().getKeys().setEncryption(TypeConverter.convert(e0)); final ByteBuffer b1 = ByteBuffer.wrap("1".getBytes()); b1.mark(); e1 = new com.kareebo.contacts.thrift.EncryptionKey( b1, com.kareebo.contacts.thrift.EncryptionAlgorithm.RSA2048); final Client client01 = createClient(clientId01, verificationKey); client01.getKeys().setEncryption(TypeConverter.convert(e1)); clients0.put(TypeConverter.convert(clientId01.getClient()), client01); user0.setClients(clients0); final Client client10 = createClient(clientId10, verificationKey); final Client client11 = createClient(clientId11, verificationKey); final User user1 = new User(); user1.setBlind(b0); final Map<CharSequence, Client> clients1 = new HashMap<>(2); clients1.put(TypeConverter.convert(clientId10.getClient()), client10); clients1.put(TypeConverter.convert(clientId11.getClient()), client11); user1.setClients(clients1); user1.setIdentities(new ArrayList<>()); user1.setSentRequests(new ArrayList<>()); user1.setId(clientId10.getUser()); userDatastore.put(clientId.getUser(), user0); userDatastore.put(clientId10.getUser(), user1); final HashIdentity hashIdentity = new HashIdentity(); hashIdentity.setHash(b0); final HashIdentityValue hashIdentityValue = new HashIdentityValue(); hashIdentityValue.setConfirmers(new ArrayList<>()); hashIdentityValue.setId(clientId10.getUser()); hashIdentity.setHashIdentity(hashIdentityValue); u.setAlgorithm(HashAlgorithm.SHA256); u.setBuffer(b0); identityDataStore.put(b0, hashIdentity); }