All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.wire.xenon.models.otr.Recipients Maven / Gradle / Ivy

There is a newer version: 1.8.1
Show newest version
package com.wire.xenon.models.otr;

import com.wire.xenon.backend.models.QualifiedId;

import java.util.HashMap;
import java.util.Set;

/**
 * Used as request body when discovering client with or without existing crypto sessions.
 */
// //Base64 encoded cipher
public class Recipients extends HashMap {

    public String get(QualifiedId userId, String clientId) {
        HashMap clients = toClients(userId);
        return clients.get(clientId);
    }

    public void add(QualifiedId userId, String clientId, String cipher) {
        ClientCipher clients = toClients(userId);
        clients.put(clientId, cipher);
    }

    //>
    public void add(QualifiedId userId, ClientCipher clients) {
        Set clientIds = clients.keySet();
        for (String clientId : clientIds) {
            String bytes = clients.get(clientId);
            add(userId, clientId, bytes);
        }
    }

    public void add(Recipients recipients) {
        Set userIds = recipients.keySet();
        for (QualifiedId userId : userIds) {
            ClientCipher hashMap = recipients.get(userId);
            add(userId, hashMap);
        }
    }

    private ClientCipher toClients(QualifiedId userId) {
        return computeIfAbsent(userId, k -> new ClientCipher());
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy