public async Task <bool> registerPreKeys(IdentityKey identityKey,
                                                 PreKeyRecord lastResortKey,
                                                 SignedPreKeyRecord signedPreKey,
                                                 IList <PreKeyRecord> records)
        //throws IOException
        {
            List <PreKeyEntity> entities = new List <PreKeyEntity>();

            foreach (PreKeyRecord record in records)
            {
                PreKeyEntity entity = new PreKeyEntity(record.getId(),
                                                       record.getKeyPair().getPublicKey());

                entities.Add(entity);
            }

            PreKeyEntity lastResortEntity = new PreKeyEntity(lastResortKey.getId(),
                                                             lastResortKey.getKeyPair().getPublicKey());

            SignedPreKeyEntity signedPreKeyEntity = new SignedPreKeyEntity(signedPreKey.getId(),
                                                                           signedPreKey.getKeyPair().getPublicKey(),
                                                                           signedPreKey.getSignature());

            await makeRequest(string.Format(PREKEY_PATH, ""), "PUT",
                              JsonUtil.toJson(new PreKeyState(entities, lastResortEntity,
                                                              signedPreKeyEntity, identityKey)));

            return(true);
        }
Example #2
0
 public PreKeyState(List<PreKeyEntity> preKeys, PreKeyEntity lastResortKey,
                    SignedPreKeyEntity signedPreKey, IdentityKey identityKey)
 {
     this.preKeys = preKeys;
     this.lastResortKey = lastResortKey;
     this.signedPreKey = signedPreKey;
     this.identityKey = identityKey;
 }
 public PreKeyState(List <PreKeyEntity> preKeys, PreKeyEntity lastResortKey,
                    SignedPreKeyEntity signedPreKey, IdentityKey identityKey)
 {
     this.preKeys       = preKeys;
     this.lastResortKey = lastResortKey;
     this.signedPreKey  = signedPreKey;
     this.identityKey   = identityKey;
 }
        public async Task <bool> setCurrentSignedPreKey(SignedPreKeyRecord signedPreKey)// throws IOException
        {
            SignedPreKeyEntity signedPreKeyEntity = new SignedPreKeyEntity(signedPreKey.getId(),
                                                                           signedPreKey.getKeyPair().getPublicKey(),
                                                                           signedPreKey.getSignature());

            await makeRequest(SIGNED_PREKEY_PATH, "PUT", JsonUtil.toJson(signedPreKeyEntity));

            return(true);
        }
 public async Task<bool> setCurrentSignedPreKey(SignedPreKeyRecord signedPreKey)// throws IOException
 {
     SignedPreKeyEntity signedPreKeyEntity = new SignedPreKeyEntity(signedPreKey.getId(),
                                                                    signedPreKey.getKeyPair().getPublicKey(),
                                                                    signedPreKey.getSignature());
     await makeRequest(SIGNED_PREKEY_PATH, "PUT", JsonUtil.toJson(signedPreKeyEntity));
     return true;
 }
        public async Task<bool> registerPreKeys(IdentityKey identityKey,
                                    PreKeyRecord lastResortKey,
                                    SignedPreKeyRecord signedPreKey,
                                    IList<PreKeyRecord> records)
        //throws IOException
        {
            List<PreKeyEntity> entities = new List<PreKeyEntity>();

            foreach (PreKeyRecord record in records)
            {
                PreKeyEntity entity = new PreKeyEntity(record.getId(),
                                                       record.getKeyPair().getPublicKey());

                entities.Add(entity);
            }

            PreKeyEntity lastResortEntity = new PreKeyEntity(lastResortKey.getId(),
                                                     lastResortKey.getKeyPair().getPublicKey());

            SignedPreKeyEntity signedPreKeyEntity = new SignedPreKeyEntity(signedPreKey.getId(),
                                                                   signedPreKey.getKeyPair().getPublicKey(),
                                                                   signedPreKey.getSignature());

            await makeRequest(string.Format(PREKEY_PATH, ""), "PUT",
                JsonUtil.toJson(new PreKeyState(entities, lastResortEntity,
                                                signedPreKeyEntity, identityKey)));
            return true;
        }