Last active
December 15, 2017 15:32
-
-
Save communikein/33ad7767ac46ebc76d666f9f209c90ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.text.TextUtils; | |
import android.util.Base64; | |
import android.util.SparseArray; | |
import org.json.JSONArray; | |
import org.json.JSONException; | |
import org.json.JSONObject; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
public class User { | |
private String mUsername; | |
private String mPassword; | |
private String mAuthToken; | |
private String mSessionId; | |
public User(String username, String password) { | |
setPassword(password); | |
setUsername(username); | |
setAuthToken(username, password); | |
setSessionID(null); | |
} | |
public String getUsername() { | |
return mUsername; | |
} | |
public void setUsername(String username) { | |
if (username != null) this.mUsername = username; | |
else this.mUsername = ""; | |
} | |
public String getPassword() { | |
return mPassword; | |
} | |
public void setPassword(String password) { | |
if (password != null) this.mPassword = password; | |
else this.mPassword = ""; | |
} | |
private void setAuthToken(String username, String password) { | |
if (username.isEmpty() || password.isEmpty()) this.mAuthToken = null; | |
String authString = username + ":" + password; | |
byte[] authEncBytes = Base64.encode(authString.getBytes(), Base64.NO_WRAP); | |
this.mAuthToken = new String(authEncBytes); | |
} | |
public String getAuthToken() { | |
return mAuthToken; | |
} | |
public String getSessionID() { | |
return mSessionId; | |
} | |
public void setSessionID(String sessionID) { | |
if (sessionID != null) this.mSessionId = sessionID; | |
else this.mSessionId = ""; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment