public 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());

            makeRequest(string.Format(PREKEY_PATH, ""), "PUT",
                        JsonUtil.toJson(new PreKeyState(entities, lastResortEntity,
                                                        signedPreKeyEntity, identityKey)));
            return(true);
        }
예제 #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;
 }
예제 #3
0
        public async Task <bool> RegisterPreKeys(CancellationToken token, IdentityKey identityKey, 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);
            }

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

            await MakeServiceRequestAsync(token, string.Format(PREKEY_PATH, ""), "PUT",
                                          JsonUtil.ToJson(new PreKeyState(entities, signedPreKeyEntity, identityKey)));

            return(true);
        }