Base() throws GoraException { userDatastore = DataStoreFactory.getDataStore(Long.class, User.class, new Configuration()); notifier = new Notifier(); pendingNotificationDataStore = DataStoreFactory.getDataStore(Long.class, PendingNotification.class, new Configuration()); clientNotifier = new ClientNotifier(notifier, pendingNotificationDataStore); identityDataStore = DataStoreFactory.getDataStore(ByteBuffer.class, HashIdentity.class, new Configuration()); sendContactCard = new SendContactCard(userDatastore, identityDataStore, clientNotifier); final User user = new User(); final ByteBuffer b = ByteBuffer.wrap("".getBytes()); b.mark(); user.setBlind(b); user.setId(clientId.getUser()); user.setIdentities(new ArrayList<>()); user.setSentRequests(new ArrayList<>()); final Map<CharSequence, Client> clients = new HashMap<>(1); clients.put( TypeConverter.convert(clientId.getClient()), createClient(clientId, verificationKey)); user.setClients(clients); userDatastore.put(user.getId(), user); }
Base3() throws GoraException, TException, NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException, SignatureException { final User user = new User(); user.setId(userId); final ByteBuffer b = ByteBuffer.wrap("".getBytes()); b.mark(); user.setBlind(b); user.setIdentities(new ArrayList<>()); user.setSentRequests(new ArrayList<>()); final Map<CharSequence, Client> clients = new HashMap<>(2); final VerificationKey verificationKey = new VerificationKey(); verificationKey.setAlgorithm(com.kareebo.contacts.server.gora.SignatureAlgorithm.Fake); verificationKey.setBuffer(b); clients.put( TypeConverter.convert(clientId0.getClient()), createClient(clientId0, verificationKey)); clients.put( TypeConverter.convert(clientId1.getClient()), createClient(clientId1, verificationKey)); user.setClients(clients); userDatastore.put(userId, user); final com.kareebo.contacts.thrift.EncryptedBuffer encryptedBuffer0 = new com.kareebo.contacts.thrift.EncryptedBuffer( b, com.kareebo.contacts.thrift.EncryptionAlgorithm.Fake, clientId0); final EncryptedBufferSigned encryptedBufferSigned0 = new EncryptedBufferSigned(encryptedBuffer0, sign(encryptedBuffer0, clientId)); encryptedBufferSignedSet.add(encryptedBufferSigned0); e0 = new EncryptedBufferSignedWithVerificationKey( encryptedBufferSigned0, TypeConverter.convert(this.verificationKey)); final com.kareebo.contacts.thrift.EncryptedBuffer encryptedBuffer1 = new com.kareebo.contacts.thrift.EncryptedBuffer( b, com.kareebo.contacts.thrift.EncryptionAlgorithm.Fake, clientId1); final EncryptedBufferSigned encryptedBufferSigned1 = new EncryptedBufferSigned(encryptedBuffer1, sign(encryptedBuffer1, clientId)); encryptedBufferSignedSet.add(encryptedBufferSigned1); e1 = new EncryptedBufferSignedWithVerificationKey( encryptedBufferSigned1, TypeConverter.convert(this.verificationKey)); }
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); }
@Before public void setUp() throws Exception { super.setUp(); clientIdInvalid.setClient(clientIdValid.getClient() + 1); clientIdInvalid.setUser(clientIdValid.getUser()); }