Search in sources :

Example 1 with ApiEncyptedBoxKey

use of im.actor.core.api.ApiEncyptedBoxKey in project actor-platform by actorapp.

the class EncryptedMsgActor method onDecrypt.

public void onDecrypt(int uid, ApiEncryptedMessage message) {
    Log.d(TAG, "onDecrypt:" + uid);
    final long start = im.actor.runtime.Runtime.getActorTime();
    ArrayList<EncryptedBoxKey> encryptedBoxKeys = new ArrayList<EncryptedBoxKey>();
    for (ApiEncyptedBoxKey key : message.getBox().getKeys()) {
        if (key.getUsersId() == myUid()) {
            encryptedBoxKeys.add(new EncryptedBoxKey(key.getUsersId(), key.getKeyGroupId(), key.getAlgType(), key.getEncryptedKey()));
        }
    }
    final EncryptedBox encryptedBox = new EncryptedBox(encryptedBoxKeys.toArray(new EncryptedBoxKey[0]), message.getBox().getEncPackage());
// TODO: Implement
//        ask(context().getEncryption().getEncryptedChatManager(uid), new EncryptedPeerActor.DecryptBox(encryptedBox), new AskCallback() {
//            @Override
//            public void onResult(Object obj) {
//                Log.d(TAG, "onDecrypt:onResult in " + (Runtime.getActorTime() - start) + " ms");
//                EncryptedPeerActor.DecryptBoxResponse re = (EncryptedPeerActor.DecryptBoxResponse) obj;
//                try {
//                    ApiMessage message = ApiMessage.fromBytes(re.getData());
//                    Log.d(TAG, "onDecrypt:onResult " + message);
//                } catch (IOException e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public void onError(Exception e) {
//                Log.d(TAG, "onDecrypt:onError");
//                e.printStackTrace();
//            }
//        });
}
Also used : EncryptedBoxKey(im.actor.core.modules.encryption.entity.EncryptedBoxKey) ArrayList(java.util.ArrayList) EncryptedBox(im.actor.core.modules.encryption.entity.EncryptedBox) ApiEncryptedBox(im.actor.core.api.ApiEncryptedBox) ApiEncyptedBoxKey(im.actor.core.api.ApiEncyptedBoxKey)

Aggregations

ApiEncryptedBox (im.actor.core.api.ApiEncryptedBox)1 ApiEncyptedBoxKey (im.actor.core.api.ApiEncyptedBoxKey)1 EncryptedBox (im.actor.core.modules.encryption.entity.EncryptedBox)1 EncryptedBoxKey (im.actor.core.modules.encryption.entity.EncryptedBoxKey)1 ArrayList (java.util.ArrayList)1