added placeholder proxy to AddKeyServer

This commit is contained in:
Adithya Abraham Philip
2015-06-07 22:08:08 +05:30
parent 731ec3382e
commit 413536c62b
2 changed files with 23 additions and 7 deletions

View File

@@ -100,8 +100,7 @@ public class ImportKeysListCloudLoader
*/ */
private void queryServer(boolean enforceFingerprint) { private void queryServer(boolean enforceFingerprint) {
try { try {
ArrayList<ImportKeysListEntry> searchResult ArrayList<ImportKeysListEntry> searchResult = CloudSearch.search(mServerQuery, mCloudPrefs, mProxy);
= CloudSearch.search(mServerQuery, mCloudPrefs, mProxy);
mEntryList.clear(); mEntryList.clear();
// add result to data // add result to data

View File

@@ -48,11 +48,26 @@ import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener; import android.widget.TextView.OnEditorActionListener;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.keyimport.HkpKeyserver;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.TlsHelper; import org.sufficientlysecure.keychain.util.TlsHelper;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import java.io.IOException;
import java.net.*;
import javax.net.ssl.HttpsURLConnection;
public class AddEditKeyserverDialogFragment extends DialogFragment implements OnEditorActionListener { public class AddEditKeyserverDialogFragment extends DialogFragment implements OnEditorActionListener {
private static final String ARG_MESSENGER = "arg_messenger"; private static final String ARG_MESSENGER = "arg_messenger";
private static final String ARG_ACTION = "arg_dialog_action"; private static final String ARG_ACTION = "arg_dialog_action";
@@ -207,7 +222,8 @@ public class AddEditKeyserverDialogFragment extends DialogFragment implements On
// behaviour same for edit and add // behaviour same for edit and add
String keyserverUrl = mKeyserverEditText.getText().toString(); String keyserverUrl = mKeyserverEditText.getText().toString();
if (mVerifyKeyserverCheckBox.isChecked()) { if (mVerifyKeyserverCheckBox.isChecked()) {
verifyConnection(keyserverUrl); // TODO: PHILIP Implement proxy
verifyConnection(keyserverUrl, null);
} else { } else {
dismiss(); dismiss();
// return unverified keyserver back to activity // return unverified keyserver back to activity
@@ -249,7 +265,7 @@ public class AddEditKeyserverDialogFragment extends DialogFragment implements On
sendMessageToHandler(MESSAGE_VERIFICATION_FAILED, data); sendMessageToHandler(MESSAGE_VERIFICATION_FAILED, data);
} }
public void verifyConnection(String keyserver) { public void verifyConnection(String keyserver, final Proxy proxy) {
new AsyncTask<String, Void, FailureReason>() { new AsyncTask<String, Void, FailureReason>() {
ProgressDialog mProgressDialog; ProgressDialog mProgressDialog;
@@ -283,10 +299,11 @@ public class AddEditKeyserverDialogFragment extends DialogFragment implements On
} }
URI newKeyserver = new URI(scheme, schemeSpecificPart, fragment); URI newKeyserver = new URI(scheme, schemeSpecificPart, fragment);
Log.d(Constants.TAG, "Converted URL" + newKeyserver); Log.d("Converted URL", newKeyserver.toString());
// just see if we can get a connection, then immediately close OkHttpClient client = HkpKeyserver.getClient(newKeyserver.toURL(), proxy);
TlsHelper.openConnection(newKeyserver.toURL()).getInputStream().close(); TlsHelper.pinCertificateIfNecessary(client, newKeyserver.toURL());
client.newCall(new Request.Builder().url(newKeyserver.toURL()).build()).execute();
} catch (TlsHelper.TlsHelperException e) { } catch (TlsHelper.TlsHelperException e) {
reason = FailureReason.CONNECTION_FAILED; reason = FailureReason.CONNECTION_FAILED;
} catch (MalformedURLException | URISyntaxException e) { } catch (MalformedURLException | URISyntaxException e) {