本文整理汇总了Java中net.java.otr4j.OtrPolicyImpl类的典型用法代码示例。如果您正苦于以下问题:Java OtrPolicyImpl类的具体用法?Java OtrPolicyImpl怎么用?Java OtrPolicyImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OtrPolicyImpl类属于net.java.otr4j包,在下文中一共展示了OtrPolicyImpl类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: OtrService
import net.java.otr4j.OtrPolicyImpl; //导入依赖的package包/类
public OtrService(XmppConnectionService service, Account account) {
this.account = account;
this.otrPolicy = new OtrPolicyImpl();
this.otrPolicy.setAllowV1(false);
this.otrPolicy.setAllowV2(true);
this.otrPolicy.setAllowV3(true);
this.keyPair = loadKey(account.getKeys());
this.mXmppConnectionService = service;
}
示例2: newSession
import net.java.otr4j.OtrPolicyImpl; //导入依赖的package包/类
@Override
public Send<Bytestring> newSession(Session<Address, Bytestring> session) throws InterruptedException {
final SessionID sessionID = new SessionID("", "", "");
OtrPolicy policy = new OtrPolicyImpl(OtrPolicy.ALLOW_V2 | OtrPolicy.ALLOW_V3
| OtrPolicy.ERROR_START_AKE); // this assumes the user wants either v2 or v3
SessionImpl sessionImpl = new SessionImpl(sessionID, new SendOtrEngineHost(policy, session));
return new OtrSendBob(this.l, session, sessionImpl);
}
示例3: openSession
import net.java.otr4j.OtrPolicyImpl; //导入依赖的package包/类
/**
* The openSession() method starts the OTR protocol. It creates a BasicChan object
* that is passed into OtrSendAlice and when the key exchange is complete, this Chan
* "chan" is notified and an OtrSession object is returned. We also create a SessionImpl
* object for handling messages and pass that into both our OtrSendAlice object and the
* returned OtrSession object. To start the actual protocol, a specific string needs to
* be crafted. In our implementation, we used "?OTRv23?" which means we are initializing
* OTR version 3, with version 2 as a backup if version 3 is not available. Other protocol
* strings are possible. We then call chan.receive(), and when the key exchange in
* OtrSendAlice returns, we check to see if the key exchange was successful or not.
* If it is, we return a new OtrSession object. Else, we shut everything down.
*
* Note: The OtrPolicy variable allows OTRv2 and OTRv3. This can be changed if the user
* desires different versions of OTR.
*/
@Override
public synchronized OtrSession openSession(Send<Bytestring> send) throws InterruptedException, IOException {
if (send == null) throw new NullPointerException();
Chan<Boolean> chan = new BasicChan<>(1);
final SessionID sessionID = new SessionID("", "", "");
OtrPolicy policy = new OtrPolicyImpl(OtrPolicy.ALLOW_V2 | OtrPolicy.ALLOW_V3
| OtrPolicy.ERROR_START_AKE); // this assumes the user wants either v2 or v3
SendOtrEngineHost otrEngineHost = new SendOtrEngineHost(policy);
SessionImpl sessionImpl = new SessionImpl(sessionID, otrEngineHost);
OtrSendAlice alice = new OtrSendAlice(send, chan, sessionImpl);
Session<Address, Bytestring> session = peer.openSession(alice);
if (session == null) return null;
otrEngineHost.setSession(session);
// This string depends on the version / type of OTR encryption that the user wants.
String query = "?OTRv23?";
session.send(new Bytestring(query.getBytes()));
/**
* Waiting for the final OTR initialization message from Bob.
*/
Boolean result = chan.receive();
if (result == null || !result) {
chan.close();
session.close();
return null;
}
return new OtrSession(session, sessionImpl);
}
示例4: OtrService
import net.java.otr4j.OtrPolicyImpl; //导入依赖的package包/类
public OtrService(XmppConnectionService service, Account account) {
this.account = account;
this.otrPolicy = new OtrPolicyImpl();
this.otrPolicy.setAllowV1(false);
this.otrPolicy.setAllowV2(true);
this.otrPolicy.setAllowV3(true);
this.keyPair = loadKey(account.getKeys());
this.mXmppConnectionService = service;
}
示例5: OtrEngine
import net.java.otr4j.OtrPolicyImpl; //导入依赖的package包/类
public OtrEngine(XmppConnectionService service, Account account) {
this.account = account;
this.otrPolicy = new OtrPolicyImpl();
this.otrPolicy.setAllowV1(false);
this.otrPolicy.setAllowV2(true);
this.otrPolicy.setAllowV3(true);
this.keyPair = loadKey(account.getKeys());
this.mXmppConnectionService = service;
}
示例6: OtrEngine
import net.java.otr4j.OtrPolicyImpl; //导入依赖的package包/类
public OtrEngine(Context context, Account account) {
this.account = account;
this.otrPolicy = new OtrPolicyImpl();
this.otrPolicy.setAllowV1(false);
this.otrPolicy.setAllowV2(true);
this.otrPolicy.setAllowV3(true);
this.keyPair = loadKey(account.getKeys());
}
示例7: OTRSession
import net.java.otr4j.OtrPolicyImpl; //导入依赖的package包/类
/**
* OTRSession Constructor
*
* @param chatroom
* chat room related to this OTR session
* @param myJID
* my own JID
* @param remoteJID
* the JID of the participant
*/
public OTRSession(ChatRoomImpl chatroom, String myJID, String remoteJID) {
_chatRoom = chatroom;
_myJID = myJID;
_remoteJID = remoteJID;
_otrEngineHost = new OTREngineHost(new OtrPolicyImpl(OtrPolicy.ALLOW_V2 | OtrPolicy.ERROR_START_AKE), _chatRoom);
_mySession = new SessionID(_myJID, _remoteJID, "Scytale");
_engine = new OtrEngineImpl(_otrEngineHost);
setUpMessageListener();
createButton();
// Only initialize the actionListener once
_otrButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (_engine.getSessionStatus(_mySession).equals(SessionStatus.ENCRYPTED)) {
stopSession();
} else {
startSession();
}
}
});
_otrButton.setToolTipText(OTRResources.getString("otr.chat.button.tooltip"));
_OtrEnabled = OTRProperties.getInstance().getIsOTREnabled();
}
示例8: OtrChatManager
import net.java.otr4j.OtrPolicyImpl; //导入依赖的package包/类
private OtrChatManager(int otrPolicy, RemoteImService imService, OtrAndroidKeyManagerImpl otrKeyManager) throws Exception {
mContext = (Context)imService;
mOtrEngineHost = new OtrEngineHostImpl(new OtrPolicyImpl(otrPolicy),
mContext, otrKeyManager, imService);
mOtrEngine = new OtrEngineImpl(mOtrEngineHost);
mOtrEngine.addOtrEngineListener(this);
mSessions = new Hashtable<String, SessionID>();
mOtrSms = new Hashtable<String, OtrSm>();
// Use the Application-managed PushManager which has a push account already authenticated
mApp = ((ImApp)mContext.getApplicationContext());
}
示例9: setPolicy
import net.java.otr4j.OtrPolicyImpl; //导入依赖的package包/类
public void setPolicy(int otrPolicy) {
mOtrEngineHost.setSessionPolicy(new OtrPolicyImpl(otrPolicy));
}
示例10: OtrChatManager
import net.java.otr4j.OtrPolicyImpl; //导入依赖的package包/类
private OtrChatManager(int otrPolicy, ImService context, OtrKeyManager otrKeyManager) throws Exception {
mOtrEngineHost = new OtrEngineHostImpl(new OtrPolicyImpl(otrPolicy),
context, otrKeyManager);
mOtrEngine = new OtrEngineImpl(mOtrEngineHost);
mOtrEngine.addOtrEngineListener(this);
mSessions = new Hashtable<String, SessionID>();
mOtrSms = new Hashtable<SessionID, OtrSm>();
mContext = context;
mOtrKeyManager = otrKeyManager;
}