Search in sources :

Example 56 with IqPacket

use of eu.siacs.conversations.xmpp.stanzas.IqPacket in project Conversations by siacs.

the class IqGenerator method requestHttpUploadSlot.

public IqPacket requestHttpUploadSlot(Jid host, DownloadableFile file, String mime) {
    IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
    packet.setTo(host);
    Element request = packet.addChild("request", Namespace.HTTP_UPLOAD);
    request.addChild("filename").setContent(convertFilename(file.getName()));
    request.addChild("size").setContent(String.valueOf(file.getExpectedSize()));
    if (mime != null) {
        request.addChild("content-type").setContent(mime);
    }
    return packet;
}
Also used : Element(eu.siacs.conversations.xml.Element) IqPacket(eu.siacs.conversations.xmpp.stanzas.IqPacket)

Example 57 with IqPacket

use of eu.siacs.conversations.xmpp.stanzas.IqPacket in project Conversations by siacs.

the class IqGenerator method pushTokenToAppServer.

public IqPacket pushTokenToAppServer(Jid appServer, String token, String deviceId) {
    IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
    packet.setTo(appServer);
    Element command = packet.addChild("command", "http://jabber.org/protocol/commands");
    command.setAttribute("node", "register-push-gcm");
    command.setAttribute("action", "execute");
    Data data = new Data();
    data.put("token", token);
    data.put("device-id", deviceId);
    data.submit();
    command.addChild(data);
    return packet;
}
Also used : Element(eu.siacs.conversations.xml.Element) Data(eu.siacs.conversations.xmpp.forms.Data) IqPacket(eu.siacs.conversations.xmpp.stanzas.IqPacket)

Example 58 with IqPacket

use of eu.siacs.conversations.xmpp.stanzas.IqPacket in project Conversations by siacs.

the class IqGenerator method queryAffiliation.

public IqPacket queryAffiliation(Conversation conversation, String affiliation) {
    IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
    packet.setTo(conversation.getJid().toBareJid());
    packet.query("http://jabber.org/protocol/muc#admin").addChild("item").setAttribute("affiliation", affiliation);
    return packet;
}
Also used : IqPacket(eu.siacs.conversations.xmpp.stanzas.IqPacket)

Example 59 with IqPacket

use of eu.siacs.conversations.xmpp.stanzas.IqPacket in project Conversations by siacs.

the class AxolotlService method publishDeviceVerificationAndBundle.

public void publishDeviceVerificationAndBundle(final SignedPreKeyRecord signedPreKeyRecord, final Set<PreKeyRecord> preKeyRecords, final boolean announceAfter, final boolean wipe) {
    try {
        IdentityKey axolotlPublicKey = axolotlStore.getIdentityKeyPair().getPublicKey();
        PrivateKey x509PrivateKey = KeyChain.getPrivateKey(mXmppConnectionService, account.getPrivateKeyAlias());
        X509Certificate[] chain = KeyChain.getCertificateChain(mXmppConnectionService, account.getPrivateKeyAlias());
        Signature verifier = Signature.getInstance("sha256WithRSA");
        verifier.initSign(x509PrivateKey, mXmppConnectionService.getRNG());
        verifier.update(axolotlPublicKey.serialize());
        byte[] signature = verifier.sign();
        IqPacket packet = mXmppConnectionService.getIqGenerator().publishVerification(signature, chain, getOwnDeviceId());
        Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account) + ": publish verification for device " + getOwnDeviceId());
        mXmppConnectionService.sendIqPacket(account, packet, new OnIqPacketReceived() {

            @Override
            public void onIqPacketReceived(final Account account, IqPacket packet) {
                String node = AxolotlService.PEP_VERIFICATION + ":" + getOwnDeviceId();
                Bundle pubsubOptions = new Bundle();
                pubsubOptions.putString("pubsub#access_model", "open");
                mXmppConnectionService.pushNodeConfiguration(account, account.getJid().toBareJid(), node, pubsubOptions, new XmppConnectionService.OnConfigurationPushed() {

                    @Override
                    public void onPushSucceeded() {
                        Log.d(Config.LOGTAG, getLogprefix(account) + "configured verification node to be world readable");
                        publishDeviceBundle(signedPreKeyRecord, preKeyRecords, announceAfter, wipe);
                    }

                    @Override
                    public void onPushFailed() {
                        Log.d(Config.LOGTAG, getLogprefix(account) + "unable to set access model on verification node");
                        publishDeviceBundle(signedPreKeyRecord, preKeyRecords, announceAfter, wipe);
                    }
                });
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Account(eu.siacs.conversations.entities.Account) IdentityKey(org.whispersystems.libaxolotl.IdentityKey) PrivateKey(java.security.PrivateKey) OnIqPacketReceived(eu.siacs.conversations.xmpp.OnIqPacketReceived) Bundle(android.os.Bundle) PreKeyBundle(org.whispersystems.libaxolotl.state.PreKeyBundle) X509Certificate(java.security.cert.X509Certificate) InvalidJidException(eu.siacs.conversations.xmpp.jid.InvalidJidException) InvalidKeyException(org.whispersystems.libaxolotl.InvalidKeyException) InvalidKeyIdException(org.whispersystems.libaxolotl.InvalidKeyIdException) UntrustedIdentityException(org.whispersystems.libaxolotl.UntrustedIdentityException) IqPacket(eu.siacs.conversations.xmpp.stanzas.IqPacket) Signature(java.security.Signature)

Example 60 with IqPacket

use of eu.siacs.conversations.xmpp.stanzas.IqPacket in project Conversations by siacs.

the class AxolotlService method wipeOtherPepDevices.

public void wipeOtherPepDevices() {
    if (pepBroken) {
        Log.d(Config.LOGTAG, getLogprefix(account) + "wipeOtherPepDevices called, but PEP is broken. Ignoring... ");
        return;
    }
    Set<Integer> deviceIds = new HashSet<>();
    deviceIds.add(getOwnDeviceId());
    IqPacket publish = mXmppConnectionService.getIqGenerator().publishDeviceIds(deviceIds);
    Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Wiping all other devices from Pep:" + publish);
    mXmppConnectionService.sendIqPacket(account, publish, null);
}
Also used : HashSet(java.util.HashSet) IqPacket(eu.siacs.conversations.xmpp.stanzas.IqPacket)

Aggregations

IqPacket (eu.siacs.conversations.xmpp.stanzas.IqPacket)78 Element (eu.siacs.conversations.xml.Element)43 Account (eu.siacs.conversations.entities.Account)41 OnIqPacketReceived (eu.siacs.conversations.xmpp.OnIqPacketReceived)33 Jid (eu.siacs.conversations.xmpp.jid.Jid)14 Data (eu.siacs.conversations.xmpp.forms.Data)6 InvalidJidException (eu.siacs.conversations.xmpp.jid.InvalidJidException)6 ArrayList (java.util.ArrayList)6 JinglePacket (eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket)4 HashSet (java.util.HashSet)4 InvalidKeyException (org.whispersystems.libaxolotl.InvalidKeyException)4 PreKeyBundle (org.whispersystems.libaxolotl.state.PreKeyBundle)4 Pair (android.util.Pair)3 Conversation (eu.siacs.conversations.entities.Conversation)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 InvalidKeyIdException (org.whispersystems.libaxolotl.InvalidKeyIdException)3 Bundle (android.os.Bundle)2 Bookmark (eu.siacs.conversations.entities.Bookmark)2 Contact (eu.siacs.conversations.entities.Contact)2