You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LuDataAccessConfigDbo.java 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package com.luticate.utils.dbo;
  2. import android.util.Base64;
  3. import org.json.JSONException;
  4. import org.json.JSONObject;
  5. import java.util.HashMap;
  6. import java.util.Map;
  7. /**
  8. *
  9. * Created by robin on 11/28/15.
  10. */
  11. public class LuDataAccessConfigDbo extends LuDbo {
  12. protected String _baseUrl;
  13. protected String _httpUsername;
  14. protected String _httpPassword;
  15. public String getBaseUrl() {
  16. return _baseUrl;
  17. }
  18. public void setBaseUrl(String baseUrl) {
  19. _baseUrl = baseUrl;
  20. }
  21. public String getHttpUsername() {
  22. return _httpUsername;
  23. }
  24. public void setHttpUsername(String httpUsername) {
  25. _httpUsername = httpUsername;
  26. }
  27. public String getHttpPassword() {
  28. return _httpPassword;
  29. }
  30. public void setHttpPassword(String httpPassword) {
  31. _httpPassword = httpPassword;
  32. }
  33. public Map<String, String> getHeaders()
  34. {
  35. Map<String, String> map = new HashMap<>();
  36. if (_httpUsername != null) {
  37. map.put("Authorization", "Basic " + Base64.encodeToString(
  38. String.format("%s:%s", _httpUsername, _httpPassword).getBytes(), Base64.DEFAULT));
  39. }
  40. return map;
  41. }
  42. @Override
  43. public void fromJson(JSONObject json) throws JSONException {
  44. _baseUrl = json.getString("baseURL");
  45. if (!json.isNull("httpUsername")) {
  46. _httpUsername = json.getString("httpUsername");
  47. _httpPassword = json.getString("httpPassword");
  48. }
  49. else {
  50. _httpUsername = null;
  51. _httpPassword = null;
  52. }
  53. }
  54. @Override
  55. public HashMap<String, Object> toArray() {
  56. return null;
  57. }
  58. }