Rename KeyServer to Keyserver

This commit is contained in:
Dominik Schürmann 2014-05-18 23:06:50 +02:00
parent 9025de2b74
commit 19072824ba
9 changed files with 34 additions and 38 deletions

View File

@ -52,7 +52,7 @@ import java.util.TimeZone;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public class HkpKeyServer extends KeyServer { public class HkpKeyserver extends Keyserver {
private static class HttpError extends Exception { private static class HttpError extends Exception {
private static final long serialVersionUID = 1718783705229428893L; private static final long serialVersionUID = 1718783705229428893L;
private int mCode; private int mCode;
@ -148,7 +148,7 @@ public class HkpKeyServer extends KeyServer {
* connect using {@link #PORT_DEFAULT}. However, port may be specified after colon * connect using {@link #PORT_DEFAULT}. However, port may be specified after colon
* ("<code>hostname:port</code>", eg. "<code>p80.pool.sks-keyservers.net:80</code>"). * ("<code>hostname:port</code>", eg. "<code>p80.pool.sks-keyservers.net:80</code>").
*/ */
public HkpKeyServer(String hostAndPort) { public HkpKeyserver(String hostAndPort) {
String host = hostAndPort; String host = hostAndPort;
short port = PORT_DEFAULT; short port = PORT_DEFAULT;
final int colonPosition = hostAndPort.lastIndexOf(':'); final int colonPosition = hostAndPort.lastIndexOf(':');
@ -161,7 +161,7 @@ public class HkpKeyServer extends KeyServer {
mPort = port; mPort = port;
} }
public HkpKeyServer(String host, short port) { public HkpKeyserver(String host, short port) {
mHost = host; mHost = host;
mPort = port; mPort = port;
} }

View File

@ -29,11 +29,8 @@ import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.TimeZone;
import java.util.WeakHashMap;
public class KeybaseKeyServer extends KeyServer { public class KeybaseKeyserver extends Keyserver {
@Override @Override
public ArrayList<ImportKeysListEntry> search(String query) throws QueryException, TooManyResponses, public ArrayList<ImportKeysListEntry> search(String query) throws QueryException, TooManyResponses,

View File

@ -23,7 +23,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.List; import java.util.List;
public abstract class KeyServer { public abstract class Keyserver {
public static class QueryException extends Exception { public static class QueryException extends Exception {
private static final long serialVersionUID = 2703768928624654512L; private static final long serialVersionUID = 2703768928624654512L;

View File

@ -36,9 +36,9 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry; import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
import org.sufficientlysecure.keychain.keyimport.HkpKeyServer; import org.sufficientlysecure.keychain.keyimport.HkpKeyserver;
import org.sufficientlysecure.keychain.util.IterableIterator; import org.sufficientlysecure.keychain.util.IterableIterator;
import org.sufficientlysecure.keychain.keyimport.KeyServer.AddKeyException; import org.sufficientlysecure.keychain.keyimport.Keyserver.AddKeyException;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -100,7 +100,7 @@ public class PgpImportExport {
} }
} }
public boolean uploadKeyRingToServer(HkpKeyServer server, PGPPublicKeyRing keyring) { public boolean uploadKeyRingToServer(HkpKeyserver server, PGPPublicKeyRing keyring) {
ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream();
ArmoredOutputStream aos = null; ArmoredOutputStream aos = null;
try { try {

View File

@ -39,6 +39,7 @@ import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.FileHelper; import org.sufficientlysecure.keychain.helper.FileHelper;
import org.sufficientlysecure.keychain.helper.OtherHelper; import org.sufficientlysecure.keychain.helper.OtherHelper;
import org.sufficientlysecure.keychain.helper.Preferences; import org.sufficientlysecure.keychain.helper.Preferences;
import org.sufficientlysecure.keychain.keyimport.HkpKeyserver;
import org.sufficientlysecure.keychain.pgp.PgpConversionHelper; import org.sufficientlysecure.keychain.pgp.PgpConversionHelper;
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify; import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify;
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult; import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult;
@ -54,9 +55,8 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.KeychainDatabase; import org.sufficientlysecure.keychain.provider.KeychainDatabase;
import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry; import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
import org.sufficientlysecure.keychain.keyimport.HkpKeyServer;
import org.sufficientlysecure.keychain.util.InputData; import org.sufficientlysecure.keychain.util.InputData;
import org.sufficientlysecure.keychain.keyimport.KeybaseKeyServer; import org.sufficientlysecure.keychain.keyimport.KeybaseKeyserver;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.ProgressScaler; import org.sufficientlysecure.keychain.util.ProgressScaler;
@ -724,7 +724,7 @@ public class KeychainIntentService extends IntentService
// and dataUri! // and dataUri!
/* Operation */ /* Operation */
HkpKeyServer server = new HkpKeyServer(keyServer); HkpKeyserver server = new HkpKeyserver(keyServer);
ProviderHelper providerHelper = new ProviderHelper(this); ProviderHelper providerHelper = new ProviderHelper(this);
PGPPublicKeyRing keyring = (PGPPublicKeyRing) providerHelper.getPGPKeyRing(dataUri); PGPPublicKeyRing keyring = (PGPPublicKeyRing) providerHelper.getPGPKeyRing(dataUri);
@ -746,7 +746,7 @@ public class KeychainIntentService extends IntentService
ArrayList<ImportKeysListEntry> entries = data.getParcelableArrayList(DOWNLOAD_KEY_LIST); ArrayList<ImportKeysListEntry> entries = data.getParcelableArrayList(DOWNLOAD_KEY_LIST);
try { try {
KeybaseKeyServer server = new KeybaseKeyServer(); KeybaseKeyserver server = new KeybaseKeyserver();
for (ImportKeysListEntry entry : entries) { for (ImportKeysListEntry entry : entries) {
// the keybase handle is in userId(1) // the keybase handle is in userId(1)
String keybaseId = entry.getExtraData(); String keybaseId = entry.getExtraData();
@ -797,7 +797,7 @@ public class KeychainIntentService extends IntentService
String keyServer = data.getString(DOWNLOAD_KEY_SERVER); String keyServer = data.getString(DOWNLOAD_KEY_SERVER);
// this downloads the keys and places them into the ImportKeysListEntry entries // this downloads the keys and places them into the ImportKeysListEntry entries
HkpKeyServer server = new HkpKeyServer(keyServer); HkpKeyserver server = new HkpKeyserver(keyServer);
for (ImportKeysListEntry entry : entries) { for (ImportKeysListEntry entry : entries) {
// if available use complete fingerprint for get request // if available use complete fingerprint for get request

View File

@ -38,7 +38,7 @@ import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListKeybaseLoader;
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListLoader; import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListLoader;
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListServerLoader; import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListServerLoader;
import org.sufficientlysecure.keychain.util.InputData; import org.sufficientlysecure.keychain.util.InputData;
import org.sufficientlysecure.keychain.keyimport.KeyServer; import org.sufficientlysecure.keychain.keyimport.Keyserver;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -280,13 +280,13 @@ public class ImportKeysListFragment extends ListFragment implements
mAdapter.getCount(), mAdapter.getCount()), mAdapter.getCount(), mAdapter.getCount()),
AppMsg.STYLE_INFO AppMsg.STYLE_INFO
).show(); ).show();
} else if (error instanceof KeyServer.InsufficientQuery) { } else if (error instanceof Keyserver.InsufficientQuery) {
AppMsg.makeText(getActivity(), R.string.error_keyserver_insufficient_query, AppMsg.makeText(getActivity(), R.string.error_keyserver_insufficient_query,
AppMsg.STYLE_ALERT).show(); AppMsg.STYLE_ALERT).show();
} else if (error instanceof KeyServer.QueryException) { } else if (error instanceof Keyserver.QueryException) {
AppMsg.makeText(getActivity(), R.string.error_keyserver_query, AppMsg.makeText(getActivity(), R.string.error_keyserver_query,
AppMsg.STYLE_ALERT).show(); AppMsg.STYLE_ALERT).show();
} else if (error instanceof KeyServer.TooManyResponses) { } else if (error instanceof Keyserver.TooManyResponses) {
AppMsg.makeText(getActivity(), R.string.error_keyserver_too_many_responses, AppMsg.makeText(getActivity(), R.string.error_keyserver_too_many_responses,
AppMsg.STYLE_ALERT).show(); AppMsg.STYLE_ALERT).show();
} }
@ -300,7 +300,7 @@ public class ImportKeysListFragment extends ListFragment implements
mAdapter.getCount(), mAdapter.getCount()), mAdapter.getCount(), mAdapter.getCount()),
AppMsg.STYLE_INFO AppMsg.STYLE_INFO
).show(); ).show();
} else if (error instanceof KeyServer.QueryException) { } else if (error instanceof Keyserver.QueryException) {
AppMsg.makeText(getActivity(), R.string.error_keyserver_query, AppMsg.makeText(getActivity(), R.string.error_keyserver_query,
AppMsg.STYLE_ALERT).show(); AppMsg.STYLE_ALERT).show();
} }

View File

@ -130,7 +130,7 @@ public class KeyListFragment extends LoaderFragment
/** /**
* Define Adapter and Loader on create of Activity * Define Adapter and Loader on create of Activity
*/ */
@SuppressLint("NewApi") @TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override @Override
public void onActivityCreated(Bundle savedInstanceState) { public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
@ -141,8 +141,7 @@ public class KeyListFragment extends LoaderFragment
mStickyList.setFastScrollEnabled(true); mStickyList.setFastScrollEnabled(true);
/* /*
* ActionBarSherlock does not support MultiChoiceModeListener. Thus multi-selection is only * Multi-selection is only available for Android >= 3.0
* available for Android >= 3.0
*/ */
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mStickyList.setFastScrollAlwaysVisible(true); mStickyList.setFastScrollAlwaysVisible(true);
@ -312,7 +311,7 @@ public class KeyListFragment extends LoaderFragment
startActivity(viewIntent); startActivity(viewIntent);
} }
@TargetApi(11) @TargetApi(Build.VERSION_CODES.HONEYCOMB)
protected void encrypt(ActionMode mode, long[] masterKeyIds) { protected void encrypt(ActionMode mode, long[] masterKeyIds) {
Intent intent = new Intent(getActivity(), EncryptActivity.class); Intent intent = new Intent(getActivity(), EncryptActivity.class);
intent.setAction(EncryptActivity.ACTION_ENCRYPT); intent.setAction(EncryptActivity.ACTION_ENCRYPT);
@ -329,7 +328,7 @@ public class KeyListFragment extends LoaderFragment
* @param masterKeyIds * @param masterKeyIds
* @param hasSecret must contain whether the list of masterKeyIds contains a secret key or not * @param hasSecret must contain whether the list of masterKeyIds contains a secret key or not
*/ */
@TargetApi(11) @TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void showDeleteKeyDialog(final ActionMode mode, long[] masterKeyIds, boolean hasSecret) { public void showDeleteKeyDialog(final ActionMode mode, long[] masterKeyIds, boolean hasSecret) {
// Can only work on singular secret keys // Can only work on singular secret keys
if(hasSecret && masterKeyIds.length > 1) { if(hasSecret && masterKeyIds.length > 1) {

View File

@ -22,8 +22,8 @@ import android.support.v4.content.AsyncTaskLoader;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry; import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
import org.sufficientlysecure.keychain.keyimport.KeyServer; import org.sufficientlysecure.keychain.keyimport.Keyserver;
import org.sufficientlysecure.keychain.keyimport.KeybaseKeyServer; import org.sufficientlysecure.keychain.keyimport.KeybaseKeyserver;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
import java.util.ArrayList; import java.util.ArrayList;
@ -86,7 +86,7 @@ public class ImportKeysListKeybaseLoader
*/ */
private void queryServer(String query) { private void queryServer(String query) {
KeybaseKeyServer server = new KeybaseKeyServer(); KeybaseKeyserver server = new KeybaseKeyserver();
try { try {
ArrayList<ImportKeysListEntry> searchResult = server.search(query); ArrayList<ImportKeysListEntry> searchResult = server.search(query);
@ -94,11 +94,11 @@ public class ImportKeysListKeybaseLoader
mEntryList.addAll(searchResult); mEntryList.addAll(searchResult);
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null); mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null);
} catch (KeyServer.InsufficientQuery e) { } catch (Keyserver.InsufficientQuery e) {
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e); mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
} catch (KeyServer.QueryException e) { } catch (Keyserver.QueryException e) {
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e); mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
} catch (KeyServer.TooManyResponses e) { } catch (Keyserver.TooManyResponses e) {
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e); mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
} }

View File

@ -21,9 +21,9 @@ import android.content.Context;
import android.support.v4.content.AsyncTaskLoader; import android.support.v4.content.AsyncTaskLoader;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.keyimport.HkpKeyServer; import org.sufficientlysecure.keychain.keyimport.HkpKeyserver;
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry; import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
import org.sufficientlysecure.keychain.keyimport.KeyServer; import org.sufficientlysecure.keychain.keyimport.Keyserver;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
import java.util.ArrayList; import java.util.ArrayList;
@ -92,7 +92,7 @@ public class ImportKeysListServerLoader
* Query keyserver * Query keyserver
*/ */
private void queryServer(String query, String keyServer, boolean enforceFingerprint) { private void queryServer(String query, String keyServer, boolean enforceFingerprint) {
HkpKeyServer server = new HkpKeyServer(keyServer); HkpKeyserver server = new HkpKeyserver(keyServer);
try { try {
ArrayList<ImportKeysListEntry> searchResult = server.search(query); ArrayList<ImportKeysListEntry> searchResult = server.search(query);
@ -116,11 +116,11 @@ public class ImportKeysListServerLoader
mEntryList.addAll(searchResult); mEntryList.addAll(searchResult);
} }
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null); mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null);
} catch (KeyServer.InsufficientQuery e) { } catch (Keyserver.InsufficientQuery e) {
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e); mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
} catch (KeyServer.QueryException e) { } catch (Keyserver.QueryException e) {
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e); mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
} catch (KeyServer.TooManyResponses e) { } catch (Keyserver.TooManyResponses e) {
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e); mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
} }
} }