add initial query string parsing code

This commit is contained in:
David Blacka 2010-06-08 23:18:45 -04:00
parent bed1ca599d
commit 48bc1d9d5c

View File

@ -3,6 +3,7 @@ package com.verisign.cl;
import java.util.*;
import org.xbill.DNS.*;
import com.verisign.tat.dnssec.CaptiveValidator;
public class DNSSECReconciler {
@ -24,8 +25,61 @@ public class DNSSECReconciler {
validator = new CaptiveValidator();
}
public void execute() {
/**
* Convert a query line of the form: <qname> <qtype> <flags> to a request
* message.
*
* @param query_line
* @return A query message
* @throws TextParseException
* @throws NameTooLongException
*/
private Message queryFromString(String query_line)
throws TextParseException, NameTooLongException {
String[] tokens = query_line.split("[ \t]+");
Name qname = null;
int qtype = -1;
int qclass = -1;
if (tokens.length < 1)
return null;
qname = Name.fromString(tokens[0]);
if (!qname.isAbsolute()) {
qname = Name.concatenate(qname, Name.root);
}
for (int i = 1; i < tokens.length; i++) {
if (tokens[i].startsWith("+")) {
// For now, we ignore flags as uninteresting
continue;
}
int type = Type.value(tokens[i]);
if (type > 0) {
qtype = type;
continue;
}
int cls = DClass.value(tokens[i]);
if (cls > 0) {
qclass = cls;
continue;
}
}
if (qtype < 0) {
qtype = Type.A;
}
if (qclass < 0) {
qclass = DClass.IN;
}
Message query = Message.newQuery(Record.newRecord(qname, qtype, qclass));
return query;
}
public void execute() {
}
private static void usage() {
@ -90,7 +144,6 @@ public class DNSSECReconciler {
return 1;
}
// Execute the job
dr.execute();