Search in sources :

Example 1 with Fingerprint

use of org.matrix.androidsdk.ssl.Fingerprint in project matrix-android-sdk by matrix-org.

the class HomeServerConnectionConfig method toJson.

/**
 * Convert the object instance into a JSon object
 *
 * @return the JSon representation
 * @throws JSONException the JSON conversion failure reason
 */
public JSONObject toJson() throws JSONException {
    JSONObject json = new JSONObject();
    json.put("home_server_url", mHomeServerUri.toString());
    Uri jitsiServerUri = getJitsiServerUri();
    if (jitsiServerUri != null) {
        json.put("jitsi_server_url", jitsiServerUri.toString());
    }
    Uri identityServerUri = getIdentityServerUri();
    if (identityServerUri != null) {
        json.put("identity_server_url", identityServerUri.toString());
    }
    if (mAntiVirusServerUri != null) {
        json.put("antivirus_server_url", mAntiVirusServerUri.toString());
    }
    json.put("pin", mPin);
    if (mCredentials != null)
        json.put("credentials", mCredentials.toJson());
    if (mAllowedFingerprints != null) {
        List<JSONObject> fingerprints = new ArrayList<>(mAllowedFingerprints.size());
        for (Fingerprint fingerprint : mAllowedFingerprints) {
            fingerprints.add(fingerprint.toJson());
        }
        json.put("fingerprints", new JSONArray(fingerprints));
    }
    json.put("tls_extensions", mShouldAcceptTlsExtensions);
    if (mTlsVersions != null) {
        List<String> tlsVersions = new ArrayList<>(mTlsVersions.size());
        for (TlsVersion tlsVersion : mTlsVersions) {
            tlsVersions.add(tlsVersion.javaName());
        }
        json.put("tls_versions", new JSONArray(tlsVersions));
    }
    json.put("force_usage_of_tls_versions", mForceUsageTlsVersions);
    if (mTlsCipherSuites != null) {
        List<String> tlsCipherSuites = new ArrayList<>(mTlsCipherSuites.size());
        for (CipherSuite tlsCipherSuite : mTlsCipherSuites) {
            tlsCipherSuites.add(tlsCipherSuite.javaName());
        }
        json.put("tls_cipher_suites", new JSONArray(tlsCipherSuites));
    }
    if (mProxyPort != -1) {
        json.put("proxy_port", mProxyPort);
    }
    if (mProxyHostname != null && mProxyHostname.length() > 0) {
        json.put("proxy_hostname", mProxyHostname);
    }
    return json;
}
Also used : TlsVersion(okhttp3.TlsVersion) Fingerprint(org.matrix.androidsdk.ssl.Fingerprint) JSONObject(org.json.JSONObject) CipherSuite(okhttp3.CipherSuite) ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) Uri(android.net.Uri)

Aggregations

Uri (android.net.Uri)1 ArrayList (java.util.ArrayList)1 CipherSuite (okhttp3.CipherSuite)1 TlsVersion (okhttp3.TlsVersion)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1 Fingerprint (org.matrix.androidsdk.ssl.Fingerprint)1