diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-01-16 13:57:18 +0100 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-01-16 13:57:18 +0100 |
commit | b6a1463161779b820a8b03a9d17c8a35dccea338 (patch) | |
tree | 4ebb57b9b3f30c0bf416fd1ab90ae09a84f25f7d /OpenKeychain/src/main/java | |
parent | 6935509d22fd1db7d9af29141511efe426acdba6 (diff) | |
download | open-keychain-b6a1463161779b820a8b03a9d17c8a35dccea338.tar.gz open-keychain-b6a1463161779b820a8b03a9d17c8a35dccea338.tar.bz2 open-keychain-b6a1463161779b820a8b03a9d17c8a35dccea338.zip |
dns resource is parametrized by fqdn, class and type
Diffstat (limited to 'OpenKeychain/src/main/java')
2 files changed, 34 insertions, 5 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/DnsResource.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/DnsResource.java index 1c66ffeca..a2836e666 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/DnsResource.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/DnsResource.java @@ -17,16 +17,26 @@ import de.measite.minidns.Client; import de.measite.minidns.DNSMessage; import de.measite.minidns.Question; import de.measite.minidns.Record; +import de.measite.minidns.Record.CLASS; import de.measite.minidns.Record.TYPE; import de.measite.minidns.record.TXT; public class DnsResource extends LinkedResource { - static Pattern magicPattern = + final static Pattern magicPattern = Pattern.compile("pgpid\\+cookie=([a-zA-Z0-9]+)(?:#|;)([a-zA-Z0-9]+)"); - DnsResource(Set<String> flags, HashMap<String, String> params, URI uri) { + String mFqdn; + CLASS mClass; + TYPE mType; + + DnsResource(Set<String> flags, HashMap<String, String> params, URI uri, + String fqdn, CLASS clazz, TYPE type) { super(flags, params, uri); + + mFqdn = fqdn; + mClass = clazz; + mType = type; } public static String generateText (Context context, byte[] fingerprint, String nonce) { @@ -49,14 +59,33 @@ public class DnsResource extends LinkedResource { && (params == null || params.isEmpty()))) { return null; } - return new DnsResource(flags, params, uri); + + // + String spec = uri.getSchemeSpecificPart(); + // If there are // at the beginning, this includes an authority - we don't support those! + if (spec.startsWith("//")) { + return null; + } + + String[] pieces = spec.split("\\?", 2); + // In either case, part before a ? is the fqdn + String fqdn = pieces[0]; + // There may be a query part + if (pieces.length > 1) { + // TODO parse CLASS and TYPE query paramters + } + + CLASS clazz = CLASS.IN; + TYPE type = TYPE.TXT; + + return new DnsResource(flags, params, uri, fqdn, clazz, type); } @Override protected String fetchResource (OperationLog log, int indent) { Client c = new Client(); - DNSMessage msg = c.query(new Question("mugenguild.com", TYPE.TXT)); + DNSMessage msg = c.query(new Question(mFqdn, mType, mClass)); Record aw = msg.getAnswers()[0]; TXT txt = (TXT) aw.getPayload(); return txt.getText().toLowerCase(); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateDnsStep1Fragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateDnsStep1Fragment.java index ba57ace4b..973067246 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateDnsStep1Fragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateDnsStep1Fragment.java @@ -121,7 +121,7 @@ public class LinkedIdCreateDnsStep1Fragment extends Fragment { } }); - mEditDns.setText("mugenguild.com"); + mEditDns.setText("test.mugenguild.com"); return view; } |