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


Java TLV类代码示例

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


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

示例1: runMiddleOfProtocol

import net.java.otr4j.session.TLV; //导入依赖的package包/类
private void runMiddleOfProtocol(List<TLV> tlvs) throws SMException, OtrException {
    sm_b.processTlv(tlvs.get(0));
    assertEquals(SM.EXPECT1, sm_b.smstate.nextExpected);
    assertNull(sm_b.getPendingTlvs());

    tlvs = sm_b.initRespondSmp(null, "xyz", false);
    assertEquals(SM.EXPECT3, sm_b.smstate.nextExpected);
    assertEquals(1, tlvs.size());

    sm_a.processTlv(tlvs.get(0));
    assertEquals(SM.EXPECT4, sm_a.smstate.nextExpected);
    assertEquals(1, sm_a.getPendingTlvs().size());

    assertFalse(manager_a.isVerified(sessionId_a));
    assertFalse(manager_b.isVerified(sessionId_b));

    sm_b.processTlv(sm_a.getPendingTlvs().get(0));
    assertEquals(SM.EXPECT1, sm_b.smstate.nextExpected);
    assertEquals(1, sm_b.getPendingTlvs().size());

    sm_a.processTlv(sm_b.getPendingTlvs().get(0));
    assertEquals(SM.EXPECT1, sm_a.smstate.nextExpected);

    assertNull(sm_a.getPendingTlvs());
}
 
开发者ID:prive,项目名称:prive-android,代码行数:26,代码来源:OtrSmTest.java

示例2: decryptMessage

import net.java.otr4j.session.TLV; //导入依赖的package包/类
public String decryptMessage(String localUserId, String remoteUserId, String msg, List<TLV> tlvs) throws OtrException {
    String plain = null;

    SessionID sessionId = getSessionId(localUserId, remoteUserId);
    OtrDebugLogger.log("session status: " + mOtrEngine.getSessionStatus(sessionId));

    if (mOtrEngine != null && sessionId != null) {
        mOtrEngineHost.putSessionResource(sessionId, processResource(remoteUserId));
        plain = mOtrEngine.transformReceiving(sessionId, msg, tlvs);
        OtrSm otrSm = mOtrSms.get(sessionId);

        if (otrSm != null) {
            List<TLV> smTlvs = otrSm.getPendingTlvs();
            if (smTlvs != null) {
                String encrypted = mOtrEngine.transformSending(sessionId, "", smTlvs);
                mOtrEngineHost.injectMessage(sessionId, encrypted);

            }
        }

        if (plain != null && plain.length() == 0)
            return null;
    }
    return plain;
}
 
开发者ID:prive,项目名称:prive-android,代码行数:26,代码来源:OtrChatManager.java

示例3: decryptMessage

import net.java.otr4j.session.TLV; //导入依赖的package包/类
public String decryptMessage(String localUserId, String remoteUserId, String msg, List<TLV> tlvs) throws OtrException {

        String plain = null;

        SessionID sessionId = getSessionId(localUserId, remoteUserId);
       // OtrDebugLogger.log("session status: " + mOtrEngine.getSessionStatus(sessionId));

        if (mOtrEngine != null && sessionId != null) {

            mOtrEngineHost.putSessionResource(sessionId, processResource(remoteUserId));

            plain = mOtrEngine.transformReceiving(sessionId, msg, tlvs);

            OtrSm otrSm = mOtrSms.get(sessionId.toString());

            if (otrSm != null) {
                List<TLV> smTlvs = otrSm.getPendingTlvs();
                if (smTlvs != null) {
                    String encrypted = mOtrEngine.transformSending(sessionId, "", smTlvs);
                    mOtrEngineHost.injectMessage(sessionId, encrypted);
                }
            }

            //not null, but empty so make it null!
            if (TextUtils.isEmpty(plain))
                return null;
        }

        return plain;
    }
 
开发者ID:zom,项目名称:Zom-Android,代码行数:31,代码来源:OtrChatManager.java

示例4: respondSmp

import net.java.otr4j.session.TLV; //导入依赖的package包/类
public void respondSmp(SessionID sessionID, String secret) throws OtrException {
    OtrSm otrSm = mOtrSms.get(sessionID.toString());

    List<TLV> tlvs;

    if (otrSm == null) {
        showError(sessionID, "Could not respond to verification because conversation is not encrypted");
        return;
    }

    tlvs = otrSm.initRespondSmp(null, secret, false);
    String encrypted = mOtrEngine.transformSending(sessionID, "", tlvs);
    mOtrEngineHost.injectMessage(sessionID, encrypted);
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:15,代码来源:OtrChatManager.java

示例5: initSmp

import net.java.otr4j.session.TLV; //导入依赖的package包/类
public void initSmp(SessionID sessionID, String question, String secret) throws OtrException {
    OtrSm otrSm = mOtrSms.get(sessionID.toString());

    List<TLV> tlvs;

    if (otrSm == null) {
        showError(sessionID, "Could not perform verification because conversation is not encrypted");
        return;
    }

    tlvs = otrSm.initRespondSmp(question, secret, true);
    String encrypted = mOtrEngine.transformSending(sessionID, "", tlvs);
    mOtrEngineHost.injectMessage(sessionID, encrypted);
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:15,代码来源:OtrChatManager.java

示例6: abortSmp

import net.java.otr4j.session.TLV; //导入依赖的package包/类
public void abortSmp(SessionID sessionID) throws OtrException {
    OtrSm otrSm = mOtrSms.get(sessionID.toString());

    if (otrSm == null)
        return;

    List<TLV> tlvs = otrSm.abortSmp();
    String encrypted = mOtrEngine.transformSending(sessionID, "", tlvs);
    mOtrEngineHost.injectMessage(sessionID, encrypted);
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:11,代码来源:OtrChatManager.java

示例7: transformPushWhitelistTokenSending

import net.java.otr4j.session.TLV; //导入依赖的package包/类
/**
 * Create a message body describing the ChatSecure-Push Whitelist Token Exchange.
 * See <a href="https://github.com/ChatSecure/ChatSecure-Push-Server/wiki/Chat-Client-Implementation-Notes#json-whitelist-token-exchange">JSON Whitelist Token Exchange</a>
 *
 * @param message         A {@link Message} providing the 'to' & 'from' addresses, as well as
 *                        any message body text (this is currently unused by the ChatSecure-Push
 *                        spec).
 * @param whitelistTokens An Array of one or more ChatSecure-Push Whitelist tokens
 */
public boolean transformPushWhitelistTokenSending(@NonNull Message message,
                                                  @NonNull String[] whitelistTokens) {

    String localUserId = message.getFrom().getAddress();
    String remoteUserId = message.getTo().getAddress();
    String body = message.getBody();

    SessionID sessionId = getSessionId(localUserId, remoteUserId);

    try {

        List<TLV> tlvs = new ArrayList<>(1);


        if (mOtrEngine != null && sessionId != null) {
            SessionStatus sessionStatus = mOtrEngine.getSessionStatus(sessionId);
            if (sessionStatus != SessionStatus.ENCRYPTED) {
                // Cannot send Whitelist token without OTR.
                // TODO: Is it possible to Postpone-send a TLV message?
                OtrDebugLogger.log("Could not send ChatSecure-Push Whitelist Token TLV. Session not encrypted.");
                return false;
            }
            OtrDebugLogger.log("session status: " + sessionStatus);

            body = mOtrEngine.transformSending(sessionId, body, tlvs);
            message.setTo(mOtrEngineHost.appendSessionResource(sessionId, message.getTo()));
        }

        message.setBody(body);

        return true;

    } catch (Exception e) {
        OtrDebugLogger.log("error encrypting", e);
        return false;
    }
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:47,代码来源:OtrChatManager.java

示例8: transformSending

import net.java.otr4j.session.TLV; //导入依赖的package包/类
public String transformSending(SessionID sessionID, String msgText, boolean isResponse, byte[] data)
        throws OtrException {
    List<TLV> tlvs = null;
    if (data != null) {
        tlvs = new ArrayList<TLV>(1);
        tlvs.add(new TLV(isResponse ? TLV_DATA_RESPONSE : TLV_DATA_REQUEST, data));
    }
    return this.getSession(sessionID).transformSending(msgText, tlvs);
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:10,代码来源:OtrEngineImpl.java

示例9: testSuccess

import net.java.otr4j.session.TLV; //导入依赖的package包/类
@Test
public void testSuccess() throws Exception {
    replayAll();
    List<TLV> tlvs = sm_a.initRespondSmp(null, "xyz", true);
    assertEquals(SM.EXPECT2, sm_a.smstate.nextExpected);
    assertEquals(1, tlvs.size());

    runMiddleOfProtocol(tlvs);
    assertTrue(manager_b.isVerified(sessionId_b));

    assertTrue(manager_a.isVerified(sessionId_a));
}
 
开发者ID:prive,项目名称:prive-android,代码行数:13,代码来源:OtrSmTest.java

示例10: testSuccess_question

import net.java.otr4j.session.TLV; //导入依赖的package包/类
@Test
public void testSuccess_question() throws Exception {
    replayAll();
    List<TLV> tlvs = sm_a.initRespondSmp("qqq", "xyz", true);
    assertEquals(SM.EXPECT2, sm_a.smstate.nextExpected);
    assertEquals(1, tlvs.size());

    runMiddleOfProtocol(tlvs);

    assertTrue(manager_b.isVerified(sessionId_b));

    assertTrue(manager_a.isVerified(sessionId_a));
}
 
开发者ID:prive,项目名称:prive-android,代码行数:14,代码来源:OtrSmTest.java

示例11: testFailure

import net.java.otr4j.session.TLV; //导入依赖的package包/类
@Test
public void testFailure() throws Exception {
    replayAll();
    List<TLV> tlvs = sm_a.initRespondSmp(null, "abc", true);
    assertEquals(SM.EXPECT2, sm_a.smstate.nextExpected);
    assertEquals(1, tlvs.size());

    runMiddleOfProtocol(tlvs);

    assertFalse(manager_b.isVerified(sessionId_b));

    assertFalse(manager_a.isVerified(sessionId_a));
}
 
开发者ID:prive,项目名称:prive-android,代码行数:14,代码来源:OtrSmTest.java

示例12: testFailure_question

import net.java.otr4j.session.TLV; //导入依赖的package包/类
@Test
public void testFailure_question() throws Exception {
    replayAll();
    List<TLV> tlvs = sm_a.initRespondSmp("qqq", "abc", true);
    assertEquals(SM.EXPECT2, sm_a.smstate.nextExpected);
    assertEquals(1, tlvs.size());

    runMiddleOfProtocol(tlvs);

    assertFalse(manager_b.isVerified(sessionId_b));

    assertFalse(manager_a.isVerified(sessionId_a));
}
 
开发者ID:prive,项目名称:prive-android,代码行数:14,代码来源:OtrSmTest.java

示例13: respondSmp

import net.java.otr4j.session.TLV; //导入依赖的package包/类
public void respondSmp(SessionID sessionID, String secret) throws OtrException {
    OtrSm otrSm = mOtrSms.get(sessionID);

    List<TLV> tlvs;

    if (otrSm == null) {
        showError(sessionID, "Could not respond to verification because conversation is not encrypted");
        return;
    }
    
    tlvs = otrSm.initRespondSmp(null, secret, false);
    String encrypted = mOtrEngine.transformSending(sessionID, "", tlvs);
    mOtrEngineHost.injectMessage(sessionID, encrypted);
}
 
开发者ID:prive,项目名称:prive-android,代码行数:15,代码来源:OtrChatManager.java

示例14: initSmp

import net.java.otr4j.session.TLV; //导入依赖的package包/类
public void initSmp(SessionID sessionID, String question, String secret) throws OtrException {
    OtrSm otrSm = mOtrSms.get(sessionID);

    List<TLV> tlvs;

    if (otrSm == null) {
        showError(sessionID, "Could not perform verification because conversation is not encrypted");
        return;
    }
    
    tlvs = otrSm.initRespondSmp(question, secret, true);
    String encrypted = mOtrEngine.transformSending(sessionID, "", tlvs);
    mOtrEngineHost.injectMessage(sessionID, encrypted);
}
 
开发者ID:prive,项目名称:prive-android,代码行数:15,代码来源:OtrChatManager.java

示例15: abortSmp

import net.java.otr4j.session.TLV; //导入依赖的package包/类
public void abortSmp(SessionID sessionID) throws OtrException {
    OtrSm otrSm = mOtrSms.get(sessionID);
    
    if (otrSm == null)
        return;

    List<TLV> tlvs = otrSm.abortSmp();
    String encrypted = mOtrEngine.transformSending(sessionID, "", tlvs);
    mOtrEngineHost.injectMessage(sessionID, encrypted);
}
 
开发者ID:prive,项目名称:prive-android,代码行数:11,代码来源:OtrChatManager.java


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