Android Open Source - CipherChat Chat Activity Runnable






From Project

Back to project page CipherChat.

License

The source code is released under:

MIT License

If you think the Android project CipherChat listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ist.cipherchat.networking;
/*from www .j  av  a  2 s  .c o m*/
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.StreamCorruptedException;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

import android.util.Log;

import com.ist.cipherchat.gui.ChatActivity;

public class ChatActivityRunnable implements Runnable {

  public String thisUsername;
  private String otherUsername;
  private CyclicBarrier barrier;

  /** Unsecured socket for 'other' (B in the Needham-Shroeder protocol) */
  public static OutputSocketHandler thisSocket;

  public ChatActivity activity;

  public ChatActivityRunnable(CyclicBarrier barrier, String thisUsername, String otherUsername, ChatActivity activity) {
    this.thisUsername = thisUsername;
    this.otherUsername = otherUsername;
    this.activity = activity;
    this.barrier = barrier;
  }

  @Override
  public void run() {

    thisSocket = new OutputSocketHandler(thisUsername, otherUsername);

    // Ask KDC for IP for the other user
    if (!thisSocket.askOtherIp()) {
      // TODO GO BACK TO PREV ACTIVITY
      Log.d("register", ":( NO IP!!!");
      this.activity.finish();

    }

    // Open socket to the IP address gotten from the KDC
    if (!thisSocket.openSocket()) {
      // TODO GO BACK TO PREV ACTIVITY
      Log.d("register", "SOCK NOT OPENED!");
      this.activity.finish();
    }

    Log.d("register", "Socket opened with user " + otherUsername);

    // From here on, the Needham-Shroeder protocol in run

    // 1 and 2
    if (!thisSocket.sendStartMessage()) {
      this.activity.finish();

    }

    // 3 and 4
    if (!thisSocket.sessionKeyEnquiry()) {

      this.activity.finish();
    }

    // 5, 6, 7 and 8
    if (!thisSocket.connectToOther()) {

      this.activity.finish();
    }

    Log.d("register", "User A finished NS.");


    try {
      barrier.await();
    } catch (InterruptedException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    } catch (BrokenBarrierException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    

    
    Thread t = new Thread(new ChatInRunnable());
    t.start();
  }
}




Java Source Code List

com.desperate.AdminConsole.java
com.desperate.ClientHandler.java
com.desperate.CryptoServer.java
com.desperate.UserDatabase.java
com.desperate.User.java
com.desperate.common.Message.java
com.desperate.common.NoncePacket.java
com.desperate.common.SessionKeyRequestInfo.java
com.desperate.common.TestCipherSerializable.java
com.desperate.common.Utilities.java
com.desperate.common.messages.ChatMessage.java
com.desperate.common.messages.IPMessage.java
com.desperate.common.messages.LoginMessage.java
com.desperate.common.messages.LogoutMessage.java
com.desperate.common.messages.RegisterMessage.java
com.desperate.common.messages.SessionKeyRequestMessage.java
com.desperate.common.messages.StartChatMessage.java
com.desperate.common.messages.UserListMessage.java
com.desperate.common.replies.CheckSessionMessage.java
com.desperate.common.replies.IPReplyMessage.java
com.desperate.common.replies.LoginReplyMessage.java
com.desperate.common.replies.LogoutReplyMessage.java
com.desperate.common.replies.NeedhamSchroederSuccessReply.java
com.desperate.common.replies.RegisterReplyMessage.java
com.desperate.common.replies.ReplyMessage.java
com.desperate.common.replies.SessionKeyReplyMessage.java
com.desperate.common.replies.StartChatReply.java
com.desperate.common.replies.UserListReplyMessage.java
com.desperate.debug.DebugClient.java
com.desperate.debug.DebugCryptoClient.java
com.desperate.debug.PlainServer.java
com.ist.cipherchat.gui.ChatActivity.java
com.ist.cipherchat.gui.ChooseServerActivity.java
com.ist.cipherchat.gui.Contacts.java
com.ist.cipherchat.gui.Origin.java
com.ist.cipherchat.networking.ChatActivityRunnable.java
com.ist.cipherchat.networking.ChatInRunnable.java
com.ist.cipherchat.networking.ChatOutHandler.java
com.ist.cipherchat.networking.Core.java
com.ist.cipherchat.networking.Globals.java
com.ist.cipherchat.networking.OutputSocketHandler.java
com.ist.cipherchat.networking.PhoneServerSocketHandler.java
com.ist.cipherchat.networking.ThreadComm.java