diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-03-13 19:08:29 +0100 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-03-13 19:08:29 +0100 |
commit | bc1a3850ac91f3c81f14a9fd6690d0c90104ee0f (patch) | |
tree | 261d41339318418215a81c08a445e5dada052c98 /OpenPGP-Keychain/src/main | |
parent | 908cf8e7695b282760d7a790ae782346424e7ba8 (diff) | |
parent | 32dcf86212570725e48166fcdbae3bb1d5b59be3 (diff) | |
download | open-keychain-bc1a3850ac91f3c81f14a9fd6690d0c90104ee0f.tar.gz open-keychain-bc1a3850ac91f3c81f14a9fd6690d0c90104ee0f.tar.bz2 open-keychain-bc1a3850ac91f3c81f14a9fd6690d0c90104ee0f.zip |
Merge branch 'master' of github.com:openpgp-keychain/openpgp-keychain
Diffstat (limited to 'OpenPGP-Keychain/src/main')
-rw-r--r-- | OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java index 32266839c..99cac1152 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java @@ -18,24 +18,7 @@ package org.sufficientlysecure.keychain.util; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.InetAddress; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLEncoder; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.GregorianCalendar; -import java.util.List; -import java.util.TimeZone; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.Locale; - +import android.text.Html; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; @@ -51,7 +34,14 @@ import org.sufficientlysecure.keychain.pgp.PgpHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; -import android.text.Html; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.*; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * TODO: @@ -82,7 +72,7 @@ public class HkpKeyServer extends KeyServer { } private String mHost; - private short mPort = 11371; + private short mPort; // example: // pub 2048R/<a href="/pks/lookup?op=get&search=0x887DF4BE9F5C9090">9F5C9090</a> 2009-08-17 <a @@ -95,9 +85,25 @@ public class HkpKeyServer extends KeyServer { public static Pattern USER_ID_LINE = Pattern.compile("^ +(.+)$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE); - public HkpKeyServer(String host) { - mHost = host; - } + private static final short PORT_DEFAULT = 11371; + + /** + * @param hostAndPort may be just "<code>hostname</code>" (eg. "<code>pool.sks-keyservers.net</code>"), then it will + * 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>"). + */ + public HkpKeyServer(String hostAndPort) { + String host = hostAndPort; + short port = PORT_DEFAULT; + final int colonPosition = hostAndPort.lastIndexOf(':'); + if (colonPosition > 0) { + host = hostAndPort.substring(0, colonPosition); + final String portStr = hostAndPort.substring(colonPosition + 1); + port = Short.decode(portStr); + } + mHost = host; + mPort = port; + } public HkpKeyServer(String host, short port) { mHost = host; |