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


Java Session类代码示例

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


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

示例1: generateOtrChat

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

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

示例3: initSmp

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

示例4: abortSmp

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

示例5: generateOtrChat

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

示例6: generateOtrChat

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

示例7: renewSymmetricKey

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

示例8: initSmp

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

示例9: abortSmp

import net.java.otr4j.session.Session; //导入依赖的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:kriztan,项目名称:Pix-Art-Messenger,代码行数:17,代码来源:VerifyOTRActivity.java

示例10: renewSymmetricKey

import net.java.otr4j.session.Session; //导入依赖的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());
		packet.addChild("private", "urn:xmpp:carbons:2");
		packet.addChild("no-copy", "urn:xmpp:hints");
		packet.setAttribute("to", otrSession.getSessionID().getAccountID() + "/"
				+ otrSession.getSessionID().getUserID());
		try {
			packet.setBody(otrSession
					.transformSending(CryptoHelper.FILETRANSFER
						+ CryptoHelper.bytesToHex(symmetricKey)));
			sendMessagePacket(account, packet);
			conversation.setSymmetricKey(symmetricKey);
			return true;
		} catch (OtrException e) {
			return false;
		}
	}
	return false;
}
 
开发者ID:juanignaciomolina,项目名称:txtr,代码行数:27,代码来源:XmppConnectionService.java

示例11: renewSymmetricKey

import net.java.otr4j.session.Session; //导入依赖的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.getFullJid());
		packet.addChild("private", "urn:xmpp:carbons:2");
		packet.addChild("no-copy", "urn:xmpp:hints");
		packet.setTo(otrSession.getSessionID().getAccountID() + "/"
				+ otrSession.getSessionID().getUserID());
		try {
			packet.setBody(otrSession
					.transformSending(CryptoHelper.FILETRANSFER
							+ CryptoHelper.bytesToHex(symmetricKey)));
			account.getXmppConnection().sendMessagePacket(packet);
			conversation.setSymmetricKey(symmetricKey);
			return true;
		} catch (OtrException e) {
			return false;
		}
	}
	return false;
}
 
开发者ID:GitESS,项目名称:SyncChatAndroid,代码行数:27,代码来源:XmppConnectionService.java

示例12: onOtrSessionEstablished

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

示例13: respondSmp

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

示例14: onOtrSessionEstablished

import net.java.otr4j.session.Session; //导入依赖的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:kriztan,项目名称:Pix-Art-Messenger,代码行数:33,代码来源:XmppConnectionService.java

示例15: respondSmp

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


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