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


Java SessionID类代码示例

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


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

示例1: startOtrSession

import net.java.otr4j.session.SessionID; //导入依赖的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

示例2: getLocalKeyPair

import net.java.otr4j.session.SessionID; //导入依赖的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

示例3: sendOtrErrorMessage

import net.java.otr4j.session.SessionID; //导入依赖的package包/类
public void sendOtrErrorMessage(SessionID session, String errorText) {
	try {
		Jid jid = Jid.fromSessionID(session);
		Conversation conversation = mXmppConnectionService.find(account, jid);
		String id = conversation == null ? null : conversation.getLastReceivedOtrMessageId();
		if (id != null) {
			MessagePacket packet = mXmppConnectionService.getMessageGenerator()
					.generateOtrError(jid, id, errorText);
			packet.setFrom(account.getJid());
			mXmppConnectionService.sendMessagePacket(account,packet);
			Log.d(Config.LOGTAG,packet.toString());
			Log.d(Config.LOGTAG,account.getJid().toBareJid().toString()
					+": unreadable OTR message in "+conversation.getName());
		}
	} catch (InvalidJidException e) {
		return;
	}
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:19,代码来源:OtrService.java

示例4: verify

import net.java.otr4j.session.SessionID; //导入依赖的package包/类
@Override
public void verify(SessionID id, String fingerprint, boolean approved) {
	Log.d(Config.LOGTAG,"OtrService.verify("+id.toString()+","+fingerprint+","+String.valueOf(approved)+")");
	try {
		final Jid jid = Jid.fromSessionID(id);
		Conversation conversation = this.mXmppConnectionService.find(this.account,jid);
		if (conversation!=null) {
			if (approved) {
				conversation.getContact().addOtrFingerprint(fingerprint);
			}
			conversation.smp().hint = null;
			conversation.smp().status = Conversation.Smp.STATUS_VERIFIED;
			mXmppConnectionService.updateConversationUi();
			mXmppConnectionService.syncRosterToDisk(conversation.getAccount());
		}
	} catch (final InvalidJidException ignored) {
	}
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:19,代码来源:OtrService.java

示例5: startOtrSession

import net.java.otr4j.session.SessionID; //导入依赖的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

示例6: sendOtrErrorMessage

import net.java.otr4j.session.SessionID; //导入依赖的package包/类
public void sendOtrErrorMessage(SessionID session, String errorText) {
    try {
        Jid jid = Jid.fromSessionID(session);
        Conversation conversation = mXmppConnectionService.find(account, jid);
        String id = conversation == null ? null : conversation.getLastReceivedOtrMessageId();
        if (id != null) {
            MessagePacket packet = mXmppConnectionService.getMessageGenerator()
                    .generateOtrError(jid, id, errorText);
            packet.setFrom(account.getJid());
            mXmppConnectionService.sendMessagePacket(account, packet);
            Log.d(Config.LOGTAG, packet.toString());
            Log.d(Config.LOGTAG, account.getJid().toBareJid().toString()
                    + ": unreadable OTR message in " + conversation.getName());
        }
    } catch (InvalidJidException e) {
        return;
    }
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:19,代码来源:OtrService.java

示例7: verify

import net.java.otr4j.session.SessionID; //导入依赖的package包/类
@Override
public void verify(SessionID id, String fingerprint, boolean approved) {
    Log.d(Config.LOGTAG, "OtrService.verify(" + id.toString() + "," + fingerprint + "," + String.valueOf(approved) + ")");
    try {
        final Jid jid = Jid.fromSessionID(id);
        Conversation conversation = this.mXmppConnectionService.find(this.account, jid);
        if (conversation != null) {
            if (approved) {
                conversation.getContact().addOtrFingerprint(fingerprint);
            }
            conversation.smp().hint = null;
            conversation.smp().status = Conversation.Smp.STATUS_VERIFIED;
            mXmppConnectionService.updateConversationUi();
            mXmppConnectionService.syncRosterToDisk(conversation.getAccount());
        }
    } catch (final InvalidJidException ignored) {
    }
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:19,代码来源:OtrService.java

示例8: sendDataAsync

import net.java.otr4j.session.SessionID; //导入依赖的package包/类
private void sendDataAsync (OtrChatManager cm, Message message, boolean isResponse, byte[] data)
{
    SessionID sId = cm.getSessionId(message.getFrom().getAddress(), message.getTo().getAddress());
    SessionStatus otrStatus = cm.getSessionStatus(sId);

    //can't send if not encrypted session
    if (otrStatus == SessionStatus.ENCRYPTED) {

        boolean verified = cm.getKeyManager().isVerified(sId);

        if (verified) {
            message.setType(Imps.MessageType.OUTGOING_ENCRYPTED_VERIFIED);
        } else {
            message.setType(Imps.MessageType.OUTGOING_ENCRYPTED);
        }

        boolean canSend = cm.transformSending(message, isResponse, data);

        if (canSend)
            mManager.sendMessageAsync(this, message);
    }


}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:25,代码来源:ChatSession.java

示例9: endSessionsForAccount

import net.java.otr4j.session.SessionID; //导入依赖的package包/类
public static void endSessionsForAccount(Contact localUserContact) {
    if (mInstance == null) {
        return;
    }
    String localUserId = localUserContact.getAddress().getBareAddress();
    
    Enumeration<String> sKeys = mInstance.mSessions.keys();
    
    while (sKeys.hasMoreElements())
    {
        String sKey = sKeys.nextElement();
        if (sKey.contains(localUserId))
        {
            SessionID sessionId = mInstance.mSessions.get(sKey);
            
            if (sessionId != null)
                mInstance.endSession(sessionId);
        }
    }
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:21,代码来源:OtrChatManager.java

示例10: savePublicKey

import net.java.otr4j.session.SessionID; //导入依赖的package包/类
public void savePublicKey(SessionID sessionID, PublicKey pubKey) {
    if (sessionID == null)
        return;

    X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(pubKey.getEncoded());

    String userID = sessionID.getRemoteUserId();

    byte[] keyEnc = x509EncodedKeySpec.getEncoded();
    String keyString = userID + ".publicKey";

    byte[] keyExisting = store.getPropertyBytes(keyString);

    if (keyExisting != null && (!Arrays.equals(keyEnc, keyExisting)))
    {
        store.removeProperty(userID + ".publicKey.verified"); //remove any verified state
        store.setProperty(userID + ".publicKey", keyEnc);
    }
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:20,代码来源:OtrKeyManagerDefaultImpl.java

示例11: generateLocalKeyPair

import net.java.otr4j.session.SessionID; //导入依赖的package包/类
public void generateLocalKeyPair(SessionID sessionID) {
    if (sessionID == null)
        return;

    String accountID = sessionID.getLocalUserId();
    KeyPair keyPair;
    try {
        keyPair = KeyPairGenerator.getInstance("DSA").genKeyPair();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
        return;
    }

    // Store Public Key.
    PublicKey pubKey = keyPair.getPublic();
    X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(pubKey.getEncoded());

    this.store.setProperty(accountID + ".publicKey", x509EncodedKeySpec.getEncoded());

    // Store Private Key.
    PrivateKey privKey = keyPair.getPrivate();
    PKCS8EncodedKeySpec pkcs8EncodedKeySpec = new PKCS8EncodedKeySpec(privKey.getEncoded());

    this.store.setProperty(accountID + ".privateKey", pkcs8EncodedKeySpec.getEncoded());

}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:27,代码来源:OtrKeyManagerDefaultImpl.java

示例12: injectMessage

import net.java.otr4j.session.SessionID; //导入依赖的package包/类
public void injectMessage(SessionID sessionID, String msg) throws OtrException {

		    try {
                main.sendMessage(sessionID.getUserID(), msg);
                logger.finest("IM injects message: " + msg);
            }
            catch (Exception e)
            {
                logger.finest("IM sending error: " + e);
            }


		}
 
开发者ID:zom,项目名称:zombot-java,代码行数:14,代码来源:OtrEngineHostImpl.java

示例13: getLocalKeyPair

import net.java.otr4j.session.SessionID; //导入依赖的package包/类
public KeyPair getLocalKeyPair(SessionID paramSessionID) {
    KeyPair keypair = this.keypairs.get(paramSessionID);
    if (keypair == null) {
        try {
            KeyPairGenerator kg = KeyPairGenerator.getInstance("DSA");
            keypair = kg.genKeyPair();
            this.keypairs.put(paramSessionID, keypair);
        } catch (NoSuchAlgorithmException e) {
            logger.severe(e.getMessage());
        }
    }
    return keypair;
}
 
开发者ID:zom,项目名称:zombot-java,代码行数:14,代码来源:OtrEngineHostImpl.java

示例14: getLocalFingerprintRaw

import net.java.otr4j.session.SessionID; //导入依赖的package包/类
public byte[] getLocalFingerprintRaw(SessionID sessionID) {
	try {
		return OtrCryptoEngine.getFingerprintRaw(getLocalKeyPair(sessionID)
						.getPublic());
	} catch (OtrCryptoException e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:zom,项目名称:zombot-java,代码行数:10,代码来源:OtrEngineHostImpl.java

示例15: onOtrSessionEstablished

import net.java.otr4j.session.SessionID; //导入依赖的package包/类
public void onOtrSessionEstablished(Conversation conversation) {
	final Account account = conversation.getAccount();
	final Session otrSession = conversation.getOtrSession();
	Log.d(Config.LOGTAG,
			account.getJid().toBareJid() + " otr session established with "
					+ conversation.getJid() + "/"
					+ otrSession.getSessionID().getUserID());
	conversation.findUnsentMessagesWithEncryption(Message.ENCRYPTION_OTR, new Conversation.OnMessageFound() {

		@Override
		public void onMessageFound(Message message) {
			SessionID id = otrSession.getSessionID();
			try {
				message.setCounterpart(Jid.fromString(id.getAccountID() + "/" + id.getUserID()));
			} catch (InvalidJidException e) {
				return;
			}
			if (message.needsUploading()) {
				mJingleConnectionManager.createNewConnection(message);
			} else {
				MessagePacket outPacket = mMessageGenerator.generateOtrChat(message);
				if (outPacket != null) {
					mMessageGenerator.addDelay(outPacket, message.getTimeSent());
					message.setStatus(Message.STATUS_SEND);
					databaseBackend.updateMessage(message);
					sendMessagePacket(account, outPacket);
				}
			}
			updateConversationUi();
		}
	});
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:33,代码来源:XmppConnectionService.java


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