1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package com.luticate.utils.dbo;
-
- import android.util.Base64;
-
- import org.json.JSONException;
- import org.json.JSONObject;
-
- import java.util.HashMap;
- import java.util.Map;
-
- /**
- *
- * Created by robin on 11/28/15.
- */
- public class LuDataAccessConfigDbo extends LuDbo {
-
- protected String _baseUrl;
-
- protected String _httpUsername;
-
- protected String _httpPassword;
-
- public String getBaseUrl() {
- return _baseUrl;
- }
-
- public void setBaseUrl(String baseUrl) {
- _baseUrl = baseUrl;
- }
-
- public String getHttpUsername() {
- return _httpUsername;
- }
-
- public void setHttpUsername(String httpUsername) {
- _httpUsername = httpUsername;
- }
-
- public String getHttpPassword() {
- return _httpPassword;
- }
-
- public void setHttpPassword(String httpPassword) {
- _httpPassword = httpPassword;
- }
-
- public Map<String, String> getHeaders()
- {
- Map<String, String> map = new HashMap<>();
- if (_httpUsername != null) {
- map.put("Authorization", "Basic " + Base64.encodeToString(
- String.format("%s:%s", _httpUsername, _httpPassword).getBytes(), Base64.DEFAULT));
- }
- return map;
- }
-
- @Override
- public void fromJson(JSONObject json) throws JSONException {
- _baseUrl = json.getString("baseURL");
- if (!json.isNull("httpUsername")) {
- _httpUsername = json.getString("httpUsername");
- _httpPassword = json.getString("httpPassword");
- }
- else {
- _httpUsername = null;
- _httpPassword = null;
- }
- }
-
- @Override
- public HashMap<String, Object> toArray() {
- return null;
- }
- }
|