当前位置: 首页>>代码示例>>Java>>正文


Java OtrException类代码示例

本文整理汇总了Java中net.java.otr4j.OtrException的典型用法代码示例。如果您正苦于以下问题:Java OtrException类的具体用法?Java OtrException怎么用?Java OtrException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OtrException类属于net.java.otr4j包,在下文中一共展示了OtrException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateOtrChat

import net.java.otr4j.OtrException; //导入依赖的package包/类
public MessagePacket generateOtrChat(Message message) {
    Session otrSession = message.getConversation().getOtrSession();
    if (otrSession == null) {
        return null;
    }
    MessagePacket packet = preparePacket(message);
    addMessageHints(packet);
    try {
        String content;
        if (message.hasFileOnRemoteHost()) {
            content = message.getFileParams().url.toString();
        } else {
            content = message.getBody();
        }
        packet.setBody(otrSession.transformSending(content)[0]);
        packet.addChild("encryption","urn:xmpp:eme:0")
                .setAttribute("namespace","urn:xmpp:otr:0");
        return packet;
    } catch (OtrException e) {
        return null;
    }
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:23,代码来源:MessageGenerator.java

示例2: startOtrSession

import net.java.otr4j.OtrException; //导入依赖的package包/类
public SessionImpl startOtrSession(String presence, boolean sendStart) {
    if (this.otrSession != null) {
        return this.otrSession;
    } else {
        final SessionID sessionId = new SessionID(this.getJid().toBareJid().toString(),
                presence,
                "xmpp");
        this.otrSession = new SessionImpl(sessionId, getAccount().getOtrService());
        try {
            if (sendStart) {
                this.otrSession.startSession();
                return this.otrSession;
            }
            return this.otrSession;
        } catch (OtrException e) {
            return null;
        }
    }

}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:21,代码来源:Conversation.java

示例3: endOtrIfNeeded

import net.java.otr4j.OtrException; //导入依赖的package包/类
public boolean endOtrIfNeeded() {
    if (this.otrSession != null) {
        if (this.otrSession.getSessionStatus() == SessionStatus.ENCRYPTED) {
            try {
                this.otrSession.endSession();
                this.resetOtrSession();
                return true;
            } catch (OtrException e) {
                this.resetOtrSession();
                return false;
            }
        } else {
            this.resetOtrSession();
            return false;
        }
    } else {
        return false;
    }
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:20,代码来源:Conversation.java

示例4: renewSymmetricKey

import net.java.otr4j.OtrException; //导入依赖的package包/类
public boolean renewSymmetricKey(Conversation conversation) {
    Account account = conversation.getAccount();
    byte[] symmetricKey = new byte[32];
    this.mRandom.nextBytes(symmetricKey);
    Session otrSession = conversation.getOtrSession();
    if (otrSession != null) {
        MessagePacket packet = new MessagePacket();
        packet.setType(MessagePacket.TYPE_CHAT);
        packet.setFrom(account.getJid());
        MessageGenerator.addMessageHints(packet);
        packet.setAttribute("to", otrSession.getSessionID().getAccountID() + "/"
                + otrSession.getSessionID().getUserID());
        try {
            packet.setBody(otrSession
                    .transformSending(CryptoHelper.FILETRANSFER
                            + CryptoHelper.bytesToHex(symmetricKey))[0]);
            sendMessagePacket(account, packet);
            conversation.setSymmetricKey(symmetricKey);
            return true;
        } catch (OtrException e) {
            return false;
        }
    }
    return false;
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:26,代码来源:XmppConnectionService.java

示例5: getLocalKeyPair

import net.java.otr4j.OtrException; //导入依赖的package包/类
@Override
public KeyPair getLocalKeyPair(SessionID arg0) throws OtrException {
    if (this.keyPair == null) {
        KeyPairGenerator kg;
        try {
            kg = KeyPairGenerator.getInstance("DSA");
            this.keyPair = kg.genKeyPair();
            this.saveKey();
            mXmppConnectionService.databaseBackend.updateAccount(account);
        } catch (NoSuchAlgorithmException e) {
            Log.d(Config.LOGTAG,
                    "error generating key pair " + e.getMessage());
        }
    }
    return this.keyPair;
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:17,代码来源:OtrService.java

示例6: initSmp

import net.java.otr4j.OtrException; //导入依赖的package包/类
protected boolean initSmp(final String question, final String secret) {
    final Session session = mConversation.getOtrSession();
    if (session!=null) {
        try {
            session.initSmp(question, secret);
            mConversation.smp().status = Conversation.Smp.STATUS_WE_REQUESTED;
            mConversation.smp().secret = secret;
            mConversation.smp().hint = question;
            return true;
        } catch (OtrException e) {
            return false;
        }
    } else {
        return false;
    }
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:17,代码来源:VerifyOTRActivity.java

示例7: abortSmp

import net.java.otr4j.OtrException; //导入依赖的package包/类
protected boolean abortSmp() {
    final Session session = mConversation.getOtrSession();
    if (session!=null) {
        try {
            session.abortSmp();
            mConversation.smp().status = Conversation.Smp.STATUS_NONE;
            mConversation.smp().hint = null;
            mConversation.smp().secret = null;
            return true;
        } catch (OtrException e) {
            return false;
        }
    } else {
        return false;
    }
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:17,代码来源:VerifyOTRActivity.java

示例8: generateOtrChat

import net.java.otr4j.OtrException; //导入依赖的package包/类
public MessagePacket generateOtrChat(Message message) {
    Session otrSession = message.getConversation().getOtrSession();
    if (otrSession == null) {
        return null;
    }
    MessagePacket packet = preparePacket(message);
    addMessageHints(packet);
    try {
        String content;
        if (message.hasFileOnRemoteHost()) {
            content = message.getFileParams().url.toString();
        } else {
            content = message.getBody();
        }
        packet.setBody(otrSession.transformSending(content)[0]);
        return packet;
    } catch (OtrException e) {
        return null;
    }
}
 
开发者ID:xavierle,项目名称:messengerxmpp,代码行数:21,代码来源:MessageGenerator.java

示例9: send

import net.java.otr4j.OtrException; //导入依赖的package包/类
/**
 * This method will take a Bytestring message and encrypt it via the member variable
 * SessionImpl's transformSending() method.  Since we are using chunks of unlimited size,
 * outgoingMessage will only contain one chunk that contains the entire encrypted message.
 * After the message is encrypted, it is then sent to the inner Session object.
 */

@Override
public synchronized boolean send(Bytestring message) throws InterruptedException, IOException {
    String[] outgoingMessage;
    try {
        synchronized (lock) {
            outgoingMessage = sessionImpl.transformSending(new String(Hex.encode(message.bytes)), null);
        }
    } catch (OtrException | EncoderException e) {
        this.close();
        return false;
    }

    for (String part : outgoingMessage) {
        s.send(new Bytestring(part.getBytes()));
    }
    return true;
}
 
开发者ID:DanielKrawisz,项目名称:Shufflepuff,代码行数:25,代码来源:OtrChannel.java

示例10: generateOtrChat

import net.java.otr4j.OtrException; //导入依赖的package包/类
public MessagePacket generateOtrChat(Message message) {
    Session otrSession = message.getConversation().getOtrSession();
    if (otrSession == null) {
        return null;
    }
    MessagePacket packet = preparePacket(message);
    addMessageHints(packet);
    try {
        String content;
        if (message.hasFileOnRemoteHost()) {
            content = message.getFileParams().url.toString();
        } else {
            content = message.getBody();
        }
        packet.setBody(otrSession.transformSending(content)[0]);
        packet.addChild("encryption", "urn:xmpp:eme:0").setAttribute("namespace", "urn:xmpp:otr:0");
        return packet;
    } catch (OtrException e) {
        return null;
    }
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:22,代码来源:MessageGenerator.java

示例11: startOtrSession

import net.java.otr4j.OtrException; //导入依赖的package包/类
public SessionImpl startOtrSession(String presence, boolean sendStart) {
    if (this.otrSession != null) {
        return this.otrSession;
    } else {
        final SessionID sessionId = new SessionID(this.getJid().toBareJid().toString(),
                presence,
                "xmpp");
        this.otrSession = new SessionImpl(sessionId, getAccount().getOtrService());
        try {
            if (sendStart) {
                this.otrSession.startSession();
                return this.otrSession;
            }
            return this.otrSession;
        } catch (OtrException e) {
            return null;
        }
    }

}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:21,代码来源:Conversation.java

示例12: endOtrIfNeeded

import net.java.otr4j.OtrException; //导入依赖的package包/类
public boolean endOtrIfNeeded() {
    if (this.otrSession != null) {
        if (this.otrSession.getSessionStatus() == SessionStatus.ENCRYPTED) {
            try {
                this.otrSession.endSession();
                this.resetOtrSession();
                return true;
            } catch (OtrException e) {
                this.resetOtrSession();
                return false;
            }
        } else {
            this.resetOtrSession();
            return false;
        }
    } else {
        return false;
    }
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:20,代码来源:Conversation.java

示例13: renewSymmetricKey

import net.java.otr4j.OtrException; //导入依赖的package包/类
public boolean renewSymmetricKey(Conversation conversation) {
    Account account = conversation.getAccount();
    byte[] symmetricKey = new byte[32];
    this.mRandom.nextBytes(symmetricKey);
    Session otrSession = conversation.getOtrSession();
    if (otrSession != null) {
        MessagePacket packet = new MessagePacket();
        packet.setType(MessagePacket.TYPE_CHAT);
        packet.setFrom(account.getJid());
        MessageGenerator.addMessageHints(packet);
        packet.setAttribute("to", otrSession.getSessionID().getAccountID() + "/"
                + otrSession.getSessionID().getUserID());
        try {
            packet.setBody(otrSession
                    .transformSending(CryptoHelper.FILETRANSFER
                            + CryptoHelper.bytesToHex(symmetricKey))[0]);
            sendMessagePacket(account, packet);
            conversation.setSymmetricKey(symmetricKey);
            return true;
        } catch (OtrException e) {
            return false;
        }
    }
    return false;
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:26,代码来源:XmppConnectionService.java

示例14: getLocalKeyPair

import net.java.otr4j.OtrException; //导入依赖的package包/类
@Override
public KeyPair getLocalKeyPair(SessionID arg0) throws OtrException {
    if (this.keyPair == null) {
        KeyPairGenerator kg;
        try {
            kg = KeyPairGenerator.getInstance("DSA");
            this.keyPair = kg.genKeyPair();
            this.saveKey();
            mXmppConnectionService.databaseBackend.updateAccount(account);
        } catch (NoSuchAlgorithmException e) {
            Log.d(Config.LOGTAG,
                    "error generating key pair " + e.getMessage());
        }
    }
    return this.keyPair;
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:17,代码来源:OtrService.java

示例15: initSmp

import net.java.otr4j.OtrException; //导入依赖的package包/类
protected boolean initSmp(final String question, final String secret) {
    final Session session = mConversation.getOtrSession();
    if (session != null) {
        try {
            session.initSmp(question, secret);
            mConversation.smp().status = Conversation.Smp.STATUS_WE_REQUESTED;
            mConversation.smp().secret = secret;
            mConversation.smp().hint = question;
            return true;
        } catch (OtrException e) {
            return false;
        }
    } else {
        return false;
    }
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:17,代码来源:VerifyOTRActivity.java


注:本文中的net.java.otr4j.OtrException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。