Android Open Source - schat Public Key Response






From Project

Back to project page schat.

License

The source code is released under:

MIT License

If you think the Android project schat 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 data.contents;
/*from   ww w . j  ava 2  s  .c  om*/
import crypto.Cryptography;
import data.Content;

import java.security.PublicKey;

/**
 * @author Gary Ye
 * @version 12/1/13
 */
public class PublicKeyResponse extends Content {
    private String requestId;
    private byte[] publicKey;

    /**
     * Constructs a public key response, which will be sent back
     * from the server as a response of the PublicKeyRequest
     *
     * @param requestId the id of the requested user
     * @param publicKey the public key of the requested user
     */
    public PublicKeyResponse(String requestId, PublicKey publicKey) {
        this.type = Type.PUBLIC_KEY_RESPONSE;
        this.requestId = requestId;
        this.publicKey = publicKey.getEncoded();
    }

    /**
     * @return the string
     */
    @Override
    public String toString() {
        return "Public key of " + requestId + " is inside";
    }

    /**
     * Returns the request id
     *
     * @return the request id
     */
    public String getRequestId() {
        return requestId;
    }

    /**
     * Return the public key
     *
     * @return the public key
     */
    public PublicKey getPublicKey() {
        return Cryptography.getPublicKeyFromBytes(publicKey);
    }

    /**
     * Return if the user exists
     *
     * @return whether the user exists or not
     */
    boolean userNotExisting() {
        return publicKey == null;
    }
}




Java Source Code List

.ServerMain.java
com.activities.Activity_Chat.java
com.activities.Activity_ContactList.java
com.activities.ContactView.java
com.data.AddContact.java
com.data.AndroidSQLManager.java
com.data.ApplicationUser.java
com.data.ChatAdapter.java
com.data.ChatArrayList.java
com.data.MySQLiteHelper.java
com.security.AndroidKeyPairManager.java
com.security.PRNGFixes.java
com.services.MessageService.java
crypto.CryptoConstants.java
crypto.Cryptography.java
crypto.Envelope.java
crypto.SecureMessage.java
crypto.TestCrypto.java
data.ChatMessage.java
data.Content.java
data.DatabaseManager.java
data.KeyPairManager.java
data.Message.java
data.SQLiteManager.java
data.User.java
data.contents.ChatContent.java
data.contents.LoginSuccess.java
data.contents.Login.java
data.contents.PublicKeyRequest.java
data.contents.PublicKeyResponse.java
data.contents.Registration.java
networking.SChatClientListener.java
networking.SChatClientWriter.java
networking.SChatClient.java
networking.SChatServerThread.java
networking.SChatServer.java