當前位置: 首頁>>代碼示例>>Java>>正文


Java E2EEncryption類代碼示例

本文整理匯總了Java中org.kontalk.client.E2EEncryption的典型用法代碼示例。如果您正苦於以下問題:Java E2EEncryption類的具體用法?Java E2EEncryption怎麽用?Java E2EEncryption使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


E2EEncryption類屬於org.kontalk.client包,在下文中一共展示了E2EEncryption類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configure

import org.kontalk.client.E2EEncryption; //導入依賴的package包/類
private void configure() {
    ProviderManager.addIQProvider(Ping.ELEMENT_NAME, Ping.NAMESPACE, new Ping.Provider());
    ProviderManager.addIQProvider(UploadInfo.ELEMENT_NAME, UploadInfo.NAMESPACE, new UploadInfo.Provider());
    ProviderManager.addIQProvider(VCard4.ELEMENT_NAME, VCard4.NAMESPACE, new VCard4.Provider());
    ProviderManager.addIQProvider(BlockingCommand.BLOCKLIST, BlockingCommand.NAMESPACE, new BlockingCommand.Provider());
    ProviderManager.addExtensionProvider(StanzaGroupExtension.ELEMENT_NAME, StanzaGroupExtension.NAMESPACE, new StanzaGroupExtension.Provider());
    ProviderManager.addExtensionProvider(SentServerReceipt.ELEMENT_NAME, SentServerReceipt.NAMESPACE, new SentServerReceipt.Provider());
    ProviderManager.addExtensionProvider(ReceivedServerReceipt.ELEMENT_NAME, ReceivedServerReceipt.NAMESPACE, new ReceivedServerReceipt.Provider());
    ProviderManager.addExtensionProvider(ServerReceiptRequest.ELEMENT_NAME, ServerReceiptRequest.NAMESPACE, new ServerReceiptRequest.Provider());
    ProviderManager.addExtensionProvider(AckServerReceipt.ELEMENT_NAME, AckServerReceipt.NAMESPACE, new AckServerReceipt.Provider());
    ProviderManager.addExtensionProvider(OutOfBandData.ELEMENT_NAME, OutOfBandData.NAMESPACE, new OutOfBandData.Provider());
    ProviderManager.addExtensionProvider(BitsOfBinary.ELEMENT_NAME, BitsOfBinary.NAMESPACE, new BitsOfBinary.Provider());
    ProviderManager.addExtensionProvider(SubscribePublicKey.ELEMENT_NAME, SubscribePublicKey.NAMESPACE, new SubscribePublicKey.Provider());
    ProviderManager.addExtensionProvider(E2EEncryption.ELEMENT_NAME, E2EEncryption.NAMESPACE, new E2EEncryption.Provider());
}
 
開發者ID:ShadiNachat,項目名稱:Chatting-App-,代碼行數:16,代碼來源:MessageCenterService.java

示例2: parseMessageContent

import org.kontalk.client.E2EEncryption; //導入依賴的package包/類
public static MessageContent parseMessageContent(Message m, boolean decrypted) {
    MessageContent.Builder builder = new MessageContent.Builder();

    // parsing only default body
    String plainText = StringUtils.defaultString(m.getBody());
    String encrypted = "";

    if (!decrypted) {
        ExtensionElement e2eExt = m.getExtension(E2EEncryption.ELEMENT_NAME, E2EEncryption.NAMESPACE);
        if (e2eExt instanceof E2EEncryption) {
            // encryption extension (RFC 3923), decrypted later
            encrypted = EncodingUtils.bytesToBase64(((E2EEncryption) e2eExt).getData());
            // remove extension before parsing all others
            m.removeExtension(E2EEncryption.ELEMENT_NAME, E2EEncryption.NAMESPACE);
        }
        ExtensionElement openPGPExt = m.getExtension(OpenPGPExtension.ELEMENT_NAME, OpenPGPExtension.NAMESPACE);
        if (openPGPExt instanceof OpenPGPExtension) {
            if (!encrypted.isEmpty()) {
                LOGGER.info("message contains e2e and OpenPGP element, ignoring e2e");
            }
            encrypted = ((OpenPGPExtension) openPGPExt).getData();
            // remove extension before parsing all others
            m.removeExtension(OpenPGPExtension.ELEMENT_NAME, OpenPGPExtension.NAMESPACE);
        }
    }

    if (!encrypted.isEmpty()) {
        if (!plainText.isEmpty()) {
            LOGGER.config("message contains encryption and body (ignoring body): " + plainText);
            plainText = "";
        }
        builder.encrypted(encrypted);
    }
    addContent(builder, m.getExtensions(), plainText, decrypted);
    return builder.build();
}
 
開發者ID:kontalk,項目名稱:desktopclient-java,代碼行數:37,代碼來源:ClientUtils.java


注:本文中的org.kontalk.client.E2EEncryption類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。