Exception Fact Sheet for "DNSJava"

The goal of an Exception Fact Sheet is to reveal the design of exception handling in an application.

--Maxence, Martin

For feedback, please contact Martin

Table of contents

Basic Statistics

Number of Classes 166
Number of Domain Exception Types (Thrown or Caught) 17
Number of Domain Checked Exception Types 12
Number of Domain Runtime Exception Types 5
Number of Domain Unknown Exception Types 0
nTh = Number of Throw 323
nTh = Number of Throw in Catch 51
Number of Catch-Rethrow (may not be correct) 4
nC = Number of Catch 93
nCTh = Number of Catch with Throw 50
Number of Empty Catch (really Empty) 17
Number of Empty Catch (with comments) 1
Number of Empty Catch 18
nM = Number of Methods 1355
nbFunctionWithCatch = Number of Methods with Catch 83 / 1355
nbFunctionWithThrow = Number of Methods with Throw 206 / 1355
nbFunctionWithThrowS = Number of Methods with ThrowS 260 / 1355
nbFunctionTransmitting = Number of Methods with "Throws" but NO catch, NO throw (only transmitting) 149 / 1355
P1 = nCTh / nC 53.8% (0.538)
P2 = nMC / nM 6.1% (0.061)
P3 = nbFunctionWithThrow / nbFunction 15.2% (0.152)
P4 = nbFunctionTransmitting / nbFunction 11% (0.11)
P5 = nbThrowInCatch / nbThrow 15.8% (0.158)
R2 = nCatch / nThrow 0.288
A1 = Number of Caught Exception Types From External Libraries 13
A2 = Number of Reused Exception Types From External Libraries (thrown from application code) 11

W1 is a rough estimation of the richness of the exception model. It does not take into account the inheritance relationships between domain exceptions.

Proportion P1 measures the overall exception flow. According to our experience, it varies from 5% to 70%. Early-catch design generally yields a low P1, libraries that must warn clients about errors (e.g. databases) generally have a high P1.

Proportion P2 measures the dispersion of catch blocks in the application. According to our experience, it varies from 2% to 15%. A small P2 indicates a rather centralized management of errors.

R1 shows how many exceptions types from libraries (incl. JDK) are thrown from application code. For instance, IllegalArgumentException comes from the JDK but is used in many applications.

A1 measures the awareness of the application to library exceptions. A high value of A1 means either that the application is polluted with checked exceptions or that it is able to apply specific recovery depending on the library exception.

Exception Hierachy

Exception Map

Each exception that is used at least once in the project is a dot. A orange dot represents a domain exception that is defined in the application. A blue dot exception is defined in the JDK or in a library. The x-axis represents the number of times an exception is caught, the y-axis the number of times an exception is thrown.

Exceptions With State

State means fields. Number of exceptions with state: 4
TokenizerException
              package org.xbill.DNS;static class TokenizerException extends TextParseException {
	String message;

	public
	TokenizerException(String filename, int line, String message) {
		super(filename + ":" + line + ": " + message);
		this.message = message;
	}

	public String
	getBaseMessage() {
		return message;
	}
}
            
KeyMismatchException
              package org.xbill.DNS;public static class KeyMismatchException extends DNSSECException {
	private KEYBase key;
	private SIGBase sig;

	KeyMismatchException(KEYBase key, SIGBase sig) {
		super("key " +
		      key.getName() + "/" +
		      DNSSEC.Algorithm.string(key.getAlgorithm()) + "/" +
		      key.getFootprint() + " " +
		      "does not match signature " +
		      sig.getSigner() + "/" +
		      DNSSEC.Algorithm.string(sig.getAlgorithm()) + "/" +
		      sig.getFootprint());
	}
}
            
SignatureExpiredException
              package org.xbill.DNS;public static class SignatureExpiredException extends DNSSECException {
	private Date when, now;

	SignatureExpiredException(Date when, Date now) {
		super("signature expired");
		this.when = when;
		this.now = now;
	}

	/**
	 * @return When the signature expired
	 */
	public Date
	getExpiration() {
		return when;
	}

	/**
	 * @return When the verification was attempted
	 */
	public Date
	getVerifyTime() {
		return now;
	}
}
            
SignatureNotYetValidException
              package org.xbill.DNS;public static class SignatureNotYetValidException extends DNSSECException {
	private Date when, now;

	SignatureNotYetValidException(Date when, Date now) {
		super("signature is not yet valid");
		this.when = when;
		this.now = now;
	}

	/**
	 * @return When the signature will become valid
	 */
	public Date
	getExpiration() {
		return when;
	}

	/**
	 * @return When the verification was attempted
	 */
	public Date
	getVerifyTime() {
		return now;
	}
}
            

Thrown Exceptions Summary

A (Domain) exception is defined in the application. A (Lib) exception is defined in the JDK or in a library. An exception can be thrown, thrown from within a catch, or declared in the signature of a method (usually for checked exceptions). Hovering over a number triggers showing code snippets from the application code.

Type Exception Thrown Thrown
from Catch
Declared
- Unknown 96
              
//in org/xbill/DNS/APLRecord.java
throw st.exception("invalid address prefix element");

              
//in org/xbill/DNS/APLRecord.java
throw st.exception("invalid address prefix element");

              
//in org/xbill/DNS/APLRecord.java
throw st.exception("invalid family");

              
//in org/xbill/DNS/APLRecord.java
throw st.exception("unknown family");

              
//in org/xbill/DNS/APLRecord.java
throw st.exception("invalid prefix length");

              
//in org/xbill/DNS/APLRecord.java
throw st.exception("invalid prefix length");

              
//in org/xbill/DNS/APLRecord.java
throw st.exception("invalid IP address " +
					   addressString);

              
//in org/xbill/DNS/NXTRecord.java
throw st.exception("Invalid type: " + t.value);

              
//in org/xbill/DNS/ISDNRecord.java
throw st.exception(e.getMessage());

              
//in org/xbill/DNS/TSIGRecord.java
throw st.exception("no text format defined for TSIG");

              
//in org/xbill/DNS/ExtendedResolver.java
throw (IOException) thrown;

              
//in org/xbill/DNS/ExtendedResolver.java
throw (RuntimeException) thrown;

              
//in org/xbill/DNS/ExtendedResolver.java
throw (Error) thrown;

              
//in org/xbill/DNS/Record.java
throw st.exception("invalid unknown RR encoding: " +
					   "length mismatch");

              
//in org/xbill/DNS/Record.java
throw st.exception("unexpected tokens at end of record");

              
//in org/xbill/DNS/HINFORecord.java
throw st.exception(e.getMessage());

              
//in org/xbill/DNS/SimpleResolver.java
throw (WireParseException) e;

              
//in org/xbill/DNS/Name.java
throw parseException(fullName, "Name too long");

              
//in org/xbill/DNS/Name.java
throw parseException(s, "empty name");

              
//in org/xbill/DNS/Name.java
throw parseException(s, "bad escape");

              
//in org/xbill/DNS/Name.java
throw parseException(s, "bad escape");

              
//in org/xbill/DNS/Name.java
throw parseException(s, "label too long");

              
//in org/xbill/DNS/Name.java
throw parseException(s, "invalid empty label");

              
//in org/xbill/DNS/Name.java
throw parseException(s, "label too long");

              
//in org/xbill/DNS/Name.java
throw parseException(s, "bad escape");

              
//in org/xbill/DNS/Name.java
throw parseException(s, "bad escape");

              
//in org/xbill/DNS/Master.java
throw st.exception(e.getMessage());

              
//in org/xbill/DNS/Master.java
throw st.exception("Invalid type '" + s + "'");

              
//in org/xbill/DNS/Master.java
throw st.exception("missing TTL");

              
//in org/xbill/DNS/Master.java
throw st.exception("Invalid $GENERATE range specifier: " + s);

              
//in org/xbill/DNS/Master.java
throw st.exception("Invalid $GENERATE range specifier: " + s);

              
//in org/xbill/DNS/Master.java
throw st.exception("$GENERATE does not support " +
				   Type.string(currentType) + " records");

              
//in org/xbill/DNS/Master.java
throw st.exception("Parsing $GENERATE: " + e.getBaseMessage());

              
//in org/xbill/DNS/Master.java
throw st.exception("Parsing $GENERATE: " + e.getMessage());

              
//in org/xbill/DNS/Master.java
throw st.exception("no owner");

              
//in org/xbill/DNS/Master.java
throw st.exception("Invalid directive: " + s);

              
//in org/xbill/DNS/TXTBase.java
throw st.exception(e.getMessage());

              
//in org/xbill/DNS/spi/DNSJavaNameService.java
throw e;

              
//in org/xbill/DNS/NSEC3PARAMRecord.java
throw st.exception("salt value too long");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("unbalanced parentheses");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("EOF in " +
							"quoted string");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("invalid " +
								"close " +
								"parenthesis");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("unterminated escape sequence");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("newline in quoted string");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("expected a string");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("expected " + expected);

              
//in org/xbill/DNS/Tokenizer.java
throw exception("expected an integer");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("expected an integer");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("expected an 32 bit unsigned integer");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("expected an 16 bit unsigned integer");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("expected an 8 bit unsigned integer");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("expected a TTL value");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("expected a TTL-like value");

              
//in org/xbill/DNS/Tokenizer.java
throw exception(e.getMessage());

              
//in org/xbill/DNS/Tokenizer.java
throw exception(e.getMessage());

              
//in org/xbill/DNS/Tokenizer.java
throw exception("expected EOL or EOF");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("expected base64 encoded string");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("invalid base64 encoding");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("expected hex encoded string");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("invalid hex encoding");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("invalid hex encoding");

              
//in org/xbill/DNS/Tokenizer.java
throw exception("invalid base32 encoding");

              
//in org/xbill/DNS/A6Record.java
throw st.exception("prefix bits must be [0..128]");

              
//in org/xbill/DNS/A6Record.java
throw st.exception("invalid IPv6 address: " + s);

              
//in org/xbill/DNS/NULLRecord.java
throw st.exception("no defined text format for NULL records");

              
//in org/xbill/DNS/DNSKEYRecord.java
throw st.exception("Invalid algorithm: " + algString);

              
//in org/xbill/DNS/CERTRecord.java
throw st.exception("Invalid certificate type: " +
				   certTypeString);

              
//in org/xbill/DNS/CERTRecord.java
throw st.exception("Invalid algorithm: " + algString);

              
//in org/xbill/DNS/Message.java
throw e;

              
//in org/xbill/DNS/Generator.java
throw new
							   TextParseException(
							   "invalid width");

              
//in org/xbill/DNS/TKEYRecord.java
throw st.exception("no text format defined for TKEY");

              
//in org/xbill/DNS/GPOSRecord.java
throw st.exception(e.getMessage());

              
//in org/xbill/DNS/KEYRecord.java
throw st.exception("Invalid flags: " + flagString);

              
//in org/xbill/DNS/KEYRecord.java
throw st.exception("Invalid protocol: " + protoString);

              
//in org/xbill/DNS/KEYRecord.java
throw st.exception("Invalid algorithm: " + algString);

              
//in org/xbill/DNS/LOCRecord.java
throw st.exception("Invalid LOC " + type + " degrees");

              
//in org/xbill/DNS/LOCRecord.java
throw st.exception("Invalid LOC " + type + " minutes");

              
//in org/xbill/DNS/LOCRecord.java
throw st.exception("Invalid LOC " + type + " seconds");

              
//in org/xbill/DNS/LOCRecord.java
throw st.exception("Invalid LOC " + type);

              
//in org/xbill/DNS/LOCRecord.java
throw st.exception("Invalid LOC " + type);

              
//in org/xbill/DNS/LOCRecord.java
throw st.exception("Invalid LOC " + type);

              
//in org/xbill/DNS/LOCRecord.java
throw st.exception("Invalid LOC " + type);

              
//in org/xbill/DNS/LOCRecord.java
throw st.exception("Invalid LOC " + type);

              
//in org/xbill/DNS/X25Record.java
throw st.exception("invalid PSDN address " + addr);

              
//in org/xbill/DNS/UNKRecord.java
throw st.exception("invalid unknown RR encoding");

              
//in org/xbill/DNS/ZoneTransferIn.java
throw (WireParseException) e;

              
//in org/xbill/DNS/OPTRecord.java
throw st.exception("no text format defined for OPT");

              
//in org/xbill/DNS/TypeBitmap.java
throw st.exception("Invalid type: " + t.value);

              
//in org/xbill/DNS/NSAPRecord.java
throw st.exception("invalid NSAP address " + addr);

              
//in org/xbill/DNS/WKSRecord.java
throw st.exception("invalid address");

              
//in org/xbill/DNS/WKSRecord.java
throw st.exception("Invalid IP protocol: " + s);

              
//in org/xbill/DNS/WKSRecord.java
throw st.exception("Invalid TCP/UDP service: " +
					   t.value);

              
//in org/xbill/DNS/SIGBase.java
throw st.exception("Invalid type: " + typeString);

              
//in org/xbill/DNS/SIGBase.java
throw st.exception("Invalid algorithm: " + algString);

              
//in org/xbill/DNS/NSEC3Record.java
throw st.exception("salt value too long");

              
//in org/xbill/DNS/NAPTRRecord.java
throw st.exception(e.getMessage());

            
- -
- Builder 89
              
// in org/xbill/DNS/APLRecord.java
throw st.exception("invalid address prefix element");

              
// in org/xbill/DNS/APLRecord.java
throw st.exception("invalid address prefix element");

              
// in org/xbill/DNS/APLRecord.java
throw st.exception("invalid family");

              
// in org/xbill/DNS/APLRecord.java
throw st.exception("unknown family");

              
// in org/xbill/DNS/APLRecord.java
throw st.exception("invalid prefix length");

              
// in org/xbill/DNS/APLRecord.java
throw st.exception("invalid prefix length");

              
// in org/xbill/DNS/APLRecord.java
throw st.exception("invalid IP address " +
					   addressString);

              
// in org/xbill/DNS/NXTRecord.java
throw st.exception("Invalid type: " + t.value);

              
// in org/xbill/DNS/ISDNRecord.java
throw st.exception(e.getMessage());

              
// in org/xbill/DNS/TSIGRecord.java
throw st.exception("no text format defined for TSIG");

              
// in org/xbill/DNS/Record.java
throw st.exception("invalid unknown RR encoding: " +
					   "length mismatch");

              
// in org/xbill/DNS/Record.java
throw st.exception("unexpected tokens at end of record");

              
// in org/xbill/DNS/HINFORecord.java
throw st.exception(e.getMessage());

              
// in org/xbill/DNS/Name.java
throw parseException(fullName, "Name too long");

              
// in org/xbill/DNS/Name.java
throw parseException(s, "empty name");

              
// in org/xbill/DNS/Name.java
throw parseException(s, "bad escape");

              
// in org/xbill/DNS/Name.java
throw parseException(s, "bad escape");

              
// in org/xbill/DNS/Name.java
throw parseException(s, "label too long");

              
// in org/xbill/DNS/Name.java
throw parseException(s, "invalid empty label");

              
// in org/xbill/DNS/Name.java
throw parseException(s, "label too long");

              
// in org/xbill/DNS/Name.java
throw parseException(s, "bad escape");

              
// in org/xbill/DNS/Name.java
throw parseException(s, "bad escape");

              
// in org/xbill/DNS/Master.java
throw st.exception(e.getMessage());

              
// in org/xbill/DNS/Master.java
throw st.exception("Invalid type '" + s + "'");

              
// in org/xbill/DNS/Master.java
throw st.exception("missing TTL");

              
// in org/xbill/DNS/Master.java
throw st.exception("Invalid $GENERATE range specifier: " + s);

              
// in org/xbill/DNS/Master.java
throw st.exception("Invalid $GENERATE range specifier: " + s);

              
// in org/xbill/DNS/Master.java
throw st.exception("$GENERATE does not support " +
				   Type.string(currentType) + " records");

              
// in org/xbill/DNS/Master.java
throw st.exception("Parsing $GENERATE: " + e.getBaseMessage());

              
// in org/xbill/DNS/Master.java
throw st.exception("Parsing $GENERATE: " + e.getMessage());

              
// in org/xbill/DNS/Master.java
throw st.exception("no owner");

              
// in org/xbill/DNS/Master.java
throw st.exception("Invalid directive: " + s);

              
// in org/xbill/DNS/TXTBase.java
throw st.exception(e.getMessage());

              
// in org/xbill/DNS/NSEC3PARAMRecord.java
throw st.exception("salt value too long");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("unbalanced parentheses");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("EOF in " +
							"quoted string");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("invalid " +
								"close " +
								"parenthesis");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("unterminated escape sequence");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("newline in quoted string");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("expected a string");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("expected " + expected);

              
// in org/xbill/DNS/Tokenizer.java
throw exception("expected an integer");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("expected an integer");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("expected an 32 bit unsigned integer");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("expected an 16 bit unsigned integer");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("expected an 8 bit unsigned integer");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("expected a TTL value");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("expected a TTL-like value");

              
// in org/xbill/DNS/Tokenizer.java
throw exception(e.getMessage());

              
// in org/xbill/DNS/Tokenizer.java
throw exception(e.getMessage());

              
// in org/xbill/DNS/Tokenizer.java
throw exception("expected EOL or EOF");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("expected base64 encoded string");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("invalid base64 encoding");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("expected hex encoded string");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("invalid hex encoding");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("invalid hex encoding");

              
// in org/xbill/DNS/Tokenizer.java
throw exception("invalid base32 encoding");

              
// in org/xbill/DNS/A6Record.java
throw st.exception("prefix bits must be [0..128]");

              
// in org/xbill/DNS/A6Record.java
throw st.exception("invalid IPv6 address: " + s);

              
// in org/xbill/DNS/NULLRecord.java
throw st.exception("no defined text format for NULL records");

              
// in org/xbill/DNS/DNSKEYRecord.java
throw st.exception("Invalid algorithm: " + algString);

              
// in org/xbill/DNS/CERTRecord.java
throw st.exception("Invalid certificate type: " +
				   certTypeString);

              
// in org/xbill/DNS/CERTRecord.java
throw st.exception("Invalid algorithm: " + algString);

              
// in org/xbill/DNS/Generator.java
throw new
							   TextParseException(
							   "invalid width");

              
// in org/xbill/DNS/TKEYRecord.java
throw st.exception("no text format defined for TKEY");

              
// in org/xbill/DNS/GPOSRecord.java
throw st.exception(e.getMessage());

              
// in org/xbill/DNS/KEYRecord.java
throw st.exception("Invalid flags: " + flagString);

              
// in org/xbill/DNS/KEYRecord.java
throw st.exception("Invalid protocol: " + protoString);

              
// in org/xbill/DNS/KEYRecord.java
throw st.exception("Invalid algorithm: " + algString);

              
// in org/xbill/DNS/LOCRecord.java
throw st.exception("Invalid LOC " + type + " degrees");

              
// in org/xbill/DNS/LOCRecord.java
throw st.exception("Invalid LOC " + type + " minutes");

              
// in org/xbill/DNS/LOCRecord.java
throw st.exception("Invalid LOC " + type + " seconds");

              
// in org/xbill/DNS/LOCRecord.java
throw st.exception("Invalid LOC " + type);

              
// in org/xbill/DNS/LOCRecord.java
throw st.exception("Invalid LOC " + type);

              
// in org/xbill/DNS/LOCRecord.java
throw st.exception("Invalid LOC " + type);

              
// in org/xbill/DNS/LOCRecord.java
throw st.exception("Invalid LOC " + type);

              
// in org/xbill/DNS/LOCRecord.java
throw st.exception("Invalid LOC " + type);

              
// in org/xbill/DNS/X25Record.java
throw st.exception("invalid PSDN address " + addr);

              
// in org/xbill/DNS/UNKRecord.java
throw st.exception("invalid unknown RR encoding");

              
// in org/xbill/DNS/OPTRecord.java
throw st.exception("no text format defined for OPT");

              
// in org/xbill/DNS/TypeBitmap.java
throw st.exception("Invalid type: " + t.value);

              
// in org/xbill/DNS/NSAPRecord.java
throw st.exception("invalid NSAP address " + addr);

              
// in org/xbill/DNS/WKSRecord.java
throw st.exception("invalid address");

              
// in org/xbill/DNS/WKSRecord.java
throw st.exception("Invalid IP protocol: " + s);

              
// in org/xbill/DNS/WKSRecord.java
throw st.exception("Invalid TCP/UDP service: " +
					   t.value);

              
// in org/xbill/DNS/SIGBase.java
throw st.exception("Invalid type: " + typeString);

              
// in org/xbill/DNS/SIGBase.java
throw st.exception("Invalid algorithm: " + algString);

              
// in org/xbill/DNS/NSEC3Record.java
throw st.exception("salt value too long");

              
// in org/xbill/DNS/NAPTRRecord.java
throw st.exception(e.getMessage());

            
- -
- Variable 7
              
// in org/xbill/DNS/ExtendedResolver.java
throw (IOException) thrown;

              
// in org/xbill/DNS/ExtendedResolver.java
throw (RuntimeException) thrown;

              
// in org/xbill/DNS/ExtendedResolver.java
throw (Error) thrown;

              
// in org/xbill/DNS/SimpleResolver.java
throw (WireParseException) e;

              
// in org/xbill/DNS/spi/DNSJavaNameService.java
throw e;

              
// in org/xbill/DNS/Message.java
throw e;

              
// in org/xbill/DNS/ZoneTransferIn.java
throw (WireParseException) e;

            
- -
(Lib) IllegalArgumentException 88
              
// in org/xbill/DNS/Mnemonic.java
public void check(int val) { if (val < 0 || val > max) { throw new IllegalArgumentException(description + " " + val + "is out of range"); } }
// in org/xbill/DNS/Mnemonic.java
public void addAll(Mnemonic source) { if (wordcase != source.wordcase) throw new IllegalArgumentException(source.description + ": wordcases do not match"); strings.putAll(source.strings); values.putAll(source.values); }
// in org/xbill/DNS/Record.java
static int checkU8(String field, int val) { if (val < 0 || val > 0xFF) throw new IllegalArgumentException("\"" + field + "\" " + val + " must be an unsigned 8 " + "bit value"); return val; }
// in org/xbill/DNS/Record.java
static int checkU16(String field, int val) { if (val < 0 || val > 0xFFFF) throw new IllegalArgumentException("\"" + field + "\" " + val + " must be an unsigned 16 " + "bit value"); return val; }
// in org/xbill/DNS/Record.java
static long checkU32(String field, long val) { if (val < 0 || val > 0xFFFFFFFFL) throw new IllegalArgumentException("\"" + field + "\" " + val + " must be an unsigned 32 " + "bit value"); return val; }
// in org/xbill/DNS/Record.java
static byte [] checkByteArrayLength(String field, byte [] array, int maxLength) { if (array.length > 0xFFFF) throw new IllegalArgumentException("\"" + field + "\" array " + "must have no more than " + maxLength + " elements"); byte [] out = new byte[array.length]; System.arraycopy(array, 0, out, 0, array.length); return out; }
// in org/xbill/DNS/SimpleResolver.java
public void setEDNS(int level, int payloadSize, int flags, List options) { if (level != 0 && level != -1) throw new IllegalArgumentException("invalid EDNS level - " + "must be 0 or -1"); if (payloadSize == 0) payloadSize = DEFAULT_EDNS_PAYLOADSIZE; queryOPT = new OPTRecord(payloadSize, 0, level, flags, options); }
// in org/xbill/DNS/Name.java
private final int offset(int n) { if (n == 0 && getlabels() == 0) return 0; if (n < 0 || n >= getlabels()) throw new IllegalArgumentException("label out of range"); if (n < MAXOFFSETS) { int shift = 8 * (7 - n); return ((int)(offsets >>> shift) & 0xFF); } else { int pos = offset(MAXOFFSETS - 1); for (int i = MAXOFFSETS - 1; i < n; i++) pos += (name[pos] + 1); return (pos); } }
// in org/xbill/DNS/Name.java
public static Name fromConstantString(String s) { try { return fromString(s, null); } catch (TextParseException e) { throw new IllegalArgumentException("Invalid name '" + s + "'"); } }
// in org/xbill/DNS/Name.java
public Name wild(int n) { if (n < 1) throw new IllegalArgumentException("must replace 1 or more " + "labels"); try { Name newname = new Name(); copy(wild, newname); newname.append(name, offset(n), getlabels() - n); return newname; } catch (NameTooLongException e) { throw new IllegalStateException ("Name.wild: concatenate failed"); } }
// in org/xbill/DNS/Name.java
public void toWire(DNSOutput out, Compression c) { if (!isAbsolute()) throw new IllegalArgumentException("toWire() called on " + "non-absolute name"); int labels = labels(); for (int i = 0; i < labels - 1; i++) { Name tname; if (i == 0) tname = this; else tname = new Name(this, i); int pos = -1; if (c != null) pos = c.get(tname); if (pos >= 0) { pos |= (LABEL_MASK << 8); out.writeU16(pos); return; } else { if (c != null) c.add(out.current(), tname); int off = offset(i); out.writeByteArray(name, off, name[off] + 1); } } out.writeU8(0); }
// in org/xbill/DNS/ReverseMap.java
public static Name fromAddress(byte [] addr) { if (addr.length != 4 && addr.length != 16) throw new IllegalArgumentException("array must contain " + "4 or 16 elements"); StringBuffer sb = new StringBuffer(); if (addr.length == 4) { for (int i = addr.length - 1; i >= 0; i--) { sb.append(addr[i] & 0xFF); if (i > 0) sb.append("."); } } else { int [] nibbles = new int[2]; for (int i = addr.length - 1; i >= 0; i--) { nibbles[0] = (addr[i] & 0xFF) >> 4; nibbles[1] = (addr[i] & 0xFF) & 0xF; for (int j = nibbles.length - 1; j >= 0; j--) { sb.append(Integer.toHexString(nibbles[j])); if (i > 0 || j > 0) sb.append("."); } } } try { if (addr.length == 4) return Name.fromString(sb.toString(), inaddr4); else return Name.fromString(sb.toString(), inaddr6); } catch (TextParseException e) { throw new IllegalStateException("name cannot be invalid"); } }
// in org/xbill/DNS/ReverseMap.java
public static Name fromAddress(int [] addr) { byte [] bytes = new byte[addr.length]; for (int i = 0; i < addr.length; i++) { if (addr[i] < 0 || addr[i] > 0xFF) throw new IllegalArgumentException("array must " + "contain values " + "between 0 and 255"); bytes[i] = (byte) addr[i]; } return fromAddress(bytes); }
// in org/xbill/DNS/spi/DNSJavaNameService.java
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { if (method.getName().equals("getHostByAddr")) { return this.getHostByAddr((byte[]) args[0]); } else if (method.getName().equals("lookupAllHostAddr")) { InetAddress[] addresses; addresses = this.lookupAllHostAddr((String) args[0]); Class returnType = method.getReturnType(); if (returnType.equals(InetAddress[].class)) { // method for Java >= 1.6 return addresses; } else if (returnType.equals(byte[][].class)) { // method for Java <= 1.5 int naddrs = addresses.length; byte [][] byteAddresses = new byte[naddrs][]; byte [] addr; for (int i = 0; i < naddrs; i++) { addr = addresses[i].getAddress(); byteAddresses[i] = addr; } return byteAddresses; } } } catch (Throwable e) { System.err.println("DNSJavaNameService: Unexpected error."); e.printStackTrace(); throw e; } throw new IllegalArgumentException( "Unknown function name or arguments."); }
// in org/xbill/DNS/Serial.java
public static int compare(long serial1, long serial2) { if (serial1 < 0 || serial1 > MAX32) throw new IllegalArgumentException(serial1 + " out of range"); if (serial2 < 0 || serial2 > MAX32) throw new IllegalArgumentException(serial2 + " out of range"); long diff = serial1 - serial2; if (diff >= MAX32) diff -= (MAX32 + 1); else if (diff < -MAX32) diff += (MAX32 + 1); return (int)diff; }
// in org/xbill/DNS/Serial.java
public static long increment(long serial) { if (serial < 0 || serial > MAX32) throw new IllegalArgumentException(serial + " out of range"); if (serial == MAX32) return 0; return serial + 1; }
// in org/xbill/DNS/Tokenizer.java
private Token set(int type, StringBuffer value) { if (type < 0) throw new IllegalArgumentException(); this.type = type; this.value = value == null ? null : value.toString(); return this; }
// in org/xbill/DNS/SetResponse.java
static SetResponse ofType(int type) { switch (type) { case UNKNOWN: return unknown; case NXDOMAIN: return nxdomain; case NXRRSET: return nxrrset; case DELEGATION: case CNAME: case DNAME: case SUCCESSFUL: SetResponse sr = new SetResponse(); sr.type = type; sr.data = null; return sr; default: throw new IllegalArgumentException("invalid type"); } }
// in org/xbill/DNS/DNSSEC.java
static byte [] generateDSDigest(DNSKEYRecord key, int digestid) { MessageDigest digest; try { switch (digestid) { case DSRecord.Digest.SHA1: digest = MessageDigest.getInstance("sha-1"); break; case DSRecord.Digest.SHA256: digest = MessageDigest.getInstance("sha-256"); break; default: throw new IllegalArgumentException( "unknown DS digest type " + digestid); } } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("no message digest support"); } digest.update(key.getName().toWire()); digest.update(key.rdataToWireCanonical()); return digest.digest(); }
// in org/xbill/DNS/Header.java
static private void checkFlag(int bit) { if (!validFlag(bit)) throw new IllegalArgumentException("invalid flag bit " + bit); }
// in org/xbill/DNS/Header.java
public void setID(int id) { if (id < 0 || id > 0xffff) throw new IllegalArgumentException("DNS message ID " + id + " is out of range"); this.id = id; }
// in org/xbill/DNS/Header.java
public void setRcode(int value) { if (value < 0 || value > 0xF) throw new IllegalArgumentException("DNS Rcode " + value + " is out of range"); flags &= ~0xF; flags |= value; }
// in org/xbill/DNS/Header.java
public void setOpcode(int value) { if (value < 0 || value > 0xF) throw new IllegalArgumentException("DNS Opcode " + value + "is out of range"); flags &= 0x87FF; flags |= (value << 11); }
// in org/xbill/DNS/Header.java
void setCount(int field, int value) { if (value < 0 || value > 0xFFFF) throw new IllegalArgumentException("DNS section count " + value + " is out of range"); counts[field] = value; }
// in org/xbill/DNS/TSIG.java
private void getDigest() { if (alg.equals(HMAC_MD5)) { digest = "md5"; digestBlockLength = 64; } else if (alg.equals(HMAC_SHA1)) { digest = "sha-1"; digestBlockLength = 64; } else if (alg.equals(HMAC_SHA224)) { digest = "sha-224"; digestBlockLength = 64; } else if (alg.equals(HMAC_SHA256)) { digest = "sha-256"; digestBlockLength = 64; } else if (alg.equals(HMAC_SHA512)) { digest = "sha-512"; digestBlockLength = 128; } else if (alg.equals(HMAC_SHA384)) { digest = "sha-384"; digestBlockLength = 128; } else throw new IllegalArgumentException("Invalid algorithm"); }
// in org/xbill/DNS/TSIG.java
static public TSIG fromString(String str) { String [] parts = str.split("[:/]", 3); if (parts.length < 2) throw new IllegalArgumentException("Invalid TSIG key " + "specification"); if (parts.length == 3) { try { return new TSIG(parts[0], parts[1], parts[2]); } catch (IllegalArgumentException e) { parts = str.split("[:/]", 2); } } return new TSIG(HMAC_MD5, parts[0], parts[1]); }
// in org/xbill/DNS/DNSInput.java
public void setActive(int len) { if (len > array.length - pos) { throw new IllegalArgumentException("cannot set active " + "region past end of input"); } end = pos + len; }
// in org/xbill/DNS/DNSInput.java
public void restoreActive(int pos) { if (pos > array.length) { throw new IllegalArgumentException("cannot set active " + "region past end of input"); } end = pos; }
// in org/xbill/DNS/DNSInput.java
public void jump(int index) { if (index >= array.length) { throw new IllegalArgumentException("cannot jump past " + "end of input"); } pos = index; end = array.length; }
// in org/xbill/DNS/Address.java
public static byte [] toByteArray(String s, int family) { if (family == IPv4) return parseV4(s); else if (family == IPv6) return parseV6(s); else throw new IllegalArgumentException("unknown address family"); }
// in org/xbill/DNS/Address.java
public static InetAddress getByAddress(String addr, int family) throws UnknownHostException { if (family != IPv4 && family != IPv6) throw new IllegalArgumentException("unknown address family"); byte [] bytes; bytes = toByteArray(addr, family); if (bytes != null) return InetAddress.getByAddress(bytes); throw new UnknownHostException("Invalid address: " + addr); }
// in org/xbill/DNS/Address.java
public static int familyOf(InetAddress address) { if (address instanceof Inet4Address) return IPv4; if (address instanceof Inet6Address) return IPv6; throw new IllegalArgumentException("unknown address family"); }
// in org/xbill/DNS/Address.java
public static int addressLength(int family) { if (family == IPv4) return 4; if (family == IPv6) return 16; throw new IllegalArgumentException("unknown address family"); }
// in org/xbill/DNS/Address.java
public static InetAddress truncate(InetAddress address, int maskLength) { int family = familyOf(address); int maxMaskLength = addressLength(family) * 8; if (maskLength < 0 || maskLength > maxMaskLength) throw new IllegalArgumentException("invalid mask length"); if (maskLength == maxMaskLength) return address; byte [] bytes = address.getAddress(); for (int i = maskLength / 8 + 1; i < bytes.length; i++) bytes[i] = 0; int maskBits = maskLength % 8; int bitmask = 0; for (int i = 0; i < maskBits; i++) bitmask |= (1 << (7 - i)); bytes[maskLength / 8] &= bitmask; try { return InetAddress.getByAddress(bytes); } catch (UnknownHostException e) { throw new IllegalArgumentException("invalid address"); } }
// in org/xbill/DNS/Zone.java
private void fromXFR(ZoneTransferIn xfrin) throws IOException, ZoneTransferException { data = new TreeMap(); origin = xfrin.getName(); List records = xfrin.run(); for (Iterator it = records.iterator(); it.hasNext(); ) { Record record = (Record) it.next(); maybeAddRecord(record); } if (!xfrin.isAXFR()) throw new IllegalArgumentException("zones can only be " + "created from AXFRs"); validate(); }
// in org/xbill/DNS/Zone.java
private synchronized RRset oneRRset(Object types, int type) { if (type == Type.ANY) throw new IllegalArgumentException("oneRRset(ANY)"); if (types instanceof List) { List list = (List) types; for (int i = 0; i < list.size(); i++) { RRset set = (RRset) list.get(i); if (set.getType() == type) return set; } } else { RRset set = (RRset) types; if (set.getType() == type) return set; } return null; }
// in org/xbill/DNS/GPOSRecord.java
private void validate(double longitude, double latitude) throws IllegalArgumentException { if (longitude < -90.0 || longitude > 90.0) { throw new IllegalArgumentException("illegal longitude " + longitude); } if (latitude < -180.0 || latitude > 180.0) { throw new IllegalArgumentException("illegal latitude " + latitude); } }
// in org/xbill/DNS/DNSOutput.java
private void check(long val, int bits) { long max = 1; max <<= bits; if (val < 0 || val > max) { throw new IllegalArgumentException(val + " out of range for " + bits + " bit value"); } }
// in org/xbill/DNS/DNSOutput.java
public void jump(int index) { if (index > pos) { throw new IllegalArgumentException("cannot jump past " + "end of data"); } pos = index; }
// in org/xbill/DNS/DNSOutput.java
public void writeU16At(int val, int where) { check(val, 16); if (where > pos - 2) throw new IllegalArgumentException("cannot write past " + "end of data"); array[where++] = (byte)((val >>> 8) & 0xFF); array[where++] = (byte)(val & 0xFF); }
// in org/xbill/DNS/DNSOutput.java
public void writeCountedString(byte [] s) { if (s.length > 0xFF) { throw new IllegalArgumentException("Invalid counted string"); } need(1 + s.length); array[pos++] = (byte)(s.length & 0xFF); writeByteArray(s, 0, s.length); }
// in org/xbill/DNS/Cache.java
private synchronized Element oneElement(Name name, Object types, int type, int minCred) { Element found = null; if (type == Type.ANY) throw new IllegalArgumentException("oneElement(ANY)"); if (types instanceof List) { List list = (List) types; for (int i = 0; i < list.size(); i++) { Element set = (Element) list.get(i); if (set.getType() == type) { found = set; break; } } } else { Element set = (Element) types; if (set.getType() == type) found = set; } if (found == null) return null; if (found.expired()) { removeElement(name, type); return null; } if (found.compareCredibility(minCred) < 0) return null; return found; }
// in org/xbill/DNS/Cache.java
private final int getCred(int section, boolean isAuth) { if (section == Section.ANSWER) { if (isAuth) return Credibility.AUTH_ANSWER; else return Credibility.NONAUTH_ANSWER; } else if (section == Section.AUTHORITY) { if (isAuth) return Credibility.AUTH_AUTHORITY; else return Credibility.NONAUTH_AUTHORITY; } else if (section == Section.ADDITIONAL) { return Credibility.ADDITIONAL; } else throw new IllegalArgumentException("getCred: invalid section"); }
// in org/xbill/DNS/RRset.java
public synchronized void addRR(Record r) { if (rrs.size() == 0) { safeAddRR(r); return; } Record first = first(); if (!r.sameRRset(first)) throw new IllegalArgumentException("record does not match " + "rrset"); if (r.getTTL() != first.getTTL()) { if (r.getTTL() > first.getTTL()) { r = r.cloneRecord(); r.setTTL(first.getTTL()); } else { for (int i = 0; i < rrs.size(); i++) { Record tmp = (Record) rrs.get(i); tmp = tmp.cloneRecord(); tmp.setTTL(r.getTTL()); rrs.set(i, tmp); } } } if (!rrs.contains(r)) safeAddRR(r); }
// in org/xbill/DNS/ZoneTransferIn.java
public void setTimeout(int secs) { if (secs < 0) throw new IllegalArgumentException("timeout cannot be " + "negative"); timeout = 1000L * secs; }
// in org/xbill/DNS/ZoneTransferIn.java
private BasicHandler getBasicHandler() throws IllegalArgumentException { if (handler instanceof BasicHandler) return (BasicHandler) handler; throw new IllegalArgumentException("ZoneTransferIn used callback " + "interface"); }
// in org/xbill/DNS/ClientSubnetOption.java
private static int checkMaskLength(String field, int family, int val) { int max = Address.addressLength(family) * 8; if (val < 0 || val > max) throw new IllegalArgumentException("\"" + field + "\" " + val + " must be in the range " + "[0.." + max + "]"); return val; }
// in org/xbill/DNS/Lookup.java
public void setNdots(int ndots) { if (ndots < 0) throw new IllegalArgumentException("Illegal ndots value: " + ndots); defaultNdots = ndots; }
10
              
// in org/xbill/DNS/ISDNRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/HINFORecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/Name.java
catch (TextParseException e) { throw new IllegalArgumentException("Invalid name '" + s + "'"); }
// in org/xbill/DNS/utils/HMAC.java
catch (NoSuchAlgorithmException e) { throw new IllegalArgumentException("unknown digest algorithm " + digestName); }
// in org/xbill/DNS/TXTBase.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/TSIG.java
catch (TextParseException e) { throw new IllegalArgumentException("Invalid TSIG key name"); }
// in org/xbill/DNS/Address.java
catch (UnknownHostException e) { throw new IllegalArgumentException("invalid address"); }
// in org/xbill/DNS/GPOSRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/ZoneTransferIn.java
catch (NameTooLongException e) { throw new IllegalArgumentException("ZoneTransferIn: " + "name too long"); }
// in org/xbill/DNS/NAPTRRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
2
              
// in org/xbill/DNS/GPOSRecord.java
private void validate(double longitude, double latitude) throws IllegalArgumentException { if (longitude < -90.0 || longitude > 90.0) { throw new IllegalArgumentException("illegal longitude " + longitude); } if (latitude < -180.0 || latitude > 180.0) { throw new IllegalArgumentException("illegal latitude " + latitude); } }
// in org/xbill/DNS/ZoneTransferIn.java
private BasicHandler getBasicHandler() throws IllegalArgumentException { if (handler instanceof BasicHandler) return (BasicHandler) handler; throw new IllegalArgumentException("ZoneTransferIn used callback " + "interface"); }
(Domain) WireParseException 28
              
// in org/xbill/DNS/APLRecord.java
private static byte [] parseAddress(byte [] in, int length) throws WireParseException { if (in.length > length) throw new WireParseException("invalid address length"); if (in.length == length) return in; byte [] out = new byte[length]; System.arraycopy(in, 0, out, 0, in.length); return out; }
// in org/xbill/DNS/APLRecord.java
void rrFromWire(DNSInput in) throws IOException { elements = new ArrayList(1); while (in.remaining() != 0) { int family = in.readU16(); int prefix = in.readU8(); int length = in.readU8(); boolean negative = (length & 0x80) != 0; length &= ~0x80; byte [] data = in.readByteArray(length); Element element; if (!validatePrefixLength(family, prefix)) { throw new WireParseException("invalid prefix length"); } if (family == Address.IPv4 || family == Address.IPv6) { data = parseAddress(data, Address.addressLength(family)); InetAddress addr = InetAddress.getByAddress(data); element = new Element(negative, addr, prefix); } else { element = new Element(family, negative, data, prefix); } elements.add(element); } }
// in org/xbill/DNS/Record.java
private static Record newRecord(Name name, int type, int dclass, long ttl, int length, DNSInput in) throws IOException { Record rec; rec = getEmptyRecord(name, type, dclass, ttl, in != null); if (in != null) { if (in.remaining() < length) throw new WireParseException("truncated record"); in.setActive(length); rec.rrFromWire(in); if (in.remaining() > 0) throw new WireParseException("invalid record length"); in.clearActive(); } return rec; }
// in org/xbill/DNS/SimpleResolver.java
public Message send(Message query) throws IOException { if (Options.check("verbose")) System.err.println("Sending to " + address.getAddress().getHostAddress() + ":" + address.getPort()); if (query.getHeader().getOpcode() == Opcode.QUERY) { Record question = query.getQuestion(); if (question != null && question.getType() == Type.AXFR) return sendAXFR(query); } query = (Message) query.clone(); applyEDNS(query); if (tsig != null) tsig.apply(query, null); byte [] out = query.toWire(Message.MAXLENGTH); int udpSize = maxUDPSize(query); boolean tcp = false; long endTime = System.currentTimeMillis() + timeoutValue; do { byte [] in; if (useTCP || out.length > udpSize) tcp = true; if (tcp) in = TCPClient.sendrecv(localAddress, address, out, endTime); else in = UDPClient.sendrecv(localAddress, address, out, udpSize, endTime); /* * Check that the response is long enough. */ if (in.length < Header.LENGTH) { throw new WireParseException("invalid DNS header - " + "too short"); } /* * Check that the response ID matches the query ID. We want * to check this before actually parsing the message, so that * if there's a malformed response that's not ours, it * doesn't confuse us. */ int id = ((in[0] & 0xFF) << 8) + (in[1] & 0xFF); int qid = query.getHeader().getID(); if (id != qid) { String error = "invalid message id: expected " + qid + "; got id " + id; if (tcp) { throw new WireParseException(error); } else { if (Options.check("verbose")) { System.err.println(error); } continue; } } Message response = parseMessage(in); verifyTSIG(query, response, in, tsig); if (!tcp && !ignoreTruncation && response.getHeader().getFlag(Flags.TC)) { tcp = true; continue; } return response; } while (true); }
// in org/xbill/DNS/SimpleResolver.java
private Message sendAXFR(Message query) throws IOException { Name qname = query.getQuestion().getName(); ZoneTransferIn xfrin = ZoneTransferIn.newAXFR(qname, address, tsig); xfrin.setTimeout((int)(getTimeout() / 1000)); xfrin.setLocalAddress(localAddress); try { xfrin.run(); } catch (ZoneTransferException e) { throw new WireParseException(e.getMessage()); } List records = xfrin.getAXFR(); Message response = new Message(query.getHeader().getID()); response.getHeader().setFlag(Flags.AA); response.getHeader().setFlag(Flags.QR); response.addRecord(query.getQuestion(), Section.QUESTION); Iterator it = records.iterator(); while (it.hasNext()) response.addRecord((Record)it.next(), Section.ANSWER); return response; }
// in org/xbill/DNS/DNSInput.java
private void require(int n) throws WireParseException{ if (n > remaining()) { throw new WireParseException("end of input"); } }
// in org/xbill/DNS/IPSECKEYRecord.java
void rrFromWire(DNSInput in) throws IOException { precedence = in.readU8(); gatewayType = in.readU8(); algorithmType = in.readU8(); switch (gatewayType) { case Gateway.None: gateway = null; break; case Gateway.IPv4: gateway = InetAddress.getByAddress(in.readByteArray(4)); break; case Gateway.IPv6: gateway = InetAddress.getByAddress(in.readByteArray(16)); break; case Gateway.Name: gateway = new Name(in); break; default: throw new WireParseException("invalid gateway type"); } if (in.remaining() > 0) key = in.readByteArray(); }
// in org/xbill/DNS/IPSECKEYRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { precedence = st.getUInt8(); gatewayType = st.getUInt8(); algorithmType = st.getUInt8(); switch (gatewayType) { case Gateway.None: String s = st.getString(); if (!s.equals(".")) throw new TextParseException("invalid gateway format"); gateway = null; break; case Gateway.IPv4: gateway = st.getAddress(Address.IPv4); break; case Gateway.IPv6: gateway = st.getAddress(Address.IPv6); break; case Gateway.Name: gateway = st.getName(origin); break; default: throw new WireParseException("invalid gateway type"); } key = st.getBase64(false); }
// in org/xbill/DNS/GPOSRecord.java
void rrFromWire(DNSInput in) throws IOException { longitude = in.readCountedString(); latitude = in.readCountedString(); altitude = in.readCountedString(); try { validate(getLongitude(), getLatitude()); } catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); } }
// in org/xbill/DNS/GPOSRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { try { longitude = byteArrayFromString(st.getString()); latitude = byteArrayFromString(st.getString()); altitude = byteArrayFromString(st.getString()); } catch (TextParseException e) { throw st.exception(e.getMessage()); } try { validate(getLongitude(), getLatitude()); } catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); } }
// in org/xbill/DNS/LOCRecord.java
void rrFromWire(DNSInput in) throws IOException { int version; version = in.readU8(); if (version != 0) throw new WireParseException("Invalid LOC version"); size = parseLOCformat(in.readU8()); hPrecision = parseLOCformat(in.readU8()); vPrecision = parseLOCformat(in.readU8()); latitude = in.readU32(); longitude = in.readU32(); altitude = in.readU32(); }
// in org/xbill/DNS/LOCRecord.java
private static long parseLOCformat(int b) throws WireParseException { long out = b >> 4; int exp = b & 0xF; if (out > 9 || exp > 9) throw new WireParseException("Invalid LOC Encoding"); while (exp-- > 0) out *= 10; return (out); }
// in org/xbill/DNS/EDNSOption.java
static EDNSOption fromWire(DNSInput in) throws IOException { int code, length; code = in.readU16(); length = in.readU16(); if (in.remaining() < length) throw new WireParseException("truncated option"); int save = in.saveActive(); in.setActive(length); EDNSOption option; switch (code) { case Code.NSID: option = new NSIDOption(); break; case Code.CLIENT_SUBNET: option = new ClientSubnetOption(); break; default: option = new GenericEDNSOption(code); break; } option.optionFromWire(in); in.restoreActive(save); return option; }
// in org/xbill/DNS/ZoneTransferIn.java
private Message parseMessage(byte [] b) throws WireParseException { try { return new Message(b); } catch (IOException e) { if (e instanceof WireParseException) throw (WireParseException) e; throw new WireParseException("Error parsing message"); } }
// in org/xbill/DNS/ClientSubnetOption.java
void optionFromWire(DNSInput in) throws WireParseException { family = in.readU16(); if (family != Address.IPv4 && family != Address.IPv6) throw new WireParseException("unknown address family"); sourceNetmask = in.readU8(); if (sourceNetmask > Address.addressLength(family) * 8) throw new WireParseException("invalid source netmask"); scopeNetmask = in.readU8(); if (scopeNetmask > Address.addressLength(family) * 8) throw new WireParseException("invalid scope netmask"); // Read the truncated address byte [] addr = in.readByteArray(); if (addr.length != (sourceNetmask + 7) / 8) throw new WireParseException("invalid address"); // Convert it to a full length address. byte [] fulladdr = new byte[Address.addressLength(family)]; System.arraycopy(addr, 0, fulladdr, 0, addr.length); try { address = InetAddress.getByAddress(fulladdr); } catch (UnknownHostException e) { throw new WireParseException("invalid address", e); } InetAddress tmp = Address.truncate(address, sourceNetmask); if (!tmp.equals(address)) throw new WireParseException("invalid padding"); }
5
              
// in org/xbill/DNS/SimpleResolver.java
catch (ZoneTransferException e) { throw new WireParseException(e.getMessage()); }
// in org/xbill/DNS/GPOSRecord.java
catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); }
// in org/xbill/DNS/GPOSRecord.java
catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); }
// in org/xbill/DNS/ZoneTransferIn.java
catch (IOException e) { if (e instanceof WireParseException) throw (WireParseException) e; throw new WireParseException("Error parsing message"); }
// in org/xbill/DNS/ClientSubnetOption.java
catch (UnknownHostException e) { throw new WireParseException("invalid address", e); }
14
              
// in org/xbill/DNS/APLRecord.java
private static byte [] parseAddress(byte [] in, int length) throws WireParseException { if (in.length > length) throw new WireParseException("invalid address length"); if (in.length == length) return in; byte [] out = new byte[length]; System.arraycopy(in, 0, out, 0, in.length); return out; }
// in org/xbill/DNS/SimpleResolver.java
private Message parseMessage(byte [] b) throws WireParseException { try { return (new Message(b)); } catch (IOException e) { if (Options.check("verbose")) e.printStackTrace(); if (!(e instanceof WireParseException)) e = new WireParseException("Error parsing message"); throw (WireParseException) e; } }
// in org/xbill/DNS/DNSInput.java
private void require(int n) throws WireParseException{ if (n > remaining()) { throw new WireParseException("end of input"); } }
// in org/xbill/DNS/DNSInput.java
public int readU8() throws WireParseException { require(1); return (array[pos++] & 0xFF); }
// in org/xbill/DNS/DNSInput.java
public int readU16() throws WireParseException { require(2); int b1 = array[pos++] & 0xFF; int b2 = array[pos++] & 0xFF; return ((b1 << 8) + b2); }
// in org/xbill/DNS/DNSInput.java
public long readU32() throws WireParseException { require(4); int b1 = array[pos++] & 0xFF; int b2 = array[pos++] & 0xFF; int b3 = array[pos++] & 0xFF; int b4 = array[pos++] & 0xFF; return (((long)b1 << 24) + (b2 << 16) + (b3 << 8) + b4); }
// in org/xbill/DNS/DNSInput.java
public void readByteArray(byte [] b, int off, int len) throws WireParseException { require(len); System.arraycopy(array, pos, b, off, len); pos += len; }
// in org/xbill/DNS/DNSInput.java
public byte [] readByteArray(int len) throws WireParseException { require(len); byte [] out = new byte[len]; System.arraycopy(array, pos, out, 0, len); pos += len; return out; }
// in org/xbill/DNS/DNSInput.java
public byte [] readCountedString() throws WireParseException { require(1); int len = array[pos++] & 0xFF; return readByteArray(len); }
// in org/xbill/DNS/LOCRecord.java
private static long parseLOCformat(int b) throws WireParseException { long out = b >> 4; int exp = b & 0xF; if (out > 9 || exp > 9) throw new WireParseException("Invalid LOC Encoding"); while (exp-- > 0) out *= 10; return (out); }
// in org/xbill/DNS/ZoneTransferIn.java
private Message parseMessage(byte [] b) throws WireParseException { try { return new Message(b); } catch (IOException e) { if (e instanceof WireParseException) throw (WireParseException) e; throw new WireParseException("Error parsing message"); } }
// in org/xbill/DNS/ClientSubnetOption.java
void optionFromWire(DNSInput in) throws WireParseException { family = in.readU16(); if (family != Address.IPv4 && family != Address.IPv6) throw new WireParseException("unknown address family"); sourceNetmask = in.readU8(); if (sourceNetmask > Address.addressLength(family) * 8) throw new WireParseException("invalid source netmask"); scopeNetmask = in.readU8(); if (scopeNetmask > Address.addressLength(family) * 8) throw new WireParseException("invalid scope netmask"); // Read the truncated address byte [] addr = in.readByteArray(); if (addr.length != (sourceNetmask + 7) / 8) throw new WireParseException("invalid address"); // Convert it to a full length address. byte [] fulladdr = new byte[Address.addressLength(family)]; System.arraycopy(addr, 0, fulladdr, 0, addr.length); try { address = InetAddress.getByAddress(fulladdr); } catch (UnknownHostException e) { throw new WireParseException("invalid address", e); } InetAddress tmp = Address.truncate(address, sourceNetmask); if (!tmp.equals(address)) throw new WireParseException("invalid padding"); }
(Lib) IllegalStateException 23
              
// in org/xbill/DNS/ExtendedResolver.java
public Message start() throws IOException { try { /* * First, try sending synchronously. If this works, * we're done. Otherwise, we'll get an exception * and continue. It would be easier to call send(0), * but this avoids a thread creation. If and when * SimpleResolver.sendAsync() can be made to not * create a thread, this could be changed. */ sent[0]++; outstanding++; inprogress[0] = new Object(); return resolvers[0].send(query); } catch (Exception e) { /* * This will either cause more queries to be sent * asynchronously or will set the 'done' flag. */ handleException(inprogress[0], e); } /* * Wait for a successful response or for each * subresolver to fail. */ synchronized (this) { while (!done) { try { wait(); } catch (InterruptedException e) { } } } /* Return the response or throw an exception */ if (response != null) return response; else if (thrown instanceof IOException) throw (IOException) thrown; else if (thrown instanceof RuntimeException) throw (RuntimeException) thrown; else if (thrown instanceof Error) throw (Error) thrown; else throw new IllegalStateException ("ExtendedResolver failure"); }
// in org/xbill/DNS/Record.java
Record cloneRecord() { try { return (Record) clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException(); } }
// in org/xbill/DNS/Name.java
private final void append(byte [] array, int start, int n) throws NameTooLongException { int length = (name == null ? 0 : (name.length - offset(0))); int alength = 0; for (int i = 0, pos = start; i < n; i++) { int len = array[pos]; if (len > MAXLABEL) throw new IllegalStateException("invalid label"); len++; pos += len; alength += len; } int newlength = length + alength; if (newlength > MAXNAME) throw new NameTooLongException(); int labels = getlabels(); int newlabels = labels + n; if (newlabels > MAXLABELS) throw new IllegalStateException("too many labels"); byte [] newname = new byte[newlength]; if (length != 0) System.arraycopy(name, offset(0), newname, 0, length); System.arraycopy(array, start, newname, length, alength); name = newname; for (int i = 0, pos = length; i < n; i++) { setoffset(labels + i, pos); pos += (newname[pos] + 1); } setlabels(newlabels); }
// in org/xbill/DNS/Name.java
public Name wild(int n) { if (n < 1) throw new IllegalArgumentException("must replace 1 or more " + "labels"); try { Name newname = new Name(); copy(wild, newname); newname.append(name, offset(n), getlabels() - n); return newname; } catch (NameTooLongException e) { throw new IllegalStateException ("Name.wild: concatenate failed"); } }
// in org/xbill/DNS/Name.java
public String toString() { int labels = labels(); if (labels == 0) return "@"; else if (labels == 1 && name[offset(0)] == 0) return "."; StringBuffer sb = new StringBuffer(); for (int i = 0, pos = offset(0); i < labels; i++) { int len = name[pos]; if (len > MAXLABEL) throw new IllegalStateException("invalid label"); if (len == 0) break; sb.append(byteString(name, pos)); sb.append('.'); pos += (1 + len); } if (!isAbsolute()) sb.deleteCharAt(sb.length() - 1); return sb.toString(); }
// in org/xbill/DNS/Name.java
public byte [] toWireCanonical() { int labels = labels(); if (labels == 0) return (new byte[0]); byte [] b = new byte[name.length - offset(0)]; for (int i = 0, spos = offset(0), dpos = 0; i < labels; i++) { int len = name[spos]; if (len > MAXLABEL) throw new IllegalStateException("invalid label"); b[dpos++] = name[spos++]; for (int j = 0; j < len; j++) b[dpos++] = lowercase[(name[spos++] & 0xFF)]; } return b; }
// in org/xbill/DNS/Name.java
private final boolean equals(byte [] b, int bpos) { int labels = labels(); for (int i = 0, pos = offset(0); i < labels; i++) { if (name[pos] != b[bpos]) return false; int len = name[pos++]; bpos++; if (len > MAXLABEL) throw new IllegalStateException("invalid label"); for (int j = 0; j < len; j++) if (lowercase[(name[pos++] & 0xFF)] != lowercase[(b[bpos++] & 0xFF)]) return false; } return true; }
// in org/xbill/DNS/Master.java
public Record _nextRecord() throws IOException { Tokenizer.Token token; String s; if (included != null) { Record rec = included.nextRecord(); if (rec != null) return rec; included = null; } if (generator != null) { Record rec = nextGenerated(); if (rec != null) return rec; endGenerate(); } while (true) { Name name; token = st.get(true, false); if (token.type == Tokenizer.WHITESPACE) { Tokenizer.Token next = st.get(); if (next.type == Tokenizer.EOL) continue; else if (next.type == Tokenizer.EOF) return null; else st.unget(); if (last == null) throw st.exception("no owner"); name = last.getName(); } else if (token.type == Tokenizer.EOL) continue; else if (token.type == Tokenizer.EOF) return null; else if (((String) token.value).charAt(0) == '$') { s = token.value; if (s.equalsIgnoreCase("$ORIGIN")) { origin = st.getName(Name.root); st.getEOL(); continue; } else if (s.equalsIgnoreCase("$TTL")) { defaultTTL = st.getTTL(); st.getEOL(); continue; } else if (s.equalsIgnoreCase("$INCLUDE")) { String filename = st.getString(); File newfile; if (file != null) { String parent = file.getParent(); newfile = new File(parent, filename); } else { newfile = new File(filename); } Name incorigin = origin; token = st.get(); if (token.isString()) { incorigin = parseName(token.value, Name.root); st.getEOL(); } included = new Master(newfile, incorigin, defaultTTL); /* * If we continued, we wouldn't be looking in * the new file. Recursing works better. */ return nextRecord(); } else if (s.equalsIgnoreCase("$GENERATE")) { if (generator != null) throw new IllegalStateException ("cannot nest $GENERATE"); startGenerate(); if (noExpandGenerate) { endGenerate(); continue; } return nextGenerated(); } else { throw st.exception("Invalid directive: " + s); } } else { s = token.value; name = parseName(s, origin); if (last != null && name.equals(last.getName())) { name = last.getName(); } } parseTTLClassAndType(); last = Record.fromString(name, currentType, currentDClass, currentTTL, st, origin); if (needSOATTL) { long ttl = ((SOARecord)last).getMinimum(); last.setTTL(ttl); defaultTTL = ttl; needSOATTL = false; } return last; } }
// in org/xbill/DNS/ReverseMap.java
public static Name fromAddress(byte [] addr) { if (addr.length != 4 && addr.length != 16) throw new IllegalArgumentException("array must contain " + "4 or 16 elements"); StringBuffer sb = new StringBuffer(); if (addr.length == 4) { for (int i = addr.length - 1; i >= 0; i--) { sb.append(addr[i] & 0xFF); if (i > 0) sb.append("."); } } else { int [] nibbles = new int[2]; for (int i = addr.length - 1; i >= 0; i--) { nibbles[0] = (addr[i] & 0xFF) >> 4; nibbles[1] = (addr[i] & 0xFF) & 0xF; for (int j = nibbles.length - 1; j >= 0; j--) { sb.append(Integer.toHexString(nibbles[j])); if (i > 0 || j > 0) sb.append("."); } } } try { if (addr.length == 4) return Name.fromString(sb.toString(), inaddr4); else return Name.fromString(sb.toString(), inaddr6); } catch (TextParseException e) { throw new IllegalStateException("name cannot be invalid"); } }
// in org/xbill/DNS/Tokenizer.java
public Token get(boolean wantWhitespace, boolean wantComment) throws IOException { int type; int c; if (ungottenToken) { ungottenToken = false; if (current.type == WHITESPACE) { if (wantWhitespace) return current; } else if (current.type == COMMENT) { if (wantComment) return current; } else { if (current.type == EOL) line++; return current; } } int skipped = skipWhitespace(); if (skipped > 0 && wantWhitespace) return current.set(WHITESPACE, null); type = IDENTIFIER; sb.setLength(0); while (true) { c = getChar(); if (c == -1 || delimiters.indexOf(c) != -1) { if (c == -1) { if (quoting) throw exception("EOF in " + "quoted string"); else if (sb.length() == 0) return current.set(EOF, null); else return current.set(type, sb); } if (sb.length() == 0 && type != QUOTED_STRING) { if (c == '(') { multiline++; skipWhitespace(); continue; } else if (c == ')') { if (multiline <= 0) throw exception("invalid " + "close " + "parenthesis"); multiline--; skipWhitespace(); continue; } else if (c == '"') { if (!quoting) { quoting = true; delimiters = quotes; type = QUOTED_STRING; } else { quoting = false; delimiters = delim; skipWhitespace(); } continue; } else if (c == '\n') { return current.set(EOL, null); } else if (c == ';') { while (true) { c = getChar(); if (c == '\n' || c == -1) break; sb.append((char)c); } if (wantComment) { ungetChar(c); return current.set(COMMENT, sb); } else if (c == -1 && type != QUOTED_STRING) { checkUnbalancedParens(); return current.set(EOF, null); } else if (multiline > 0) { skipWhitespace(); sb.setLength(0); continue; } else return current.set(EOL, null); } else throw new IllegalStateException(); } else ungetChar(c); break; } else if (c == '\\') { c = getChar(); if (c == -1) throw exception("unterminated escape sequence"); sb.append('\\'); } else if (quoting && c == '\n') { throw exception("newline in quoted string"); } sb.append((char)c); } if (sb.length() == 0 && type != QUOTED_STRING) { checkUnbalancedParens(); return current.set(EOF, null); } return current.set(type, sb); }
// in org/xbill/DNS/Tokenizer.java
public void unget() { if (ungottenToken) throw new IllegalStateException ("Cannot unget multiple tokens"); if (current.type == EOL) line--; ungottenToken = true; }
// in org/xbill/DNS/SetResponse.java
public String toString() { switch (type) { case UNKNOWN: return "unknown"; case NXDOMAIN: return "NXDOMAIN"; case NXRRSET: return "NXRRSET"; case DELEGATION: return "delegation: " + data; case CNAME: return "CNAME: " + data; case DNAME: return "DNAME: " + data; case SUCCESSFUL: return "successful"; default: throw new IllegalStateException(); } }
// in org/xbill/DNS/DNSSEC.java
private static void verify(PublicKey key, int alg, byte [] data, byte [] signature) throws DNSSECException { if (key instanceof DSAPublicKey) { try { signature = DSASignaturefromDNS(signature); } catch (IOException e) { throw new IllegalStateException(); } } try { Signature s = Signature.getInstance(algString(alg)); s.initVerify(key); s.update(data); if (!s.verify(signature)) throw new SignatureVerificationException(); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } }
// in org/xbill/DNS/DNSSEC.java
private static byte [] sign(PrivateKey privkey, PublicKey pubkey, int alg, byte [] data, String provider) throws DNSSECException { byte [] signature; try { Signature s; if (provider != null) s = Signature.getInstance(algString(alg), provider); else s = Signature.getInstance(algString(alg)); s.initSign(privkey); s.update(data); signature = s.sign(); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } if (pubkey instanceof DSAPublicKey) { try { DSAPublicKey dsa = (DSAPublicKey) pubkey; BigInteger P = dsa.getParams().getP(); int t = (BigIntegerLength(P) - 64) / 8; signature = DSASignaturetoDNS(signature, t); } catch (IOException e) { throw new IllegalStateException(); } } return signature; }
// in org/xbill/DNS/DNSSEC.java
static byte [] generateDSDigest(DNSKEYRecord key, int digestid) { MessageDigest digest; try { switch (digestid) { case DSRecord.Digest.SHA1: digest = MessageDigest.getInstance("sha-1"); break; case DSRecord.Digest.SHA256: digest = MessageDigest.getInstance("sha-256"); break; default: throw new IllegalArgumentException( "unknown DS digest type " + digestid); } } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("no message digest support"); } digest.update(key.getName().toWire()); digest.update(key.rdataToWireCanonical()); return digest.digest(); }
// in org/xbill/DNS/Header.java
void incCount(int field) { if (counts[field] == 0xFFFF) throw new IllegalStateException("DNS section count cannot " + "be incremented"); counts[field]++; }
// in org/xbill/DNS/Header.java
void decCount(int field) { if (counts[field] == 0) throw new IllegalStateException("DNS section count cannot " + "be decremented"); counts[field]--; }
// in org/xbill/DNS/DNSInput.java
public void restore() { if (saved_pos < 0) { throw new IllegalStateException("no previous state"); } pos = saved_pos; end = saved_end; saved_pos = -1; saved_end = -1; }
// in org/xbill/DNS/DNSOutput.java
public void restore() { if (saved_pos < 0) { throw new IllegalStateException("no previous state"); } pos = saved_pos; saved_pos = -1; }
// in org/xbill/DNS/RRset.java
public synchronized Record first() { if (rrs.size() == 0) throw new IllegalStateException("rrset is empty"); return (Record) rrs.get(0); }
// in org/xbill/DNS/Lookup.java
private void checkDone() { if (done && result != -1) return; StringBuffer sb = new StringBuffer("Lookup of " + name + " "); if (dclass != DClass.IN) sb.append(DClass.string(dclass) + " "); sb.append(Type.string(type) + " isn't done"); throw new IllegalStateException(sb.toString()); }
// in org/xbill/DNS/Lookup.java
public String getErrorString() { checkDone(); if (error != null) return error; switch (result) { case SUCCESSFUL: return "successful"; case UNRECOVERABLE: return "unrecoverable error"; case TRY_AGAIN: return "try again"; case HOST_NOT_FOUND: return "host not found"; case TYPE_NOT_FOUND: return "type not found"; } throw new IllegalStateException("unknown result"); }
6
              
// in org/xbill/DNS/Record.java
catch (CloneNotSupportedException e) { throw new IllegalStateException(); }
// in org/xbill/DNS/Name.java
catch (NameTooLongException e) { throw new IllegalStateException ("Name.wild: concatenate failed"); }
// in org/xbill/DNS/ReverseMap.java
catch (TextParseException e) { throw new IllegalStateException("name cannot be invalid"); }
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new IllegalStateException(); }
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new IllegalStateException(); }
// in org/xbill/DNS/DNSSEC.java
catch (NoSuchAlgorithmException e) { throw new IllegalStateException("no message digest support"); }
0
(Domain) TextParseException 14
              
// in org/xbill/DNS/FormattedTime.java
public static Date parse(String s) throws TextParseException { if (s.length() != 14) { throw new TextParseException("Invalid time encoding: " + s); } Calendar c = new GregorianCalendar(TimeZone.getTimeZone("UTC")); c.clear(); try { int year = Integer.parseInt(s.substring(0, 4)); int month = Integer.parseInt(s.substring(4, 6)) - 1; int date = Integer.parseInt(s.substring(6, 8)); int hour = Integer.parseInt(s.substring(8, 10)); int minute = Integer.parseInt(s.substring(10, 12)); int second = Integer.parseInt(s.substring(12, 14)); c.set(year, month, date, hour, minute, second); } catch (NumberFormatException e) { throw new TextParseException("Invalid time encoding: " + s); } return c.getTime(); }
// in org/xbill/DNS/Record.java
protected static byte [] byteArrayFromString(String s) throws TextParseException { byte [] array = s.getBytes(); boolean escaped = false; boolean hasEscapes = false; for (int i = 0; i < array.length; i++) { if (array[i] == '\\') { hasEscapes = true; break; } } if (!hasEscapes) { if (array.length > 255) { throw new TextParseException("text string too long"); } return array; } ByteArrayOutputStream os = new ByteArrayOutputStream(); int digits = 0; int intval = 0; for (int i = 0; i < array.length; i++) { byte b = array[i]; if (escaped) { if (b >= '0' && b <= '9' && digits < 3) { digits++; intval *= 10; intval += (b - '0'); if (intval > 255) throw new TextParseException ("bad escape"); if (digits < 3) continue; b = (byte) intval; } else if (digits > 0 && digits < 3) throw new TextParseException("bad escape"); os.write(b); escaped = false; } else if (array[i] == '\\') { escaped = true; digits = 0; intval = 0; } else os.write(array[i]); } if (digits > 0 && digits < 3) throw new TextParseException("bad escape"); array = os.toByteArray(); if (array.length > 255) { throw new TextParseException("text string too long"); } return os.toByteArray(); }
// in org/xbill/DNS/Generator.java
private String substitute(String spec, long n) throws IOException { boolean escaped = false; byte [] str = spec.getBytes(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < str.length; i++) { char c = (char)(str[i] & 0xFF); if (escaped) { sb.append(c); escaped = false; } else if (c == '\\') { if (i + 1 == str.length) throw new TextParseException ("invalid escape character"); escaped = true; } else if (c == '$') { boolean negative = false; long offset = 0; long width = 0; long base = 10; boolean wantUpperCase = false; if (i + 1 < str.length && str[i + 1] == '$') { // '$$' == literal '$' for backwards // compatibility with old versions of BIND. c = (char)(str[++i] & 0xFF); sb.append(c); continue; } else if (i + 1 < str.length && str[i + 1] == '{') { // It's a substitution with modifiers. i++; if (i + 1 < str.length && str[i + 1] == '-') { negative = true; i++; } while (i + 1 < str.length) { c = (char)(str[++i] & 0xFF); if (c == ',' || c == '}') break; if (c < '0' || c > '9') throw new TextParseException( "invalid offset"); c -= '0'; offset *= 10; offset += c; } if (negative) offset = -offset; if (c == ',') { while (i + 1 < str.length) { c = (char)(str[++i] & 0xFF); if (c == ',' || c == '}') break; if (c < '0' || c > '9') throw new TextParseException( "invalid width"); c -= '0'; width *= 10; width += c; } } if (c == ',') { if (i + 1 == str.length) throw new TextParseException( "invalid base"); c = (char)(str[++i] & 0xFF); if (c == 'o') base = 8; else if (c == 'x') base = 16; else if (c == 'X') { base = 16; wantUpperCase = true; } else if (c != 'd') throw new TextParseException( "invalid base"); } if (i + 1 == str.length || str[i + 1] != '}') throw new TextParseException ("invalid modifiers"); i++; } long v = n + offset; if (v < 0) throw new TextParseException ("invalid offset expansion"); String number; if (base == 8) number = Long.toOctalString(v); else if (base == 16) number = Long.toHexString(v); else number = Long.toString(v); if (wantUpperCase) number = number.toUpperCase(); if (width != 0 && width > number.length()) { int zeros = (int)width - number.length(); while (zeros-- > 0) sb.append('0'); } sb.append(number); } else { sb.append(c); } } return sb.toString(); }
// in org/xbill/DNS/IPSECKEYRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { precedence = st.getUInt8(); gatewayType = st.getUInt8(); algorithmType = st.getUInt8(); switch (gatewayType) { case Gateway.None: String s = st.getString(); if (!s.equals(".")) throw new TextParseException("invalid gateway format"); gateway = null; break; case Gateway.IPv4: gateway = st.getAddress(Address.IPv4); break; case Gateway.IPv6: gateway = st.getAddress(Address.IPv6); break; case Gateway.Name: gateway = st.getName(origin); break; default: throw new WireParseException("invalid gateway type"); } key = st.getBase64(false); }
1
              
// in org/xbill/DNS/FormattedTime.java
catch (NumberFormatException e) { throw new TextParseException("Invalid time encoding: " + s); }
14
              
// in org/xbill/DNS/FormattedTime.java
public static Date parse(String s) throws TextParseException { if (s.length() != 14) { throw new TextParseException("Invalid time encoding: " + s); } Calendar c = new GregorianCalendar(TimeZone.getTimeZone("UTC")); c.clear(); try { int year = Integer.parseInt(s.substring(0, 4)); int month = Integer.parseInt(s.substring(4, 6)) - 1; int date = Integer.parseInt(s.substring(6, 8)); int hour = Integer.parseInt(s.substring(8, 10)); int minute = Integer.parseInt(s.substring(10, 12)); int second = Integer.parseInt(s.substring(12, 14)); c.set(year, month, date, hour, minute, second); } catch (NumberFormatException e) { throw new TextParseException("Invalid time encoding: " + s); } return c.getTime(); }
// in org/xbill/DNS/Record.java
protected static byte [] byteArrayFromString(String s) throws TextParseException { byte [] array = s.getBytes(); boolean escaped = false; boolean hasEscapes = false; for (int i = 0; i < array.length; i++) { if (array[i] == '\\') { hasEscapes = true; break; } } if (!hasEscapes) { if (array.length > 255) { throw new TextParseException("text string too long"); } return array; } ByteArrayOutputStream os = new ByteArrayOutputStream(); int digits = 0; int intval = 0; for (int i = 0; i < array.length; i++) { byte b = array[i]; if (escaped) { if (b >= '0' && b <= '9' && digits < 3) { digits++; intval *= 10; intval += (b - '0'); if (intval > 255) throw new TextParseException ("bad escape"); if (digits < 3) continue; b = (byte) intval; } else if (digits > 0 && digits < 3) throw new TextParseException("bad escape"); os.write(b); escaped = false; } else if (array[i] == '\\') { escaped = true; digits = 0; intval = 0; } else os.write(array[i]); } if (digits > 0 && digits < 3) throw new TextParseException("bad escape"); array = os.toByteArray(); if (array.length > 255) { throw new TextParseException("text string too long"); } return os.toByteArray(); }
// in org/xbill/DNS/Name.java
private final void appendFromString(String fullName, byte [] array, int start, int n) throws TextParseException { try { append(array, start, n); } catch (NameTooLongException e) { throw parseException(fullName, "Name too long"); } }
// in org/xbill/DNS/Name.java
public static Name fromString(String s, Name origin) throws TextParseException { if (s.equals("@") && origin != null) return origin; else if (s.equals(".")) return (root); return new Name(s, origin); }
// in org/xbill/DNS/Name.java
public static Name fromString(String s) throws TextParseException { return fromString(s, null); }
// in org/xbill/DNS/Master.java
private Name parseName(String s, Name origin) throws TextParseException { try { return Name.fromString(s, origin); } catch (TextParseException e) { throw st.exception(e.getMessage()); } }
// in org/xbill/DNS/Tokenizer.java
private void checkUnbalancedParens() throws TextParseException { if (multiline > 0) throw exception("unbalanced parentheses"); }
// in org/xbill/DNS/Lookup.java
public static synchronized void setDefaultSearchPath(String [] domains) throws TextParseException { if (domains == null) { defaultSearchPath = null; return; } Name [] newdomains = new Name[domains.length]; for (int i = 0; i < domains.length; i++) newdomains[i] = Name.fromString(domains[i], Name.root); defaultSearchPath = newdomains; }
// in org/xbill/DNS/Lookup.java
public void setSearchPath(String [] domains) throws TextParseException { if (domains == null) { this.searchPath = null; return; } Name [] newdomains = new Name[domains.length]; for (int i = 0; i < domains.length; i++) newdomains[i] = Name.fromString(domains[i], Name.root); this.searchPath = newdomains; }
(Lib) IOException 11
              
// in org/xbill/DNS/DNSSEC.java
private static byte [] DSASignaturetoDNS(byte [] key, int t) throws IOException { DNSInput in = new DNSInput(key); DNSOutput out = new DNSOutput(); out.writeU8(t); int tmp = in.readU8(); if (tmp != ASN1_SEQ) throw new IOException(); int seqlen = in.readU8(); tmp = in.readU8(); if (tmp != ASN1_INT) throw new IOException(); int rlen = in.readU8(); if (rlen == DSA_LEN + 1) { if (in.readU8() != 0) throw new IOException(); } else if (rlen != DSA_LEN) throw new IOException(); byte [] bytes = in.readByteArray(DSA_LEN); out.writeByteArray(bytes); tmp = in.readU8(); if (tmp != ASN1_INT) throw new IOException(); int slen = in.readU8(); if (slen == DSA_LEN + 1) { if (in.readU8() != 0) throw new IOException(); } else if (slen != DSA_LEN) throw new IOException(); bytes = in.readByteArray(DSA_LEN); out.writeByteArray(bytes); return out.toByteArray(); }
// in org/xbill/DNS/Zone.java
private void validate() throws IOException { originNode = exactName(origin); if (originNode == null) throw new IOException(origin + ": no data specified"); RRset rrset = oneRRset(originNode, Type.SOA); if (rrset == null || rrset.size() != 1) throw new IOException(origin + ": exactly 1 SOA must be specified"); Iterator it = rrset.rrs(); SOA = (SOARecord) it.next(); NS = oneRRset(originNode, Type.NS); if (NS == null) throw new IOException(origin + ": no NS set specified"); }
// in org/xbill/DNS/Zone.java
private final void maybeAddRecord(Record record) throws IOException { int rtype = record.getType(); Name name = record.getName(); if (rtype == Type.SOA && !name.equals(origin)) { throw new IOException("SOA owner " + name + " does not match zone origin " + origin); } if (name.subdomain(origin)) addRecord(record); }
0 181
              
// in org/xbill/DNS/SSHFPRecord.java
void rrFromWire(DNSInput in) throws IOException { alg = in.readU8(); digestType = in.readU8(); fingerprint = in.readByteArray(); }
// in org/xbill/DNS/SSHFPRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { alg = st.getUInt8(); digestType = st.getUInt8(); fingerprint = st.getHex(true); }
// in org/xbill/DNS/APLRecord.java
void rrFromWire(DNSInput in) throws IOException { elements = new ArrayList(1); while (in.remaining() != 0) { int family = in.readU16(); int prefix = in.readU8(); int length = in.readU8(); boolean negative = (length & 0x80) != 0; length &= ~0x80; byte [] data = in.readByteArray(length); Element element; if (!validatePrefixLength(family, prefix)) { throw new WireParseException("invalid prefix length"); } if (family == Address.IPv4 || family == Address.IPv6) { data = parseAddress(data, Address.addressLength(family)); InetAddress addr = InetAddress.getByAddress(data); element = new Element(negative, addr, prefix); } else { element = new Element(family, negative, data, prefix); } elements.add(element); } }
// in org/xbill/DNS/APLRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { elements = new ArrayList(1); while (true) { Tokenizer.Token t = st.get(); if (!t.isString()) break; boolean negative = false; int family = 0; int prefix = 0; String s = t.value; int start = 0; if (s.startsWith("!")) { negative = true; start = 1; } int colon = s.indexOf(':', start); if (colon < 0) throw st.exception("invalid address prefix element"); int slash = s.indexOf('/', colon); if (slash < 0) throw st.exception("invalid address prefix element"); String familyString = s.substring(start, colon); String addressString = s.substring(colon + 1, slash); String prefixString = s.substring(slash + 1); try { family = Integer.parseInt(familyString); } catch (NumberFormatException e) { throw st.exception("invalid family"); } if (family != Address.IPv4 && family != Address.IPv6) throw st.exception("unknown family"); try { prefix = Integer.parseInt(prefixString); } catch (NumberFormatException e) { throw st.exception("invalid prefix length"); } if (!validatePrefixLength(family, prefix)) { throw st.exception("invalid prefix length"); } byte [] bytes = Address.toByteArray(addressString, family); if (bytes == null) throw st.exception("invalid IP address " + addressString); InetAddress address = InetAddress.getByAddress(bytes); elements.add(new Element(negative, address, prefix)); } st.unget(); }
// in org/xbill/DNS/NXTRecord.java
void rrFromWire(DNSInput in) throws IOException { next = new Name(in); bitmap = new BitSet(); int bitmapLength = in.remaining(); for (int i = 0; i < bitmapLength; i++) { int t = in.readU8(); for (int j = 0; j < 8; j++) if ((t & (1 << (7 - j))) != 0) bitmap.set(i * 8 + j); } }
// in org/xbill/DNS/NXTRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { next = st.getName(origin); bitmap = new BitSet(); while (true) { Tokenizer.Token t = st.get(); if (!t.isString()) break; int typecode = Type.value(t.value, true); if (typecode <= 0 || typecode > 128) throw st.exception("Invalid type: " + t.value); bitmap.set(typecode); } st.unget(); }
// in org/xbill/DNS/ISDNRecord.java
void rrFromWire(DNSInput in) throws IOException { address = in.readCountedString(); if (in.remaining() > 0) subAddress = in.readCountedString(); }
// in org/xbill/DNS/ISDNRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { try { address = byteArrayFromString(st.getString()); Tokenizer.Token t = st.get(); if (t.isString()) { subAddress = byteArrayFromString(t.value); } else { st.unget(); } } catch (TextParseException e) { throw st.exception(e.getMessage()); } }
// in org/xbill/DNS/TSIGRecord.java
void rrFromWire(DNSInput in) throws IOException { alg = new Name(in); long timeHigh = in.readU16(); long timeLow = in.readU32(); long time = (timeHigh << 32) + timeLow; timeSigned = new Date(time * 1000); fudge = in.readU16(); int sigLen = in.readU16(); signature = in.readByteArray(sigLen); originalID = in.readU16(); error = in.readU16(); int otherLen = in.readU16(); if (otherLen > 0) other = in.readByteArray(otherLen); else other = null; }
// in org/xbill/DNS/TSIGRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { throw st.exception("no text format defined for TSIG"); }
// in org/xbill/DNS/ARecord.java
void rrFromWire(DNSInput in) throws IOException { addr = fromArray(in.readByteArray(4)); }
// in org/xbill/DNS/ARecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { InetAddress address = st.getAddress(Address.IPv4); addr = fromArray(address.getAddress()); }
// in org/xbill/DNS/GenericEDNSOption.java
void optionFromWire(DNSInput in) throws IOException { data = in.readByteArray(); }
// in org/xbill/DNS/ExtendedResolver.java
public Message start() throws IOException { try { /* * First, try sending synchronously. If this works, * we're done. Otherwise, we'll get an exception * and continue. It would be easier to call send(0), * but this avoids a thread creation. If and when * SimpleResolver.sendAsync() can be made to not * create a thread, this could be changed. */ sent[0]++; outstanding++; inprogress[0] = new Object(); return resolvers[0].send(query); } catch (Exception e) { /* * This will either cause more queries to be sent * asynchronously or will set the 'done' flag. */ handleException(inprogress[0], e); } /* * Wait for a successful response or for each * subresolver to fail. */ synchronized (this) { while (!done) { try { wait(); } catch (InterruptedException e) { } } } /* Return the response or throw an exception */ if (response != null) return response; else if (thrown instanceof IOException) throw (IOException) thrown; else if (thrown instanceof RuntimeException) throw (RuntimeException) thrown; else if (thrown instanceof Error) throw (Error) thrown; else throw new IllegalStateException ("ExtendedResolver failure"); }
// in org/xbill/DNS/ExtendedResolver.java
public Message send(Message query) throws IOException { Resolution res = new Resolution(this, query); return res.start(); }
// in org/xbill/DNS/Record.java
private static Record newRecord(Name name, int type, int dclass, long ttl, int length, DNSInput in) throws IOException { Record rec; rec = getEmptyRecord(name, type, dclass, ttl, in != null); if (in != null) { if (in.remaining() < length) throw new WireParseException("truncated record"); in.setActive(length); rec.rrFromWire(in); if (in.remaining() > 0) throw new WireParseException("invalid record length"); in.clearActive(); } return rec; }
// in org/xbill/DNS/Record.java
static Record fromWire(DNSInput in, int section, boolean isUpdate) throws IOException { int type, dclass; long ttl; int length; Name name; Record rec; name = new Name(in); type = in.readU16(); dclass = in.readU16(); if (section == Section.QUESTION) return newRecord(name, type, dclass); ttl = in.readU32(); length = in.readU16(); if (length == 0 && isUpdate && (section == Section.PREREQ || section == Section.UPDATE)) return newRecord(name, type, dclass, ttl); rec = newRecord(name, type, dclass, ttl, length, in); return rec; }
// in org/xbill/DNS/Record.java
static Record fromWire(DNSInput in, int section) throws IOException { return fromWire(in, section, false); }
// in org/xbill/DNS/Record.java
public static Record fromWire(byte [] b, int section) throws IOException { return fromWire(new DNSInput(b), section, false); }
// in org/xbill/DNS/Record.java
public static Record fromString(Name name, int type, int dclass, long ttl, Tokenizer st, Name origin) throws IOException { Record rec; if (!name.isAbsolute()) throw new RelativeNameException(name); Type.check(type); DClass.check(dclass); TTL.check(ttl); Tokenizer.Token t = st.get(); if (t.type == Tokenizer.IDENTIFIER && t.value.equals("\\#")) { int length = st.getUInt16(); byte [] data = st.getHex(); if (data == null) { data = new byte[0]; } if (length != data.length) throw st.exception("invalid unknown RR encoding: " + "length mismatch"); DNSInput in = new DNSInput(data); return newRecord(name, type, dclass, ttl, length, in); } st.unget(); rec = getEmptyRecord(name, type, dclass, ttl, true); rec.rdataFromString(st, origin); t = st.get(); if (t.type != Tokenizer.EOL && t.type != Tokenizer.EOF) { throw st.exception("unexpected tokens at end of record"); } return rec; }
// in org/xbill/DNS/Record.java
public static Record fromString(Name name, int type, int dclass, long ttl, String s, Name origin) throws IOException { return fromString(name, type, dclass, ttl, new Tokenizer(s), origin); }
// in org/xbill/DNS/HINFORecord.java
void rrFromWire(DNSInput in) throws IOException { cpu = in.readCountedString(); os = in.readCountedString(); }
// in org/xbill/DNS/HINFORecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { try { cpu = byteArrayFromString(st.getString()); os = byteArrayFromString(st.getString()); } catch (TextParseException e) { throw st.exception(e.getMessage()); } }
// in org/xbill/DNS/SimpleResolver.java
public Message send(Message query) throws IOException { if (Options.check("verbose")) System.err.println("Sending to " + address.getAddress().getHostAddress() + ":" + address.getPort()); if (query.getHeader().getOpcode() == Opcode.QUERY) { Record question = query.getQuestion(); if (question != null && question.getType() == Type.AXFR) return sendAXFR(query); } query = (Message) query.clone(); applyEDNS(query); if (tsig != null) tsig.apply(query, null); byte [] out = query.toWire(Message.MAXLENGTH); int udpSize = maxUDPSize(query); boolean tcp = false; long endTime = System.currentTimeMillis() + timeoutValue; do { byte [] in; if (useTCP || out.length > udpSize) tcp = true; if (tcp) in = TCPClient.sendrecv(localAddress, address, out, endTime); else in = UDPClient.sendrecv(localAddress, address, out, udpSize, endTime); /* * Check that the response is long enough. */ if (in.length < Header.LENGTH) { throw new WireParseException("invalid DNS header - " + "too short"); } /* * Check that the response ID matches the query ID. We want * to check this before actually parsing the message, so that * if there's a malformed response that's not ours, it * doesn't confuse us. */ int id = ((in[0] & 0xFF) << 8) + (in[1] & 0xFF); int qid = query.getHeader().getID(); if (id != qid) { String error = "invalid message id: expected " + qid + "; got id " + id; if (tcp) { throw new WireParseException(error); } else { if (Options.check("verbose")) { System.err.println(error); } continue; } } Message response = parseMessage(in); verifyTSIG(query, response, in, tsig); if (!tcp && !ignoreTruncation && response.getHeader().getFlag(Flags.TC)) { tcp = true; continue; } return response; } while (true); }
// in org/xbill/DNS/SimpleResolver.java
private Message sendAXFR(Message query) throws IOException { Name qname = query.getQuestion().getName(); ZoneTransferIn xfrin = ZoneTransferIn.newAXFR(qname, address, tsig); xfrin.setTimeout((int)(getTimeout() / 1000)); xfrin.setLocalAddress(localAddress); try { xfrin.run(); } catch (ZoneTransferException e) { throw new WireParseException(e.getMessage()); } List records = xfrin.getAXFR(); Message response = new Message(query.getHeader().getID()); response.getHeader().setFlag(Flags.AA); response.getHeader().setFlag(Flags.QR); response.addRecord(query.getQuestion(), Section.QUESTION); Iterator it = records.iterator(); while (it.hasNext()) response.addRecord((Record)it.next(), Section.ANSWER); return response; }
// in org/xbill/DNS/AAAARecord.java
void rrFromWire(DNSInput in) throws IOException { address = InetAddress.getByAddress(in.readByteArray(16)); }
// in org/xbill/DNS/AAAARecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { address = st.getAddress(Address.IPv6); }
// in org/xbill/DNS/Master.java
private void parseTTLClassAndType() throws IOException { String s; boolean seen_class = false; // This is a bit messy, since any of the following are legal: // class ttl type // ttl class type // class type // ttl type // type seen_class = false; s = st.getString(); if ((currentDClass = DClass.value(s)) >= 0) { s = st.getString(); seen_class = true; } currentTTL = -1; try { currentTTL = TTL.parseTTL(s); s = st.getString(); } catch (NumberFormatException e) { if (defaultTTL >= 0) currentTTL = defaultTTL; else if (last != null) currentTTL = last.getTTL(); } if (!seen_class) { if ((currentDClass = DClass.value(s)) >= 0) { s = st.getString(); } else { currentDClass = DClass.IN; } } if ((currentType = Type.value(s)) < 0) throw st.exception("Invalid type '" + s + "'"); // BIND allows a missing TTL for the initial SOA record, and uses // the SOA minimum value. If the SOA is not the first record, // this is an error. if (currentTTL < 0) { if (currentType != Type.SOA) throw st.exception("missing TTL"); needSOATTL = true; currentTTL = 0; } }
// in org/xbill/DNS/Master.java
private void startGenerate() throws IOException { String s; int n; // The first field is of the form start-end[/step] // Regexes would be useful here. s = st.getIdentifier(); n = s.indexOf("-"); if (n < 0) throw st.exception("Invalid $GENERATE range specifier: " + s); String startstr = s.substring(0, n); String endstr = s.substring(n + 1); String stepstr = null; n = endstr.indexOf("/"); if (n >= 0) { stepstr = endstr.substring(n + 1); endstr = endstr.substring(0, n); } long start = parseUInt32(startstr); long end = parseUInt32(endstr); long step; if (stepstr != null) step = parseUInt32(stepstr); else step = 1; if (start < 0 || end < 0 || start > end || step <= 0) throw st.exception("Invalid $GENERATE range specifier: " + s); // The next field is the name specification. String nameSpec = st.getIdentifier(); // Then the ttl/class/type, in the same form as a normal record. // Only some types are supported. parseTTLClassAndType(); if (!Generator.supportedType(currentType)) throw st.exception("$GENERATE does not support " + Type.string(currentType) + " records"); // Next comes the rdata specification. String rdataSpec = st.getIdentifier(); // That should be the end. However, we don't want to move past the // line yet, so put back the EOL after reading it. st.getEOL(); st.unget(); generator = new Generator(start, end, step, nameSpec, currentType, currentDClass, currentTTL, rdataSpec, origin); if (generators == null) generators = new ArrayList(1); generators.add(generator); }
// in org/xbill/DNS/Master.java
private void endGenerate() throws IOException { // Read the EOL that we put back before. st.getEOL(); generator = null; }
// in org/xbill/DNS/Master.java
private Record nextGenerated() throws IOException { try { return generator.nextRecord(); } catch (Tokenizer.TokenizerException e) { throw st.exception("Parsing $GENERATE: " + e.getBaseMessage()); } catch (TextParseException e) { throw st.exception("Parsing $GENERATE: " + e.getMessage()); } }
// in org/xbill/DNS/Master.java
public Record _nextRecord() throws IOException { Tokenizer.Token token; String s; if (included != null) { Record rec = included.nextRecord(); if (rec != null) return rec; included = null; } if (generator != null) { Record rec = nextGenerated(); if (rec != null) return rec; endGenerate(); } while (true) { Name name; token = st.get(true, false); if (token.type == Tokenizer.WHITESPACE) { Tokenizer.Token next = st.get(); if (next.type == Tokenizer.EOL) continue; else if (next.type == Tokenizer.EOF) return null; else st.unget(); if (last == null) throw st.exception("no owner"); name = last.getName(); } else if (token.type == Tokenizer.EOL) continue; else if (token.type == Tokenizer.EOF) return null; else if (((String) token.value).charAt(0) == '$') { s = token.value; if (s.equalsIgnoreCase("$ORIGIN")) { origin = st.getName(Name.root); st.getEOL(); continue; } else if (s.equalsIgnoreCase("$TTL")) { defaultTTL = st.getTTL(); st.getEOL(); continue; } else if (s.equalsIgnoreCase("$INCLUDE")) { String filename = st.getString(); File newfile; if (file != null) { String parent = file.getParent(); newfile = new File(parent, filename); } else { newfile = new File(filename); } Name incorigin = origin; token = st.get(); if (token.isString()) { incorigin = parseName(token.value, Name.root); st.getEOL(); } included = new Master(newfile, incorigin, defaultTTL); /* * If we continued, we wouldn't be looking in * the new file. Recursing works better. */ return nextRecord(); } else if (s.equalsIgnoreCase("$GENERATE")) { if (generator != null) throw new IllegalStateException ("cannot nest $GENERATE"); startGenerate(); if (noExpandGenerate) { endGenerate(); continue; } return nextGenerated(); } else { throw st.exception("Invalid directive: " + s); } } else { s = token.value; name = parseName(s, origin); if (last != null && name.equals(last.getName())) { name = last.getName(); } } parseTTLClassAndType(); last = Record.fromString(name, currentType, currentDClass, currentTTL, st, origin); if (needSOATTL) { long ttl = ((SOARecord)last).getMinimum(); last.setTTL(ttl); defaultTTL = ttl; needSOATTL = false; } return last; } }
// in org/xbill/DNS/Master.java
public Record nextRecord() throws IOException { Record rec = null; try { rec = _nextRecord(); } finally { if (rec == null) { st.close(); } } return rec; }
// in org/xbill/DNS/TXTBase.java
void rrFromWire(DNSInput in) throws IOException { strings = new ArrayList(2); while (in.remaining() > 0) { byte [] b = in.readCountedString(); strings.add(b); } }
// in org/xbill/DNS/TXTBase.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { strings = new ArrayList(2); while (true) { Tokenizer.Token t = st.get(); if (!t.isString()) break; try { strings.add(byteArrayFromString(t.value)); } catch (TextParseException e) { throw st.exception(e.getMessage()); } } st.unget(); }
// in org/xbill/DNS/DLVRecord.java
void rrFromWire(DNSInput in) throws IOException { footprint = in.readU16(); alg = in.readU8(); digestid = in.readU8(); digest = in.readByteArray(); }
// in org/xbill/DNS/DLVRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { footprint = st.getUInt16(); alg = st.getUInt8(); digestid = st.getUInt8(); digest = st.getHex(); }
// in org/xbill/DNS/SingleNameBase.java
void rrFromWire(DNSInput in) throws IOException { singleName = new Name(in); }
// in org/xbill/DNS/SingleNameBase.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { singleName = st.getName(origin); }
// in org/xbill/DNS/KEYBase.java
void rrFromWire(DNSInput in) throws IOException { flags = in.readU16(); proto = in.readU8(); alg = in.readU8(); if (in.remaining() > 0) key = in.readByteArray(); }
// in org/xbill/DNS/Client.java
static protected void blockUntil(SelectionKey key, long endTime) throws IOException { long timeout = endTime - System.currentTimeMillis(); int nkeys = 0; if (timeout > 0) nkeys = key.selector().select(timeout); else if (timeout == 0) nkeys = key.selector().selectNow(); if (nkeys == 0) throw new SocketTimeoutException(); }
// in org/xbill/DNS/Client.java
void cleanup() throws IOException { key.selector().close(); key.channel().close(); }
// in org/xbill/DNS/NSEC3PARAMRecord.java
void rrFromWire(DNSInput in) throws IOException { hashAlg = in.readU8(); flags = in.readU8(); iterations = in.readU16(); int salt_length = in.readU8(); if (salt_length > 0) salt = in.readByteArray(salt_length); else salt = null; }
// in org/xbill/DNS/NSEC3PARAMRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { hashAlg = st.getUInt8(); flags = st.getUInt8(); iterations = st.getUInt16(); String s = st.getString(); if (s.equals("-")) salt = null; else { st.unget(); salt = st.getHexString(); if (salt.length > 255) throw st.exception("salt value too long"); } }
// in org/xbill/DNS/Tokenizer.java
private int getChar() throws IOException { int c = is.read(); if (c == '\r') { int next = is.read(); if (next != '\n') is.unread(next); c = '\n'; } if (c == '\n') line++; return c; }
// in org/xbill/DNS/Tokenizer.java
private void ungetChar(int c) throws IOException { if (c == -1) return; is.unread(c); if (c == '\n') line--; }
// in org/xbill/DNS/Tokenizer.java
private int skipWhitespace() throws IOException { int skipped = 0; while (true) { int c = getChar(); if (c != ' ' && c != '\t') { if (!(c == '\n' && multiline > 0)) { ungetChar(c); return skipped; } } skipped++; } }
// in org/xbill/DNS/Tokenizer.java
public Token get(boolean wantWhitespace, boolean wantComment) throws IOException { int type; int c; if (ungottenToken) { ungottenToken = false; if (current.type == WHITESPACE) { if (wantWhitespace) return current; } else if (current.type == COMMENT) { if (wantComment) return current; } else { if (current.type == EOL) line++; return current; } } int skipped = skipWhitespace(); if (skipped > 0 && wantWhitespace) return current.set(WHITESPACE, null); type = IDENTIFIER; sb.setLength(0); while (true) { c = getChar(); if (c == -1 || delimiters.indexOf(c) != -1) { if (c == -1) { if (quoting) throw exception("EOF in " + "quoted string"); else if (sb.length() == 0) return current.set(EOF, null); else return current.set(type, sb); } if (sb.length() == 0 && type != QUOTED_STRING) { if (c == '(') { multiline++; skipWhitespace(); continue; } else if (c == ')') { if (multiline <= 0) throw exception("invalid " + "close " + "parenthesis"); multiline--; skipWhitespace(); continue; } else if (c == '"') { if (!quoting) { quoting = true; delimiters = quotes; type = QUOTED_STRING; } else { quoting = false; delimiters = delim; skipWhitespace(); } continue; } else if (c == '\n') { return current.set(EOL, null); } else if (c == ';') { while (true) { c = getChar(); if (c == '\n' || c == -1) break; sb.append((char)c); } if (wantComment) { ungetChar(c); return current.set(COMMENT, sb); } else if (c == -1 && type != QUOTED_STRING) { checkUnbalancedParens(); return current.set(EOF, null); } else if (multiline > 0) { skipWhitespace(); sb.setLength(0); continue; } else return current.set(EOL, null); } else throw new IllegalStateException(); } else ungetChar(c); break; } else if (c == '\\') { c = getChar(); if (c == -1) throw exception("unterminated escape sequence"); sb.append('\\'); } else if (quoting && c == '\n') { throw exception("newline in quoted string"); } sb.append((char)c); } if (sb.length() == 0 && type != QUOTED_STRING) { checkUnbalancedParens(); return current.set(EOF, null); } return current.set(type, sb); }
// in org/xbill/DNS/Tokenizer.java
public Token get() throws IOException { return get(false, false); }
// in org/xbill/DNS/Tokenizer.java
public String getString() throws IOException { Token next = get(); if (!next.isString()) { throw exception("expected a string"); } return next.value; }
// in org/xbill/DNS/Tokenizer.java
private String _getIdentifier(String expected) throws IOException { Token next = get(); if (next.type != IDENTIFIER) throw exception("expected " + expected); return next.value; }
// in org/xbill/DNS/Tokenizer.java
public String getIdentifier() throws IOException { return _getIdentifier("an identifier"); }
// in org/xbill/DNS/Tokenizer.java
public long getLong() throws IOException { String next = _getIdentifier("an integer"); if (!Character.isDigit(next.charAt(0))) throw exception("expected an integer"); try { return Long.parseLong(next); } catch (NumberFormatException e) { throw exception("expected an integer"); } }
// in org/xbill/DNS/Tokenizer.java
public long getUInt32() throws IOException { long l = getLong(); if (l < 0 || l > 0xFFFFFFFFL) throw exception("expected an 32 bit unsigned integer"); return l; }
// in org/xbill/DNS/Tokenizer.java
public int getUInt16() throws IOException { long l = getLong(); if (l < 0 || l > 0xFFFFL) throw exception("expected an 16 bit unsigned integer"); return (int) l; }
// in org/xbill/DNS/Tokenizer.java
public int getUInt8() throws IOException { long l = getLong(); if (l < 0 || l > 0xFFL) throw exception("expected an 8 bit unsigned integer"); return (int) l; }
// in org/xbill/DNS/Tokenizer.java
public long getTTL() throws IOException { String next = _getIdentifier("a TTL value"); try { return TTL.parseTTL(next); } catch (NumberFormatException e) { throw exception("expected a TTL value"); } }
// in org/xbill/DNS/Tokenizer.java
public long getTTLLike() throws IOException { String next = _getIdentifier("a TTL-like value"); try { return TTL.parse(next, false); } catch (NumberFormatException e) { throw exception("expected a TTL-like value"); } }
// in org/xbill/DNS/Tokenizer.java
public Name getName(Name origin) throws IOException { String next = _getIdentifier("a name"); try { Name name = Name.fromString(next, origin); if (!name.isAbsolute()) throw new RelativeNameException(name); return name; } catch (TextParseException e) { throw exception(e.getMessage()); } }
// in org/xbill/DNS/Tokenizer.java
public InetAddress getAddress(int family) throws IOException { String next = _getIdentifier("an address"); try { return Address.getByAddress(next, family); } catch (UnknownHostException e) { throw exception(e.getMessage()); } }
// in org/xbill/DNS/Tokenizer.java
public void getEOL() throws IOException { Token next = get(); if (next.type != EOL && next.type != EOF) { throw exception("expected EOL or EOF"); } }
// in org/xbill/DNS/Tokenizer.java
private String remainingStrings() throws IOException { StringBuffer buffer = null; while (true) { Tokenizer.Token t = get(); if (!t.isString()) break; if (buffer == null) buffer = new StringBuffer(); buffer.append(t.value); } unget(); if (buffer == null) return null; return buffer.toString(); }
// in org/xbill/DNS/Tokenizer.java
public byte [] getBase64(boolean required) throws IOException { String s = remainingStrings(); if (s == null) { if (required) throw exception("expected base64 encoded string"); else return null; } byte [] array = base64.fromString(s); if (array == null) throw exception("invalid base64 encoding"); return array; }
// in org/xbill/DNS/Tokenizer.java
public byte [] getBase64() throws IOException { return getBase64(false); }
// in org/xbill/DNS/Tokenizer.java
public byte [] getHex(boolean required) throws IOException { String s = remainingStrings(); if (s == null) { if (required) throw exception("expected hex encoded string"); else return null; } byte [] array = base16.fromString(s); if (array == null) throw exception("invalid hex encoding"); return array; }
// in org/xbill/DNS/Tokenizer.java
public byte [] getHex() throws IOException { return getHex(false); }
// in org/xbill/DNS/Tokenizer.java
public byte [] getHexString() throws IOException { String next = _getIdentifier("a hex string"); byte [] array = base16.fromString(next); if (array == null) throw exception("invalid hex encoding"); return array; }
// in org/xbill/DNS/Tokenizer.java
public byte [] getBase32String(base32 b32) throws IOException { String next = _getIdentifier("a base32 string"); byte [] array = b32.fromString(next); if (array == null) throw exception("invalid base32 encoding"); return array; }
// in org/xbill/DNS/A6Record.java
void rrFromWire(DNSInput in) throws IOException { prefixBits = in.readU8(); int suffixbits = 128 - prefixBits; int suffixbytes = (suffixbits + 7) / 8; if (prefixBits < 128) { byte [] bytes = new byte[16]; in.readByteArray(bytes, 16 - suffixbytes, suffixbytes); suffix = InetAddress.getByAddress(bytes); } if (prefixBits > 0) prefix = new Name(in); }
// in org/xbill/DNS/A6Record.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { prefixBits = st.getUInt8(); if (prefixBits > 128) { throw st.exception("prefix bits must be [0..128]"); } else if (prefixBits < 128) { String s = st.getString(); try { suffix = Address.getByAddress(s, Address.IPv6); } catch (UnknownHostException e) { throw st.exception("invalid IPv6 address: " + s); } } if (prefixBits > 0) prefix = st.getName(origin); }
// in org/xbill/DNS/DNSSEC.java
private static BigInteger readBigInteger(DNSInput in, int len) throws IOException { byte [] b = in.readByteArray(len); return new BigInteger(1, b); }
// in org/xbill/DNS/DNSSEC.java
private static PublicKey toRSAPublicKey(KEYBase r) throws IOException, GeneralSecurityException { DNSInput in = new DNSInput(r.getKey()); int exponentLength = in.readU8(); if (exponentLength == 0) exponentLength = in.readU16(); BigInteger exponent = readBigInteger(in, exponentLength); BigInteger modulus = readBigInteger(in); KeyFactory factory = KeyFactory.getInstance("RSA"); return factory.generatePublic(new RSAPublicKeySpec(modulus, exponent)); }
// in org/xbill/DNS/DNSSEC.java
private static PublicKey toDSAPublicKey(KEYBase r) throws IOException, GeneralSecurityException, MalformedKeyException { DNSInput in = new DNSInput(r.getKey()); int t = in.readU8(); if (t > 8) throw new MalformedKeyException(r); BigInteger q = readBigInteger(in, 20); BigInteger p = readBigInteger(in, 64 + t*8); BigInteger g = readBigInteger(in, 64 + t*8); BigInteger y = readBigInteger(in, 64 + t*8); KeyFactory factory = KeyFactory.getInstance("DSA"); return factory.generatePublic(new DSAPublicKeySpec(y, p, q, g)); }
// in org/xbill/DNS/DNSSEC.java
private static byte [] DSASignaturefromDNS(byte [] dns) throws DNSSECException, IOException { if (dns.length != 1 + DSA_LEN * 2) throw new SignatureVerificationException(); DNSInput in = new DNSInput(dns); DNSOutput out = new DNSOutput(); int t = in.readU8(); byte [] r = in.readByteArray(DSA_LEN); int rlen = DSA_LEN; if (r[0] < 0) rlen++; byte [] s = in.readByteArray(DSA_LEN); int slen = DSA_LEN; if (s[0] < 0) slen++; out.writeU8(ASN1_SEQ); out.writeU8(rlen + slen + 4); out.writeU8(ASN1_INT); out.writeU8(rlen); if (rlen > DSA_LEN) out.writeU8(0); out.writeByteArray(r); out.writeU8(ASN1_INT); out.writeU8(slen); if (slen > DSA_LEN) out.writeU8(0); out.writeByteArray(s); return out.toByteArray(); }
// in org/xbill/DNS/DNSSEC.java
private static byte [] DSASignaturetoDNS(byte [] key, int t) throws IOException { DNSInput in = new DNSInput(key); DNSOutput out = new DNSOutput(); out.writeU8(t); int tmp = in.readU8(); if (tmp != ASN1_SEQ) throw new IOException(); int seqlen = in.readU8(); tmp = in.readU8(); if (tmp != ASN1_INT) throw new IOException(); int rlen = in.readU8(); if (rlen == DSA_LEN + 1) { if (in.readU8() != 0) throw new IOException(); } else if (rlen != DSA_LEN) throw new IOException(); byte [] bytes = in.readByteArray(DSA_LEN); out.writeByteArray(bytes); tmp = in.readU8(); if (tmp != ASN1_INT) throw new IOException(); int slen = in.readU8(); if (slen == DSA_LEN + 1) { if (in.readU8() != 0) throw new IOException(); } else if (slen != DSA_LEN) throw new IOException(); bytes = in.readByteArray(DSA_LEN); out.writeByteArray(bytes); return out.toByteArray(); }
// in org/xbill/DNS/RPRecord.java
void rrFromWire(DNSInput in) throws IOException { mailbox = new Name(in); textDomain = new Name(in); }
// in org/xbill/DNS/RPRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { mailbox = st.getName(origin); textDomain = st.getName(origin); }
// in org/xbill/DNS/DHCIDRecord.java
void rrFromWire(DNSInput in) throws IOException { data = in.readByteArray(); }
// in org/xbill/DNS/DHCIDRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { data = st.getBase64(); }
// in org/xbill/DNS/NULLRecord.java
void rrFromWire(DNSInput in) throws IOException { data = in.readByteArray(); }
// in org/xbill/DNS/NULLRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { throw st.exception("no defined text format for NULL records"); }
// in org/xbill/DNS/DNSKEYRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { flags = st.getUInt16(); proto = st.getUInt8(); String algString = st.getString(); alg = DNSSEC.Algorithm.value(algString); if (alg < 0) throw st.exception("Invalid algorithm: " + algString); key = st.getBase64(); }
// in org/xbill/DNS/CERTRecord.java
void rrFromWire(DNSInput in) throws IOException { certType = in.readU16(); keyTag = in.readU16(); alg = in.readU8(); cert = in.readByteArray(); }
// in org/xbill/DNS/CERTRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { String certTypeString = st.getString(); certType = CertificateType.value(certTypeString); if (certType < 0) throw st.exception("Invalid certificate type: " + certTypeString); keyTag = st.getUInt16(); String algString = st.getString(); alg = DNSSEC.Algorithm.value(algString); if (alg < 0) throw st.exception("Invalid algorithm: " + algString); cert = st.getBase64(); }
// in org/xbill/DNS/Generator.java
private String substitute(String spec, long n) throws IOException { boolean escaped = false; byte [] str = spec.getBytes(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < str.length; i++) { char c = (char)(str[i] & 0xFF); if (escaped) { sb.append(c); escaped = false; } else if (c == '\\') { if (i + 1 == str.length) throw new TextParseException ("invalid escape character"); escaped = true; } else if (c == '$') { boolean negative = false; long offset = 0; long width = 0; long base = 10; boolean wantUpperCase = false; if (i + 1 < str.length && str[i + 1] == '$') { // '$$' == literal '$' for backwards // compatibility with old versions of BIND. c = (char)(str[++i] & 0xFF); sb.append(c); continue; } else if (i + 1 < str.length && str[i + 1] == '{') { // It's a substitution with modifiers. i++; if (i + 1 < str.length && str[i + 1] == '-') { negative = true; i++; } while (i + 1 < str.length) { c = (char)(str[++i] & 0xFF); if (c == ',' || c == '}') break; if (c < '0' || c > '9') throw new TextParseException( "invalid offset"); c -= '0'; offset *= 10; offset += c; } if (negative) offset = -offset; if (c == ',') { while (i + 1 < str.length) { c = (char)(str[++i] & 0xFF); if (c == ',' || c == '}') break; if (c < '0' || c > '9') throw new TextParseException( "invalid width"); c -= '0'; width *= 10; width += c; } } if (c == ',') { if (i + 1 == str.length) throw new TextParseException( "invalid base"); c = (char)(str[++i] & 0xFF); if (c == 'o') base = 8; else if (c == 'x') base = 16; else if (c == 'X') { base = 16; wantUpperCase = true; } else if (c != 'd') throw new TextParseException( "invalid base"); } if (i + 1 == str.length || str[i + 1] != '}') throw new TextParseException ("invalid modifiers"); i++; } long v = n + offset; if (v < 0) throw new TextParseException ("invalid offset expansion"); String number; if (base == 8) number = Long.toOctalString(v); else if (base == 16) number = Long.toHexString(v); else number = Long.toString(v); if (wantUpperCase) number = number.toUpperCase(); if (width != 0 && width > number.length()) { int zeros = (int)width - number.length(); while (zeros-- > 0) sb.append('0'); } sb.append(number); } else { sb.append(c); } } return sb.toString(); }
// in org/xbill/DNS/Generator.java
public Record nextRecord() throws IOException { if (current > end) return null; String namestr = substitute(namePattern, current); Name name = Name.fromString(namestr, origin); String rdata = substitute(rdataPattern, current); current += step; return Record.fromString(name, type, dclass, ttl, rdata, origin); }
// in org/xbill/DNS/Generator.java
public Record [] expand() throws IOException { List list = new ArrayList(); for (long i = start; i < end; i += step) { String namestr = substitute(namePattern, current); Name name = Name.fromString(namestr, origin); String rdata = substitute(rdataPattern, current); list.add(Record.fromString(name, type, dclass, ttl, rdata, origin)); } return (Record []) list.toArray(new Record[list.size()]); }
// in org/xbill/DNS/TKEYRecord.java
void rrFromWire(DNSInput in) throws IOException { alg = new Name(in); timeInception = new Date(1000 * in.readU32()); timeExpire = new Date(1000 * in.readU32()); mode = in.readU16(); error = in.readU16(); int keylen = in.readU16(); if (keylen > 0) key = in.readByteArray(keylen); else key = null; int otherlen = in.readU16(); if (otherlen > 0) other = in.readByteArray(otherlen); else other = null; }
// in org/xbill/DNS/TKEYRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { throw st.exception("no text format defined for TKEY"); }
// in org/xbill/DNS/EmptyRecord.java
void rrFromWire(DNSInput in) throws IOException { }
// in org/xbill/DNS/EmptyRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { }
// in org/xbill/DNS/PXRecord.java
void rrFromWire(DNSInput in) throws IOException { preference = in.readU16(); map822 = new Name(in); mapX400 = new Name(in); }
// in org/xbill/DNS/PXRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { preference = st.getUInt16(); map822 = st.getName(origin); mapX400 = st.getName(origin); }
// in org/xbill/DNS/IPSECKEYRecord.java
void rrFromWire(DNSInput in) throws IOException { precedence = in.readU8(); gatewayType = in.readU8(); algorithmType = in.readU8(); switch (gatewayType) { case Gateway.None: gateway = null; break; case Gateway.IPv4: gateway = InetAddress.getByAddress(in.readByteArray(4)); break; case Gateway.IPv6: gateway = InetAddress.getByAddress(in.readByteArray(16)); break; case Gateway.Name: gateway = new Name(in); break; default: throw new WireParseException("invalid gateway type"); } if (in.remaining() > 0) key = in.readByteArray(); }
// in org/xbill/DNS/IPSECKEYRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { precedence = st.getUInt8(); gatewayType = st.getUInt8(); algorithmType = st.getUInt8(); switch (gatewayType) { case Gateway.None: String s = st.getString(); if (!s.equals(".")) throw new TextParseException("invalid gateway format"); gateway = null; break; case Gateway.IPv4: gateway = st.getAddress(Address.IPv4); break; case Gateway.IPv6: gateway = st.getAddress(Address.IPv6); break; case Gateway.Name: gateway = st.getName(origin); break; default: throw new WireParseException("invalid gateway type"); } key = st.getBase64(false); }
// in org/xbill/DNS/SRVRecord.java
void rrFromWire(DNSInput in) throws IOException { priority = in.readU16(); weight = in.readU16(); port = in.readU16(); target = new Name(in); }
// in org/xbill/DNS/SRVRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { priority = st.getUInt16(); weight = st.getUInt16(); port = st.getUInt16(); target = st.getName(origin); }
// in org/xbill/DNS/Zone.java
private void validate() throws IOException { originNode = exactName(origin); if (originNode == null) throw new IOException(origin + ": no data specified"); RRset rrset = oneRRset(originNode, Type.SOA); if (rrset == null || rrset.size() != 1) throw new IOException(origin + ": exactly 1 SOA must be specified"); Iterator it = rrset.rrs(); SOA = (SOARecord) it.next(); NS = oneRRset(originNode, Type.NS); if (NS == null) throw new IOException(origin + ": no NS set specified"); }
// in org/xbill/DNS/Zone.java
private final void maybeAddRecord(Record record) throws IOException { int rtype = record.getType(); Name name = record.getName(); if (rtype == Type.SOA && !name.equals(origin)) { throw new IOException("SOA owner " + name + " does not match zone origin " + origin); } if (name.subdomain(origin)) addRecord(record); }
// in org/xbill/DNS/Zone.java
private void fromXFR(ZoneTransferIn xfrin) throws IOException, ZoneTransferException { data = new TreeMap(); origin = xfrin.getName(); List records = xfrin.run(); for (Iterator it = records.iterator(); it.hasNext(); ) { Record record = (Record) it.next(); maybeAddRecord(record); } if (!xfrin.isAXFR()) throw new IllegalArgumentException("zones can only be " + "created from AXFRs"); validate(); }
// in org/xbill/DNS/GPOSRecord.java
void rrFromWire(DNSInput in) throws IOException { longitude = in.readCountedString(); latitude = in.readCountedString(); altitude = in.readCountedString(); try { validate(getLongitude(), getLatitude()); } catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); } }
// in org/xbill/DNS/GPOSRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { try { longitude = byteArrayFromString(st.getString()); latitude = byteArrayFromString(st.getString()); altitude = byteArrayFromString(st.getString()); } catch (TextParseException e) { throw st.exception(e.getMessage()); } try { validate(getLongitude(), getLatitude()); } catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); } }
// in org/xbill/DNS/KEYRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { String flagString = st.getIdentifier(); flags = Flags.value(flagString); if (flags < 0) throw st.exception("Invalid flags: " + flagString); String protoString = st.getIdentifier(); proto = Protocol.value(protoString); if (proto < 0) throw st.exception("Invalid protocol: " + protoString); String algString = st.getIdentifier(); alg = DNSSEC.Algorithm.value(algString); if (alg < 0) throw st.exception("Invalid algorithm: " + algString); /* If this is a null KEY, there's no key data */ if ((flags & Flags.USE_MASK) == Flags.NOKEY) key = null; else key = st.getBase64(); }
// in org/xbill/DNS/LOCRecord.java
void rrFromWire(DNSInput in) throws IOException { int version; version = in.readU8(); if (version != 0) throw new WireParseException("Invalid LOC version"); size = parseLOCformat(in.readU8()); hPrecision = parseLOCformat(in.readU8()); vPrecision = parseLOCformat(in.readU8()); latitude = in.readU32(); longitude = in.readU32(); altitude = in.readU32(); }
// in org/xbill/DNS/LOCRecord.java
private long parsePosition(Tokenizer st, String type) throws IOException { boolean isLatitude = type.equals("latitude"); int deg = 0, min = 0; double sec = 0; long value; String s; deg = st.getUInt16(); if (deg > 180 || (deg > 90 && isLatitude)) throw st.exception("Invalid LOC " + type + " degrees"); s = st.getString(); try { min = Integer.parseInt(s); if (min < 0 || min > 59) throw st.exception("Invalid LOC " + type + " minutes"); s = st.getString(); sec = parseFixedPoint(s); if (sec < 0 || sec >= 60) throw st.exception("Invalid LOC " + type + " seconds"); s = st.getString(); } catch (NumberFormatException e) { } if (s.length() != 1) throw st.exception("Invalid LOC " + type); value = (long) (1000 * (sec + 60L * (min + 60L * deg))); char c = Character.toUpperCase(s.charAt(0)); if ((isLatitude && c == 'S') || (!isLatitude && c == 'W')) value = -value; else if ((isLatitude && c != 'N') || (!isLatitude && c != 'E')) throw st.exception("Invalid LOC " + type); value += (1L << 31); return value; }
// in org/xbill/DNS/LOCRecord.java
private long parseDouble(Tokenizer st, String type, boolean required, long min, long max, long defaultValue) throws IOException { Tokenizer.Token token = st.get(); if (token.isEOL()) { if (required) throw st.exception("Invalid LOC " + type); st.unget(); return defaultValue; } String s = token.value; if (s.length() > 1 && s.charAt(s.length() - 1) == 'm') s = s.substring(0, s.length() - 1); try { long value = (long)(100 * parseFixedPoint(s)); if (value < min || value > max) throw st.exception("Invalid LOC " + type); return value; } catch (NumberFormatException e) { throw st.exception("Invalid LOC " + type); } }
// in org/xbill/DNS/LOCRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { latitude = parsePosition(st, "latitude"); longitude = parsePosition(st, "longitude"); altitude = parseDouble(st, "altitude", true, -10000000, 4284967295L, 0) + 10000000; size = parseDouble(st, "size", false, 0, 9000000000L, 100); hPrecision = parseDouble(st, "horizontal precision", false, 0, 9000000000L, 1000000); vPrecision = parseDouble(st, "vertical precision", false, 0, 9000000000L, 1000); }
// in org/xbill/DNS/SOARecord.java
void rrFromWire(DNSInput in) throws IOException { host = new Name(in); admin = new Name(in); serial = in.readU32(); refresh = in.readU32(); retry = in.readU32(); expire = in.readU32(); minimum = in.readU32(); }
// in org/xbill/DNS/SOARecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { host = st.getName(origin); admin = st.getName(origin); serial = st.getUInt32(); refresh = st.getTTLLike(); retry = st.getTTLLike(); expire = st.getTTLLike(); minimum = st.getTTLLike(); }
// in org/xbill/DNS/X25Record.java
void rrFromWire(DNSInput in) throws IOException { address = in.readCountedString(); }
// in org/xbill/DNS/X25Record.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { String addr = st.getString(); this.address = checkAndConvertAddress(addr); if (this.address == null) throw st.exception("invalid PSDN address " + addr); }
// in org/xbill/DNS/EDNSOption.java
static EDNSOption fromWire(DNSInput in) throws IOException { int code, length; code = in.readU16(); length = in.readU16(); if (in.remaining() < length) throw new WireParseException("truncated option"); int save = in.saveActive(); in.setActive(length); EDNSOption option; switch (code) { case Code.NSID: option = new NSIDOption(); break; case Code.CLIENT_SUBNET: option = new ClientSubnetOption(); break; default: option = new GenericEDNSOption(code); break; } option.optionFromWire(in); in.restoreActive(save); return option; }
// in org/xbill/DNS/EDNSOption.java
public static EDNSOption fromWire(byte [] b) throws IOException { return fromWire(new DNSInput(b)); }
// in org/xbill/DNS/EDNSOption.java
public byte [] toWire() throws IOException { DNSOutput out = new DNSOutput(); toWire(out); return out.toByteArray(); }
// in org/xbill/DNS/UNKRecord.java
void rrFromWire(DNSInput in) throws IOException { data = in.readByteArray(); }
// in org/xbill/DNS/UNKRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { throw st.exception("invalid unknown RR encoding"); }
// in org/xbill/DNS/U16NameBase.java
void rrFromWire(DNSInput in) throws IOException { u16Field = in.readU16(); nameField = new Name(in); }
// in org/xbill/DNS/U16NameBase.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { u16Field = st.getUInt16(); nameField = st.getName(origin); }
// in org/xbill/DNS/ZoneTransferIn.java
private void openConnection() throws IOException { long endTime = System.currentTimeMillis() + timeout; client = new TCPClient(endTime); if (localAddress != null) client.bind(localAddress); client.connect(address); }
// in org/xbill/DNS/ZoneTransferIn.java
private void sendQuery() throws IOException { Record question = Record.newRecord(zname, qtype, dclass); Message query = new Message(); query.getHeader().setOpcode(Opcode.QUERY); query.addRecord(question, Section.QUESTION); if (qtype == Type.IXFR) { Record soa = new SOARecord(zname, dclass, 0, Name.root, Name.root, ixfr_serial, 0, 0, 0, 0); query.addRecord(soa, Section.AUTHORITY); } if (tsig != null) { tsig.apply(query, null); verifier = new TSIG.StreamVerifier(tsig, query.getTSIG()); } byte [] out = query.toWire(Message.MAXLENGTH); client.send(out); }
// in org/xbill/DNS/ZoneTransferIn.java
private void doxfr() throws IOException, ZoneTransferException { sendQuery(); while (state != END) { byte [] in = client.recv(); Message response = parseMessage(in); if (response.getHeader().getRcode() == Rcode.NOERROR && verifier != null) { TSIGRecord tsigrec = response.getTSIG(); int error = verifier.verify(response, in); if (error != Rcode.NOERROR) fail("TSIG failure"); } Record [] answers = response.getSectionArray(Section.ANSWER); if (state == INITIALSOA) { int rcode = response.getRcode(); if (rcode != Rcode.NOERROR) { if (qtype == Type.IXFR && rcode == Rcode.NOTIMP) { fallback(); doxfr(); return; } fail(Rcode.string(rcode)); } Record question = response.getQuestion(); if (question != null && question.getType() != qtype) { fail("invalid question section"); } if (answers.length == 0 && qtype == Type.IXFR) { fallback(); doxfr(); return; } } for (int i = 0; i < answers.length; i++) { parseRR(answers[i]); } if (state == END && verifier != null && !response.isVerified()) fail("last message must be signed"); } }
// in org/xbill/DNS/ZoneTransferIn.java
public void run(ZoneTransferHandler handler) throws IOException, ZoneTransferException { this.handler = handler; try { openConnection(); doxfr(); } finally { closeConnection(); } }
// in org/xbill/DNS/ZoneTransferIn.java
public List run() throws IOException, ZoneTransferException { BasicHandler handler = new BasicHandler(); run(handler); if (handler.axfr != null) return handler.axfr; return handler.ixfr; }
// in org/xbill/DNS/TCPClient.java
void bind(SocketAddress addr) throws IOException { SocketChannel channel = (SocketChannel) key.channel(); channel.socket().bind(addr); }
// in org/xbill/DNS/TCPClient.java
void connect(SocketAddress addr) throws IOException { SocketChannel channel = (SocketChannel) key.channel(); if (channel.connect(addr)) return; key.interestOps(SelectionKey.OP_CONNECT); try { while (!channel.finishConnect()) { if (!key.isConnectable()) blockUntil(key, endTime); } } finally { if (key.isValid()) key.interestOps(0); } }
// in org/xbill/DNS/TCPClient.java
void send(byte [] data) throws IOException { SocketChannel channel = (SocketChannel) key.channel(); verboseLog("TCP write", data); byte [] lengthArray = new byte[2]; lengthArray[0] = (byte)(data.length >>> 8); lengthArray[1] = (byte)(data.length & 0xFF); ByteBuffer [] buffers = new ByteBuffer[2]; buffers[0] = ByteBuffer.wrap(lengthArray); buffers[1] = ByteBuffer.wrap(data); int nsent = 0; key.interestOps(SelectionKey.OP_WRITE); try { while (nsent < data.length + 2) { if (key.isWritable()) { long n = channel.write(buffers); if (n < 0) throw new EOFException(); nsent += (int) n; if (nsent < data.length + 2 && System.currentTimeMillis() > endTime) throw new SocketTimeoutException(); } else blockUntil(key, endTime); } } finally { if (key.isValid()) key.interestOps(0); } }
// in org/xbill/DNS/TCPClient.java
private byte [] _recv(int length) throws IOException { SocketChannel channel = (SocketChannel) key.channel(); int nrecvd = 0; byte [] data = new byte[length]; ByteBuffer buffer = ByteBuffer.wrap(data); key.interestOps(SelectionKey.OP_READ); try { while (nrecvd < length) { if (key.isReadable()) { long n = channel.read(buffer); if (n < 0) throw new EOFException(); nrecvd += (int) n; if (nrecvd < length && System.currentTimeMillis() > endTime) throw new SocketTimeoutException(); } else blockUntil(key, endTime); } } finally { if (key.isValid()) key.interestOps(0); } return data; }
// in org/xbill/DNS/TCPClient.java
byte [] recv() throws IOException { byte [] buf = _recv(2); int length = ((buf[0] & 0xFF) << 8) + (buf[1] & 0xFF); byte [] data = _recv(length); verboseLog("TCP read", data); return data; }
// in org/xbill/DNS/TCPClient.java
static byte [] sendrecv(SocketAddress local, SocketAddress remote, byte [] data, long endTime) throws IOException { TCPClient client = new TCPClient(endTime); try { if (local != null) client.bind(local); client.connect(remote); client.send(data); return client.recv(); } finally { client.cleanup(); } }
// in org/xbill/DNS/TCPClient.java
static byte [] sendrecv(SocketAddress addr, byte [] data, long endTime) throws IOException { return sendrecv(null, addr, data, endTime); }
// in org/xbill/DNS/OPTRecord.java
void rrFromWire(DNSInput in) throws IOException { if (in.remaining() > 0) options = new ArrayList(); while (in.remaining() > 0) { EDNSOption option = EDNSOption.fromWire(in); options.add(option); } }
// in org/xbill/DNS/OPTRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { throw st.exception("no text format defined for OPT"); }
// in org/xbill/DNS/UDPClient.java
private void bind_random(InetSocketAddress addr) throws IOException { if (prng_initializing) { try { Thread.sleep(2); } catch (InterruptedException e) { } if (prng_initializing) return; } DatagramChannel channel = (DatagramChannel) key.channel(); InetSocketAddress temp; for (int i = 0; i < 1024; i++) { try { int port = prng.nextInt(EPHEMERAL_RANGE) + EPHEMERAL_START; if (addr != null) temp = new InetSocketAddress(addr.getAddress(), port); else temp = new InetSocketAddress(port); channel.socket().bind(temp); bound = true; return; } catch (SocketException e) { } } }
// in org/xbill/DNS/UDPClient.java
void bind(SocketAddress addr) throws IOException { if (addr == null || (addr instanceof InetSocketAddress && ((InetSocketAddress)addr).getPort() == 0)) { bind_random((InetSocketAddress) addr); if (bound) return; } if (addr != null) { DatagramChannel channel = (DatagramChannel) key.channel(); channel.socket().bind(addr); bound = true; } }
// in org/xbill/DNS/UDPClient.java
void connect(SocketAddress addr) throws IOException { if (!bound) bind(null); DatagramChannel channel = (DatagramChannel) key.channel(); channel.connect(addr); }
// in org/xbill/DNS/UDPClient.java
void send(byte [] data) throws IOException { DatagramChannel channel = (DatagramChannel) key.channel(); verboseLog("UDP write", data); channel.write(ByteBuffer.wrap(data)); }
// in org/xbill/DNS/UDPClient.java
byte [] recv(int max) throws IOException { DatagramChannel channel = (DatagramChannel) key.channel(); byte [] temp = new byte[max]; key.interestOps(SelectionKey.OP_READ); try { while (!key.isReadable()) blockUntil(key, endTime); } finally { if (key.isValid()) key.interestOps(0); } long ret = channel.read(ByteBuffer.wrap(temp)); if (ret <= 0) throw new EOFException(); int len = (int) ret; byte [] data = new byte[len]; System.arraycopy(temp, 0, data, 0, len); verboseLog("UDP read", data); return data; }
// in org/xbill/DNS/UDPClient.java
static byte [] sendrecv(SocketAddress local, SocketAddress remote, byte [] data, int max, long endTime) throws IOException { UDPClient client = new UDPClient(endTime); try { client.bind(local); client.connect(remote); client.send(data); return client.recv(max); } finally { client.cleanup(); } }
// in org/xbill/DNS/UDPClient.java
static byte [] sendrecv(SocketAddress addr, byte [] data, int max, long endTime) throws IOException { return sendrecv(null, addr, data, max, endTime); }
// in org/xbill/DNS/Update.java
public void present(Name name, int type, String record) throws IOException { newPrereq(Record.fromString(name, type, dclass, 0, record, origin)); }
// in org/xbill/DNS/Update.java
public void present(Name name, int type, Tokenizer tokenizer) throws IOException { newPrereq(Record.fromString(name, type, dclass, 0, tokenizer, origin)); }
// in org/xbill/DNS/Update.java
public void add(Name name, int type, long ttl, String record) throws IOException { newUpdate(Record.fromString(name, type, dclass, ttl, record, origin)); }
// in org/xbill/DNS/Update.java
public void add(Name name, int type, long ttl, Tokenizer tokenizer) throws IOException { newUpdate(Record.fromString(name, type, dclass, ttl, tokenizer, origin)); }
// in org/xbill/DNS/Update.java
public void delete(Name name, int type, String record) throws IOException { newUpdate(Record.fromString(name, type, DClass.NONE, 0, record, origin)); }
// in org/xbill/DNS/Update.java
public void delete(Name name, int type, Tokenizer tokenizer) throws IOException { newUpdate(Record.fromString(name, type, DClass.NONE, 0, tokenizer, origin)); }
// in org/xbill/DNS/Update.java
public void replace(Name name, int type, long ttl, String record) throws IOException { delete(name, type); add(name, type, ttl, record); }
// in org/xbill/DNS/Update.java
public void replace(Name name, int type, long ttl, Tokenizer tokenizer) throws IOException { delete(name, type); add(name, type, ttl, tokenizer); }
// in org/xbill/DNS/DSRecord.java
void rrFromWire(DNSInput in) throws IOException { footprint = in.readU16(); alg = in.readU8(); digestid = in.readU8(); digest = in.readByteArray(); }
// in org/xbill/DNS/DSRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { footprint = st.getUInt16(); alg = st.getUInt8(); digestid = st.getUInt8(); digest = st.getHex(); }
// in org/xbill/DNS/MINFORecord.java
void rrFromWire(DNSInput in) throws IOException { responsibleAddress = new Name(in); errorAddress = new Name(in); }
// in org/xbill/DNS/MINFORecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { responsibleAddress = st.getName(origin); errorAddress = st.getName(origin); }
// in org/xbill/DNS/NSAPRecord.java
void rrFromWire(DNSInput in) throws IOException { address = in.readByteArray(); }
// in org/xbill/DNS/NSAPRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { String addr = st.getString(); this.address = checkAndConvertAddress(addr); if (this.address == null) throw st.exception("invalid NSAP address " + addr); }
// in org/xbill/DNS/WKSRecord.java
void rrFromWire(DNSInput in) throws IOException { address = in.readByteArray(4); protocol = in.readU8(); byte [] array = in.readByteArray(); List list = new ArrayList(); for (int i = 0; i < array.length; i++) { for (int j = 0; j < 8; j++) { int octet = array[i] & 0xFF; if ((octet & (1 << (7 - j))) != 0) { list.add(new Integer(i * 8 + j)); } } } services = new int[list.size()]; for (int i = 0; i < list.size(); i++) { services[i] = ((Integer) list.get(i)).intValue(); } }
// in org/xbill/DNS/WKSRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { String s = st.getString(); address = Address.toByteArray(s, Address.IPv4); if (address == null) throw st.exception("invalid address"); s = st.getString(); protocol = Protocol.value(s); if (protocol < 0) { throw st.exception("Invalid IP protocol: " + s); } List list = new ArrayList(); while (true) { Tokenizer.Token t = st.get(); if (!t.isString()) break; int service = Service.value(t.value); if (service < 0) { throw st.exception("Invalid TCP/UDP service: " + t.value); } list.add(new Integer(service)); } st.unget(); services = new int[list.size()]; for (int i = 0; i < list.size(); i++) { services[i] = ((Integer) list.get(i)).intValue(); } }
// in org/xbill/DNS/SIGBase.java
void rrFromWire(DNSInput in) throws IOException { covered = in.readU16(); alg = in.readU8(); labels = in.readU8(); origttl = in.readU32(); expire = new Date(1000 * in.readU32()); timeSigned = new Date(1000 * in.readU32()); footprint = in.readU16(); signer = new Name(in); signature = in.readByteArray(); }
// in org/xbill/DNS/SIGBase.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { String typeString = st.getString(); covered = Type.value(typeString); if (covered < 0) throw st.exception("Invalid type: " + typeString); String algString = st.getString(); alg = DNSSEC.Algorithm.value(algString); if (alg < 0) throw st.exception("Invalid algorithm: " + algString); labels = st.getUInt8(); origttl = st.getTTL(); expire = FormattedTime.parse(st.getString()); timeSigned = FormattedTime.parse(st.getString()); footprint = st.getUInt16(); signer = st.getName(origin); signature = st.getBase64(); }
// in org/xbill/DNS/NSECRecord.java
void rrFromWire(DNSInput in) throws IOException { next = new Name(in); types = new TypeBitmap(in); }
// in org/xbill/DNS/NSECRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { next = st.getName(origin); types = new TypeBitmap(st); }
// in org/xbill/DNS/NSEC3Record.java
void rrFromWire(DNSInput in) throws IOException { hashAlg = in.readU8(); flags = in.readU8(); iterations = in.readU16(); int salt_length = in.readU8(); if (salt_length > 0) salt = in.readByteArray(salt_length); else salt = null; int next_length = in.readU8(); next = in.readByteArray(next_length); types = new TypeBitmap(in); }
// in org/xbill/DNS/NSEC3Record.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { hashAlg = st.getUInt8(); flags = st.getUInt8(); iterations = st.getUInt16(); String s = st.getString(); if (s.equals("-")) salt = null; else { st.unget(); salt = st.getHexString(); if (salt.length > 255) throw st.exception("salt value too long"); } next = st.getBase32String(b32); types = new TypeBitmap(st); }
// in org/xbill/DNS/NAPTRRecord.java
void rrFromWire(DNSInput in) throws IOException { order = in.readU16(); preference = in.readU16(); flags = in.readCountedString(); service = in.readCountedString(); regexp = in.readCountedString(); replacement = new Name(in); }
// in org/xbill/DNS/NAPTRRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { order = st.getUInt16(); preference = st.getUInt16(); try { flags = byteArrayFromString(st.getString()); service = byteArrayFromString(st.getString()); regexp = byteArrayFromString(st.getString()); } catch (TextParseException e) { throw st.exception(e.getMessage()); } replacement = st.getName(origin); }
(Domain) RelativeNameException 10
              
// in org/xbill/DNS/Record.java
public static Record newRecord(Name name, int type, int dclass, long ttl, int length, byte [] data) { if (!name.isAbsolute()) throw new RelativeNameException(name); Type.check(type); DClass.check(dclass); TTL.check(ttl); DNSInput in; if (data != null) in = new DNSInput(data); else in = null; try { return newRecord(name, type, dclass, ttl, length, in); } catch (IOException e) { return null; } }
// in org/xbill/DNS/Record.java
public static Record newRecord(Name name, int type, int dclass, long ttl) { if (!name.isAbsolute()) throw new RelativeNameException(name); Type.check(type); DClass.check(dclass); TTL.check(ttl); return getEmptyRecord(name, type, dclass, ttl, false); }
// in org/xbill/DNS/Record.java
public static Record fromString(Name name, int type, int dclass, long ttl, Tokenizer st, Name origin) throws IOException { Record rec; if (!name.isAbsolute()) throw new RelativeNameException(name); Type.check(type); DClass.check(dclass); TTL.check(ttl); Tokenizer.Token t = st.get(); if (t.type == Tokenizer.IDENTIFIER && t.value.equals("\\#")) { int length = st.getUInt16(); byte [] data = st.getHex(); if (data == null) { data = new byte[0]; } if (length != data.length) throw st.exception("invalid unknown RR encoding: " + "length mismatch"); DNSInput in = new DNSInput(data); return newRecord(name, type, dclass, ttl, length, in); } st.unget(); rec = getEmptyRecord(name, type, dclass, ttl, true); rec.rdataFromString(st, origin); t = st.get(); if (t.type != Tokenizer.EOL && t.type != Tokenizer.EOF) { throw st.exception("unexpected tokens at end of record"); } return rec; }
// in org/xbill/DNS/Record.java
public Record withName(Name name) { if (!name.isAbsolute()) throw new RelativeNameException(name); Record rec = cloneRecord(); rec.name = name; return rec; }
// in org/xbill/DNS/Record.java
static Name checkName(String field, Name name) { if (!name.isAbsolute()) throw new RelativeNameException(name); return name; }
// in org/xbill/DNS/Tokenizer.java
public Name getName(Name origin) throws IOException { String next = _getIdentifier("a name"); try { Name name = Name.fromString(next, origin); if (!name.isAbsolute()) throw new RelativeNameException(name); return name; } catch (TextParseException e) { throw exception(e.getMessage()); } }
0 0
(Lib) UnknownHostException 10
              
// in org/xbill/DNS/ReverseMap.java
public static Name fromAddress(String addr, int family) throws UnknownHostException { byte [] array = Address.toByteArray(addr, family); if (array == null) throw new UnknownHostException("Invalid IP address"); return fromAddress(array); }
// in org/xbill/DNS/ReverseMap.java
public static Name fromAddress(String addr) throws UnknownHostException { byte [] array = Address.toByteArray(addr, Address.IPv4); if (array == null) array = Address.toByteArray(addr, Address.IPv6); if (array == null) throw new UnknownHostException("Invalid IP address"); return fromAddress(array); }
// in org/xbill/DNS/spi/DNSJavaNameService.java
public InetAddress [] lookupAllHostAddr(String host) throws UnknownHostException { Name name = null; try { name = new Name(host); } catch (TextParseException e) { throw new UnknownHostException(host); } Record [] records = null; if (preferV6) records = new Lookup(name, Type.AAAA).run(); if (records == null) records = new Lookup(name, Type.A).run(); if (records == null && !preferV6) records = new Lookup(name, Type.AAAA).run(); if (records == null) throw new UnknownHostException(host); InetAddress[] array = new InetAddress[records.length]; for (int i = 0; i < records.length; i++) { Record record = records[i]; if (records[i] instanceof ARecord) { ARecord a = (ARecord) records[i]; array[i] = a.getAddress(); } else { AAAARecord aaaa = (AAAARecord) records[i]; array[i] = aaaa.getAddress(); } } return array; }
// in org/xbill/DNS/spi/DNSJavaNameService.java
public String getHostByAddr(byte [] addr) throws UnknownHostException { Name name = ReverseMap.fromAddress(InetAddress.getByAddress(addr)); Record [] records = new Lookup(name, Type.PTR).run(); if (records == null) throw new UnknownHostException(); return ((PTRRecord) records[0]).getTarget().toString(); }
// in org/xbill/DNS/Address.java
private static Record [] lookupHostName(String name) throws UnknownHostException { try { Record [] records = new Lookup(name).run(); if (records == null) throw new UnknownHostException("unknown host"); return records; } catch (TextParseException e) { throw new UnknownHostException("invalid name"); } }
// in org/xbill/DNS/Address.java
public static InetAddress getByAddress(String addr) throws UnknownHostException { byte [] bytes; bytes = toByteArray(addr, IPv4); if (bytes != null) return InetAddress.getByAddress(bytes); bytes = toByteArray(addr, IPv6); if (bytes != null) return InetAddress.getByAddress(bytes); throw new UnknownHostException("Invalid address: " + addr); }
// in org/xbill/DNS/Address.java
public static InetAddress getByAddress(String addr, int family) throws UnknownHostException { if (family != IPv4 && family != IPv6) throw new IllegalArgumentException("unknown address family"); byte [] bytes; bytes = toByteArray(addr, family); if (bytes != null) return InetAddress.getByAddress(bytes); throw new UnknownHostException("Invalid address: " + addr); }
// in org/xbill/DNS/Address.java
public static String getHostName(InetAddress addr) throws UnknownHostException { Name name = ReverseMap.fromAddress(addr); Record [] records = new Lookup(name, Type.PTR).run(); if (records == null) throw new UnknownHostException("unknown address"); PTRRecord ptr = (PTRRecord) records[0]; return ptr.getTarget().toString(); }
2
              
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (TextParseException e) { throw new UnknownHostException(host); }
// in org/xbill/DNS/Address.java
catch (TextParseException e) { throw new UnknownHostException("invalid name"); }
20
              
// in org/xbill/DNS/ReverseMap.java
public static Name fromAddress(String addr, int family) throws UnknownHostException { byte [] array = Address.toByteArray(addr, family); if (array == null) throw new UnknownHostException("Invalid IP address"); return fromAddress(array); }
// in org/xbill/DNS/ReverseMap.java
public static Name fromAddress(String addr) throws UnknownHostException { byte [] array = Address.toByteArray(addr, Address.IPv4); if (array == null) array = Address.toByteArray(addr, Address.IPv6); if (array == null) throw new UnknownHostException("Invalid IP address"); return fromAddress(array); }
// in org/xbill/DNS/spi/DNSJavaNameService.java
public InetAddress [] lookupAllHostAddr(String host) throws UnknownHostException { Name name = null; try { name = new Name(host); } catch (TextParseException e) { throw new UnknownHostException(host); } Record [] records = null; if (preferV6) records = new Lookup(name, Type.AAAA).run(); if (records == null) records = new Lookup(name, Type.A).run(); if (records == null && !preferV6) records = new Lookup(name, Type.AAAA).run(); if (records == null) throw new UnknownHostException(host); InetAddress[] array = new InetAddress[records.length]; for (int i = 0; i < records.length; i++) { Record record = records[i]; if (records[i] instanceof ARecord) { ARecord a = (ARecord) records[i]; array[i] = a.getAddress(); } else { AAAARecord aaaa = (AAAARecord) records[i]; array[i] = aaaa.getAddress(); } } return array; }
// in org/xbill/DNS/spi/DNSJavaNameService.java
public String getHostByAddr(byte [] addr) throws UnknownHostException { Name name = ReverseMap.fromAddress(InetAddress.getByAddress(addr)); Record [] records = new Lookup(name, Type.PTR).run(); if (records == null) throw new UnknownHostException(); return ((PTRRecord) records[0]).getTarget().toString(); }
// in org/xbill/DNS/Address.java
private static Record [] lookupHostName(String name) throws UnknownHostException { try { Record [] records = new Lookup(name).run(); if (records == null) throw new UnknownHostException("unknown host"); return records; } catch (TextParseException e) { throw new UnknownHostException("invalid name"); } }
// in org/xbill/DNS/Address.java
private static InetAddress addrFromRecord(String name, Record r) throws UnknownHostException { ARecord a = (ARecord) r; return InetAddress.getByAddress(name, a.getAddress().getAddress()); }
// in org/xbill/DNS/Address.java
public static InetAddress getByName(String name) throws UnknownHostException { try { return getByAddress(name); } catch (UnknownHostException e) { Record [] records = lookupHostName(name); return addrFromRecord(name, records[0]); } }
// in org/xbill/DNS/Address.java
public static InetAddress [] getAllByName(String name) throws UnknownHostException { try { InetAddress addr = getByAddress(name); return new InetAddress[] {addr}; } catch (UnknownHostException e) { Record [] records = lookupHostName(name); InetAddress [] addrs = new InetAddress[records.length]; for (int i = 0; i < records.length; i++) addrs[i] = addrFromRecord(name, records[i]); return addrs; } }
// in org/xbill/DNS/Address.java
public static InetAddress getByAddress(String addr) throws UnknownHostException { byte [] bytes; bytes = toByteArray(addr, IPv4); if (bytes != null) return InetAddress.getByAddress(bytes); bytes = toByteArray(addr, IPv6); if (bytes != null) return InetAddress.getByAddress(bytes); throw new UnknownHostException("Invalid address: " + addr); }
// in org/xbill/DNS/Address.java
public static InetAddress getByAddress(String addr, int family) throws UnknownHostException { if (family != IPv4 && family != IPv6) throw new IllegalArgumentException("unknown address family"); byte [] bytes; bytes = toByteArray(addr, family); if (bytes != null) return InetAddress.getByAddress(bytes); throw new UnknownHostException("Invalid address: " + addr); }
// in org/xbill/DNS/Address.java
public static String getHostName(InetAddress addr) throws UnknownHostException { Name name = ReverseMap.fromAddress(addr); Record [] records = new Lookup(name, Type.PTR).run(); if (records == null) throw new UnknownHostException("unknown address"); PTRRecord ptr = (PTRRecord) records[0]; return ptr.getTarget().toString(); }
// in org/xbill/DNS/ZoneTransferIn.java
public static ZoneTransferIn newAXFR(Name zone, String host, int port, TSIG key) throws UnknownHostException { if (port == 0) port = SimpleResolver.DEFAULT_PORT; return newAXFR(zone, new InetSocketAddress(host, port), key); }
// in org/xbill/DNS/ZoneTransferIn.java
public static ZoneTransferIn newAXFR(Name zone, String host, TSIG key) throws UnknownHostException { return newAXFR(zone, host, 0, key); }
// in org/xbill/DNS/ZoneTransferIn.java
public static ZoneTransferIn newIXFR(Name zone, long serial, boolean fallback, String host, int port, TSIG key) throws UnknownHostException { if (port == 0) port = SimpleResolver.DEFAULT_PORT; return newIXFR(zone, serial, fallback, new InetSocketAddress(host, port), key); }
// in org/xbill/DNS/ZoneTransferIn.java
public static ZoneTransferIn newIXFR(Name zone, long serial, boolean fallback, String host, TSIG key) throws UnknownHostException { return newIXFR(zone, serial, fallback, host, 0, key); }
(Lib) NumberFormatException 6
              
// in org/xbill/DNS/TTL.java
public static long parse(String s, boolean clamp) { if (s == null || s.length() == 0 || !Character.isDigit(s.charAt(0))) throw new NumberFormatException(); long value = 0; long ttl = 0; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); long oldvalue = value; if (Character.isDigit(c)) { value = (value * 10) + Character.getNumericValue(c); if (value < oldvalue) throw new NumberFormatException(); } else { switch (Character.toUpperCase(c)) { case 'W': value *= 7; case 'D': value *= 24; case 'H': value *= 60; case 'M': value *= 60; case 'S': break; default: throw new NumberFormatException(); } ttl += value; value = 0; if (ttl > 0xFFFFFFFFL) throw new NumberFormatException(); } } if (ttl == 0) ttl = value; if (ttl > 0xFFFFFFFFL) throw new NumberFormatException(); else if (ttl > MAX_VALUE && clamp) ttl = MAX_VALUE; return ttl; }
// in org/xbill/DNS/LOCRecord.java
private double parseFixedPoint(String s) { if (s.matches("^-?\\d+$")) return Integer.parseInt(s); else if (s.matches("^-?\\d+\\.\\d*$")) { String [] parts = s.split("\\."); double value = Integer.parseInt(parts[0]); double fraction = Integer.parseInt(parts[1]); if (value < 0) fraction *= -1; int digits = parts[1].length(); return value + (fraction / Math.pow(10, digits)); } else throw new NumberFormatException(); }
0 0
(Domain) IncompatibleKeyException 4
              
// in org/xbill/DNS/DNSSEC.java
static byte [] fromPublicKey(PublicKey key, int alg) throws DNSSECException { byte [] data = null; switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: if (! (key instanceof RSAPublicKey)) throw new IncompatibleKeyException(); return fromRSAPublicKey((RSAPublicKey) key); case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: if (! (key instanceof DSAPublicKey)) throw new IncompatibleKeyException(); return fromDSAPublicKey((DSAPublicKey) key); default: throw new UnsupportedAlgorithmException(alg); } }
// in org/xbill/DNS/DNSSEC.java
static void checkAlgorithm(PrivateKey key, int alg) throws UnsupportedAlgorithmException { switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: if (! (key instanceof RSAPrivateKey)) throw new IncompatibleKeyException(); break; case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: if (! (key instanceof DSAPrivateKey)) throw new IncompatibleKeyException(); break; default: throw new UnsupportedAlgorithmException(alg); } }
0 0
(Domain) UnsupportedAlgorithmException 4
              
// in org/xbill/DNS/DNSSEC.java
static PublicKey toPublicKey(KEYBase r) throws DNSSECException { int alg = r.getAlgorithm(); try { switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: return toRSAPublicKey(r); case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: return toDSAPublicKey(r); default: throw new UnsupportedAlgorithmException(alg); } } catch (IOException e) { throw new MalformedKeyException(r); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } }
// in org/xbill/DNS/DNSSEC.java
static byte [] fromPublicKey(PublicKey key, int alg) throws DNSSECException { byte [] data = null; switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: if (! (key instanceof RSAPublicKey)) throw new IncompatibleKeyException(); return fromRSAPublicKey((RSAPublicKey) key); case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: if (! (key instanceof DSAPublicKey)) throw new IncompatibleKeyException(); return fromDSAPublicKey((DSAPublicKey) key); default: throw new UnsupportedAlgorithmException(alg); } }
// in org/xbill/DNS/DNSSEC.java
public static String algString(int alg) throws UnsupportedAlgorithmException { switch (alg) { case Algorithm.RSAMD5: return "MD5withRSA"; case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: return "SHA1withDSA"; case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: return "SHA1withRSA"; case Algorithm.RSASHA256: return "SHA256withRSA"; case Algorithm.RSASHA512: return "SHA512withRSA"; default: throw new UnsupportedAlgorithmException(alg); } }
// in org/xbill/DNS/DNSSEC.java
static void checkAlgorithm(PrivateKey key, int alg) throws UnsupportedAlgorithmException { switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: if (! (key instanceof RSAPrivateKey)) throw new IncompatibleKeyException(); break; case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: if (! (key instanceof DSAPrivateKey)) throw new IncompatibleKeyException(); break; default: throw new UnsupportedAlgorithmException(alg); } }
0 2
              
// in org/xbill/DNS/DNSSEC.java
public static String algString(int alg) throws UnsupportedAlgorithmException { switch (alg) { case Algorithm.RSAMD5: return "MD5withRSA"; case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: return "SHA1withDSA"; case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: return "SHA1withRSA"; case Algorithm.RSASHA256: return "SHA256withRSA"; case Algorithm.RSASHA512: return "SHA512withRSA"; default: throw new UnsupportedAlgorithmException(alg); } }
// in org/xbill/DNS/DNSSEC.java
static void checkAlgorithm(PrivateKey key, int alg) throws UnsupportedAlgorithmException { switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: if (! (key instanceof RSAPrivateKey)) throw new IncompatibleKeyException(); break; case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: if (! (key instanceof DSAPrivateKey)) throw new IncompatibleKeyException(); break; default: throw new UnsupportedAlgorithmException(alg); } }
(Domain) DNSSECException 3
              
// in org/xbill/DNS/DNSSEC.java
static PublicKey toPublicKey(KEYBase r) throws DNSSECException { int alg = r.getAlgorithm(); try { switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: return toRSAPublicKey(r); case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: return toDSAPublicKey(r); default: throw new UnsupportedAlgorithmException(alg); } } catch (IOException e) { throw new MalformedKeyException(r); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } }
// in org/xbill/DNS/DNSSEC.java
private static void verify(PublicKey key, int alg, byte [] data, byte [] signature) throws DNSSECException { if (key instanceof DSAPublicKey) { try { signature = DSASignaturefromDNS(signature); } catch (IOException e) { throw new IllegalStateException(); } } try { Signature s = Signature.getInstance(algString(alg)); s.initVerify(key); s.update(data); if (!s.verify(signature)) throw new SignatureVerificationException(); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } }
// in org/xbill/DNS/DNSSEC.java
private static byte [] sign(PrivateKey privkey, PublicKey pubkey, int alg, byte [] data, String provider) throws DNSSECException { byte [] signature; try { Signature s; if (provider != null) s = Signature.getInstance(algString(alg), provider); else s = Signature.getInstance(algString(alg)); s.initSign(privkey); s.update(data); signature = s.sign(); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } if (pubkey instanceof DSAPublicKey) { try { DSAPublicKey dsa = (DSAPublicKey) pubkey; BigInteger P = dsa.getParams().getP(); int t = (BigIntegerLength(P) - 64) / 8; signature = DSASignaturetoDNS(signature, t); } catch (IOException e) { throw new IllegalStateException(); } } return signature; }
3
              
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
15
              
// in org/xbill/DNS/SIG0.java
public static void signMessage(Message message, KEYRecord key, PrivateKey privkey, SIGRecord previous) throws DNSSEC.DNSSECException { int validity = Options.intValue("sig0validity"); if (validity < 0) validity = VALIDITY; long now = System.currentTimeMillis(); Date timeSigned = new Date(now); Date timeExpires = new Date(now + validity * 1000); SIGRecord sig = DNSSEC.signMessage(message, previous, key, privkey, timeSigned, timeExpires); message.addRecord(sig, Section.ADDITIONAL); }
// in org/xbill/DNS/SIG0.java
public static void verifyMessage(Message message, byte [] b, KEYRecord key, SIGRecord previous) throws DNSSEC.DNSSECException { SIGRecord sig = null; Record [] additional = message.getSectionArray(Section.ADDITIONAL); for (int i = 0; i < additional.length; i++) { if (additional[i].getType() != Type.SIG) continue; if (((SIGRecord) additional[i]).getTypeCovered() != 0) continue; sig = (SIGRecord) additional[i]; break; } DNSSEC.verifyMessage(message, b, sig, previous, key); }
// in org/xbill/DNS/KEYBase.java
public PublicKey getPublicKey() throws DNSSEC.DNSSECException { if (publicKey != null) return publicKey; publicKey = DNSSEC.toPublicKey(this); return publicKey; }
// in org/xbill/DNS/DNSSEC.java
static PublicKey toPublicKey(KEYBase r) throws DNSSECException { int alg = r.getAlgorithm(); try { switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: return toRSAPublicKey(r); case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: return toDSAPublicKey(r); default: throw new UnsupportedAlgorithmException(alg); } } catch (IOException e) { throw new MalformedKeyException(r); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } }
// in org/xbill/DNS/DNSSEC.java
static byte [] fromPublicKey(PublicKey key, int alg) throws DNSSECException { byte [] data = null; switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: if (! (key instanceof RSAPublicKey)) throw new IncompatibleKeyException(); return fromRSAPublicKey((RSAPublicKey) key); case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: if (! (key instanceof DSAPublicKey)) throw new IncompatibleKeyException(); return fromDSAPublicKey((DSAPublicKey) key); default: throw new UnsupportedAlgorithmException(alg); } }
// in org/xbill/DNS/DNSSEC.java
private static byte [] DSASignaturefromDNS(byte [] dns) throws DNSSECException, IOException { if (dns.length != 1 + DSA_LEN * 2) throw new SignatureVerificationException(); DNSInput in = new DNSInput(dns); DNSOutput out = new DNSOutput(); int t = in.readU8(); byte [] r = in.readByteArray(DSA_LEN); int rlen = DSA_LEN; if (r[0] < 0) rlen++; byte [] s = in.readByteArray(DSA_LEN); int slen = DSA_LEN; if (s[0] < 0) slen++; out.writeU8(ASN1_SEQ); out.writeU8(rlen + slen + 4); out.writeU8(ASN1_INT); out.writeU8(rlen); if (rlen > DSA_LEN) out.writeU8(0); out.writeByteArray(r); out.writeU8(ASN1_INT); out.writeU8(slen); if (slen > DSA_LEN) out.writeU8(0); out.writeByteArray(s); return out.toByteArray(); }
// in org/xbill/DNS/DNSSEC.java
private static void verify(PublicKey key, int alg, byte [] data, byte [] signature) throws DNSSECException { if (key instanceof DSAPublicKey) { try { signature = DSASignaturefromDNS(signature); } catch (IOException e) { throw new IllegalStateException(); } } try { Signature s = Signature.getInstance(algString(alg)); s.initVerify(key); s.update(data); if (!s.verify(signature)) throw new SignatureVerificationException(); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } }
// in org/xbill/DNS/DNSSEC.java
public static void verify(RRset rrset, RRSIGRecord rrsig, DNSKEYRecord key) throws DNSSECException { if (!matches(rrsig, key)) throw new KeyMismatchException(key, rrsig); Date now = new Date(); if (now.compareTo(rrsig.getExpire()) > 0) throw new SignatureExpiredException(rrsig.getExpire(), now); if (now.compareTo(rrsig.getTimeSigned()) < 0) throw new SignatureNotYetValidException(rrsig.getTimeSigned(), now); verify(key.getPublicKey(), rrsig.getAlgorithm(), digestRRset(rrsig, rrset), rrsig.getSignature()); }
// in org/xbill/DNS/DNSSEC.java
private static byte [] sign(PrivateKey privkey, PublicKey pubkey, int alg, byte [] data, String provider) throws DNSSECException { byte [] signature; try { Signature s; if (provider != null) s = Signature.getInstance(algString(alg), provider); else s = Signature.getInstance(algString(alg)); s.initSign(privkey); s.update(data); signature = s.sign(); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } if (pubkey instanceof DSAPublicKey) { try { DSAPublicKey dsa = (DSAPublicKey) pubkey; BigInteger P = dsa.getParams().getP(); int t = (BigIntegerLength(P) - 64) / 8; signature = DSASignaturetoDNS(signature, t); } catch (IOException e) { throw new IllegalStateException(); } } return signature; }
// in org/xbill/DNS/DNSSEC.java
public static RRSIGRecord sign(RRset rrset, DNSKEYRecord key, PrivateKey privkey, Date inception, Date expiration) throws DNSSECException { return sign(rrset, key, privkey, inception, expiration, null); }
// in org/xbill/DNS/DNSSEC.java
public static RRSIGRecord sign(RRset rrset, DNSKEYRecord key, PrivateKey privkey, Date inception, Date expiration, String provider) throws DNSSECException { int alg = key.getAlgorithm(); checkAlgorithm(privkey, alg); RRSIGRecord rrsig = new RRSIGRecord(rrset.getName(), rrset.getDClass(), rrset.getTTL(), rrset.getType(), alg, rrset.getTTL(), expiration, inception, key.getFootprint(), key.getName(), null); rrsig.setSignature(sign(privkey, key.getPublicKey(), alg, digestRRset(rrsig, rrset), provider)); return rrsig; }
// in org/xbill/DNS/DNSSEC.java
static SIGRecord signMessage(Message message, SIGRecord previous, KEYRecord key, PrivateKey privkey, Date inception, Date expiration) throws DNSSECException { int alg = key.getAlgorithm(); checkAlgorithm(privkey, alg); SIGRecord sig = new SIGRecord(Name.root, DClass.ANY, 0, 0, alg, 0, expiration, inception, key.getFootprint(), key.getName(), null); DNSOutput out = new DNSOutput(); digestSIG(out, sig); if (previous != null) out.writeByteArray(previous.getSignature()); message.toWire(out); sig.setSignature(sign(privkey, key.getPublicKey(), alg, out.toByteArray(), null)); return sig; }
// in org/xbill/DNS/DNSSEC.java
static void verifyMessage(Message message, byte [] bytes, SIGRecord sig, SIGRecord previous, KEYRecord key) throws DNSSECException { if (!matches(sig, key)) throw new KeyMismatchException(key, sig); Date now = new Date(); if (now.compareTo(sig.getExpire()) > 0) throw new SignatureExpiredException(sig.getExpire(), now); if (now.compareTo(sig.getTimeSigned()) < 0) throw new SignatureNotYetValidException(sig.getTimeSigned(), now); DNSOutput out = new DNSOutput(); digestSIG(out, sig); if (previous != null) out.writeByteArray(previous.getSignature()); Header header = (Header) message.getHeader().clone(); header.decCount(Section.ADDITIONAL); out.writeByteArray(header.toWire()); out.writeByteArray(bytes, Header.LENGTH, message.sig0start - Header.LENGTH); verify(key.getPublicKey(), sig.getAlgorithm(), out.toByteArray(), sig.getSignature()); }
(Lib) EOFException 3
              
// in org/xbill/DNS/TCPClient.java
void send(byte [] data) throws IOException { SocketChannel channel = (SocketChannel) key.channel(); verboseLog("TCP write", data); byte [] lengthArray = new byte[2]; lengthArray[0] = (byte)(data.length >>> 8); lengthArray[1] = (byte)(data.length & 0xFF); ByteBuffer [] buffers = new ByteBuffer[2]; buffers[0] = ByteBuffer.wrap(lengthArray); buffers[1] = ByteBuffer.wrap(data); int nsent = 0; key.interestOps(SelectionKey.OP_WRITE); try { while (nsent < data.length + 2) { if (key.isWritable()) { long n = channel.write(buffers); if (n < 0) throw new EOFException(); nsent += (int) n; if (nsent < data.length + 2 && System.currentTimeMillis() > endTime) throw new SocketTimeoutException(); } else blockUntil(key, endTime); } } finally { if (key.isValid()) key.interestOps(0); } }
// in org/xbill/DNS/TCPClient.java
private byte [] _recv(int length) throws IOException { SocketChannel channel = (SocketChannel) key.channel(); int nrecvd = 0; byte [] data = new byte[length]; ByteBuffer buffer = ByteBuffer.wrap(data); key.interestOps(SelectionKey.OP_READ); try { while (nrecvd < length) { if (key.isReadable()) { long n = channel.read(buffer); if (n < 0) throw new EOFException(); nrecvd += (int) n; if (nrecvd < length && System.currentTimeMillis() > endTime) throw new SocketTimeoutException(); } else blockUntil(key, endTime); } } finally { if (key.isValid()) key.interestOps(0); } return data; }
// in org/xbill/DNS/UDPClient.java
byte [] recv(int max) throws IOException { DatagramChannel channel = (DatagramChannel) key.channel(); byte [] temp = new byte[max]; key.interestOps(SelectionKey.OP_READ); try { while (!key.isReadable()) blockUntil(key, endTime); } finally { if (key.isValid()) key.interestOps(0); } long ret = channel.read(ByteBuffer.wrap(temp)); if (ret <= 0) throw new EOFException(); int len = (int) ret; byte [] data = new byte[len]; System.arraycopy(temp, 0, data, 0, len); verboseLog("UDP read", data); return data; }
0 0
(Lib) SocketTimeoutException 3
              
// in org/xbill/DNS/Client.java
static protected void blockUntil(SelectionKey key, long endTime) throws IOException { long timeout = endTime - System.currentTimeMillis(); int nkeys = 0; if (timeout > 0) nkeys = key.selector().select(timeout); else if (timeout == 0) nkeys = key.selector().selectNow(); if (nkeys == 0) throw new SocketTimeoutException(); }
// in org/xbill/DNS/TCPClient.java
void send(byte [] data) throws IOException { SocketChannel channel = (SocketChannel) key.channel(); verboseLog("TCP write", data); byte [] lengthArray = new byte[2]; lengthArray[0] = (byte)(data.length >>> 8); lengthArray[1] = (byte)(data.length & 0xFF); ByteBuffer [] buffers = new ByteBuffer[2]; buffers[0] = ByteBuffer.wrap(lengthArray); buffers[1] = ByteBuffer.wrap(data); int nsent = 0; key.interestOps(SelectionKey.OP_WRITE); try { while (nsent < data.length + 2) { if (key.isWritable()) { long n = channel.write(buffers); if (n < 0) throw new EOFException(); nsent += (int) n; if (nsent < data.length + 2 && System.currentTimeMillis() > endTime) throw new SocketTimeoutException(); } else blockUntil(key, endTime); } } finally { if (key.isValid()) key.interestOps(0); } }
// in org/xbill/DNS/TCPClient.java
private byte [] _recv(int length) throws IOException { SocketChannel channel = (SocketChannel) key.channel(); int nrecvd = 0; byte [] data = new byte[length]; ByteBuffer buffer = ByteBuffer.wrap(data); key.interestOps(SelectionKey.OP_READ); try { while (nrecvd < length) { if (key.isReadable()) { long n = channel.read(buffer); if (n < 0) throw new EOFException(); nrecvd += (int) n; if (nrecvd < length && System.currentTimeMillis() > endTime) throw new SocketTimeoutException(); } else blockUntil(key, endTime); } } finally { if (key.isValid()) key.interestOps(0); } return data; }
0 0
(Domain) KeyMismatchException 2
              
// in org/xbill/DNS/DNSSEC.java
public static void verify(RRset rrset, RRSIGRecord rrsig, DNSKEYRecord key) throws DNSSECException { if (!matches(rrsig, key)) throw new KeyMismatchException(key, rrsig); Date now = new Date(); if (now.compareTo(rrsig.getExpire()) > 0) throw new SignatureExpiredException(rrsig.getExpire(), now); if (now.compareTo(rrsig.getTimeSigned()) < 0) throw new SignatureNotYetValidException(rrsig.getTimeSigned(), now); verify(key.getPublicKey(), rrsig.getAlgorithm(), digestRRset(rrsig, rrset), rrsig.getSignature()); }
// in org/xbill/DNS/DNSSEC.java
static void verifyMessage(Message message, byte [] bytes, SIGRecord sig, SIGRecord previous, KEYRecord key) throws DNSSECException { if (!matches(sig, key)) throw new KeyMismatchException(key, sig); Date now = new Date(); if (now.compareTo(sig.getExpire()) > 0) throw new SignatureExpiredException(sig.getExpire(), now); if (now.compareTo(sig.getTimeSigned()) < 0) throw new SignatureNotYetValidException(sig.getTimeSigned(), now); DNSOutput out = new DNSOutput(); digestSIG(out, sig); if (previous != null) out.writeByteArray(previous.getSignature()); Header header = (Header) message.getHeader().clone(); header.decCount(Section.ADDITIONAL); out.writeByteArray(header.toWire()); out.writeByteArray(bytes, Header.LENGTH, message.sig0start - Header.LENGTH); verify(key.getPublicKey(), sig.getAlgorithm(), out.toByteArray(), sig.getSignature()); }
0 0
(Domain) MalformedKeyException 2
              
// in org/xbill/DNS/DNSSEC.java
private static PublicKey toDSAPublicKey(KEYBase r) throws IOException, GeneralSecurityException, MalformedKeyException { DNSInput in = new DNSInput(r.getKey()); int t = in.readU8(); if (t > 8) throw new MalformedKeyException(r); BigInteger q = readBigInteger(in, 20); BigInteger p = readBigInteger(in, 64 + t*8); BigInteger g = readBigInteger(in, 64 + t*8); BigInteger y = readBigInteger(in, 64 + t*8); KeyFactory factory = KeyFactory.getInstance("DSA"); return factory.generatePublic(new DSAPublicKeySpec(y, p, q, g)); }
// in org/xbill/DNS/DNSSEC.java
static PublicKey toPublicKey(KEYBase r) throws DNSSECException { int alg = r.getAlgorithm(); try { switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: return toRSAPublicKey(r); case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: return toDSAPublicKey(r); default: throw new UnsupportedAlgorithmException(alg); } } catch (IOException e) { throw new MalformedKeyException(r); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } }
1
              
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new MalformedKeyException(r); }
1
              
// in org/xbill/DNS/DNSSEC.java
private static PublicKey toDSAPublicKey(KEYBase r) throws IOException, GeneralSecurityException, MalformedKeyException { DNSInput in = new DNSInput(r.getKey()); int t = in.readU8(); if (t > 8) throw new MalformedKeyException(r); BigInteger q = readBigInteger(in, 20); BigInteger p = readBigInteger(in, 64 + t*8); BigInteger g = readBigInteger(in, 64 + t*8); BigInteger y = readBigInteger(in, 64 + t*8); KeyFactory factory = KeyFactory.getInstance("DSA"); return factory.generatePublic(new DSAPublicKeySpec(y, p, q, g)); }
(Domain) NameTooLongException 2
              
// in org/xbill/DNS/Name.java
private final void append(byte [] array, int start, int n) throws NameTooLongException { int length = (name == null ? 0 : (name.length - offset(0))); int alength = 0; for (int i = 0, pos = start; i < n; i++) { int len = array[pos]; if (len > MAXLABEL) throw new IllegalStateException("invalid label"); len++; pos += len; alength += len; } int newlength = length + alength; if (newlength > MAXNAME) throw new NameTooLongException(); int labels = getlabels(); int newlabels = labels + n; if (newlabels > MAXLABELS) throw new IllegalStateException("too many labels"); byte [] newname = new byte[newlength]; if (length != 0) System.arraycopy(name, offset(0), newname, 0, length); System.arraycopy(array, start, newname, length, alength); name = newname; for (int i = 0, pos = length; i < n; i++) { setoffset(labels + i, pos); pos += (newname[pos] + 1); } setlabels(newlabels); }
// in org/xbill/DNS/Name.java
public Name fromDNAME(DNAMERecord dname) throws NameTooLongException { Name dnameowner = dname.getName(); Name dnametarget = dname.getTarget(); if (!subdomain(dnameowner)) return null; int plabels = labels() - dnameowner.labels(); int plength = length() - dnameowner.length(); int pstart = offset(0); int dlabels = dnametarget.labels(); int dlength = dnametarget.length(); if (plength + dlength > MAXNAME) throw new NameTooLongException(); Name newname = new Name(); newname.setlabels(plabels + dlabels); newname.name = new byte[plength + dlength]; System.arraycopy(name, pstart, newname.name, 0, plength); System.arraycopy(dnametarget.name, 0, newname.name, plength, dlength); for (int i = 0, pos = 0; i < MAXOFFSETS && i < plabels + dlabels; i++) { newname.setoffset(i, pos); pos += (newname.name[pos] + 1); } return newname; }
0 3
              
// in org/xbill/DNS/Name.java
private final void append(byte [] array, int start, int n) throws NameTooLongException { int length = (name == null ? 0 : (name.length - offset(0))); int alength = 0; for (int i = 0, pos = start; i < n; i++) { int len = array[pos]; if (len > MAXLABEL) throw new IllegalStateException("invalid label"); len++; pos += len; alength += len; } int newlength = length + alength; if (newlength > MAXNAME) throw new NameTooLongException(); int labels = getlabels(); int newlabels = labels + n; if (newlabels > MAXLABELS) throw new IllegalStateException("too many labels"); byte [] newname = new byte[newlength]; if (length != 0) System.arraycopy(name, offset(0), newname, 0, length); System.arraycopy(array, start, newname, length, alength); name = newname; for (int i = 0, pos = length; i < n; i++) { setoffset(labels + i, pos); pos += (newname[pos] + 1); } setlabels(newlabels); }
// in org/xbill/DNS/Name.java
public static Name concatenate(Name prefix, Name suffix) throws NameTooLongException { if (prefix.isAbsolute()) return (prefix); Name newname = new Name(); copy(prefix, newname); newname.append(suffix.name, suffix.offset(0), suffix.getlabels()); return newname; }
// in org/xbill/DNS/Name.java
public Name fromDNAME(DNAMERecord dname) throws NameTooLongException { Name dnameowner = dname.getName(); Name dnametarget = dname.getTarget(); if (!subdomain(dnameowner)) return null; int plabels = labels() - dnameowner.labels(); int plength = length() - dnameowner.length(); int pstart = offset(0); int dlabels = dnametarget.labels(); int dlength = dnametarget.length(); if (plength + dlength > MAXNAME) throw new NameTooLongException(); Name newname = new Name(); newname.setlabels(plabels + dlabels); newname.name = new byte[plength + dlength]; System.arraycopy(name, pstart, newname.name, 0, plength); System.arraycopy(dnametarget.name, 0, newname.name, plength, dlength); for (int i = 0, pos = 0; i < MAXOFFSETS && i < plabels + dlabels; i++) { newname.setoffset(i, pos); pos += (newname.name[pos] + 1); } return newname; }
(Domain) SignatureExpiredException 2
              
// in org/xbill/DNS/DNSSEC.java
public static void verify(RRset rrset, RRSIGRecord rrsig, DNSKEYRecord key) throws DNSSECException { if (!matches(rrsig, key)) throw new KeyMismatchException(key, rrsig); Date now = new Date(); if (now.compareTo(rrsig.getExpire()) > 0) throw new SignatureExpiredException(rrsig.getExpire(), now); if (now.compareTo(rrsig.getTimeSigned()) < 0) throw new SignatureNotYetValidException(rrsig.getTimeSigned(), now); verify(key.getPublicKey(), rrsig.getAlgorithm(), digestRRset(rrsig, rrset), rrsig.getSignature()); }
// in org/xbill/DNS/DNSSEC.java
static void verifyMessage(Message message, byte [] bytes, SIGRecord sig, SIGRecord previous, KEYRecord key) throws DNSSECException { if (!matches(sig, key)) throw new KeyMismatchException(key, sig); Date now = new Date(); if (now.compareTo(sig.getExpire()) > 0) throw new SignatureExpiredException(sig.getExpire(), now); if (now.compareTo(sig.getTimeSigned()) < 0) throw new SignatureNotYetValidException(sig.getTimeSigned(), now); DNSOutput out = new DNSOutput(); digestSIG(out, sig); if (previous != null) out.writeByteArray(previous.getSignature()); Header header = (Header) message.getHeader().clone(); header.decCount(Section.ADDITIONAL); out.writeByteArray(header.toWire()); out.writeByteArray(bytes, Header.LENGTH, message.sig0start - Header.LENGTH); verify(key.getPublicKey(), sig.getAlgorithm(), out.toByteArray(), sig.getSignature()); }
0 0
(Domain) SignatureNotYetValidException 2
              
// in org/xbill/DNS/DNSSEC.java
public static void verify(RRset rrset, RRSIGRecord rrsig, DNSKEYRecord key) throws DNSSECException { if (!matches(rrsig, key)) throw new KeyMismatchException(key, rrsig); Date now = new Date(); if (now.compareTo(rrsig.getExpire()) > 0) throw new SignatureExpiredException(rrsig.getExpire(), now); if (now.compareTo(rrsig.getTimeSigned()) < 0) throw new SignatureNotYetValidException(rrsig.getTimeSigned(), now); verify(key.getPublicKey(), rrsig.getAlgorithm(), digestRRset(rrsig, rrset), rrsig.getSignature()); }
// in org/xbill/DNS/DNSSEC.java
static void verifyMessage(Message message, byte [] bytes, SIGRecord sig, SIGRecord previous, KEYRecord key) throws DNSSECException { if (!matches(sig, key)) throw new KeyMismatchException(key, sig); Date now = new Date(); if (now.compareTo(sig.getExpire()) > 0) throw new SignatureExpiredException(sig.getExpire(), now); if (now.compareTo(sig.getTimeSigned()) < 0) throw new SignatureNotYetValidException(sig.getTimeSigned(), now); DNSOutput out = new DNSOutput(); digestSIG(out, sig); if (previous != null) out.writeByteArray(previous.getSignature()); Header header = (Header) message.getHeader().clone(); header.decCount(Section.ADDITIONAL); out.writeByteArray(header.toWire()); out.writeByteArray(bytes, Header.LENGTH, message.sig0start - Header.LENGTH); verify(key.getPublicKey(), sig.getAlgorithm(), out.toByteArray(), sig.getSignature()); }
0 0
(Domain) SignatureVerificationException 2
              
// in org/xbill/DNS/DNSSEC.java
private static byte [] DSASignaturefromDNS(byte [] dns) throws DNSSECException, IOException { if (dns.length != 1 + DSA_LEN * 2) throw new SignatureVerificationException(); DNSInput in = new DNSInput(dns); DNSOutput out = new DNSOutput(); int t = in.readU8(); byte [] r = in.readByteArray(DSA_LEN); int rlen = DSA_LEN; if (r[0] < 0) rlen++; byte [] s = in.readByteArray(DSA_LEN); int slen = DSA_LEN; if (s[0] < 0) slen++; out.writeU8(ASN1_SEQ); out.writeU8(rlen + slen + 4); out.writeU8(ASN1_INT); out.writeU8(rlen); if (rlen > DSA_LEN) out.writeU8(0); out.writeByteArray(r); out.writeU8(ASN1_INT); out.writeU8(slen); if (slen > DSA_LEN) out.writeU8(0); out.writeByteArray(s); return out.toByteArray(); }
// in org/xbill/DNS/DNSSEC.java
private static void verify(PublicKey key, int alg, byte [] data, byte [] signature) throws DNSSECException { if (key instanceof DSAPublicKey) { try { signature = DSASignaturefromDNS(signature); } catch (IOException e) { throw new IllegalStateException(); } } try { Signature s = Signature.getInstance(algString(alg)); s.initVerify(key); s.update(data); if (!s.verify(signature)) throw new SignatureVerificationException(); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } }
0 0
(Domain) InvalidDClassException 1
              
// in org/xbill/DNS/DClass.java
public static void check(int i) { if (i < 0 || i > 0xFFFF) throw new InvalidDClassException(i); }
0 0
(Domain) InvalidTTLException 1
              
// in org/xbill/DNS/TTL.java
static void check(long i) { if (i < 0 || i > MAX_VALUE) throw new InvalidTTLException(i); }
0 0
(Domain) InvalidTypeException 1
              
// in org/xbill/DNS/Type.java
public static void check(int val) { if (val < 0 || val > 0xFFFF) throw new InvalidTypeException(val); }
0 0
(Lib) NoSuchAlgorithmException 1
              
// in org/xbill/DNS/NSEC3Record.java
static byte [] hashName(Name name, int hashAlg, int iterations, byte [] salt) throws NoSuchAlgorithmException { MessageDigest digest; switch (hashAlg) { case Digest.SHA1: digest = MessageDigest.getInstance("sha-1"); break; default: throw new NoSuchAlgorithmException("Unknown NSEC3 algorithm" + "identifier: " + hashAlg); } byte [] hash = null; for (int i = 0; i <= iterations; i++) { digest.reset(); if (i == 0) digest.update(name.toWireCanonical()); else digest.update(hash); if (salt != null) digest.update(salt); hash = digest.digest(); } return hash; }
0 3
              
// in org/xbill/DNS/NSEC3PARAMRecord.java
public byte [] hashName(Name name) throws NoSuchAlgorithmException { return NSEC3Record.hashName(name, hashAlg, iterations, salt); }
// in org/xbill/DNS/NSEC3Record.java
static byte [] hashName(Name name, int hashAlg, int iterations, byte [] salt) throws NoSuchAlgorithmException { MessageDigest digest; switch (hashAlg) { case Digest.SHA1: digest = MessageDigest.getInstance("sha-1"); break; default: throw new NoSuchAlgorithmException("Unknown NSEC3 algorithm" + "identifier: " + hashAlg); } byte [] hash = null; for (int i = 0; i <= iterations; i++) { digest.reset(); if (i == 0) digest.update(name.toWireCanonical()); else digest.update(hash); if (salt != null) digest.update(salt); hash = digest.digest(); } return hash; }
// in org/xbill/DNS/NSEC3Record.java
public byte [] hashName(Name name) throws NoSuchAlgorithmException { return hashName(name, hashAlg, iterations, salt); }
(Lib) NoSuchElementException 1
              
// in org/xbill/DNS/Zone.java
public Object next() { if (!hasNext()) { throw new NoSuchElementException(); } if (current == null) { wantLastSOA = false; return oneRRset(originNode, Type.SOA); } Object set = current[count++]; if (count == current.length) { current = null; while (zentries.hasNext()) { Map.Entry entry = (Map.Entry) zentries.next(); if (entry.getKey().equals(origin)) continue; RRset [] sets = allRRsets(entry.getValue()); if (sets.length == 0) continue; current = sets; count = 0; break; } } return set; }
0 0
(Lib) RuntimeException 1
              
// in org/xbill/DNS/Lookup.java
public static synchronized void refreshDefault() { try { defaultResolver = new ExtendedResolver(); } catch (UnknownHostException e) { throw new RuntimeException("Failed to initialize resolver"); } defaultSearchPath = ResolverConfig.getCurrentConfig().searchPath(); defaultCaches = new HashMap(); defaultNdots = ResolverConfig.getCurrentConfig().ndots(); }
1
              
// in org/xbill/DNS/Lookup.java
catch (UnknownHostException e) { throw new RuntimeException("Failed to initialize resolver"); }
0
(Lib) UnsupportedOperationException 1
              
// in org/xbill/DNS/Zone.java
public void remove() { throw new UnsupportedOperationException(); }
0 0
(Domain) ZoneTransferException 1
              
// in org/xbill/DNS/ZoneTransferIn.java
private void fail(String s) throws ZoneTransferException { throw new ZoneTransferException(s); }
0 9
              
// in org/xbill/DNS/Zone.java
private void fromXFR(ZoneTransferIn xfrin) throws IOException, ZoneTransferException { data = new TreeMap(); origin = xfrin.getName(); List records = xfrin.run(); for (Iterator it = records.iterator(); it.hasNext(); ) { Record record = (Record) it.next(); maybeAddRecord(record); } if (!xfrin.isAXFR()) throw new IllegalArgumentException("zones can only be " + "created from AXFRs"); validate(); }
// in org/xbill/DNS/ZoneTransferIn.java
private void fail(String s) throws ZoneTransferException { throw new ZoneTransferException(s); }
// in org/xbill/DNS/ZoneTransferIn.java
private void fallback() throws ZoneTransferException { if (!want_fallback) fail("server doesn't support IXFR"); logxfr("falling back to AXFR"); qtype = Type.AXFR; state = INITIALSOA; }
// in org/xbill/DNS/ZoneTransferIn.java
private void parseRR(Record rec) throws ZoneTransferException { int type = rec.getType(); Delta delta; switch (state) { case INITIALSOA: if (type != Type.SOA) fail("missing initial SOA"); initialsoa = rec; // Remember the serial number in the initial SOA; we need it // to recognize the end of an IXFR. end_serial = getSOASerial(rec); if (qtype == Type.IXFR && Serial.compare(end_serial, ixfr_serial) <= 0) { logxfr("up to date"); state = END; break; } state = FIRSTDATA; break; case FIRSTDATA: // If the transfer begins with 1 SOA, it's an AXFR. // If it begins with 2 SOAs, it's an IXFR. if (qtype == Type.IXFR && type == Type.SOA && getSOASerial(rec) == ixfr_serial) { rtype = Type.IXFR; handler.startIXFR(); logxfr("got incremental response"); state = IXFR_DELSOA; } else { rtype = Type.AXFR; handler.startAXFR(); handler.handleRecord(initialsoa); logxfr("got nonincremental response"); state = AXFR; } parseRR(rec); // Restart... return; case IXFR_DELSOA: handler.startIXFRDeletes(rec); state = IXFR_DEL; break; case IXFR_DEL: if (type == Type.SOA) { current_serial = getSOASerial(rec); state = IXFR_ADDSOA; parseRR(rec); // Restart... return; } handler.handleRecord(rec); break; case IXFR_ADDSOA: handler.startIXFRAdds(rec); state = IXFR_ADD; break; case IXFR_ADD: if (type == Type.SOA) { long soa_serial = getSOASerial(rec); if (soa_serial == end_serial) { state = END; break; } else if (soa_serial != current_serial) { fail("IXFR out of sync: expected serial " + current_serial + " , got " + soa_serial); } else { state = IXFR_DELSOA; parseRR(rec); // Restart... return; } } handler.handleRecord(rec); break; case AXFR: // Old BINDs sent cross class A records for non IN classes. if (type == Type.A && rec.getDClass() != dclass) break; handler.handleRecord(rec); if (type == Type.SOA) { state = END; } break; case END: fail("extra data"); break; default: fail("invalid state"); break; } }
// in org/xbill/DNS/ZoneTransferIn.java
private void doxfr() throws IOException, ZoneTransferException { sendQuery(); while (state != END) { byte [] in = client.recv(); Message response = parseMessage(in); if (response.getHeader().getRcode() == Rcode.NOERROR && verifier != null) { TSIGRecord tsigrec = response.getTSIG(); int error = verifier.verify(response, in); if (error != Rcode.NOERROR) fail("TSIG failure"); } Record [] answers = response.getSectionArray(Section.ANSWER); if (state == INITIALSOA) { int rcode = response.getRcode(); if (rcode != Rcode.NOERROR) { if (qtype == Type.IXFR && rcode == Rcode.NOTIMP) { fallback(); doxfr(); return; } fail(Rcode.string(rcode)); } Record question = response.getQuestion(); if (question != null && question.getType() != qtype) { fail("invalid question section"); } if (answers.length == 0 && qtype == Type.IXFR) { fallback(); doxfr(); return; } } for (int i = 0; i < answers.length; i++) { parseRR(answers[i]); } if (state == END && verifier != null && !response.isVerified()) fail("last message must be signed"); } }
// in org/xbill/DNS/ZoneTransferIn.java
public void run(ZoneTransferHandler handler) throws IOException, ZoneTransferException { this.handler = handler; try { openConnection(); doxfr(); } finally { closeConnection(); } }
// in org/xbill/DNS/ZoneTransferIn.java
public List run() throws IOException, ZoneTransferException { BasicHandler handler = new BasicHandler(); run(handler); if (handler.axfr != null) return handler.axfr; return handler.ixfr; }
Explicit thrown (throw new...): 227/323
Explicit thrown ratio: 70.3%
Builder thrown ratio: 27.6%
Variable thrown ratio: 2.2%
Checked Runtime Total
Domain 62 17 79
Lib 11 113 124
Total 73 130

Caught Exceptions Summary

A (Domain) exception is defined in the application. A (Lib) exception is defined in the JDK or in a library. An exception can be caught, and it happens that the catch block contains a throw (e.g. for wrapping a low-level exception). Hovering over a number triggers showing code snippets from the application code.

Type Exception Caught
(directly)
Caught
with Thrown
(Domain) TextParseException 21
            
// in org/xbill/DNS/ISDNRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/ISDNRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/HINFORecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/HINFORecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/Name.java
catch (TextParseException e) { throw new IllegalArgumentException("Invalid name '" + s + "'"); }
// in org/xbill/DNS/Master.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/Master.java
catch (TextParseException e) { throw st.exception("Parsing $GENERATE: " + e.getMessage()); }
// in org/xbill/DNS/ReverseMap.java
catch (TextParseException e) { throw new IllegalStateException("name cannot be invalid"); }
// in org/xbill/DNS/TXTBase.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/TXTBase.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (TextParseException e) { System.err.println("DNSJavaNameService: invalid " + domainProperty); }
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (TextParseException e) { throw new UnknownHostException(host); }
// in org/xbill/DNS/Tokenizer.java
catch (TextParseException e) { throw exception(e.getMessage()); }
// in org/xbill/DNS/TSIG.java
catch (TextParseException e) { throw new IllegalArgumentException("Invalid TSIG key name"); }
// in org/xbill/DNS/ResolverConfig.java
catch (TextParseException e) { return; }
// in org/xbill/DNS/ResolverConfig.java
catch (TextParseException e) { continue; }
// in org/xbill/DNS/Address.java
catch (TextParseException e) { throw new UnknownHostException("invalid name"); }
// in org/xbill/DNS/GPOSRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/GPOSRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/NAPTRRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/NAPTRRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
18
            
// in org/xbill/DNS/ISDNRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/ISDNRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/HINFORecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/HINFORecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/Name.java
catch (TextParseException e) { throw new IllegalArgumentException("Invalid name '" + s + "'"); }
// in org/xbill/DNS/Master.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/Master.java
catch (TextParseException e) { throw st.exception("Parsing $GENERATE: " + e.getMessage()); }
// in org/xbill/DNS/ReverseMap.java
catch (TextParseException e) { throw new IllegalStateException("name cannot be invalid"); }
// in org/xbill/DNS/TXTBase.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/TXTBase.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (TextParseException e) { throw new UnknownHostException(host); }
// in org/xbill/DNS/Tokenizer.java
catch (TextParseException e) { throw exception(e.getMessage()); }
// in org/xbill/DNS/TSIG.java
catch (TextParseException e) { throw new IllegalArgumentException("Invalid TSIG key name"); }
// in org/xbill/DNS/Address.java
catch (TextParseException e) { throw new UnknownHostException("invalid name"); }
// in org/xbill/DNS/GPOSRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/GPOSRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/NAPTRRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/NAPTRRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
(Lib) IOException 15
            
// in org/xbill/DNS/Record.java
catch (IOException e) { return null; }
// in org/xbill/DNS/SimpleResolver.java
catch (IOException e) { if (Options.check("verbose")) e.printStackTrace(); if (!(e instanceof WireParseException)) e = new WireParseException("Error parsing message"); throw (WireParseException) e; }
// in org/xbill/DNS/utils/base64.java
catch (IOException e) { }
// in org/xbill/DNS/utils/base32.java
catch (IOException e) { }
// in org/xbill/DNS/utils/base16.java
catch (IOException e) { }
// in org/xbill/DNS/Tokenizer.java
catch (IOException e) { }
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new MalformedKeyException(r); }
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new IllegalStateException(); }
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new IllegalStateException(); }
// in org/xbill/DNS/ResolverConfig.java
catch (IOException e) { }
// in org/xbill/DNS/ResolverConfig.java
catch (IOException e) { }
// in org/xbill/DNS/ResolverConfig.java
catch (IOException e) { return; }
// in org/xbill/DNS/ZoneTransferIn.java
catch (IOException e) { }
// in org/xbill/DNS/ZoneTransferIn.java
catch (IOException e) { if (e instanceof WireParseException) throw (WireParseException) e; throw new WireParseException("Error parsing message"); }
// in org/xbill/DNS/Lookup.java
catch (IOException e) { // A network error occurred. Press on. if (e instanceof InterruptedIOException) timedout = true; else networkerror = true; return; }
6
            
// in org/xbill/DNS/SimpleResolver.java
catch (IOException e) { if (Options.check("verbose")) e.printStackTrace(); if (!(e instanceof WireParseException)) e = new WireParseException("Error parsing message"); throw (WireParseException) e; }
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new MalformedKeyException(r); }
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new IllegalStateException(); }
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new IllegalStateException(); }
// in org/xbill/DNS/ZoneTransferIn.java
catch (IOException e) { if (e instanceof WireParseException) throw (WireParseException) e; throw new WireParseException("Error parsing message"); }
(Lib) NumberFormatException 15
            
// in org/xbill/DNS/APLRecord.java
catch (NumberFormatException e) { throw st.exception("invalid family"); }
// in org/xbill/DNS/APLRecord.java
catch (NumberFormatException e) { throw st.exception("invalid prefix length"); }
// in org/xbill/DNS/FormattedTime.java
catch (NumberFormatException e) { throw new TextParseException("Invalid time encoding: " + s); }
// in org/xbill/DNS/Mnemonic.java
catch (NumberFormatException e) { }
// in org/xbill/DNS/Master.java
catch (NumberFormatException e) { if (defaultTTL >= 0) currentTTL = defaultTTL; else if (last != null) currentTTL = last.getTTL(); }
// in org/xbill/DNS/Master.java
catch (NumberFormatException e) { return -1; }
// in org/xbill/DNS/Tokenizer.java
catch (NumberFormatException e) { throw exception("expected an integer"); }
// in org/xbill/DNS/Tokenizer.java
catch (NumberFormatException e) { throw exception("expected a TTL value"); }
// in org/xbill/DNS/Tokenizer.java
catch (NumberFormatException e) { throw exception("expected a TTL-like value"); }
// in org/xbill/DNS/ResolverConfig.java
catch (NumberFormatException e) { }
// in org/xbill/DNS/Address.java
catch (NumberFormatException e) { return null; }
// in org/xbill/DNS/Options.java
catch (NumberFormatException e) { }
// in org/xbill/DNS/KEYRecord.java
catch (NumberFormatException e) { }
// in org/xbill/DNS/LOCRecord.java
catch (NumberFormatException e) { }
// in org/xbill/DNS/LOCRecord.java
catch (NumberFormatException e) { throw st.exception("Invalid LOC " + type); }
7
            
// in org/xbill/DNS/APLRecord.java
catch (NumberFormatException e) { throw st.exception("invalid family"); }
// in org/xbill/DNS/APLRecord.java
catch (NumberFormatException e) { throw st.exception("invalid prefix length"); }
// in org/xbill/DNS/FormattedTime.java
catch (NumberFormatException e) { throw new TextParseException("Invalid time encoding: " + s); }
// in org/xbill/DNS/Tokenizer.java
catch (NumberFormatException e) { throw exception("expected an integer"); }
// in org/xbill/DNS/Tokenizer.java
catch (NumberFormatException e) { throw exception("expected a TTL value"); }
// in org/xbill/DNS/Tokenizer.java
catch (NumberFormatException e) { throw exception("expected a TTL-like value"); }
// in org/xbill/DNS/LOCRecord.java
catch (NumberFormatException e) { throw st.exception("Invalid LOC " + type); }
(Lib) UnknownHostException 10
            
// in org/xbill/DNS/ARecord.java
catch (UnknownHostException e) { return null; }
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (UnknownHostException e) { System.err.println("DNSJavaNameService: invalid " + nsProperty); }
// in org/xbill/DNS/Tokenizer.java
catch (UnknownHostException e) { throw exception(e.getMessage()); }
// in org/xbill/DNS/A6Record.java
catch (UnknownHostException e) { throw st.exception("invalid IPv6 address: " + s); }
// in org/xbill/DNS/Address.java
catch (UnknownHostException e) { Record [] records = lookupHostName(name); return addrFromRecord(name, records[0]); }
// in org/xbill/DNS/Address.java
catch (UnknownHostException e) { Record [] records = lookupHostName(name); InetAddress [] addrs = new InetAddress[records.length]; for (int i = 0; i < records.length; i++) addrs[i] = addrFromRecord(name, records[i]); return addrs; }
// in org/xbill/DNS/Address.java
catch (UnknownHostException e) { throw new IllegalArgumentException("invalid address"); }
// in org/xbill/DNS/ClientSubnetOption.java
catch (UnknownHostException e) { throw new WireParseException("invalid address", e); }
// in org/xbill/DNS/WKSRecord.java
catch (UnknownHostException e) { return null; }
// in org/xbill/DNS/Lookup.java
catch (UnknownHostException e) { throw new RuntimeException("Failed to initialize resolver"); }
5
            
// in org/xbill/DNS/Tokenizer.java
catch (UnknownHostException e) { throw exception(e.getMessage()); }
// in org/xbill/DNS/A6Record.java
catch (UnknownHostException e) { throw st.exception("invalid IPv6 address: " + s); }
// in org/xbill/DNS/Address.java
catch (UnknownHostException e) { throw new IllegalArgumentException("invalid address"); }
// in org/xbill/DNS/ClientSubnetOption.java
catch (UnknownHostException e) { throw new WireParseException("invalid address", e); }
// in org/xbill/DNS/Lookup.java
catch (UnknownHostException e) { throw new RuntimeException("Failed to initialize resolver"); }
(Domain) NameTooLongException 7
            
// in org/xbill/DNS/Name.java
catch (NameTooLongException e) { throw parseException(fullName, "Name too long"); }
// in org/xbill/DNS/Name.java
catch (NameTooLongException e) { }
// in org/xbill/DNS/Name.java
catch (NameTooLongException e) { throw new IllegalStateException ("Name.wild: concatenate failed"); }
// in org/xbill/DNS/Cache.java
catch (NameTooLongException e) { break; }
// in org/xbill/DNS/ZoneTransferIn.java
catch (NameTooLongException e) { throw new IllegalArgumentException("ZoneTransferIn: " + "name too long"); }
// in org/xbill/DNS/Lookup.java
catch (NameTooLongException e) { result = UNRECOVERABLE; error = "Invalid DNAME target"; done = true; }
// in org/xbill/DNS/Lookup.java
catch (NameTooLongException e) { nametoolong = true; return; }
3
            
// in org/xbill/DNS/Name.java
catch (NameTooLongException e) { throw parseException(fullName, "Name too long"); }
// in org/xbill/DNS/Name.java
catch (NameTooLongException e) { throw new IllegalStateException ("Name.wild: concatenate failed"); }
// in org/xbill/DNS/ZoneTransferIn.java
catch (NameTooLongException e) { throw new IllegalArgumentException("ZoneTransferIn: " + "name too long"); }
(Lib) Exception 6
            
// in org/xbill/DNS/ExtendedResolver.java
catch (Exception e) { /* * This will either cause more queries to be sent * asynchronously or will set the 'done' flag. */ handleException(inprogress[0], e); }
// in org/xbill/DNS/ResolveThread.java
catch (Exception e) { listener.handleException(id, e); }
// in org/xbill/DNS/ResolverConfig.java
catch (Exception e) { return false; }
// in org/xbill/DNS/ResolverConfig.java
catch (Exception e) { return; }
// in org/xbill/DNS/ResolverConfig.java
catch (Exception e) { return; }
// in org/xbill/DNS/ResolverConfig.java
catch ( Exception e ) { // ignore resolutely }
0
(Lib) GeneralSecurityException 3
            
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
3
            
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
(Lib) IllegalArgumentException 3
            
// in org/xbill/DNS/TSIG.java
catch (IllegalArgumentException e) { parts = str.split("[:/]", 2); }
// in org/xbill/DNS/GPOSRecord.java
catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); }
// in org/xbill/DNS/GPOSRecord.java
catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); }
2
            
// in org/xbill/DNS/GPOSRecord.java
catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); }
// in org/xbill/DNS/GPOSRecord.java
catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); }
(Lib) InterruptedException 2
            
// in org/xbill/DNS/ExtendedResolver.java
catch (InterruptedException e) { }
// in org/xbill/DNS/UDPClient.java
catch (InterruptedException e) { }
0
(Lib) NoSuchAlgorithmException 2
            
// in org/xbill/DNS/utils/HMAC.java
catch (NoSuchAlgorithmException e) { throw new IllegalArgumentException("unknown digest algorithm " + digestName); }
// in org/xbill/DNS/DNSSEC.java
catch (NoSuchAlgorithmException e) { throw new IllegalStateException("no message digest support"); }
2
            
// in org/xbill/DNS/utils/HMAC.java
catch (NoSuchAlgorithmException e) { throw new IllegalArgumentException("unknown digest algorithm " + digestName); }
// in org/xbill/DNS/DNSSEC.java
catch (NoSuchAlgorithmException e) { throw new IllegalStateException("no message digest support"); }
(Lib) Throwable 2
            
// in org/xbill/DNS/ExtendedResolver.java
catch (Throwable t) { synchronized (this) { thrown = t; done = true; if (listener == null) { notifyAll(); return; } } }
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (Throwable e) { System.err.println("DNSJavaNameService: Unexpected error."); e.printStackTrace(); throw e; }
1
            
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (Throwable e) { System.err.println("DNSJavaNameService: Unexpected error."); e.printStackTrace(); throw e; }
(Lib) CloneNotSupportedException 1
            
// in org/xbill/DNS/Record.java
catch (CloneNotSupportedException e) { throw new IllegalStateException(); }
1
            
// in org/xbill/DNS/Record.java
catch (CloneNotSupportedException e) { throw new IllegalStateException(); }
(Lib) FileNotFoundException 1
            
// in org/xbill/DNS/ResolverConfig.java
catch (FileNotFoundException e) { return; }
0
(Lib) SecurityException 1
            
// in org/xbill/DNS/Options.java
catch (SecurityException e) { }
0
(Lib) SocketException 1
            
// in org/xbill/DNS/UDPClient.java
catch (SocketException e) { }
0
(Domain) TokenizerException 1
            
// in org/xbill/DNS/Master.java
catch (Tokenizer.TokenizerException e) { throw st.exception("Parsing $GENERATE: " + e.getBaseMessage()); }
1
            
// in org/xbill/DNS/Master.java
catch (Tokenizer.TokenizerException e) { throw st.exception("Parsing $GENERATE: " + e.getBaseMessage()); }
(Domain) WireParseException 1
            
// in org/xbill/DNS/Message.java
catch (WireParseException e) { if (!truncated) throw e; }
1
            
// in org/xbill/DNS/Message.java
catch (WireParseException e) { if (!truncated) throw e; }
(Domain) ZoneTransferException 1
            
// in org/xbill/DNS/SimpleResolver.java
catch (ZoneTransferException e) { throw new WireParseException(e.getMessage()); }
1
            
// in org/xbill/DNS/SimpleResolver.java
catch (ZoneTransferException e) { throw new WireParseException(e.getMessage()); }

Exception Recast Summary

There is a common practice of throwing exceptions from within a catch block (e.g. for wrapping a low-level exception). The following table summarizes the usage of this practice in the application. The last column gives the number of times it happens for a pair of exceptions. The graph below the table graphically renders the same information. For a given node, its color represents its origin (blue means library exception, orange means domain exception); the left-most number is the number of times it is thrown, the right-most is the number of times it is caught.

Catch Throw
(Lib) IllegalArgumentException
(Domain) WireParseException
2
                    
// in org/xbill/DNS/GPOSRecord.java
catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); }
// in org/xbill/DNS/GPOSRecord.java
catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); }
(Domain) WireParseException
Unknown
1
                    
// in org/xbill/DNS/Message.java
catch (WireParseException e) { if (!truncated) throw e; }
(Domain) NameTooLongException
(Lib) IllegalStateException
(Lib) IllegalArgumentException
Unknown
1
                    
// in org/xbill/DNS/Name.java
catch (NameTooLongException e) { throw new IllegalStateException ("Name.wild: concatenate failed"); }
1
                    
// in org/xbill/DNS/ZoneTransferIn.java
catch (NameTooLongException e) { throw new IllegalArgumentException("ZoneTransferIn: " + "name too long"); }
1
                    
// in org/xbill/DNS/Name.java
catch (NameTooLongException e) { throw parseException(fullName, "Name too long"); }
(Lib) NumberFormatException
(Domain) TextParseException
Unknown
1
                    
// in org/xbill/DNS/FormattedTime.java
catch (NumberFormatException e) { throw new TextParseException("Invalid time encoding: " + s); }
6
                    
// in org/xbill/DNS/APLRecord.java
catch (NumberFormatException e) { throw st.exception("invalid family"); }
// in org/xbill/DNS/APLRecord.java
catch (NumberFormatException e) { throw st.exception("invalid prefix length"); }
// in org/xbill/DNS/Tokenizer.java
catch (NumberFormatException e) { throw exception("expected an integer"); }
// in org/xbill/DNS/Tokenizer.java
catch (NumberFormatException e) { throw exception("expected a TTL value"); }
// in org/xbill/DNS/Tokenizer.java
catch (NumberFormatException e) { throw exception("expected a TTL-like value"); }
// in org/xbill/DNS/LOCRecord.java
catch (NumberFormatException e) { throw st.exception("Invalid LOC " + type); }
(Domain) TextParseException
(Lib) IllegalArgumentException
(Lib) IllegalStateException
(Lib) UnknownHostException
Unknown
7
                    
// in org/xbill/DNS/ISDNRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/HINFORecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/Name.java
catch (TextParseException e) { throw new IllegalArgumentException("Invalid name '" + s + "'"); }
// in org/xbill/DNS/TXTBase.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/TSIG.java
catch (TextParseException e) { throw new IllegalArgumentException("Invalid TSIG key name"); }
// in org/xbill/DNS/GPOSRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/NAPTRRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
1
                    
// in org/xbill/DNS/ReverseMap.java
catch (TextParseException e) { throw new IllegalStateException("name cannot be invalid"); }
2
                    
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (TextParseException e) { throw new UnknownHostException(host); }
// in org/xbill/DNS/Address.java
catch (TextParseException e) { throw new UnknownHostException("invalid name"); }
8
                    
// in org/xbill/DNS/ISDNRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/HINFORecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/Master.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/Master.java
catch (TextParseException e) { throw st.exception("Parsing $GENERATE: " + e.getMessage()); }
// in org/xbill/DNS/TXTBase.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/Tokenizer.java
catch (TextParseException e) { throw exception(e.getMessage()); }
// in org/xbill/DNS/GPOSRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/NAPTRRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
(Domain) TokenizerException
Unknown
1
                    
// in org/xbill/DNS/Master.java
catch (Tokenizer.TokenizerException e) { throw st.exception("Parsing $GENERATE: " + e.getBaseMessage()); }
(Domain) ZoneTransferException
(Domain) WireParseException
1
                    
// in org/xbill/DNS/SimpleResolver.java
catch (ZoneTransferException e) { throw new WireParseException(e.getMessage()); }
(Lib) UnknownHostException
(Lib) IllegalArgumentException
(Domain) WireParseException
(Lib) RuntimeException
Unknown
1
                    
// in org/xbill/DNS/Address.java
catch (UnknownHostException e) { throw new IllegalArgumentException("invalid address"); }
1
                    
// in org/xbill/DNS/ClientSubnetOption.java
catch (UnknownHostException e) { throw new WireParseException("invalid address", e); }
1
                    
// in org/xbill/DNS/Lookup.java
catch (UnknownHostException e) { throw new RuntimeException("Failed to initialize resolver"); }
2
                    
// in org/xbill/DNS/Tokenizer.java
catch (UnknownHostException e) { throw exception(e.getMessage()); }
// in org/xbill/DNS/A6Record.java
catch (UnknownHostException e) { throw st.exception("invalid IPv6 address: " + s); }
(Lib) Throwable
Unknown
1
                    
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (Throwable e) { System.err.println("DNSJavaNameService: Unexpected error."); e.printStackTrace(); throw e; }
(Lib) IOException
(Domain) MalformedKeyException
(Lib) IllegalStateException
(Domain) WireParseException
Unknown
1
                    
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new MalformedKeyException(r); }
2
                    
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new IllegalStateException(); }
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new IllegalStateException(); }
1
                    
// in org/xbill/DNS/ZoneTransferIn.java
catch (IOException e) { if (e instanceof WireParseException) throw (WireParseException) e; throw new WireParseException("Error parsing message"); }
2
                    
// in org/xbill/DNS/SimpleResolver.java
catch (IOException e) { if (Options.check("verbose")) e.printStackTrace(); if (!(e instanceof WireParseException)) e = new WireParseException("Error parsing message"); throw (WireParseException) e; }
// in org/xbill/DNS/ZoneTransferIn.java
catch (IOException e) { if (e instanceof WireParseException) throw (WireParseException) e; throw new WireParseException("Error parsing message"); }
(Lib) CloneNotSupportedException
(Lib) IllegalStateException
1
                    
// in org/xbill/DNS/Record.java
catch (CloneNotSupportedException e) { throw new IllegalStateException(); }
(Lib) NoSuchAlgorithmException
(Lib) IllegalArgumentException
(Lib) IllegalStateException
1
                    
// in org/xbill/DNS/utils/HMAC.java
catch (NoSuchAlgorithmException e) { throw new IllegalArgumentException("unknown digest algorithm " + digestName); }
1
                    
// in org/xbill/DNS/DNSSEC.java
catch (NoSuchAlgorithmException e) { throw new IllegalStateException("no message digest support"); }
(Lib) GeneralSecurityException
(Domain) DNSSECException
3
                    
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }

Caught / Thrown Exception

Not all exceptions are thrown AND caught in the same project. The following table gives the exceptions types with respect to this. The lower left hand side sell lists all exceptions thrown but not caught (prevalent for libraries), the upper right-hand side lists all exceptions caught but not thrown (usually coming from external dependencies).

Thrown Not Thrown
Caught
Type Name
(Lib) IllegalArgumentException
(Domain) WireParseException
(Domain) NameTooLongException
(Lib) NumberFormatException
(Domain) TextParseException
(Domain) ZoneTransferException
(Lib) UnknownHostException
(Lib) IOException
(Lib) NoSuchAlgorithmException
Type Name
(Domain) TokenizerException
(Lib) Throwable
(Lib) Exception
(Lib) InterruptedException
(Lib) CloneNotSupportedException
(Lib) GeneralSecurityException
(Lib) FileNotFoundException
(Lib) SecurityException
(Lib) SocketException
Not caught
Type Name
(Domain) InvalidTTLException
(Lib) IllegalStateException
(Domain) RelativeNameException
(Lib) SocketTimeoutException
(Domain) MalformedKeyException
(Domain) UnsupportedAlgorithmException
(Domain) DNSSECException
(Domain) IncompatibleKeyException
(Domain) SignatureVerificationException
(Domain) KeyMismatchException
(Domain) SignatureExpiredException
(Domain) SignatureNotYetValidException
(Lib) NoSuchElementException
(Lib) UnsupportedOperationException
(Domain) InvalidTypeException
(Lib) EOFException
(Domain) InvalidDClassException
(Lib) RuntimeException

Methods called in Catch and Finally Blocks

The following shows the methods that are called inside catch blocks (first column) and finally blocks (second column). For each method, we give the number of times it is called in a catch block (second sub-column), and the total number of calls (third sub-column). If the method name is red, it means that it is only called from catch/finally blocks. Hovering over a number triggers showing code snippets from the application code.

Catch Finally
Method Nbr Nbr total
exception 17
                  
// in org/xbill/DNS/APLRecord.java
catch (NumberFormatException e) { throw st.exception("invalid family"); }
// in org/xbill/DNS/APLRecord.java
catch (NumberFormatException e) { throw st.exception("invalid prefix length"); }
// in org/xbill/DNS/ISDNRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/HINFORecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/Master.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/Master.java
catch (Tokenizer.TokenizerException e) { throw st.exception("Parsing $GENERATE: " + e.getBaseMessage()); }
// in org/xbill/DNS/Master.java
catch (TextParseException e) { throw st.exception("Parsing $GENERATE: " + e.getMessage()); }
// in org/xbill/DNS/TXTBase.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/Tokenizer.java
catch (NumberFormatException e) { throw exception("expected an integer"); }
// in org/xbill/DNS/Tokenizer.java
catch (NumberFormatException e) { throw exception("expected a TTL value"); }
// in org/xbill/DNS/Tokenizer.java
catch (NumberFormatException e) { throw exception("expected a TTL-like value"); }
// in org/xbill/DNS/Tokenizer.java
catch (TextParseException e) { throw exception(e.getMessage()); }
// in org/xbill/DNS/Tokenizer.java
catch (UnknownHostException e) { throw exception(e.getMessage()); }
// in org/xbill/DNS/A6Record.java
catch (UnknownHostException e) { throw st.exception("invalid IPv6 address: " + s); }
// in org/xbill/DNS/GPOSRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/LOCRecord.java
catch (NumberFormatException e) { throw st.exception("Invalid LOC " + type); }
// in org/xbill/DNS/NAPTRRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
79
getMessage 17
                  
// in org/xbill/DNS/ISDNRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/ISDNRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/HINFORecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/HINFORecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/SimpleResolver.java
catch (ZoneTransferException e) { throw new WireParseException(e.getMessage()); }
// in org/xbill/DNS/Master.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/Master.java
catch (TextParseException e) { throw st.exception("Parsing $GENERATE: " + e.getMessage()); }
// in org/xbill/DNS/TXTBase.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/TXTBase.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/Tokenizer.java
catch (TextParseException e) { throw exception(e.getMessage()); }
// in org/xbill/DNS/Tokenizer.java
catch (UnknownHostException e) { throw exception(e.getMessage()); }
// in org/xbill/DNS/GPOSRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/GPOSRecord.java
catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); }
// in org/xbill/DNS/GPOSRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/GPOSRecord.java
catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); }
// in org/xbill/DNS/NAPTRRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/NAPTRRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
18
println 3
                  
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (UnknownHostException e) { System.err.println("DNSJavaNameService: invalid " + nsProperty); }
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (TextParseException e) { System.err.println("DNSJavaNameService: invalid " + domainProperty); }
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (Throwable e) { System.err.println("DNSJavaNameService: Unexpected error."); e.printStackTrace(); throw e; }
48
toString 3
                  
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
97
addrFromRecord
2
                  
// in org/xbill/DNS/Address.java
catch (UnknownHostException e) { Record [] records = lookupHostName(name); return addrFromRecord(name, records[0]); }
// in org/xbill/DNS/Address.java
catch (UnknownHostException e) { Record [] records = lookupHostName(name); InetAddress [] addrs = new InetAddress[records.length]; for (int i = 0; i < records.length; i++) addrs[i] = addrFromRecord(name, records[i]); return addrs; }
2
handleException 2
                  
// in org/xbill/DNS/ExtendedResolver.java
catch (Exception e) { /* * This will either cause more queries to be sent * asynchronously or will set the 'done' flag. */ handleException(inprogress[0], e); }
// in org/xbill/DNS/ResolveThread.java
catch (Exception e) { listener.handleException(id, e); }
3
lookupHostName
2
                  
// in org/xbill/DNS/Address.java
catch (UnknownHostException e) { Record [] records = lookupHostName(name); return addrFromRecord(name, records[0]); }
// in org/xbill/DNS/Address.java
catch (UnknownHostException e) { Record [] records = lookupHostName(name); InetAddress [] addrs = new InetAddress[records.length]; for (int i = 0; i < records.length; i++) addrs[i] = addrFromRecord(name, records[i]); return addrs; }
2
printStackTrace
2
                  
// in org/xbill/DNS/SimpleResolver.java
catch (IOException e) { if (Options.check("verbose")) e.printStackTrace(); if (!(e instanceof WireParseException)) e = new WireParseException("Error parsing message"); throw (WireParseException) e; }
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (Throwable e) { System.err.println("DNSJavaNameService: Unexpected error."); e.printStackTrace(); throw e; }
2
check 1
                  
// in org/xbill/DNS/SimpleResolver.java
catch (IOException e) { if (Options.check("verbose")) e.printStackTrace(); if (!(e instanceof WireParseException)) e = new WireParseException("Error parsing message"); throw (WireParseException) e; }
75
getBaseMessage
1
                  
// in org/xbill/DNS/Master.java
catch (Tokenizer.TokenizerException e) { throw st.exception("Parsing $GENERATE: " + e.getBaseMessage()); }
1
getTTL 1
                  
// in org/xbill/DNS/Master.java
catch (NumberFormatException e) { if (defaultTTL >= 0) currentTTL = defaultTTL; else if (last != null) currentTTL = last.getTTL(); }
17
notifyAll 1
                  
// in org/xbill/DNS/ExtendedResolver.java
catch (Throwable t) { synchronized (this) { thrown = t; done = true; if (listener == null) { notifyAll(); return; } } }
3
parseException 1
                  
// in org/xbill/DNS/Name.java
catch (NameTooLongException e) { throw parseException(fullName, "Name too long"); }
9
split 1
                  
// in org/xbill/DNS/TSIG.java
catch (IllegalArgumentException e) { parts = str.split("[:/]", 2); }
4
Method Nbr Nbr total
interestOps 4
                  
// in org/xbill/DNS/TCPClient.java
finally { if (key.isValid()) key.interestOps(0); }
// in org/xbill/DNS/TCPClient.java
finally { if (key.isValid()) key.interestOps(0); }
// in org/xbill/DNS/TCPClient.java
finally { if (key.isValid()) key.interestOps(0); }
// in org/xbill/DNS/UDPClient.java
finally { if (key.isValid()) key.interestOps(0); }
8
isValid
4
                  
// in org/xbill/DNS/TCPClient.java
finally { if (key.isValid()) key.interestOps(0); }
// in org/xbill/DNS/TCPClient.java
finally { if (key.isValid()) key.interestOps(0); }
// in org/xbill/DNS/TCPClient.java
finally { if (key.isValid()) key.interestOps(0); }
// in org/xbill/DNS/UDPClient.java
finally { if (key.isValid()) key.interestOps(0); }
4
close 3
                  
// in org/xbill/DNS/Master.java
finally { if (rec == null) { st.close(); } }
// in org/xbill/DNS/Client.java
finally { if (!done && selector != null) selector.close(); if (!done) channel.close(); }
9
cleanup 2
                  
// in org/xbill/DNS/TCPClient.java
finally { client.cleanup(); }
// in org/xbill/DNS/UDPClient.java
finally { client.cleanup(); }
3
closeConnection
1
                  
// in org/xbill/DNS/ZoneTransferIn.java
finally { closeConnection(); }
1

Reference Table

This table concatenates the results of the previous tables.

Checked/Runtime Type Exception Thrown Thrown from Catch Declared Caught directly Caught
with Thrown
Caught
with Thrown Runtime
unknown (Lib) CloneNotSupportedException 0 0 0 1
            
// in org/xbill/DNS/Record.java
catch (CloneNotSupportedException e) { throw new IllegalStateException(); }
1
            
// in org/xbill/DNS/Record.java
catch (CloneNotSupportedException e) { throw new IllegalStateException(); }
1
checked (Domain) DNSSECException
public static class DNSSECException extends Exception {
	DNSSECException(String s) {
		super(s);
	}
}
3
            
// in org/xbill/DNS/DNSSEC.java
static PublicKey toPublicKey(KEYBase r) throws DNSSECException { int alg = r.getAlgorithm(); try { switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: return toRSAPublicKey(r); case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: return toDSAPublicKey(r); default: throw new UnsupportedAlgorithmException(alg); } } catch (IOException e) { throw new MalformedKeyException(r); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } }
// in org/xbill/DNS/DNSSEC.java
private static void verify(PublicKey key, int alg, byte [] data, byte [] signature) throws DNSSECException { if (key instanceof DSAPublicKey) { try { signature = DSASignaturefromDNS(signature); } catch (IOException e) { throw new IllegalStateException(); } } try { Signature s = Signature.getInstance(algString(alg)); s.initVerify(key); s.update(data); if (!s.verify(signature)) throw new SignatureVerificationException(); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } }
// in org/xbill/DNS/DNSSEC.java
private static byte [] sign(PrivateKey privkey, PublicKey pubkey, int alg, byte [] data, String provider) throws DNSSECException { byte [] signature; try { Signature s; if (provider != null) s = Signature.getInstance(algString(alg), provider); else s = Signature.getInstance(algString(alg)); s.initSign(privkey); s.update(data); signature = s.sign(); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } if (pubkey instanceof DSAPublicKey) { try { DSAPublicKey dsa = (DSAPublicKey) pubkey; BigInteger P = dsa.getParams().getP(); int t = (BigIntegerLength(P) - 64) / 8; signature = DSASignaturetoDNS(signature, t); } catch (IOException e) { throw new IllegalStateException(); } } return signature; }
3
            
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
15
            
// in org/xbill/DNS/SIG0.java
public static void signMessage(Message message, KEYRecord key, PrivateKey privkey, SIGRecord previous) throws DNSSEC.DNSSECException { int validity = Options.intValue("sig0validity"); if (validity < 0) validity = VALIDITY; long now = System.currentTimeMillis(); Date timeSigned = new Date(now); Date timeExpires = new Date(now + validity * 1000); SIGRecord sig = DNSSEC.signMessage(message, previous, key, privkey, timeSigned, timeExpires); message.addRecord(sig, Section.ADDITIONAL); }
// in org/xbill/DNS/SIG0.java
public static void verifyMessage(Message message, byte [] b, KEYRecord key, SIGRecord previous) throws DNSSEC.DNSSECException { SIGRecord sig = null; Record [] additional = message.getSectionArray(Section.ADDITIONAL); for (int i = 0; i < additional.length; i++) { if (additional[i].getType() != Type.SIG) continue; if (((SIGRecord) additional[i]).getTypeCovered() != 0) continue; sig = (SIGRecord) additional[i]; break; } DNSSEC.verifyMessage(message, b, sig, previous, key); }
// in org/xbill/DNS/KEYBase.java
public PublicKey getPublicKey() throws DNSSEC.DNSSECException { if (publicKey != null) return publicKey; publicKey = DNSSEC.toPublicKey(this); return publicKey; }
// in org/xbill/DNS/DNSSEC.java
static PublicKey toPublicKey(KEYBase r) throws DNSSECException { int alg = r.getAlgorithm(); try { switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: return toRSAPublicKey(r); case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: return toDSAPublicKey(r); default: throw new UnsupportedAlgorithmException(alg); } } catch (IOException e) { throw new MalformedKeyException(r); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } }
// in org/xbill/DNS/DNSSEC.java
static byte [] fromPublicKey(PublicKey key, int alg) throws DNSSECException { byte [] data = null; switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: if (! (key instanceof RSAPublicKey)) throw new IncompatibleKeyException(); return fromRSAPublicKey((RSAPublicKey) key); case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: if (! (key instanceof DSAPublicKey)) throw new IncompatibleKeyException(); return fromDSAPublicKey((DSAPublicKey) key); default: throw new UnsupportedAlgorithmException(alg); } }
// in org/xbill/DNS/DNSSEC.java
private static byte [] DSASignaturefromDNS(byte [] dns) throws DNSSECException, IOException { if (dns.length != 1 + DSA_LEN * 2) throw new SignatureVerificationException(); DNSInput in = new DNSInput(dns); DNSOutput out = new DNSOutput(); int t = in.readU8(); byte [] r = in.readByteArray(DSA_LEN); int rlen = DSA_LEN; if (r[0] < 0) rlen++; byte [] s = in.readByteArray(DSA_LEN); int slen = DSA_LEN; if (s[0] < 0) slen++; out.writeU8(ASN1_SEQ); out.writeU8(rlen + slen + 4); out.writeU8(ASN1_INT); out.writeU8(rlen); if (rlen > DSA_LEN) out.writeU8(0); out.writeByteArray(r); out.writeU8(ASN1_INT); out.writeU8(slen); if (slen > DSA_LEN) out.writeU8(0); out.writeByteArray(s); return out.toByteArray(); }
// in org/xbill/DNS/DNSSEC.java
private static void verify(PublicKey key, int alg, byte [] data, byte [] signature) throws DNSSECException { if (key instanceof DSAPublicKey) { try { signature = DSASignaturefromDNS(signature); } catch (IOException e) { throw new IllegalStateException(); } } try { Signature s = Signature.getInstance(algString(alg)); s.initVerify(key); s.update(data); if (!s.verify(signature)) throw new SignatureVerificationException(); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } }
// in org/xbill/DNS/DNSSEC.java
public static void verify(RRset rrset, RRSIGRecord rrsig, DNSKEYRecord key) throws DNSSECException { if (!matches(rrsig, key)) throw new KeyMismatchException(key, rrsig); Date now = new Date(); if (now.compareTo(rrsig.getExpire()) > 0) throw new SignatureExpiredException(rrsig.getExpire(), now); if (now.compareTo(rrsig.getTimeSigned()) < 0) throw new SignatureNotYetValidException(rrsig.getTimeSigned(), now); verify(key.getPublicKey(), rrsig.getAlgorithm(), digestRRset(rrsig, rrset), rrsig.getSignature()); }
// in org/xbill/DNS/DNSSEC.java
private static byte [] sign(PrivateKey privkey, PublicKey pubkey, int alg, byte [] data, String provider) throws DNSSECException { byte [] signature; try { Signature s; if (provider != null) s = Signature.getInstance(algString(alg), provider); else s = Signature.getInstance(algString(alg)); s.initSign(privkey); s.update(data); signature = s.sign(); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } if (pubkey instanceof DSAPublicKey) { try { DSAPublicKey dsa = (DSAPublicKey) pubkey; BigInteger P = dsa.getParams().getP(); int t = (BigIntegerLength(P) - 64) / 8; signature = DSASignaturetoDNS(signature, t); } catch (IOException e) { throw new IllegalStateException(); } } return signature; }
// in org/xbill/DNS/DNSSEC.java
public static RRSIGRecord sign(RRset rrset, DNSKEYRecord key, PrivateKey privkey, Date inception, Date expiration) throws DNSSECException { return sign(rrset, key, privkey, inception, expiration, null); }
// in org/xbill/DNS/DNSSEC.java
public static RRSIGRecord sign(RRset rrset, DNSKEYRecord key, PrivateKey privkey, Date inception, Date expiration, String provider) throws DNSSECException { int alg = key.getAlgorithm(); checkAlgorithm(privkey, alg); RRSIGRecord rrsig = new RRSIGRecord(rrset.getName(), rrset.getDClass(), rrset.getTTL(), rrset.getType(), alg, rrset.getTTL(), expiration, inception, key.getFootprint(), key.getName(), null); rrsig.setSignature(sign(privkey, key.getPublicKey(), alg, digestRRset(rrsig, rrset), provider)); return rrsig; }
// in org/xbill/DNS/DNSSEC.java
static SIGRecord signMessage(Message message, SIGRecord previous, KEYRecord key, PrivateKey privkey, Date inception, Date expiration) throws DNSSECException { int alg = key.getAlgorithm(); checkAlgorithm(privkey, alg); SIGRecord sig = new SIGRecord(Name.root, DClass.ANY, 0, 0, alg, 0, expiration, inception, key.getFootprint(), key.getName(), null); DNSOutput out = new DNSOutput(); digestSIG(out, sig); if (previous != null) out.writeByteArray(previous.getSignature()); message.toWire(out); sig.setSignature(sign(privkey, key.getPublicKey(), alg, out.toByteArray(), null)); return sig; }
// in org/xbill/DNS/DNSSEC.java
static void verifyMessage(Message message, byte [] bytes, SIGRecord sig, SIGRecord previous, KEYRecord key) throws DNSSECException { if (!matches(sig, key)) throw new KeyMismatchException(key, sig); Date now = new Date(); if (now.compareTo(sig.getExpire()) > 0) throw new SignatureExpiredException(sig.getExpire(), now); if (now.compareTo(sig.getTimeSigned()) < 0) throw new SignatureNotYetValidException(sig.getTimeSigned(), now); DNSOutput out = new DNSOutput(); digestSIG(out, sig); if (previous != null) out.writeByteArray(previous.getSignature()); Header header = (Header) message.getHeader().clone(); header.decCount(Section.ADDITIONAL); out.writeByteArray(header.toWire()); out.writeByteArray(bytes, Header.LENGTH, message.sig0start - Header.LENGTH); verify(key.getPublicKey(), sig.getAlgorithm(), out.toByteArray(), sig.getSignature()); }
0 0 0
unknown (Lib) EOFException 3
            
// in org/xbill/DNS/TCPClient.java
void send(byte [] data) throws IOException { SocketChannel channel = (SocketChannel) key.channel(); verboseLog("TCP write", data); byte [] lengthArray = new byte[2]; lengthArray[0] = (byte)(data.length >>> 8); lengthArray[1] = (byte)(data.length & 0xFF); ByteBuffer [] buffers = new ByteBuffer[2]; buffers[0] = ByteBuffer.wrap(lengthArray); buffers[1] = ByteBuffer.wrap(data); int nsent = 0; key.interestOps(SelectionKey.OP_WRITE); try { while (nsent < data.length + 2) { if (key.isWritable()) { long n = channel.write(buffers); if (n < 0) throw new EOFException(); nsent += (int) n; if (nsent < data.length + 2 && System.currentTimeMillis() > endTime) throw new SocketTimeoutException(); } else blockUntil(key, endTime); } } finally { if (key.isValid()) key.interestOps(0); } }
// in org/xbill/DNS/TCPClient.java
private byte [] _recv(int length) throws IOException { SocketChannel channel = (SocketChannel) key.channel(); int nrecvd = 0; byte [] data = new byte[length]; ByteBuffer buffer = ByteBuffer.wrap(data); key.interestOps(SelectionKey.OP_READ); try { while (nrecvd < length) { if (key.isReadable()) { long n = channel.read(buffer); if (n < 0) throw new EOFException(); nrecvd += (int) n; if (nrecvd < length && System.currentTimeMillis() > endTime) throw new SocketTimeoutException(); } else blockUntil(key, endTime); } } finally { if (key.isValid()) key.interestOps(0); } return data; }
// in org/xbill/DNS/UDPClient.java
byte [] recv(int max) throws IOException { DatagramChannel channel = (DatagramChannel) key.channel(); byte [] temp = new byte[max]; key.interestOps(SelectionKey.OP_READ); try { while (!key.isReadable()) blockUntil(key, endTime); } finally { if (key.isValid()) key.interestOps(0); } long ret = channel.read(ByteBuffer.wrap(temp)); if (ret <= 0) throw new EOFException(); int len = (int) ret; byte [] data = new byte[len]; System.arraycopy(temp, 0, data, 0, len); verboseLog("UDP read", data); return data; }
0 0 0 0 0
checked (Lib) Exception 0 0 2
            
// in org/xbill/DNS/tests/xfrin.java
public static void main(String [] args) throws Exception { ZoneTransferIn xfrin; TSIG key = null; int ixfr_serial = -1; String server = null; int port = SimpleResolver.DEFAULT_PORT; boolean fallback = false; Name zname; int arg = 0; while (arg < args.length) { if (args[arg].equals("-i")) { ixfr_serial = Integer.parseInt(args[++arg]); if (ixfr_serial < 0) usage("invalid serial number"); } else if (args[arg].equals("-k")) { String s = args[++arg]; int index = s.indexOf('/'); if (index < 0) usage("invalid key"); key = new TSIG(s.substring(0, index), s.substring(index+1)); } else if (args[arg].equals("-s")) { server = args[++arg]; } else if (args[arg].equals("-p")) { port = Integer.parseInt(args[++arg]); if (port < 0 || port > 0xFFFF) usage("invalid port"); } else if (args[arg].equals("-f")) { fallback = true; } else if (args[arg].startsWith("-")) { usage("invalid option"); } else { break; } arg++; } if (arg >= args.length) usage("no zone name specified"); zname = Name.fromString(args[arg]); if (server == null) { Lookup l = new Lookup(zname, Type.NS); Record [] ns = l.run(); if (ns == null) { System.out.println("failed to look up NS record: " + l.getErrorString()); System.exit(1); } server = ns[0].rdataToString(); System.out.println("sending to server '" + server + "'"); } if (ixfr_serial >= 0) xfrin = ZoneTransferIn.newIXFR(zname, ixfr_serial, fallback, server, port, key); else xfrin = ZoneTransferIn.newAXFR(zname, server, port, key); List response = xfrin.run(); if (xfrin.isAXFR()) { if (ixfr_serial >= 0) System.out.println("AXFR-like IXFR response"); else System.out.println("AXFR response"); Iterator it = response.iterator(); while (it.hasNext()) System.out.println(it.next()); } else if (xfrin.isIXFR()) { System.out.println("IXFR response"); Iterator it = response.iterator(); while (it.hasNext()) { ZoneTransferIn.Delta delta; delta = (ZoneTransferIn.Delta) it.next(); System.out.println("delta from " + delta.start + " to " + delta.end); System.out.println("deletes"); Iterator it2 = delta.deletes.iterator(); while (it2.hasNext()) System.out.println(it2.next()); System.out.println("adds"); it2 = delta.adds.iterator(); while (it2.hasNext()) System.out.println(it2.next()); } } else if (xfrin.isCurrent()) { System.out.println("up to date"); } }
// in org/xbill/DNS/tests/primary.java
public static void main(String [] args) throws Exception { boolean time = false; boolean axfr = false; boolean iterator = false; int arg = 0; if (args.length < 2) usage(); while (args.length - arg > 2) { if (args[0].equals("-t")) time = true; else if (args[0].equals("-a")) axfr = true; else if (args[0].equals("-i")) iterator = true; arg++; } Name origin = Name.fromString(args[arg++], Name.root); String file = args[arg++]; long start = System.currentTimeMillis(); Zone zone = new Zone(origin, file); long end = System.currentTimeMillis(); if (axfr) { Iterator it = zone.AXFR(); while (it.hasNext()) { System.out.println(it.next()); } } else if (iterator) { Iterator it = zone.iterator(); while (it.hasNext()) { System.out.println(it.next()); } } else { System.out.println(zone); } if (time) System.out.println("; Load time: " + (end - start) + " ms"); }
6
            
// in org/xbill/DNS/ExtendedResolver.java
catch (Exception e) { /* * This will either cause more queries to be sent * asynchronously or will set the 'done' flag. */ handleException(inprogress[0], e); }
// in org/xbill/DNS/ResolveThread.java
catch (Exception e) { listener.handleException(id, e); }
// in org/xbill/DNS/ResolverConfig.java
catch (Exception e) { return false; }
// in org/xbill/DNS/ResolverConfig.java
catch (Exception e) { return; }
// in org/xbill/DNS/ResolverConfig.java
catch (Exception e) { return; }
// in org/xbill/DNS/ResolverConfig.java
catch ( Exception e ) { // ignore resolutely }
0 0
unknown (Lib) FileNotFoundException 0 0 1 1
            
// in org/xbill/DNS/ResolverConfig.java
catch (FileNotFoundException e) { return; }
0 0
unknown (Lib) GeneralSecurityException 0 0 2
            
// in org/xbill/DNS/DNSSEC.java
private static PublicKey toRSAPublicKey(KEYBase r) throws IOException, GeneralSecurityException { DNSInput in = new DNSInput(r.getKey()); int exponentLength = in.readU8(); if (exponentLength == 0) exponentLength = in.readU16(); BigInteger exponent = readBigInteger(in, exponentLength); BigInteger modulus = readBigInteger(in); KeyFactory factory = KeyFactory.getInstance("RSA"); return factory.generatePublic(new RSAPublicKeySpec(modulus, exponent)); }
// in org/xbill/DNS/DNSSEC.java
private static PublicKey toDSAPublicKey(KEYBase r) throws IOException, GeneralSecurityException, MalformedKeyException { DNSInput in = new DNSInput(r.getKey()); int t = in.readU8(); if (t > 8) throw new MalformedKeyException(r); BigInteger q = readBigInteger(in, 20); BigInteger p = readBigInteger(in, 64 + t*8); BigInteger g = readBigInteger(in, 64 + t*8); BigInteger y = readBigInteger(in, 64 + t*8); KeyFactory factory = KeyFactory.getInstance("DSA"); return factory.generatePublic(new DSAPublicKeySpec(y, p, q, g)); }
3
            
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
3
            
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
// in org/xbill/DNS/DNSSEC.java
catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); }
0
checked (Lib) IOException 11
            
// in org/xbill/DNS/DNSSEC.java
private static byte [] DSASignaturetoDNS(byte [] key, int t) throws IOException { DNSInput in = new DNSInput(key); DNSOutput out = new DNSOutput(); out.writeU8(t); int tmp = in.readU8(); if (tmp != ASN1_SEQ) throw new IOException(); int seqlen = in.readU8(); tmp = in.readU8(); if (tmp != ASN1_INT) throw new IOException(); int rlen = in.readU8(); if (rlen == DSA_LEN + 1) { if (in.readU8() != 0) throw new IOException(); } else if (rlen != DSA_LEN) throw new IOException(); byte [] bytes = in.readByteArray(DSA_LEN); out.writeByteArray(bytes); tmp = in.readU8(); if (tmp != ASN1_INT) throw new IOException(); int slen = in.readU8(); if (slen == DSA_LEN + 1) { if (in.readU8() != 0) throw new IOException(); } else if (slen != DSA_LEN) throw new IOException(); bytes = in.readByteArray(DSA_LEN); out.writeByteArray(bytes); return out.toByteArray(); }
// in org/xbill/DNS/Zone.java
private void validate() throws IOException { originNode = exactName(origin); if (originNode == null) throw new IOException(origin + ": no data specified"); RRset rrset = oneRRset(originNode, Type.SOA); if (rrset == null || rrset.size() != 1) throw new IOException(origin + ": exactly 1 SOA must be specified"); Iterator it = rrset.rrs(); SOA = (SOARecord) it.next(); NS = oneRRset(originNode, Type.NS); if (NS == null) throw new IOException(origin + ": no NS set specified"); }
// in org/xbill/DNS/Zone.java
private final void maybeAddRecord(Record record) throws IOException { int rtype = record.getType(); Name name = record.getName(); if (rtype == Type.SOA && !name.equals(origin)) { throw new IOException("SOA owner " + name + " does not match zone origin " + origin); } if (name.subdomain(origin)) addRecord(record); }
0 181
            
// in org/xbill/DNS/SSHFPRecord.java
void rrFromWire(DNSInput in) throws IOException { alg = in.readU8(); digestType = in.readU8(); fingerprint = in.readByteArray(); }
// in org/xbill/DNS/SSHFPRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { alg = st.getUInt8(); digestType = st.getUInt8(); fingerprint = st.getHex(true); }
// in org/xbill/DNS/APLRecord.java
void rrFromWire(DNSInput in) throws IOException { elements = new ArrayList(1); while (in.remaining() != 0) { int family = in.readU16(); int prefix = in.readU8(); int length = in.readU8(); boolean negative = (length & 0x80) != 0; length &= ~0x80; byte [] data = in.readByteArray(length); Element element; if (!validatePrefixLength(family, prefix)) { throw new WireParseException("invalid prefix length"); } if (family == Address.IPv4 || family == Address.IPv6) { data = parseAddress(data, Address.addressLength(family)); InetAddress addr = InetAddress.getByAddress(data); element = new Element(negative, addr, prefix); } else { element = new Element(family, negative, data, prefix); } elements.add(element); } }
// in org/xbill/DNS/APLRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { elements = new ArrayList(1); while (true) { Tokenizer.Token t = st.get(); if (!t.isString()) break; boolean negative = false; int family = 0; int prefix = 0; String s = t.value; int start = 0; if (s.startsWith("!")) { negative = true; start = 1; } int colon = s.indexOf(':', start); if (colon < 0) throw st.exception("invalid address prefix element"); int slash = s.indexOf('/', colon); if (slash < 0) throw st.exception("invalid address prefix element"); String familyString = s.substring(start, colon); String addressString = s.substring(colon + 1, slash); String prefixString = s.substring(slash + 1); try { family = Integer.parseInt(familyString); } catch (NumberFormatException e) { throw st.exception("invalid family"); } if (family != Address.IPv4 && family != Address.IPv6) throw st.exception("unknown family"); try { prefix = Integer.parseInt(prefixString); } catch (NumberFormatException e) { throw st.exception("invalid prefix length"); } if (!validatePrefixLength(family, prefix)) { throw st.exception("invalid prefix length"); } byte [] bytes = Address.toByteArray(addressString, family); if (bytes == null) throw st.exception("invalid IP address " + addressString); InetAddress address = InetAddress.getByAddress(bytes); elements.add(new Element(negative, address, prefix)); } st.unget(); }
// in org/xbill/DNS/NXTRecord.java
void rrFromWire(DNSInput in) throws IOException { next = new Name(in); bitmap = new BitSet(); int bitmapLength = in.remaining(); for (int i = 0; i < bitmapLength; i++) { int t = in.readU8(); for (int j = 0; j < 8; j++) if ((t & (1 << (7 - j))) != 0) bitmap.set(i * 8 + j); } }
// in org/xbill/DNS/NXTRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { next = st.getName(origin); bitmap = new BitSet(); while (true) { Tokenizer.Token t = st.get(); if (!t.isString()) break; int typecode = Type.value(t.value, true); if (typecode <= 0 || typecode > 128) throw st.exception("Invalid type: " + t.value); bitmap.set(typecode); } st.unget(); }
// in org/xbill/DNS/ISDNRecord.java
void rrFromWire(DNSInput in) throws IOException { address = in.readCountedString(); if (in.remaining() > 0) subAddress = in.readCountedString(); }
// in org/xbill/DNS/ISDNRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { try { address = byteArrayFromString(st.getString()); Tokenizer.Token t = st.get(); if (t.isString()) { subAddress = byteArrayFromString(t.value); } else { st.unget(); } } catch (TextParseException e) { throw st.exception(e.getMessage()); } }
// in org/xbill/DNS/TSIGRecord.java
void rrFromWire(DNSInput in) throws IOException { alg = new Name(in); long timeHigh = in.readU16(); long timeLow = in.readU32(); long time = (timeHigh << 32) + timeLow; timeSigned = new Date(time * 1000); fudge = in.readU16(); int sigLen = in.readU16(); signature = in.readByteArray(sigLen); originalID = in.readU16(); error = in.readU16(); int otherLen = in.readU16(); if (otherLen > 0) other = in.readByteArray(otherLen); else other = null; }
// in org/xbill/DNS/TSIGRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { throw st.exception("no text format defined for TSIG"); }
// in org/xbill/DNS/ARecord.java
void rrFromWire(DNSInput in) throws IOException { addr = fromArray(in.readByteArray(4)); }
// in org/xbill/DNS/ARecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { InetAddress address = st.getAddress(Address.IPv4); addr = fromArray(address.getAddress()); }
// in org/xbill/DNS/GenericEDNSOption.java
void optionFromWire(DNSInput in) throws IOException { data = in.readByteArray(); }
// in org/xbill/DNS/ExtendedResolver.java
public Message start() throws IOException { try { /* * First, try sending synchronously. If this works, * we're done. Otherwise, we'll get an exception * and continue. It would be easier to call send(0), * but this avoids a thread creation. If and when * SimpleResolver.sendAsync() can be made to not * create a thread, this could be changed. */ sent[0]++; outstanding++; inprogress[0] = new Object(); return resolvers[0].send(query); } catch (Exception e) { /* * This will either cause more queries to be sent * asynchronously or will set the 'done' flag. */ handleException(inprogress[0], e); } /* * Wait for a successful response or for each * subresolver to fail. */ synchronized (this) { while (!done) { try { wait(); } catch (InterruptedException e) { } } } /* Return the response or throw an exception */ if (response != null) return response; else if (thrown instanceof IOException) throw (IOException) thrown; else if (thrown instanceof RuntimeException) throw (RuntimeException) thrown; else if (thrown instanceof Error) throw (Error) thrown; else throw new IllegalStateException ("ExtendedResolver failure"); }
// in org/xbill/DNS/ExtendedResolver.java
public Message send(Message query) throws IOException { Resolution res = new Resolution(this, query); return res.start(); }
// in org/xbill/DNS/Record.java
private static Record newRecord(Name name, int type, int dclass, long ttl, int length, DNSInput in) throws IOException { Record rec; rec = getEmptyRecord(name, type, dclass, ttl, in != null); if (in != null) { if (in.remaining() < length) throw new WireParseException("truncated record"); in.setActive(length); rec.rrFromWire(in); if (in.remaining() > 0) throw new WireParseException("invalid record length"); in.clearActive(); } return rec; }
// in org/xbill/DNS/Record.java
static Record fromWire(DNSInput in, int section, boolean isUpdate) throws IOException { int type, dclass; long ttl; int length; Name name; Record rec; name = new Name(in); type = in.readU16(); dclass = in.readU16(); if (section == Section.QUESTION) return newRecord(name, type, dclass); ttl = in.readU32(); length = in.readU16(); if (length == 0 && isUpdate && (section == Section.PREREQ || section == Section.UPDATE)) return newRecord(name, type, dclass, ttl); rec = newRecord(name, type, dclass, ttl, length, in); return rec; }
// in org/xbill/DNS/Record.java
static Record fromWire(DNSInput in, int section) throws IOException { return fromWire(in, section, false); }
// in org/xbill/DNS/Record.java
public static Record fromWire(byte [] b, int section) throws IOException { return fromWire(new DNSInput(b), section, false); }
// in org/xbill/DNS/Record.java
public static Record fromString(Name name, int type, int dclass, long ttl, Tokenizer st, Name origin) throws IOException { Record rec; if (!name.isAbsolute()) throw new RelativeNameException(name); Type.check(type); DClass.check(dclass); TTL.check(ttl); Tokenizer.Token t = st.get(); if (t.type == Tokenizer.IDENTIFIER && t.value.equals("\\#")) { int length = st.getUInt16(); byte [] data = st.getHex(); if (data == null) { data = new byte[0]; } if (length != data.length) throw st.exception("invalid unknown RR encoding: " + "length mismatch"); DNSInput in = new DNSInput(data); return newRecord(name, type, dclass, ttl, length, in); } st.unget(); rec = getEmptyRecord(name, type, dclass, ttl, true); rec.rdataFromString(st, origin); t = st.get(); if (t.type != Tokenizer.EOL && t.type != Tokenizer.EOF) { throw st.exception("unexpected tokens at end of record"); } return rec; }
// in org/xbill/DNS/Record.java
public static Record fromString(Name name, int type, int dclass, long ttl, String s, Name origin) throws IOException { return fromString(name, type, dclass, ttl, new Tokenizer(s), origin); }
// in org/xbill/DNS/HINFORecord.java
void rrFromWire(DNSInput in) throws IOException { cpu = in.readCountedString(); os = in.readCountedString(); }
// in org/xbill/DNS/HINFORecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { try { cpu = byteArrayFromString(st.getString()); os = byteArrayFromString(st.getString()); } catch (TextParseException e) { throw st.exception(e.getMessage()); } }
// in org/xbill/DNS/SimpleResolver.java
public Message send(Message query) throws IOException { if (Options.check("verbose")) System.err.println("Sending to " + address.getAddress().getHostAddress() + ":" + address.getPort()); if (query.getHeader().getOpcode() == Opcode.QUERY) { Record question = query.getQuestion(); if (question != null && question.getType() == Type.AXFR) return sendAXFR(query); } query = (Message) query.clone(); applyEDNS(query); if (tsig != null) tsig.apply(query, null); byte [] out = query.toWire(Message.MAXLENGTH); int udpSize = maxUDPSize(query); boolean tcp = false; long endTime = System.currentTimeMillis() + timeoutValue; do { byte [] in; if (useTCP || out.length > udpSize) tcp = true; if (tcp) in = TCPClient.sendrecv(localAddress, address, out, endTime); else in = UDPClient.sendrecv(localAddress, address, out, udpSize, endTime); /* * Check that the response is long enough. */ if (in.length < Header.LENGTH) { throw new WireParseException("invalid DNS header - " + "too short"); } /* * Check that the response ID matches the query ID. We want * to check this before actually parsing the message, so that * if there's a malformed response that's not ours, it * doesn't confuse us. */ int id = ((in[0] & 0xFF) << 8) + (in[1] & 0xFF); int qid = query.getHeader().getID(); if (id != qid) { String error = "invalid message id: expected " + qid + "; got id " + id; if (tcp) { throw new WireParseException(error); } else { if (Options.check("verbose")) { System.err.println(error); } continue; } } Message response = parseMessage(in); verifyTSIG(query, response, in, tsig); if (!tcp && !ignoreTruncation && response.getHeader().getFlag(Flags.TC)) { tcp = true; continue; } return response; } while (true); }
// in org/xbill/DNS/SimpleResolver.java
private Message sendAXFR(Message query) throws IOException { Name qname = query.getQuestion().getName(); ZoneTransferIn xfrin = ZoneTransferIn.newAXFR(qname, address, tsig); xfrin.setTimeout((int)(getTimeout() / 1000)); xfrin.setLocalAddress(localAddress); try { xfrin.run(); } catch (ZoneTransferException e) { throw new WireParseException(e.getMessage()); } List records = xfrin.getAXFR(); Message response = new Message(query.getHeader().getID()); response.getHeader().setFlag(Flags.AA); response.getHeader().setFlag(Flags.QR); response.addRecord(query.getQuestion(), Section.QUESTION); Iterator it = records.iterator(); while (it.hasNext()) response.addRecord((Record)it.next(), Section.ANSWER); return response; }
// in org/xbill/DNS/AAAARecord.java
void rrFromWire(DNSInput in) throws IOException { address = InetAddress.getByAddress(in.readByteArray(16)); }
// in org/xbill/DNS/AAAARecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { address = st.getAddress(Address.IPv6); }
// in org/xbill/DNS/Master.java
private void parseTTLClassAndType() throws IOException { String s; boolean seen_class = false; // This is a bit messy, since any of the following are legal: // class ttl type // ttl class type // class type // ttl type // type seen_class = false; s = st.getString(); if ((currentDClass = DClass.value(s)) >= 0) { s = st.getString(); seen_class = true; } currentTTL = -1; try { currentTTL = TTL.parseTTL(s); s = st.getString(); } catch (NumberFormatException e) { if (defaultTTL >= 0) currentTTL = defaultTTL; else if (last != null) currentTTL = last.getTTL(); } if (!seen_class) { if ((currentDClass = DClass.value(s)) >= 0) { s = st.getString(); } else { currentDClass = DClass.IN; } } if ((currentType = Type.value(s)) < 0) throw st.exception("Invalid type '" + s + "'"); // BIND allows a missing TTL for the initial SOA record, and uses // the SOA minimum value. If the SOA is not the first record, // this is an error. if (currentTTL < 0) { if (currentType != Type.SOA) throw st.exception("missing TTL"); needSOATTL = true; currentTTL = 0; } }
// in org/xbill/DNS/Master.java
private void startGenerate() throws IOException { String s; int n; // The first field is of the form start-end[/step] // Regexes would be useful here. s = st.getIdentifier(); n = s.indexOf("-"); if (n < 0) throw st.exception("Invalid $GENERATE range specifier: " + s); String startstr = s.substring(0, n); String endstr = s.substring(n + 1); String stepstr = null; n = endstr.indexOf("/"); if (n >= 0) { stepstr = endstr.substring(n + 1); endstr = endstr.substring(0, n); } long start = parseUInt32(startstr); long end = parseUInt32(endstr); long step; if (stepstr != null) step = parseUInt32(stepstr); else step = 1; if (start < 0 || end < 0 || start > end || step <= 0) throw st.exception("Invalid $GENERATE range specifier: " + s); // The next field is the name specification. String nameSpec = st.getIdentifier(); // Then the ttl/class/type, in the same form as a normal record. // Only some types are supported. parseTTLClassAndType(); if (!Generator.supportedType(currentType)) throw st.exception("$GENERATE does not support " + Type.string(currentType) + " records"); // Next comes the rdata specification. String rdataSpec = st.getIdentifier(); // That should be the end. However, we don't want to move past the // line yet, so put back the EOL after reading it. st.getEOL(); st.unget(); generator = new Generator(start, end, step, nameSpec, currentType, currentDClass, currentTTL, rdataSpec, origin); if (generators == null) generators = new ArrayList(1); generators.add(generator); }
// in org/xbill/DNS/Master.java
private void endGenerate() throws IOException { // Read the EOL that we put back before. st.getEOL(); generator = null; }
// in org/xbill/DNS/Master.java
private Record nextGenerated() throws IOException { try { return generator.nextRecord(); } catch (Tokenizer.TokenizerException e) { throw st.exception("Parsing $GENERATE: " + e.getBaseMessage()); } catch (TextParseException e) { throw st.exception("Parsing $GENERATE: " + e.getMessage()); } }
// in org/xbill/DNS/Master.java
public Record _nextRecord() throws IOException { Tokenizer.Token token; String s; if (included != null) { Record rec = included.nextRecord(); if (rec != null) return rec; included = null; } if (generator != null) { Record rec = nextGenerated(); if (rec != null) return rec; endGenerate(); } while (true) { Name name; token = st.get(true, false); if (token.type == Tokenizer.WHITESPACE) { Tokenizer.Token next = st.get(); if (next.type == Tokenizer.EOL) continue; else if (next.type == Tokenizer.EOF) return null; else st.unget(); if (last == null) throw st.exception("no owner"); name = last.getName(); } else if (token.type == Tokenizer.EOL) continue; else if (token.type == Tokenizer.EOF) return null; else if (((String) token.value).charAt(0) == '$') { s = token.value; if (s.equalsIgnoreCase("$ORIGIN")) { origin = st.getName(Name.root); st.getEOL(); continue; } else if (s.equalsIgnoreCase("$TTL")) { defaultTTL = st.getTTL(); st.getEOL(); continue; } else if (s.equalsIgnoreCase("$INCLUDE")) { String filename = st.getString(); File newfile; if (file != null) { String parent = file.getParent(); newfile = new File(parent, filename); } else { newfile = new File(filename); } Name incorigin = origin; token = st.get(); if (token.isString()) { incorigin = parseName(token.value, Name.root); st.getEOL(); } included = new Master(newfile, incorigin, defaultTTL); /* * If we continued, we wouldn't be looking in * the new file. Recursing works better. */ return nextRecord(); } else if (s.equalsIgnoreCase("$GENERATE")) { if (generator != null) throw new IllegalStateException ("cannot nest $GENERATE"); startGenerate(); if (noExpandGenerate) { endGenerate(); continue; } return nextGenerated(); } else { throw st.exception("Invalid directive: " + s); } } else { s = token.value; name = parseName(s, origin); if (last != null && name.equals(last.getName())) { name = last.getName(); } } parseTTLClassAndType(); last = Record.fromString(name, currentType, currentDClass, currentTTL, st, origin); if (needSOATTL) { long ttl = ((SOARecord)last).getMinimum(); last.setTTL(ttl); defaultTTL = ttl; needSOATTL = false; } return last; } }
// in org/xbill/DNS/Master.java
public Record nextRecord() throws IOException { Record rec = null; try { rec = _nextRecord(); } finally { if (rec == null) { st.close(); } } return rec; }
// in org/xbill/DNS/TXTBase.java
void rrFromWire(DNSInput in) throws IOException { strings = new ArrayList(2); while (in.remaining() > 0) { byte [] b = in.readCountedString(); strings.add(b); } }
// in org/xbill/DNS/TXTBase.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { strings = new ArrayList(2); while (true) { Tokenizer.Token t = st.get(); if (!t.isString()) break; try { strings.add(byteArrayFromString(t.value)); } catch (TextParseException e) { throw st.exception(e.getMessage()); } } st.unget(); }
// in org/xbill/DNS/DLVRecord.java
void rrFromWire(DNSInput in) throws IOException { footprint = in.readU16(); alg = in.readU8(); digestid = in.readU8(); digest = in.readByteArray(); }
// in org/xbill/DNS/DLVRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { footprint = st.getUInt16(); alg = st.getUInt8(); digestid = st.getUInt8(); digest = st.getHex(); }
// in org/xbill/DNS/SingleNameBase.java
void rrFromWire(DNSInput in) throws IOException { singleName = new Name(in); }
// in org/xbill/DNS/SingleNameBase.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { singleName = st.getName(origin); }
// in org/xbill/DNS/KEYBase.java
void rrFromWire(DNSInput in) throws IOException { flags = in.readU16(); proto = in.readU8(); alg = in.readU8(); if (in.remaining() > 0) key = in.readByteArray(); }
// in org/xbill/DNS/Client.java
static protected void blockUntil(SelectionKey key, long endTime) throws IOException { long timeout = endTime - System.currentTimeMillis(); int nkeys = 0; if (timeout > 0) nkeys = key.selector().select(timeout); else if (timeout == 0) nkeys = key.selector().selectNow(); if (nkeys == 0) throw new SocketTimeoutException(); }
// in org/xbill/DNS/Client.java
void cleanup() throws IOException { key.selector().close(); key.channel().close(); }
// in org/xbill/DNS/NSEC3PARAMRecord.java
void rrFromWire(DNSInput in) throws IOException { hashAlg = in.readU8(); flags = in.readU8(); iterations = in.readU16(); int salt_length = in.readU8(); if (salt_length > 0) salt = in.readByteArray(salt_length); else salt = null; }
// in org/xbill/DNS/NSEC3PARAMRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { hashAlg = st.getUInt8(); flags = st.getUInt8(); iterations = st.getUInt16(); String s = st.getString(); if (s.equals("-")) salt = null; else { st.unget(); salt = st.getHexString(); if (salt.length > 255) throw st.exception("salt value too long"); } }
// in org/xbill/DNS/Tokenizer.java
private int getChar() throws IOException { int c = is.read(); if (c == '\r') { int next = is.read(); if (next != '\n') is.unread(next); c = '\n'; } if (c == '\n') line++; return c; }
// in org/xbill/DNS/Tokenizer.java
private void ungetChar(int c) throws IOException { if (c == -1) return; is.unread(c); if (c == '\n') line--; }
// in org/xbill/DNS/Tokenizer.java
private int skipWhitespace() throws IOException { int skipped = 0; while (true) { int c = getChar(); if (c != ' ' && c != '\t') { if (!(c == '\n' && multiline > 0)) { ungetChar(c); return skipped; } } skipped++; } }
// in org/xbill/DNS/Tokenizer.java
public Token get(boolean wantWhitespace, boolean wantComment) throws IOException { int type; int c; if (ungottenToken) { ungottenToken = false; if (current.type == WHITESPACE) { if (wantWhitespace) return current; } else if (current.type == COMMENT) { if (wantComment) return current; } else { if (current.type == EOL) line++; return current; } } int skipped = skipWhitespace(); if (skipped > 0 && wantWhitespace) return current.set(WHITESPACE, null); type = IDENTIFIER; sb.setLength(0); while (true) { c = getChar(); if (c == -1 || delimiters.indexOf(c) != -1) { if (c == -1) { if (quoting) throw exception("EOF in " + "quoted string"); else if (sb.length() == 0) return current.set(EOF, null); else return current.set(type, sb); } if (sb.length() == 0 && type != QUOTED_STRING) { if (c == '(') { multiline++; skipWhitespace(); continue; } else if (c == ')') { if (multiline <= 0) throw exception("invalid " + "close " + "parenthesis"); multiline--; skipWhitespace(); continue; } else if (c == '"') { if (!quoting) { quoting = true; delimiters = quotes; type = QUOTED_STRING; } else { quoting = false; delimiters = delim; skipWhitespace(); } continue; } else if (c == '\n') { return current.set(EOL, null); } else if (c == ';') { while (true) { c = getChar(); if (c == '\n' || c == -1) break; sb.append((char)c); } if (wantComment) { ungetChar(c); return current.set(COMMENT, sb); } else if (c == -1 && type != QUOTED_STRING) { checkUnbalancedParens(); return current.set(EOF, null); } else if (multiline > 0) { skipWhitespace(); sb.setLength(0); continue; } else return current.set(EOL, null); } else throw new IllegalStateException(); } else ungetChar(c); break; } else if (c == '\\') { c = getChar(); if (c == -1) throw exception("unterminated escape sequence"); sb.append('\\'); } else if (quoting && c == '\n') { throw exception("newline in quoted string"); } sb.append((char)c); } if (sb.length() == 0 && type != QUOTED_STRING) { checkUnbalancedParens(); return current.set(EOF, null); } return current.set(type, sb); }
// in org/xbill/DNS/Tokenizer.java
public Token get() throws IOException { return get(false, false); }
// in org/xbill/DNS/Tokenizer.java
public String getString() throws IOException { Token next = get(); if (!next.isString()) { throw exception("expected a string"); } return next.value; }
// in org/xbill/DNS/Tokenizer.java
private String _getIdentifier(String expected) throws IOException { Token next = get(); if (next.type != IDENTIFIER) throw exception("expected " + expected); return next.value; }
// in org/xbill/DNS/Tokenizer.java
public String getIdentifier() throws IOException { return _getIdentifier("an identifier"); }
// in org/xbill/DNS/Tokenizer.java
public long getLong() throws IOException { String next = _getIdentifier("an integer"); if (!Character.isDigit(next.charAt(0))) throw exception("expected an integer"); try { return Long.parseLong(next); } catch (NumberFormatException e) { throw exception("expected an integer"); } }
// in org/xbill/DNS/Tokenizer.java
public long getUInt32() throws IOException { long l = getLong(); if (l < 0 || l > 0xFFFFFFFFL) throw exception("expected an 32 bit unsigned integer"); return l; }
// in org/xbill/DNS/Tokenizer.java
public int getUInt16() throws IOException { long l = getLong(); if (l < 0 || l > 0xFFFFL) throw exception("expected an 16 bit unsigned integer"); return (int) l; }
// in org/xbill/DNS/Tokenizer.java
public int getUInt8() throws IOException { long l = getLong(); if (l < 0 || l > 0xFFL) throw exception("expected an 8 bit unsigned integer"); return (int) l; }
// in org/xbill/DNS/Tokenizer.java
public long getTTL() throws IOException { String next = _getIdentifier("a TTL value"); try { return TTL.parseTTL(next); } catch (NumberFormatException e) { throw exception("expected a TTL value"); } }
// in org/xbill/DNS/Tokenizer.java
public long getTTLLike() throws IOException { String next = _getIdentifier("a TTL-like value"); try { return TTL.parse(next, false); } catch (NumberFormatException e) { throw exception("expected a TTL-like value"); } }
// in org/xbill/DNS/Tokenizer.java
public Name getName(Name origin) throws IOException { String next = _getIdentifier("a name"); try { Name name = Name.fromString(next, origin); if (!name.isAbsolute()) throw new RelativeNameException(name); return name; } catch (TextParseException e) { throw exception(e.getMessage()); } }
// in org/xbill/DNS/Tokenizer.java
public InetAddress getAddress(int family) throws IOException { String next = _getIdentifier("an address"); try { return Address.getByAddress(next, family); } catch (UnknownHostException e) { throw exception(e.getMessage()); } }
// in org/xbill/DNS/Tokenizer.java
public void getEOL() throws IOException { Token next = get(); if (next.type != EOL && next.type != EOF) { throw exception("expected EOL or EOF"); } }
// in org/xbill/DNS/Tokenizer.java
private String remainingStrings() throws IOException { StringBuffer buffer = null; while (true) { Tokenizer.Token t = get(); if (!t.isString()) break; if (buffer == null) buffer = new StringBuffer(); buffer.append(t.value); } unget(); if (buffer == null) return null; return buffer.toString(); }
// in org/xbill/DNS/Tokenizer.java
public byte [] getBase64(boolean required) throws IOException { String s = remainingStrings(); if (s == null) { if (required) throw exception("expected base64 encoded string"); else return null; } byte [] array = base64.fromString(s); if (array == null) throw exception("invalid base64 encoding"); return array; }
// in org/xbill/DNS/Tokenizer.java
public byte [] getBase64() throws IOException { return getBase64(false); }
// in org/xbill/DNS/Tokenizer.java
public byte [] getHex(boolean required) throws IOException { String s = remainingStrings(); if (s == null) { if (required) throw exception("expected hex encoded string"); else return null; } byte [] array = base16.fromString(s); if (array == null) throw exception("invalid hex encoding"); return array; }
// in org/xbill/DNS/Tokenizer.java
public byte [] getHex() throws IOException { return getHex(false); }
// in org/xbill/DNS/Tokenizer.java
public byte [] getHexString() throws IOException { String next = _getIdentifier("a hex string"); byte [] array = base16.fromString(next); if (array == null) throw exception("invalid hex encoding"); return array; }
// in org/xbill/DNS/Tokenizer.java
public byte [] getBase32String(base32 b32) throws IOException { String next = _getIdentifier("a base32 string"); byte [] array = b32.fromString(next); if (array == null) throw exception("invalid base32 encoding"); return array; }
// in org/xbill/DNS/A6Record.java
void rrFromWire(DNSInput in) throws IOException { prefixBits = in.readU8(); int suffixbits = 128 - prefixBits; int suffixbytes = (suffixbits + 7) / 8; if (prefixBits < 128) { byte [] bytes = new byte[16]; in.readByteArray(bytes, 16 - suffixbytes, suffixbytes); suffix = InetAddress.getByAddress(bytes); } if (prefixBits > 0) prefix = new Name(in); }
// in org/xbill/DNS/A6Record.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { prefixBits = st.getUInt8(); if (prefixBits > 128) { throw st.exception("prefix bits must be [0..128]"); } else if (prefixBits < 128) { String s = st.getString(); try { suffix = Address.getByAddress(s, Address.IPv6); } catch (UnknownHostException e) { throw st.exception("invalid IPv6 address: " + s); } } if (prefixBits > 0) prefix = st.getName(origin); }
// in org/xbill/DNS/DNSSEC.java
private static BigInteger readBigInteger(DNSInput in, int len) throws IOException { byte [] b = in.readByteArray(len); return new BigInteger(1, b); }
// in org/xbill/DNS/DNSSEC.java
private static PublicKey toRSAPublicKey(KEYBase r) throws IOException, GeneralSecurityException { DNSInput in = new DNSInput(r.getKey()); int exponentLength = in.readU8(); if (exponentLength == 0) exponentLength = in.readU16(); BigInteger exponent = readBigInteger(in, exponentLength); BigInteger modulus = readBigInteger(in); KeyFactory factory = KeyFactory.getInstance("RSA"); return factory.generatePublic(new RSAPublicKeySpec(modulus, exponent)); }
// in org/xbill/DNS/DNSSEC.java
private static PublicKey toDSAPublicKey(KEYBase r) throws IOException, GeneralSecurityException, MalformedKeyException { DNSInput in = new DNSInput(r.getKey()); int t = in.readU8(); if (t > 8) throw new MalformedKeyException(r); BigInteger q = readBigInteger(in, 20); BigInteger p = readBigInteger(in, 64 + t*8); BigInteger g = readBigInteger(in, 64 + t*8); BigInteger y = readBigInteger(in, 64 + t*8); KeyFactory factory = KeyFactory.getInstance("DSA"); return factory.generatePublic(new DSAPublicKeySpec(y, p, q, g)); }
// in org/xbill/DNS/DNSSEC.java
private static byte [] DSASignaturefromDNS(byte [] dns) throws DNSSECException, IOException { if (dns.length != 1 + DSA_LEN * 2) throw new SignatureVerificationException(); DNSInput in = new DNSInput(dns); DNSOutput out = new DNSOutput(); int t = in.readU8(); byte [] r = in.readByteArray(DSA_LEN); int rlen = DSA_LEN; if (r[0] < 0) rlen++; byte [] s = in.readByteArray(DSA_LEN); int slen = DSA_LEN; if (s[0] < 0) slen++; out.writeU8(ASN1_SEQ); out.writeU8(rlen + slen + 4); out.writeU8(ASN1_INT); out.writeU8(rlen); if (rlen > DSA_LEN) out.writeU8(0); out.writeByteArray(r); out.writeU8(ASN1_INT); out.writeU8(slen); if (slen > DSA_LEN) out.writeU8(0); out.writeByteArray(s); return out.toByteArray(); }
// in org/xbill/DNS/DNSSEC.java
private static byte [] DSASignaturetoDNS(byte [] key, int t) throws IOException { DNSInput in = new DNSInput(key); DNSOutput out = new DNSOutput(); out.writeU8(t); int tmp = in.readU8(); if (tmp != ASN1_SEQ) throw new IOException(); int seqlen = in.readU8(); tmp = in.readU8(); if (tmp != ASN1_INT) throw new IOException(); int rlen = in.readU8(); if (rlen == DSA_LEN + 1) { if (in.readU8() != 0) throw new IOException(); } else if (rlen != DSA_LEN) throw new IOException(); byte [] bytes = in.readByteArray(DSA_LEN); out.writeByteArray(bytes); tmp = in.readU8(); if (tmp != ASN1_INT) throw new IOException(); int slen = in.readU8(); if (slen == DSA_LEN + 1) { if (in.readU8() != 0) throw new IOException(); } else if (slen != DSA_LEN) throw new IOException(); bytes = in.readByteArray(DSA_LEN); out.writeByteArray(bytes); return out.toByteArray(); }
// in org/xbill/DNS/RPRecord.java
void rrFromWire(DNSInput in) throws IOException { mailbox = new Name(in); textDomain = new Name(in); }
// in org/xbill/DNS/RPRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { mailbox = st.getName(origin); textDomain = st.getName(origin); }
// in org/xbill/DNS/DHCIDRecord.java
void rrFromWire(DNSInput in) throws IOException { data = in.readByteArray(); }
// in org/xbill/DNS/DHCIDRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { data = st.getBase64(); }
// in org/xbill/DNS/NULLRecord.java
void rrFromWire(DNSInput in) throws IOException { data = in.readByteArray(); }
// in org/xbill/DNS/NULLRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { throw st.exception("no defined text format for NULL records"); }
// in org/xbill/DNS/DNSKEYRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { flags = st.getUInt16(); proto = st.getUInt8(); String algString = st.getString(); alg = DNSSEC.Algorithm.value(algString); if (alg < 0) throw st.exception("Invalid algorithm: " + algString); key = st.getBase64(); }
// in org/xbill/DNS/CERTRecord.java
void rrFromWire(DNSInput in) throws IOException { certType = in.readU16(); keyTag = in.readU16(); alg = in.readU8(); cert = in.readByteArray(); }
// in org/xbill/DNS/CERTRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { String certTypeString = st.getString(); certType = CertificateType.value(certTypeString); if (certType < 0) throw st.exception("Invalid certificate type: " + certTypeString); keyTag = st.getUInt16(); String algString = st.getString(); alg = DNSSEC.Algorithm.value(algString); if (alg < 0) throw st.exception("Invalid algorithm: " + algString); cert = st.getBase64(); }
// in org/xbill/DNS/Generator.java
private String substitute(String spec, long n) throws IOException { boolean escaped = false; byte [] str = spec.getBytes(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < str.length; i++) { char c = (char)(str[i] & 0xFF); if (escaped) { sb.append(c); escaped = false; } else if (c == '\\') { if (i + 1 == str.length) throw new TextParseException ("invalid escape character"); escaped = true; } else if (c == '$') { boolean negative = false; long offset = 0; long width = 0; long base = 10; boolean wantUpperCase = false; if (i + 1 < str.length && str[i + 1] == '$') { // '$$' == literal '$' for backwards // compatibility with old versions of BIND. c = (char)(str[++i] & 0xFF); sb.append(c); continue; } else if (i + 1 < str.length && str[i + 1] == '{') { // It's a substitution with modifiers. i++; if (i + 1 < str.length && str[i + 1] == '-') { negative = true; i++; } while (i + 1 < str.length) { c = (char)(str[++i] & 0xFF); if (c == ',' || c == '}') break; if (c < '0' || c > '9') throw new TextParseException( "invalid offset"); c -= '0'; offset *= 10; offset += c; } if (negative) offset = -offset; if (c == ',') { while (i + 1 < str.length) { c = (char)(str[++i] & 0xFF); if (c == ',' || c == '}') break; if (c < '0' || c > '9') throw new TextParseException( "invalid width"); c -= '0'; width *= 10; width += c; } } if (c == ',') { if (i + 1 == str.length) throw new TextParseException( "invalid base"); c = (char)(str[++i] & 0xFF); if (c == 'o') base = 8; else if (c == 'x') base = 16; else if (c == 'X') { base = 16; wantUpperCase = true; } else if (c != 'd') throw new TextParseException( "invalid base"); } if (i + 1 == str.length || str[i + 1] != '}') throw new TextParseException ("invalid modifiers"); i++; } long v = n + offset; if (v < 0) throw new TextParseException ("invalid offset expansion"); String number; if (base == 8) number = Long.toOctalString(v); else if (base == 16) number = Long.toHexString(v); else number = Long.toString(v); if (wantUpperCase) number = number.toUpperCase(); if (width != 0 && width > number.length()) { int zeros = (int)width - number.length(); while (zeros-- > 0) sb.append('0'); } sb.append(number); } else { sb.append(c); } } return sb.toString(); }
// in org/xbill/DNS/Generator.java
public Record nextRecord() throws IOException { if (current > end) return null; String namestr = substitute(namePattern, current); Name name = Name.fromString(namestr, origin); String rdata = substitute(rdataPattern, current); current += step; return Record.fromString(name, type, dclass, ttl, rdata, origin); }
// in org/xbill/DNS/Generator.java
public Record [] expand() throws IOException { List list = new ArrayList(); for (long i = start; i < end; i += step) { String namestr = substitute(namePattern, current); Name name = Name.fromString(namestr, origin); String rdata = substitute(rdataPattern, current); list.add(Record.fromString(name, type, dclass, ttl, rdata, origin)); } return (Record []) list.toArray(new Record[list.size()]); }
// in org/xbill/DNS/TKEYRecord.java
void rrFromWire(DNSInput in) throws IOException { alg = new Name(in); timeInception = new Date(1000 * in.readU32()); timeExpire = new Date(1000 * in.readU32()); mode = in.readU16(); error = in.readU16(); int keylen = in.readU16(); if (keylen > 0) key = in.readByteArray(keylen); else key = null; int otherlen = in.readU16(); if (otherlen > 0) other = in.readByteArray(otherlen); else other = null; }
// in org/xbill/DNS/TKEYRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { throw st.exception("no text format defined for TKEY"); }
// in org/xbill/DNS/EmptyRecord.java
void rrFromWire(DNSInput in) throws IOException { }
// in org/xbill/DNS/EmptyRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { }
// in org/xbill/DNS/PXRecord.java
void rrFromWire(DNSInput in) throws IOException { preference = in.readU16(); map822 = new Name(in); mapX400 = new Name(in); }
// in org/xbill/DNS/PXRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { preference = st.getUInt16(); map822 = st.getName(origin); mapX400 = st.getName(origin); }
// in org/xbill/DNS/IPSECKEYRecord.java
void rrFromWire(DNSInput in) throws IOException { precedence = in.readU8(); gatewayType = in.readU8(); algorithmType = in.readU8(); switch (gatewayType) { case Gateway.None: gateway = null; break; case Gateway.IPv4: gateway = InetAddress.getByAddress(in.readByteArray(4)); break; case Gateway.IPv6: gateway = InetAddress.getByAddress(in.readByteArray(16)); break; case Gateway.Name: gateway = new Name(in); break; default: throw new WireParseException("invalid gateway type"); } if (in.remaining() > 0) key = in.readByteArray(); }
// in org/xbill/DNS/IPSECKEYRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { precedence = st.getUInt8(); gatewayType = st.getUInt8(); algorithmType = st.getUInt8(); switch (gatewayType) { case Gateway.None: String s = st.getString(); if (!s.equals(".")) throw new TextParseException("invalid gateway format"); gateway = null; break; case Gateway.IPv4: gateway = st.getAddress(Address.IPv4); break; case Gateway.IPv6: gateway = st.getAddress(Address.IPv6); break; case Gateway.Name: gateway = st.getName(origin); break; default: throw new WireParseException("invalid gateway type"); } key = st.getBase64(false); }
// in org/xbill/DNS/SRVRecord.java
void rrFromWire(DNSInput in) throws IOException { priority = in.readU16(); weight = in.readU16(); port = in.readU16(); target = new Name(in); }
// in org/xbill/DNS/SRVRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { priority = st.getUInt16(); weight = st.getUInt16(); port = st.getUInt16(); target = st.getName(origin); }
// in org/xbill/DNS/Zone.java
private void validate() throws IOException { originNode = exactName(origin); if (originNode == null) throw new IOException(origin + ": no data specified"); RRset rrset = oneRRset(originNode, Type.SOA); if (rrset == null || rrset.size() != 1) throw new IOException(origin + ": exactly 1 SOA must be specified"); Iterator it = rrset.rrs(); SOA = (SOARecord) it.next(); NS = oneRRset(originNode, Type.NS); if (NS == null) throw new IOException(origin + ": no NS set specified"); }
// in org/xbill/DNS/Zone.java
private final void maybeAddRecord(Record record) throws IOException { int rtype = record.getType(); Name name = record.getName(); if (rtype == Type.SOA && !name.equals(origin)) { throw new IOException("SOA owner " + name + " does not match zone origin " + origin); } if (name.subdomain(origin)) addRecord(record); }
// in org/xbill/DNS/Zone.java
private void fromXFR(ZoneTransferIn xfrin) throws IOException, ZoneTransferException { data = new TreeMap(); origin = xfrin.getName(); List records = xfrin.run(); for (Iterator it = records.iterator(); it.hasNext(); ) { Record record = (Record) it.next(); maybeAddRecord(record); } if (!xfrin.isAXFR()) throw new IllegalArgumentException("zones can only be " + "created from AXFRs"); validate(); }
// in org/xbill/DNS/GPOSRecord.java
void rrFromWire(DNSInput in) throws IOException { longitude = in.readCountedString(); latitude = in.readCountedString(); altitude = in.readCountedString(); try { validate(getLongitude(), getLatitude()); } catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); } }
// in org/xbill/DNS/GPOSRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { try { longitude = byteArrayFromString(st.getString()); latitude = byteArrayFromString(st.getString()); altitude = byteArrayFromString(st.getString()); } catch (TextParseException e) { throw st.exception(e.getMessage()); } try { validate(getLongitude(), getLatitude()); } catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); } }
// in org/xbill/DNS/KEYRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { String flagString = st.getIdentifier(); flags = Flags.value(flagString); if (flags < 0) throw st.exception("Invalid flags: " + flagString); String protoString = st.getIdentifier(); proto = Protocol.value(protoString); if (proto < 0) throw st.exception("Invalid protocol: " + protoString); String algString = st.getIdentifier(); alg = DNSSEC.Algorithm.value(algString); if (alg < 0) throw st.exception("Invalid algorithm: " + algString); /* If this is a null KEY, there's no key data */ if ((flags & Flags.USE_MASK) == Flags.NOKEY) key = null; else key = st.getBase64(); }
// in org/xbill/DNS/LOCRecord.java
void rrFromWire(DNSInput in) throws IOException { int version; version = in.readU8(); if (version != 0) throw new WireParseException("Invalid LOC version"); size = parseLOCformat(in.readU8()); hPrecision = parseLOCformat(in.readU8()); vPrecision = parseLOCformat(in.readU8()); latitude = in.readU32(); longitude = in.readU32(); altitude = in.readU32(); }
// in org/xbill/DNS/LOCRecord.java
private long parsePosition(Tokenizer st, String type) throws IOException { boolean isLatitude = type.equals("latitude"); int deg = 0, min = 0; double sec = 0; long value; String s; deg = st.getUInt16(); if (deg > 180 || (deg > 90 && isLatitude)) throw st.exception("Invalid LOC " + type + " degrees"); s = st.getString(); try { min = Integer.parseInt(s); if (min < 0 || min > 59) throw st.exception("Invalid LOC " + type + " minutes"); s = st.getString(); sec = parseFixedPoint(s); if (sec < 0 || sec >= 60) throw st.exception("Invalid LOC " + type + " seconds"); s = st.getString(); } catch (NumberFormatException e) { } if (s.length() != 1) throw st.exception("Invalid LOC " + type); value = (long) (1000 * (sec + 60L * (min + 60L * deg))); char c = Character.toUpperCase(s.charAt(0)); if ((isLatitude && c == 'S') || (!isLatitude && c == 'W')) value = -value; else if ((isLatitude && c != 'N') || (!isLatitude && c != 'E')) throw st.exception("Invalid LOC " + type); value += (1L << 31); return value; }
// in org/xbill/DNS/LOCRecord.java
private long parseDouble(Tokenizer st, String type, boolean required, long min, long max, long defaultValue) throws IOException { Tokenizer.Token token = st.get(); if (token.isEOL()) { if (required) throw st.exception("Invalid LOC " + type); st.unget(); return defaultValue; } String s = token.value; if (s.length() > 1 && s.charAt(s.length() - 1) == 'm') s = s.substring(0, s.length() - 1); try { long value = (long)(100 * parseFixedPoint(s)); if (value < min || value > max) throw st.exception("Invalid LOC " + type); return value; } catch (NumberFormatException e) { throw st.exception("Invalid LOC " + type); } }
// in org/xbill/DNS/LOCRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { latitude = parsePosition(st, "latitude"); longitude = parsePosition(st, "longitude"); altitude = parseDouble(st, "altitude", true, -10000000, 4284967295L, 0) + 10000000; size = parseDouble(st, "size", false, 0, 9000000000L, 100); hPrecision = parseDouble(st, "horizontal precision", false, 0, 9000000000L, 1000000); vPrecision = parseDouble(st, "vertical precision", false, 0, 9000000000L, 1000); }
// in org/xbill/DNS/SOARecord.java
void rrFromWire(DNSInput in) throws IOException { host = new Name(in); admin = new Name(in); serial = in.readU32(); refresh = in.readU32(); retry = in.readU32(); expire = in.readU32(); minimum = in.readU32(); }
// in org/xbill/DNS/SOARecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { host = st.getName(origin); admin = st.getName(origin); serial = st.getUInt32(); refresh = st.getTTLLike(); retry = st.getTTLLike(); expire = st.getTTLLike(); minimum = st.getTTLLike(); }
// in org/xbill/DNS/X25Record.java
void rrFromWire(DNSInput in) throws IOException { address = in.readCountedString(); }
// in org/xbill/DNS/X25Record.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { String addr = st.getString(); this.address = checkAndConvertAddress(addr); if (this.address == null) throw st.exception("invalid PSDN address " + addr); }
// in org/xbill/DNS/EDNSOption.java
static EDNSOption fromWire(DNSInput in) throws IOException { int code, length; code = in.readU16(); length = in.readU16(); if (in.remaining() < length) throw new WireParseException("truncated option"); int save = in.saveActive(); in.setActive(length); EDNSOption option; switch (code) { case Code.NSID: option = new NSIDOption(); break; case Code.CLIENT_SUBNET: option = new ClientSubnetOption(); break; default: option = new GenericEDNSOption(code); break; } option.optionFromWire(in); in.restoreActive(save); return option; }
// in org/xbill/DNS/EDNSOption.java
public static EDNSOption fromWire(byte [] b) throws IOException { return fromWire(new DNSInput(b)); }
// in org/xbill/DNS/EDNSOption.java
public byte [] toWire() throws IOException { DNSOutput out = new DNSOutput(); toWire(out); return out.toByteArray(); }
// in org/xbill/DNS/UNKRecord.java
void rrFromWire(DNSInput in) throws IOException { data = in.readByteArray(); }
// in org/xbill/DNS/UNKRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { throw st.exception("invalid unknown RR encoding"); }
// in org/xbill/DNS/U16NameBase.java
void rrFromWire(DNSInput in) throws IOException { u16Field = in.readU16(); nameField = new Name(in); }
// in org/xbill/DNS/U16NameBase.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { u16Field = st.getUInt16(); nameField = st.getName(origin); }
// in org/xbill/DNS/ZoneTransferIn.java
private void openConnection() throws IOException { long endTime = System.currentTimeMillis() + timeout; client = new TCPClient(endTime); if (localAddress != null) client.bind(localAddress); client.connect(address); }
// in org/xbill/DNS/ZoneTransferIn.java
private void sendQuery() throws IOException { Record question = Record.newRecord(zname, qtype, dclass); Message query = new Message(); query.getHeader().setOpcode(Opcode.QUERY); query.addRecord(question, Section.QUESTION); if (qtype == Type.IXFR) { Record soa = new SOARecord(zname, dclass, 0, Name.root, Name.root, ixfr_serial, 0, 0, 0, 0); query.addRecord(soa, Section.AUTHORITY); } if (tsig != null) { tsig.apply(query, null); verifier = new TSIG.StreamVerifier(tsig, query.getTSIG()); } byte [] out = query.toWire(Message.MAXLENGTH); client.send(out); }
// in org/xbill/DNS/ZoneTransferIn.java
private void doxfr() throws IOException, ZoneTransferException { sendQuery(); while (state != END) { byte [] in = client.recv(); Message response = parseMessage(in); if (response.getHeader().getRcode() == Rcode.NOERROR && verifier != null) { TSIGRecord tsigrec = response.getTSIG(); int error = verifier.verify(response, in); if (error != Rcode.NOERROR) fail("TSIG failure"); } Record [] answers = response.getSectionArray(Section.ANSWER); if (state == INITIALSOA) { int rcode = response.getRcode(); if (rcode != Rcode.NOERROR) { if (qtype == Type.IXFR && rcode == Rcode.NOTIMP) { fallback(); doxfr(); return; } fail(Rcode.string(rcode)); } Record question = response.getQuestion(); if (question != null && question.getType() != qtype) { fail("invalid question section"); } if (answers.length == 0 && qtype == Type.IXFR) { fallback(); doxfr(); return; } } for (int i = 0; i < answers.length; i++) { parseRR(answers[i]); } if (state == END && verifier != null && !response.isVerified()) fail("last message must be signed"); } }
// in org/xbill/DNS/ZoneTransferIn.java
public void run(ZoneTransferHandler handler) throws IOException, ZoneTransferException { this.handler = handler; try { openConnection(); doxfr(); } finally { closeConnection(); } }
// in org/xbill/DNS/ZoneTransferIn.java
public List run() throws IOException, ZoneTransferException { BasicHandler handler = new BasicHandler(); run(handler); if (handler.axfr != null) return handler.axfr; return handler.ixfr; }
// in org/xbill/DNS/TCPClient.java
void bind(SocketAddress addr) throws IOException { SocketChannel channel = (SocketChannel) key.channel(); channel.socket().bind(addr); }
// in org/xbill/DNS/TCPClient.java
void connect(SocketAddress addr) throws IOException { SocketChannel channel = (SocketChannel) key.channel(); if (channel.connect(addr)) return; key.interestOps(SelectionKey.OP_CONNECT); try { while (!channel.finishConnect()) { if (!key.isConnectable()) blockUntil(key, endTime); } } finally { if (key.isValid()) key.interestOps(0); } }
// in org/xbill/DNS/TCPClient.java
void send(byte [] data) throws IOException { SocketChannel channel = (SocketChannel) key.channel(); verboseLog("TCP write", data); byte [] lengthArray = new byte[2]; lengthArray[0] = (byte)(data.length >>> 8); lengthArray[1] = (byte)(data.length & 0xFF); ByteBuffer [] buffers = new ByteBuffer[2]; buffers[0] = ByteBuffer.wrap(lengthArray); buffers[1] = ByteBuffer.wrap(data); int nsent = 0; key.interestOps(SelectionKey.OP_WRITE); try { while (nsent < data.length + 2) { if (key.isWritable()) { long n = channel.write(buffers); if (n < 0) throw new EOFException(); nsent += (int) n; if (nsent < data.length + 2 && System.currentTimeMillis() > endTime) throw new SocketTimeoutException(); } else blockUntil(key, endTime); } } finally { if (key.isValid()) key.interestOps(0); } }
// in org/xbill/DNS/TCPClient.java
private byte [] _recv(int length) throws IOException { SocketChannel channel = (SocketChannel) key.channel(); int nrecvd = 0; byte [] data = new byte[length]; ByteBuffer buffer = ByteBuffer.wrap(data); key.interestOps(SelectionKey.OP_READ); try { while (nrecvd < length) { if (key.isReadable()) { long n = channel.read(buffer); if (n < 0) throw new EOFException(); nrecvd += (int) n; if (nrecvd < length && System.currentTimeMillis() > endTime) throw new SocketTimeoutException(); } else blockUntil(key, endTime); } } finally { if (key.isValid()) key.interestOps(0); } return data; }
// in org/xbill/DNS/TCPClient.java
byte [] recv() throws IOException { byte [] buf = _recv(2); int length = ((buf[0] & 0xFF) << 8) + (buf[1] & 0xFF); byte [] data = _recv(length); verboseLog("TCP read", data); return data; }
// in org/xbill/DNS/TCPClient.java
static byte [] sendrecv(SocketAddress local, SocketAddress remote, byte [] data, long endTime) throws IOException { TCPClient client = new TCPClient(endTime); try { if (local != null) client.bind(local); client.connect(remote); client.send(data); return client.recv(); } finally { client.cleanup(); } }
// in org/xbill/DNS/TCPClient.java
static byte [] sendrecv(SocketAddress addr, byte [] data, long endTime) throws IOException { return sendrecv(null, addr, data, endTime); }
// in org/xbill/DNS/OPTRecord.java
void rrFromWire(DNSInput in) throws IOException { if (in.remaining() > 0) options = new ArrayList(); while (in.remaining() > 0) { EDNSOption option = EDNSOption.fromWire(in); options.add(option); } }
// in org/xbill/DNS/OPTRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { throw st.exception("no text format defined for OPT"); }
// in org/xbill/DNS/UDPClient.java
private void bind_random(InetSocketAddress addr) throws IOException { if (prng_initializing) { try { Thread.sleep(2); } catch (InterruptedException e) { } if (prng_initializing) return; } DatagramChannel channel = (DatagramChannel) key.channel(); InetSocketAddress temp; for (int i = 0; i < 1024; i++) { try { int port = prng.nextInt(EPHEMERAL_RANGE) + EPHEMERAL_START; if (addr != null) temp = new InetSocketAddress(addr.getAddress(), port); else temp = new InetSocketAddress(port); channel.socket().bind(temp); bound = true; return; } catch (SocketException e) { } } }
// in org/xbill/DNS/UDPClient.java
void bind(SocketAddress addr) throws IOException { if (addr == null || (addr instanceof InetSocketAddress && ((InetSocketAddress)addr).getPort() == 0)) { bind_random((InetSocketAddress) addr); if (bound) return; } if (addr != null) { DatagramChannel channel = (DatagramChannel) key.channel(); channel.socket().bind(addr); bound = true; } }
// in org/xbill/DNS/UDPClient.java
void connect(SocketAddress addr) throws IOException { if (!bound) bind(null); DatagramChannel channel = (DatagramChannel) key.channel(); channel.connect(addr); }
// in org/xbill/DNS/UDPClient.java
void send(byte [] data) throws IOException { DatagramChannel channel = (DatagramChannel) key.channel(); verboseLog("UDP write", data); channel.write(ByteBuffer.wrap(data)); }
// in org/xbill/DNS/UDPClient.java
byte [] recv(int max) throws IOException { DatagramChannel channel = (DatagramChannel) key.channel(); byte [] temp = new byte[max]; key.interestOps(SelectionKey.OP_READ); try { while (!key.isReadable()) blockUntil(key, endTime); } finally { if (key.isValid()) key.interestOps(0); } long ret = channel.read(ByteBuffer.wrap(temp)); if (ret <= 0) throw new EOFException(); int len = (int) ret; byte [] data = new byte[len]; System.arraycopy(temp, 0, data, 0, len); verboseLog("UDP read", data); return data; }
// in org/xbill/DNS/UDPClient.java
static byte [] sendrecv(SocketAddress local, SocketAddress remote, byte [] data, int max, long endTime) throws IOException { UDPClient client = new UDPClient(endTime); try { client.bind(local); client.connect(remote); client.send(data); return client.recv(max); } finally { client.cleanup(); } }
// in org/xbill/DNS/UDPClient.java
static byte [] sendrecv(SocketAddress addr, byte [] data, int max, long endTime) throws IOException { return sendrecv(null, addr, data, max, endTime); }
// in org/xbill/DNS/Update.java
public void present(Name name, int type, String record) throws IOException { newPrereq(Record.fromString(name, type, dclass, 0, record, origin)); }
// in org/xbill/DNS/Update.java
public void present(Name name, int type, Tokenizer tokenizer) throws IOException { newPrereq(Record.fromString(name, type, dclass, 0, tokenizer, origin)); }
// in org/xbill/DNS/Update.java
public void add(Name name, int type, long ttl, String record) throws IOException { newUpdate(Record.fromString(name, type, dclass, ttl, record, origin)); }
// in org/xbill/DNS/Update.java
public void add(Name name, int type, long ttl, Tokenizer tokenizer) throws IOException { newUpdate(Record.fromString(name, type, dclass, ttl, tokenizer, origin)); }
// in org/xbill/DNS/Update.java
public void delete(Name name, int type, String record) throws IOException { newUpdate(Record.fromString(name, type, DClass.NONE, 0, record, origin)); }
// in org/xbill/DNS/Update.java
public void delete(Name name, int type, Tokenizer tokenizer) throws IOException { newUpdate(Record.fromString(name, type, DClass.NONE, 0, tokenizer, origin)); }
// in org/xbill/DNS/Update.java
public void replace(Name name, int type, long ttl, String record) throws IOException { delete(name, type); add(name, type, ttl, record); }
// in org/xbill/DNS/Update.java
public void replace(Name name, int type, long ttl, Tokenizer tokenizer) throws IOException { delete(name, type); add(name, type, ttl, tokenizer); }
// in org/xbill/DNS/DSRecord.java
void rrFromWire(DNSInput in) throws IOException { footprint = in.readU16(); alg = in.readU8(); digestid = in.readU8(); digest = in.readByteArray(); }
// in org/xbill/DNS/DSRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { footprint = st.getUInt16(); alg = st.getUInt8(); digestid = st.getUInt8(); digest = st.getHex(); }
// in org/xbill/DNS/MINFORecord.java
void rrFromWire(DNSInput in) throws IOException { responsibleAddress = new Name(in); errorAddress = new Name(in); }
// in org/xbill/DNS/MINFORecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { responsibleAddress = st.getName(origin); errorAddress = st.getName(origin); }
// in org/xbill/DNS/NSAPRecord.java
void rrFromWire(DNSInput in) throws IOException { address = in.readByteArray(); }
// in org/xbill/DNS/NSAPRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { String addr = st.getString(); this.address = checkAndConvertAddress(addr); if (this.address == null) throw st.exception("invalid NSAP address " + addr); }
// in org/xbill/DNS/WKSRecord.java
void rrFromWire(DNSInput in) throws IOException { address = in.readByteArray(4); protocol = in.readU8(); byte [] array = in.readByteArray(); List list = new ArrayList(); for (int i = 0; i < array.length; i++) { for (int j = 0; j < 8; j++) { int octet = array[i] & 0xFF; if ((octet & (1 << (7 - j))) != 0) { list.add(new Integer(i * 8 + j)); } } } services = new int[list.size()]; for (int i = 0; i < list.size(); i++) { services[i] = ((Integer) list.get(i)).intValue(); } }
// in org/xbill/DNS/WKSRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { String s = st.getString(); address = Address.toByteArray(s, Address.IPv4); if (address == null) throw st.exception("invalid address"); s = st.getString(); protocol = Protocol.value(s); if (protocol < 0) { throw st.exception("Invalid IP protocol: " + s); } List list = new ArrayList(); while (true) { Tokenizer.Token t = st.get(); if (!t.isString()) break; int service = Service.value(t.value); if (service < 0) { throw st.exception("Invalid TCP/UDP service: " + t.value); } list.add(new Integer(service)); } st.unget(); services = new int[list.size()]; for (int i = 0; i < list.size(); i++) { services[i] = ((Integer) list.get(i)).intValue(); } }
// in org/xbill/DNS/SIGBase.java
void rrFromWire(DNSInput in) throws IOException { covered = in.readU16(); alg = in.readU8(); labels = in.readU8(); origttl = in.readU32(); expire = new Date(1000 * in.readU32()); timeSigned = new Date(1000 * in.readU32()); footprint = in.readU16(); signer = new Name(in); signature = in.readByteArray(); }
// in org/xbill/DNS/SIGBase.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { String typeString = st.getString(); covered = Type.value(typeString); if (covered < 0) throw st.exception("Invalid type: " + typeString); String algString = st.getString(); alg = DNSSEC.Algorithm.value(algString); if (alg < 0) throw st.exception("Invalid algorithm: " + algString); labels = st.getUInt8(); origttl = st.getTTL(); expire = FormattedTime.parse(st.getString()); timeSigned = FormattedTime.parse(st.getString()); footprint = st.getUInt16(); signer = st.getName(origin); signature = st.getBase64(); }
// in org/xbill/DNS/NSECRecord.java
void rrFromWire(DNSInput in) throws IOException { next = new Name(in); types = new TypeBitmap(in); }
// in org/xbill/DNS/NSECRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { next = st.getName(origin); types = new TypeBitmap(st); }
// in org/xbill/DNS/NSEC3Record.java
void rrFromWire(DNSInput in) throws IOException { hashAlg = in.readU8(); flags = in.readU8(); iterations = in.readU16(); int salt_length = in.readU8(); if (salt_length > 0) salt = in.readByteArray(salt_length); else salt = null; int next_length = in.readU8(); next = in.readByteArray(next_length); types = new TypeBitmap(in); }
// in org/xbill/DNS/NSEC3Record.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { hashAlg = st.getUInt8(); flags = st.getUInt8(); iterations = st.getUInt16(); String s = st.getString(); if (s.equals("-")) salt = null; else { st.unget(); salt = st.getHexString(); if (salt.length > 255) throw st.exception("salt value too long"); } next = st.getBase32String(b32); types = new TypeBitmap(st); }
// in org/xbill/DNS/NAPTRRecord.java
void rrFromWire(DNSInput in) throws IOException { order = in.readU16(); preference = in.readU16(); flags = in.readCountedString(); service = in.readCountedString(); regexp = in.readCountedString(); replacement = new Name(in); }
// in org/xbill/DNS/NAPTRRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { order = st.getUInt16(); preference = st.getUInt16(); try { flags = byteArrayFromString(st.getString()); service = byteArrayFromString(st.getString()); regexp = byteArrayFromString(st.getString()); } catch (TextParseException e) { throw st.exception(e.getMessage()); } replacement = st.getName(origin); }
15
            
// in org/xbill/DNS/Record.java
catch (IOException e) { return null; }
// in org/xbill/DNS/SimpleResolver.java
catch (IOException e) { if (Options.check("verbose")) e.printStackTrace(); if (!(e instanceof WireParseException)) e = new WireParseException("Error parsing message"); throw (WireParseException) e; }
// in org/xbill/DNS/utils/base64.java
catch (IOException e) { }
// in org/xbill/DNS/utils/base32.java
catch (IOException e) { }
// in org/xbill/DNS/utils/base16.java
catch (IOException e) { }
// in org/xbill/DNS/Tokenizer.java
catch (IOException e) { }
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new MalformedKeyException(r); }
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new IllegalStateException(); }
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new IllegalStateException(); }
// in org/xbill/DNS/ResolverConfig.java
catch (IOException e) { }
// in org/xbill/DNS/ResolverConfig.java
catch (IOException e) { }
// in org/xbill/DNS/ResolverConfig.java
catch (IOException e) { return; }
// in org/xbill/DNS/ZoneTransferIn.java
catch (IOException e) { }
// in org/xbill/DNS/ZoneTransferIn.java
catch (IOException e) { if (e instanceof WireParseException) throw (WireParseException) e; throw new WireParseException("Error parsing message"); }
// in org/xbill/DNS/Lookup.java
catch (IOException e) { // A network error occurred. Press on. if (e instanceof InterruptedIOException) timedout = true; else networkerror = true; return; }
6
            
// in org/xbill/DNS/SimpleResolver.java
catch (IOException e) { if (Options.check("verbose")) e.printStackTrace(); if (!(e instanceof WireParseException)) e = new WireParseException("Error parsing message"); throw (WireParseException) e; }
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new MalformedKeyException(r); }
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new IllegalStateException(); }
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new IllegalStateException(); }
// in org/xbill/DNS/ZoneTransferIn.java
catch (IOException e) { if (e instanceof WireParseException) throw (WireParseException) e; throw new WireParseException("Error parsing message"); }
2
runtime (Lib) IllegalArgumentException 88
            
// in org/xbill/DNS/Mnemonic.java
public void check(int val) { if (val < 0 || val > max) { throw new IllegalArgumentException(description + " " + val + "is out of range"); } }
// in org/xbill/DNS/Mnemonic.java
public void addAll(Mnemonic source) { if (wordcase != source.wordcase) throw new IllegalArgumentException(source.description + ": wordcases do not match"); strings.putAll(source.strings); values.putAll(source.values); }
// in org/xbill/DNS/Record.java
static int checkU8(String field, int val) { if (val < 0 || val > 0xFF) throw new IllegalArgumentException("\"" + field + "\" " + val + " must be an unsigned 8 " + "bit value"); return val; }
// in org/xbill/DNS/Record.java
static int checkU16(String field, int val) { if (val < 0 || val > 0xFFFF) throw new IllegalArgumentException("\"" + field + "\" " + val + " must be an unsigned 16 " + "bit value"); return val; }
// in org/xbill/DNS/Record.java
static long checkU32(String field, long val) { if (val < 0 || val > 0xFFFFFFFFL) throw new IllegalArgumentException("\"" + field + "\" " + val + " must be an unsigned 32 " + "bit value"); return val; }
// in org/xbill/DNS/Record.java
static byte [] checkByteArrayLength(String field, byte [] array, int maxLength) { if (array.length > 0xFFFF) throw new IllegalArgumentException("\"" + field + "\" array " + "must have no more than " + maxLength + " elements"); byte [] out = new byte[array.length]; System.arraycopy(array, 0, out, 0, array.length); return out; }
// in org/xbill/DNS/SimpleResolver.java
public void setEDNS(int level, int payloadSize, int flags, List options) { if (level != 0 && level != -1) throw new IllegalArgumentException("invalid EDNS level - " + "must be 0 or -1"); if (payloadSize == 0) payloadSize = DEFAULT_EDNS_PAYLOADSIZE; queryOPT = new OPTRecord(payloadSize, 0, level, flags, options); }
// in org/xbill/DNS/Name.java
private final int offset(int n) { if (n == 0 && getlabels() == 0) return 0; if (n < 0 || n >= getlabels()) throw new IllegalArgumentException("label out of range"); if (n < MAXOFFSETS) { int shift = 8 * (7 - n); return ((int)(offsets >>> shift) & 0xFF); } else { int pos = offset(MAXOFFSETS - 1); for (int i = MAXOFFSETS - 1; i < n; i++) pos += (name[pos] + 1); return (pos); } }
// in org/xbill/DNS/Name.java
public static Name fromConstantString(String s) { try { return fromString(s, null); } catch (TextParseException e) { throw new IllegalArgumentException("Invalid name '" + s + "'"); } }
// in org/xbill/DNS/Name.java
public Name wild(int n) { if (n < 1) throw new IllegalArgumentException("must replace 1 or more " + "labels"); try { Name newname = new Name(); copy(wild, newname); newname.append(name, offset(n), getlabels() - n); return newname; } catch (NameTooLongException e) { throw new IllegalStateException ("Name.wild: concatenate failed"); } }
// in org/xbill/DNS/Name.java
public void toWire(DNSOutput out, Compression c) { if (!isAbsolute()) throw new IllegalArgumentException("toWire() called on " + "non-absolute name"); int labels = labels(); for (int i = 0; i < labels - 1; i++) { Name tname; if (i == 0) tname = this; else tname = new Name(this, i); int pos = -1; if (c != null) pos = c.get(tname); if (pos >= 0) { pos |= (LABEL_MASK << 8); out.writeU16(pos); return; } else { if (c != null) c.add(out.current(), tname); int off = offset(i); out.writeByteArray(name, off, name[off] + 1); } } out.writeU8(0); }
// in org/xbill/DNS/ReverseMap.java
public static Name fromAddress(byte [] addr) { if (addr.length != 4 && addr.length != 16) throw new IllegalArgumentException("array must contain " + "4 or 16 elements"); StringBuffer sb = new StringBuffer(); if (addr.length == 4) { for (int i = addr.length - 1; i >= 0; i--) { sb.append(addr[i] & 0xFF); if (i > 0) sb.append("."); } } else { int [] nibbles = new int[2]; for (int i = addr.length - 1; i >= 0; i--) { nibbles[0] = (addr[i] & 0xFF) >> 4; nibbles[1] = (addr[i] & 0xFF) & 0xF; for (int j = nibbles.length - 1; j >= 0; j--) { sb.append(Integer.toHexString(nibbles[j])); if (i > 0 || j > 0) sb.append("."); } } } try { if (addr.length == 4) return Name.fromString(sb.toString(), inaddr4); else return Name.fromString(sb.toString(), inaddr6); } catch (TextParseException e) { throw new IllegalStateException("name cannot be invalid"); } }
// in org/xbill/DNS/ReverseMap.java
public static Name fromAddress(int [] addr) { byte [] bytes = new byte[addr.length]; for (int i = 0; i < addr.length; i++) { if (addr[i] < 0 || addr[i] > 0xFF) throw new IllegalArgumentException("array must " + "contain values " + "between 0 and 255"); bytes[i] = (byte) addr[i]; } return fromAddress(bytes); }
// in org/xbill/DNS/spi/DNSJavaNameService.java
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { if (method.getName().equals("getHostByAddr")) { return this.getHostByAddr((byte[]) args[0]); } else if (method.getName().equals("lookupAllHostAddr")) { InetAddress[] addresses; addresses = this.lookupAllHostAddr((String) args[0]); Class returnType = method.getReturnType(); if (returnType.equals(InetAddress[].class)) { // method for Java >= 1.6 return addresses; } else if (returnType.equals(byte[][].class)) { // method for Java <= 1.5 int naddrs = addresses.length; byte [][] byteAddresses = new byte[naddrs][]; byte [] addr; for (int i = 0; i < naddrs; i++) { addr = addresses[i].getAddress(); byteAddresses[i] = addr; } return byteAddresses; } } } catch (Throwable e) { System.err.println("DNSJavaNameService: Unexpected error."); e.printStackTrace(); throw e; } throw new IllegalArgumentException( "Unknown function name or arguments."); }
// in org/xbill/DNS/Serial.java
public static int compare(long serial1, long serial2) { if (serial1 < 0 || serial1 > MAX32) throw new IllegalArgumentException(serial1 + " out of range"); if (serial2 < 0 || serial2 > MAX32) throw new IllegalArgumentException(serial2 + " out of range"); long diff = serial1 - serial2; if (diff >= MAX32) diff -= (MAX32 + 1); else if (diff < -MAX32) diff += (MAX32 + 1); return (int)diff; }
// in org/xbill/DNS/Serial.java
public static long increment(long serial) { if (serial < 0 || serial > MAX32) throw new IllegalArgumentException(serial + " out of range"); if (serial == MAX32) return 0; return serial + 1; }
// in org/xbill/DNS/Tokenizer.java
private Token set(int type, StringBuffer value) { if (type < 0) throw new IllegalArgumentException(); this.type = type; this.value = value == null ? null : value.toString(); return this; }
// in org/xbill/DNS/SetResponse.java
static SetResponse ofType(int type) { switch (type) { case UNKNOWN: return unknown; case NXDOMAIN: return nxdomain; case NXRRSET: return nxrrset; case DELEGATION: case CNAME: case DNAME: case SUCCESSFUL: SetResponse sr = new SetResponse(); sr.type = type; sr.data = null; return sr; default: throw new IllegalArgumentException("invalid type"); } }
// in org/xbill/DNS/DNSSEC.java
static byte [] generateDSDigest(DNSKEYRecord key, int digestid) { MessageDigest digest; try { switch (digestid) { case DSRecord.Digest.SHA1: digest = MessageDigest.getInstance("sha-1"); break; case DSRecord.Digest.SHA256: digest = MessageDigest.getInstance("sha-256"); break; default: throw new IllegalArgumentException( "unknown DS digest type " + digestid); } } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("no message digest support"); } digest.update(key.getName().toWire()); digest.update(key.rdataToWireCanonical()); return digest.digest(); }
// in org/xbill/DNS/Header.java
static private void checkFlag(int bit) { if (!validFlag(bit)) throw new IllegalArgumentException("invalid flag bit " + bit); }
// in org/xbill/DNS/Header.java
public void setID(int id) { if (id < 0 || id > 0xffff) throw new IllegalArgumentException("DNS message ID " + id + " is out of range"); this.id = id; }
// in org/xbill/DNS/Header.java
public void setRcode(int value) { if (value < 0 || value > 0xF) throw new IllegalArgumentException("DNS Rcode " + value + " is out of range"); flags &= ~0xF; flags |= value; }
// in org/xbill/DNS/Header.java
public void setOpcode(int value) { if (value < 0 || value > 0xF) throw new IllegalArgumentException("DNS Opcode " + value + "is out of range"); flags &= 0x87FF; flags |= (value << 11); }
// in org/xbill/DNS/Header.java
void setCount(int field, int value) { if (value < 0 || value > 0xFFFF) throw new IllegalArgumentException("DNS section count " + value + " is out of range"); counts[field] = value; }
// in org/xbill/DNS/TSIG.java
private void getDigest() { if (alg.equals(HMAC_MD5)) { digest = "md5"; digestBlockLength = 64; } else if (alg.equals(HMAC_SHA1)) { digest = "sha-1"; digestBlockLength = 64; } else if (alg.equals(HMAC_SHA224)) { digest = "sha-224"; digestBlockLength = 64; } else if (alg.equals(HMAC_SHA256)) { digest = "sha-256"; digestBlockLength = 64; } else if (alg.equals(HMAC_SHA512)) { digest = "sha-512"; digestBlockLength = 128; } else if (alg.equals(HMAC_SHA384)) { digest = "sha-384"; digestBlockLength = 128; } else throw new IllegalArgumentException("Invalid algorithm"); }
// in org/xbill/DNS/TSIG.java
static public TSIG fromString(String str) { String [] parts = str.split("[:/]", 3); if (parts.length < 2) throw new IllegalArgumentException("Invalid TSIG key " + "specification"); if (parts.length == 3) { try { return new TSIG(parts[0], parts[1], parts[2]); } catch (IllegalArgumentException e) { parts = str.split("[:/]", 2); } } return new TSIG(HMAC_MD5, parts[0], parts[1]); }
// in org/xbill/DNS/DNSInput.java
public void setActive(int len) { if (len > array.length - pos) { throw new IllegalArgumentException("cannot set active " + "region past end of input"); } end = pos + len; }
// in org/xbill/DNS/DNSInput.java
public void restoreActive(int pos) { if (pos > array.length) { throw new IllegalArgumentException("cannot set active " + "region past end of input"); } end = pos; }
// in org/xbill/DNS/DNSInput.java
public void jump(int index) { if (index >= array.length) { throw new IllegalArgumentException("cannot jump past " + "end of input"); } pos = index; end = array.length; }
// in org/xbill/DNS/Address.java
public static byte [] toByteArray(String s, int family) { if (family == IPv4) return parseV4(s); else if (family == IPv6) return parseV6(s); else throw new IllegalArgumentException("unknown address family"); }
// in org/xbill/DNS/Address.java
public static InetAddress getByAddress(String addr, int family) throws UnknownHostException { if (family != IPv4 && family != IPv6) throw new IllegalArgumentException("unknown address family"); byte [] bytes; bytes = toByteArray(addr, family); if (bytes != null) return InetAddress.getByAddress(bytes); throw new UnknownHostException("Invalid address: " + addr); }
// in org/xbill/DNS/Address.java
public static int familyOf(InetAddress address) { if (address instanceof Inet4Address) return IPv4; if (address instanceof Inet6Address) return IPv6; throw new IllegalArgumentException("unknown address family"); }
// in org/xbill/DNS/Address.java
public static int addressLength(int family) { if (family == IPv4) return 4; if (family == IPv6) return 16; throw new IllegalArgumentException("unknown address family"); }
// in org/xbill/DNS/Address.java
public static InetAddress truncate(InetAddress address, int maskLength) { int family = familyOf(address); int maxMaskLength = addressLength(family) * 8; if (maskLength < 0 || maskLength > maxMaskLength) throw new IllegalArgumentException("invalid mask length"); if (maskLength == maxMaskLength) return address; byte [] bytes = address.getAddress(); for (int i = maskLength / 8 + 1; i < bytes.length; i++) bytes[i] = 0; int maskBits = maskLength % 8; int bitmask = 0; for (int i = 0; i < maskBits; i++) bitmask |= (1 << (7 - i)); bytes[maskLength / 8] &= bitmask; try { return InetAddress.getByAddress(bytes); } catch (UnknownHostException e) { throw new IllegalArgumentException("invalid address"); } }
// in org/xbill/DNS/Zone.java
private void fromXFR(ZoneTransferIn xfrin) throws IOException, ZoneTransferException { data = new TreeMap(); origin = xfrin.getName(); List records = xfrin.run(); for (Iterator it = records.iterator(); it.hasNext(); ) { Record record = (Record) it.next(); maybeAddRecord(record); } if (!xfrin.isAXFR()) throw new IllegalArgumentException("zones can only be " + "created from AXFRs"); validate(); }
// in org/xbill/DNS/Zone.java
private synchronized RRset oneRRset(Object types, int type) { if (type == Type.ANY) throw new IllegalArgumentException("oneRRset(ANY)"); if (types instanceof List) { List list = (List) types; for (int i = 0; i < list.size(); i++) { RRset set = (RRset) list.get(i); if (set.getType() == type) return set; } } else { RRset set = (RRset) types; if (set.getType() == type) return set; } return null; }
// in org/xbill/DNS/GPOSRecord.java
private void validate(double longitude, double latitude) throws IllegalArgumentException { if (longitude < -90.0 || longitude > 90.0) { throw new IllegalArgumentException("illegal longitude " + longitude); } if (latitude < -180.0 || latitude > 180.0) { throw new IllegalArgumentException("illegal latitude " + latitude); } }
// in org/xbill/DNS/DNSOutput.java
private void check(long val, int bits) { long max = 1; max <<= bits; if (val < 0 || val > max) { throw new IllegalArgumentException(val + " out of range for " + bits + " bit value"); } }
// in org/xbill/DNS/DNSOutput.java
public void jump(int index) { if (index > pos) { throw new IllegalArgumentException("cannot jump past " + "end of data"); } pos = index; }
// in org/xbill/DNS/DNSOutput.java
public void writeU16At(int val, int where) { check(val, 16); if (where > pos - 2) throw new IllegalArgumentException("cannot write past " + "end of data"); array[where++] = (byte)((val >>> 8) & 0xFF); array[where++] = (byte)(val & 0xFF); }
// in org/xbill/DNS/DNSOutput.java
public void writeCountedString(byte [] s) { if (s.length > 0xFF) { throw new IllegalArgumentException("Invalid counted string"); } need(1 + s.length); array[pos++] = (byte)(s.length & 0xFF); writeByteArray(s, 0, s.length); }
// in org/xbill/DNS/Cache.java
private synchronized Element oneElement(Name name, Object types, int type, int minCred) { Element found = null; if (type == Type.ANY) throw new IllegalArgumentException("oneElement(ANY)"); if (types instanceof List) { List list = (List) types; for (int i = 0; i < list.size(); i++) { Element set = (Element) list.get(i); if (set.getType() == type) { found = set; break; } } } else { Element set = (Element) types; if (set.getType() == type) found = set; } if (found == null) return null; if (found.expired()) { removeElement(name, type); return null; } if (found.compareCredibility(minCred) < 0) return null; return found; }
// in org/xbill/DNS/Cache.java
private final int getCred(int section, boolean isAuth) { if (section == Section.ANSWER) { if (isAuth) return Credibility.AUTH_ANSWER; else return Credibility.NONAUTH_ANSWER; } else if (section == Section.AUTHORITY) { if (isAuth) return Credibility.AUTH_AUTHORITY; else return Credibility.NONAUTH_AUTHORITY; } else if (section == Section.ADDITIONAL) { return Credibility.ADDITIONAL; } else throw new IllegalArgumentException("getCred: invalid section"); }
// in org/xbill/DNS/RRset.java
public synchronized void addRR(Record r) { if (rrs.size() == 0) { safeAddRR(r); return; } Record first = first(); if (!r.sameRRset(first)) throw new IllegalArgumentException("record does not match " + "rrset"); if (r.getTTL() != first.getTTL()) { if (r.getTTL() > first.getTTL()) { r = r.cloneRecord(); r.setTTL(first.getTTL()); } else { for (int i = 0; i < rrs.size(); i++) { Record tmp = (Record) rrs.get(i); tmp = tmp.cloneRecord(); tmp.setTTL(r.getTTL()); rrs.set(i, tmp); } } } if (!rrs.contains(r)) safeAddRR(r); }
// in org/xbill/DNS/ZoneTransferIn.java
public void setTimeout(int secs) { if (secs < 0) throw new IllegalArgumentException("timeout cannot be " + "negative"); timeout = 1000L * secs; }
// in org/xbill/DNS/ZoneTransferIn.java
private BasicHandler getBasicHandler() throws IllegalArgumentException { if (handler instanceof BasicHandler) return (BasicHandler) handler; throw new IllegalArgumentException("ZoneTransferIn used callback " + "interface"); }
// in org/xbill/DNS/ClientSubnetOption.java
private static int checkMaskLength(String field, int family, int val) { int max = Address.addressLength(family) * 8; if (val < 0 || val > max) throw new IllegalArgumentException("\"" + field + "\" " + val + " must be in the range " + "[0.." + max + "]"); return val; }
// in org/xbill/DNS/Lookup.java
public void setNdots(int ndots) { if (ndots < 0) throw new IllegalArgumentException("Illegal ndots value: " + ndots); defaultNdots = ndots; }
10
            
// in org/xbill/DNS/ISDNRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/HINFORecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/Name.java
catch (TextParseException e) { throw new IllegalArgumentException("Invalid name '" + s + "'"); }
// in org/xbill/DNS/utils/HMAC.java
catch (NoSuchAlgorithmException e) { throw new IllegalArgumentException("unknown digest algorithm " + digestName); }
// in org/xbill/DNS/TXTBase.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/TSIG.java
catch (TextParseException e) { throw new IllegalArgumentException("Invalid TSIG key name"); }
// in org/xbill/DNS/Address.java
catch (UnknownHostException e) { throw new IllegalArgumentException("invalid address"); }
// in org/xbill/DNS/GPOSRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/ZoneTransferIn.java
catch (NameTooLongException e) { throw new IllegalArgumentException("ZoneTransferIn: " + "name too long"); }
// in org/xbill/DNS/NAPTRRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
2
            
// in org/xbill/DNS/GPOSRecord.java
private void validate(double longitude, double latitude) throws IllegalArgumentException { if (longitude < -90.0 || longitude > 90.0) { throw new IllegalArgumentException("illegal longitude " + longitude); } if (latitude < -180.0 || latitude > 180.0) { throw new IllegalArgumentException("illegal latitude " + latitude); } }
// in org/xbill/DNS/ZoneTransferIn.java
private BasicHandler getBasicHandler() throws IllegalArgumentException { if (handler instanceof BasicHandler) return (BasicHandler) handler; throw new IllegalArgumentException("ZoneTransferIn used callback " + "interface"); }
3
            
// in org/xbill/DNS/TSIG.java
catch (IllegalArgumentException e) { parts = str.split("[:/]", 2); }
// in org/xbill/DNS/GPOSRecord.java
catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); }
// in org/xbill/DNS/GPOSRecord.java
catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); }
2
            
// in org/xbill/DNS/GPOSRecord.java
catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); }
// in org/xbill/DNS/GPOSRecord.java
catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); }
0
runtime (Lib) IllegalStateException 23
            
// in org/xbill/DNS/ExtendedResolver.java
public Message start() throws IOException { try { /* * First, try sending synchronously. If this works, * we're done. Otherwise, we'll get an exception * and continue. It would be easier to call send(0), * but this avoids a thread creation. If and when * SimpleResolver.sendAsync() can be made to not * create a thread, this could be changed. */ sent[0]++; outstanding++; inprogress[0] = new Object(); return resolvers[0].send(query); } catch (Exception e) { /* * This will either cause more queries to be sent * asynchronously or will set the 'done' flag. */ handleException(inprogress[0], e); } /* * Wait for a successful response or for each * subresolver to fail. */ synchronized (this) { while (!done) { try { wait(); } catch (InterruptedException e) { } } } /* Return the response or throw an exception */ if (response != null) return response; else if (thrown instanceof IOException) throw (IOException) thrown; else if (thrown instanceof RuntimeException) throw (RuntimeException) thrown; else if (thrown instanceof Error) throw (Error) thrown; else throw new IllegalStateException ("ExtendedResolver failure"); }
// in org/xbill/DNS/Record.java
Record cloneRecord() { try { return (Record) clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException(); } }
// in org/xbill/DNS/Name.java
private final void append(byte [] array, int start, int n) throws NameTooLongException { int length = (name == null ? 0 : (name.length - offset(0))); int alength = 0; for (int i = 0, pos = start; i < n; i++) { int len = array[pos]; if (len > MAXLABEL) throw new IllegalStateException("invalid label"); len++; pos += len; alength += len; } int newlength = length + alength; if (newlength > MAXNAME) throw new NameTooLongException(); int labels = getlabels(); int newlabels = labels + n; if (newlabels > MAXLABELS) throw new IllegalStateException("too many labels"); byte [] newname = new byte[newlength]; if (length != 0) System.arraycopy(name, offset(0), newname, 0, length); System.arraycopy(array, start, newname, length, alength); name = newname; for (int i = 0, pos = length; i < n; i++) { setoffset(labels + i, pos); pos += (newname[pos] + 1); } setlabels(newlabels); }
// in org/xbill/DNS/Name.java
public Name wild(int n) { if (n < 1) throw new IllegalArgumentException("must replace 1 or more " + "labels"); try { Name newname = new Name(); copy(wild, newname); newname.append(name, offset(n), getlabels() - n); return newname; } catch (NameTooLongException e) { throw new IllegalStateException ("Name.wild: concatenate failed"); } }
// in org/xbill/DNS/Name.java
public String toString() { int labels = labels(); if (labels == 0) return "@"; else if (labels == 1 && name[offset(0)] == 0) return "."; StringBuffer sb = new StringBuffer(); for (int i = 0, pos = offset(0); i < labels; i++) { int len = name[pos]; if (len > MAXLABEL) throw new IllegalStateException("invalid label"); if (len == 0) break; sb.append(byteString(name, pos)); sb.append('.'); pos += (1 + len); } if (!isAbsolute()) sb.deleteCharAt(sb.length() - 1); return sb.toString(); }
// in org/xbill/DNS/Name.java
public byte [] toWireCanonical() { int labels = labels(); if (labels == 0) return (new byte[0]); byte [] b = new byte[name.length - offset(0)]; for (int i = 0, spos = offset(0), dpos = 0; i < labels; i++) { int len = name[spos]; if (len > MAXLABEL) throw new IllegalStateException("invalid label"); b[dpos++] = name[spos++]; for (int j = 0; j < len; j++) b[dpos++] = lowercase[(name[spos++] & 0xFF)]; } return b; }
// in org/xbill/DNS/Name.java
private final boolean equals(byte [] b, int bpos) { int labels = labels(); for (int i = 0, pos = offset(0); i < labels; i++) { if (name[pos] != b[bpos]) return false; int len = name[pos++]; bpos++; if (len > MAXLABEL) throw new IllegalStateException("invalid label"); for (int j = 0; j < len; j++) if (lowercase[(name[pos++] & 0xFF)] != lowercase[(b[bpos++] & 0xFF)]) return false; } return true; }
// in org/xbill/DNS/Master.java
public Record _nextRecord() throws IOException { Tokenizer.Token token; String s; if (included != null) { Record rec = included.nextRecord(); if (rec != null) return rec; included = null; } if (generator != null) { Record rec = nextGenerated(); if (rec != null) return rec; endGenerate(); } while (true) { Name name; token = st.get(true, false); if (token.type == Tokenizer.WHITESPACE) { Tokenizer.Token next = st.get(); if (next.type == Tokenizer.EOL) continue; else if (next.type == Tokenizer.EOF) return null; else st.unget(); if (last == null) throw st.exception("no owner"); name = last.getName(); } else if (token.type == Tokenizer.EOL) continue; else if (token.type == Tokenizer.EOF) return null; else if (((String) token.value).charAt(0) == '$') { s = token.value; if (s.equalsIgnoreCase("$ORIGIN")) { origin = st.getName(Name.root); st.getEOL(); continue; } else if (s.equalsIgnoreCase("$TTL")) { defaultTTL = st.getTTL(); st.getEOL(); continue; } else if (s.equalsIgnoreCase("$INCLUDE")) { String filename = st.getString(); File newfile; if (file != null) { String parent = file.getParent(); newfile = new File(parent, filename); } else { newfile = new File(filename); } Name incorigin = origin; token = st.get(); if (token.isString()) { incorigin = parseName(token.value, Name.root); st.getEOL(); } included = new Master(newfile, incorigin, defaultTTL); /* * If we continued, we wouldn't be looking in * the new file. Recursing works better. */ return nextRecord(); } else if (s.equalsIgnoreCase("$GENERATE")) { if (generator != null) throw new IllegalStateException ("cannot nest $GENERATE"); startGenerate(); if (noExpandGenerate) { endGenerate(); continue; } return nextGenerated(); } else { throw st.exception("Invalid directive: " + s); } } else { s = token.value; name = parseName(s, origin); if (last != null && name.equals(last.getName())) { name = last.getName(); } } parseTTLClassAndType(); last = Record.fromString(name, currentType, currentDClass, currentTTL, st, origin); if (needSOATTL) { long ttl = ((SOARecord)last).getMinimum(); last.setTTL(ttl); defaultTTL = ttl; needSOATTL = false; } return last; } }
// in org/xbill/DNS/ReverseMap.java
public static Name fromAddress(byte [] addr) { if (addr.length != 4 && addr.length != 16) throw new IllegalArgumentException("array must contain " + "4 or 16 elements"); StringBuffer sb = new StringBuffer(); if (addr.length == 4) { for (int i = addr.length - 1; i >= 0; i--) { sb.append(addr[i] & 0xFF); if (i > 0) sb.append("."); } } else { int [] nibbles = new int[2]; for (int i = addr.length - 1; i >= 0; i--) { nibbles[0] = (addr[i] & 0xFF) >> 4; nibbles[1] = (addr[i] & 0xFF) & 0xF; for (int j = nibbles.length - 1; j >= 0; j--) { sb.append(Integer.toHexString(nibbles[j])); if (i > 0 || j > 0) sb.append("."); } } } try { if (addr.length == 4) return Name.fromString(sb.toString(), inaddr4); else return Name.fromString(sb.toString(), inaddr6); } catch (TextParseException e) { throw new IllegalStateException("name cannot be invalid"); } }
// in org/xbill/DNS/Tokenizer.java
public Token get(boolean wantWhitespace, boolean wantComment) throws IOException { int type; int c; if (ungottenToken) { ungottenToken = false; if (current.type == WHITESPACE) { if (wantWhitespace) return current; } else if (current.type == COMMENT) { if (wantComment) return current; } else { if (current.type == EOL) line++; return current; } } int skipped = skipWhitespace(); if (skipped > 0 && wantWhitespace) return current.set(WHITESPACE, null); type = IDENTIFIER; sb.setLength(0); while (true) { c = getChar(); if (c == -1 || delimiters.indexOf(c) != -1) { if (c == -1) { if (quoting) throw exception("EOF in " + "quoted string"); else if (sb.length() == 0) return current.set(EOF, null); else return current.set(type, sb); } if (sb.length() == 0 && type != QUOTED_STRING) { if (c == '(') { multiline++; skipWhitespace(); continue; } else if (c == ')') { if (multiline <= 0) throw exception("invalid " + "close " + "parenthesis"); multiline--; skipWhitespace(); continue; } else if (c == '"') { if (!quoting) { quoting = true; delimiters = quotes; type = QUOTED_STRING; } else { quoting = false; delimiters = delim; skipWhitespace(); } continue; } else if (c == '\n') { return current.set(EOL, null); } else if (c == ';') { while (true) { c = getChar(); if (c == '\n' || c == -1) break; sb.append((char)c); } if (wantComment) { ungetChar(c); return current.set(COMMENT, sb); } else if (c == -1 && type != QUOTED_STRING) { checkUnbalancedParens(); return current.set(EOF, null); } else if (multiline > 0) { skipWhitespace(); sb.setLength(0); continue; } else return current.set(EOL, null); } else throw new IllegalStateException(); } else ungetChar(c); break; } else if (c == '\\') { c = getChar(); if (c == -1) throw exception("unterminated escape sequence"); sb.append('\\'); } else if (quoting && c == '\n') { throw exception("newline in quoted string"); } sb.append((char)c); } if (sb.length() == 0 && type != QUOTED_STRING) { checkUnbalancedParens(); return current.set(EOF, null); } return current.set(type, sb); }
// in org/xbill/DNS/Tokenizer.java
public void unget() { if (ungottenToken) throw new IllegalStateException ("Cannot unget multiple tokens"); if (current.type == EOL) line--; ungottenToken = true; }
// in org/xbill/DNS/SetResponse.java
public String toString() { switch (type) { case UNKNOWN: return "unknown"; case NXDOMAIN: return "NXDOMAIN"; case NXRRSET: return "NXRRSET"; case DELEGATION: return "delegation: " + data; case CNAME: return "CNAME: " + data; case DNAME: return "DNAME: " + data; case SUCCESSFUL: return "successful"; default: throw new IllegalStateException(); } }
// in org/xbill/DNS/DNSSEC.java
private static void verify(PublicKey key, int alg, byte [] data, byte [] signature) throws DNSSECException { if (key instanceof DSAPublicKey) { try { signature = DSASignaturefromDNS(signature); } catch (IOException e) { throw new IllegalStateException(); } } try { Signature s = Signature.getInstance(algString(alg)); s.initVerify(key); s.update(data); if (!s.verify(signature)) throw new SignatureVerificationException(); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } }
// in org/xbill/DNS/DNSSEC.java
private static byte [] sign(PrivateKey privkey, PublicKey pubkey, int alg, byte [] data, String provider) throws DNSSECException { byte [] signature; try { Signature s; if (provider != null) s = Signature.getInstance(algString(alg), provider); else s = Signature.getInstance(algString(alg)); s.initSign(privkey); s.update(data); signature = s.sign(); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } if (pubkey instanceof DSAPublicKey) { try { DSAPublicKey dsa = (DSAPublicKey) pubkey; BigInteger P = dsa.getParams().getP(); int t = (BigIntegerLength(P) - 64) / 8; signature = DSASignaturetoDNS(signature, t); } catch (IOException e) { throw new IllegalStateException(); } } return signature; }
// in org/xbill/DNS/DNSSEC.java
static byte [] generateDSDigest(DNSKEYRecord key, int digestid) { MessageDigest digest; try { switch (digestid) { case DSRecord.Digest.SHA1: digest = MessageDigest.getInstance("sha-1"); break; case DSRecord.Digest.SHA256: digest = MessageDigest.getInstance("sha-256"); break; default: throw new IllegalArgumentException( "unknown DS digest type " + digestid); } } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("no message digest support"); } digest.update(key.getName().toWire()); digest.update(key.rdataToWireCanonical()); return digest.digest(); }
// in org/xbill/DNS/Header.java
void incCount(int field) { if (counts[field] == 0xFFFF) throw new IllegalStateException("DNS section count cannot " + "be incremented"); counts[field]++; }
// in org/xbill/DNS/Header.java
void decCount(int field) { if (counts[field] == 0) throw new IllegalStateException("DNS section count cannot " + "be decremented"); counts[field]--; }
// in org/xbill/DNS/DNSInput.java
public void restore() { if (saved_pos < 0) { throw new IllegalStateException("no previous state"); } pos = saved_pos; end = saved_end; saved_pos = -1; saved_end = -1; }
// in org/xbill/DNS/DNSOutput.java
public void restore() { if (saved_pos < 0) { throw new IllegalStateException("no previous state"); } pos = saved_pos; saved_pos = -1; }
// in org/xbill/DNS/RRset.java
public synchronized Record first() { if (rrs.size() == 0) throw new IllegalStateException("rrset is empty"); return (Record) rrs.get(0); }
// in org/xbill/DNS/Lookup.java
private void checkDone() { if (done && result != -1) return; StringBuffer sb = new StringBuffer("Lookup of " + name + " "); if (dclass != DClass.IN) sb.append(DClass.string(dclass) + " "); sb.append(Type.string(type) + " isn't done"); throw new IllegalStateException(sb.toString()); }
// in org/xbill/DNS/Lookup.java
public String getErrorString() { checkDone(); if (error != null) return error; switch (result) { case SUCCESSFUL: return "successful"; case UNRECOVERABLE: return "unrecoverable error"; case TRY_AGAIN: return "try again"; case HOST_NOT_FOUND: return "host not found"; case TYPE_NOT_FOUND: return "type not found"; } throw new IllegalStateException("unknown result"); }
6
            
// in org/xbill/DNS/Record.java
catch (CloneNotSupportedException e) { throw new IllegalStateException(); }
// in org/xbill/DNS/Name.java
catch (NameTooLongException e) { throw new IllegalStateException ("Name.wild: concatenate failed"); }
// in org/xbill/DNS/ReverseMap.java
catch (TextParseException e) { throw new IllegalStateException("name cannot be invalid"); }
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new IllegalStateException(); }
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new IllegalStateException(); }
// in org/xbill/DNS/DNSSEC.java
catch (NoSuchAlgorithmException e) { throw new IllegalStateException("no message digest support"); }
0 0 0 0
runtime (Domain) IncompatibleKeyException
public static class IncompatibleKeyException extends IllegalArgumentException {
	IncompatibleKeyException() {
		super("incompatible keys");
	}
}
4
            
// in org/xbill/DNS/DNSSEC.java
static byte [] fromPublicKey(PublicKey key, int alg) throws DNSSECException { byte [] data = null; switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: if (! (key instanceof RSAPublicKey)) throw new IncompatibleKeyException(); return fromRSAPublicKey((RSAPublicKey) key); case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: if (! (key instanceof DSAPublicKey)) throw new IncompatibleKeyException(); return fromDSAPublicKey((DSAPublicKey) key); default: throw new UnsupportedAlgorithmException(alg); } }
// in org/xbill/DNS/DNSSEC.java
static void checkAlgorithm(PrivateKey key, int alg) throws UnsupportedAlgorithmException { switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: if (! (key instanceof RSAPrivateKey)) throw new IncompatibleKeyException(); break; case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: if (! (key instanceof DSAPrivateKey)) throw new IncompatibleKeyException(); break; default: throw new UnsupportedAlgorithmException(alg); } }
0 0 0 0 0
unknown (Lib) InterruptedException 0 0 0 2
            
// in org/xbill/DNS/ExtendedResolver.java
catch (InterruptedException e) { }
// in org/xbill/DNS/UDPClient.java
catch (InterruptedException e) { }
0 0
runtime (Domain) InvalidDClassException
public class InvalidDClassException extends IllegalArgumentException {

public
InvalidDClassException(int dclass) {
	super("Invalid DNS class: " + dclass);
}

}
1
            
// in org/xbill/DNS/DClass.java
public static void check(int i) { if (i < 0 || i > 0xFFFF) throw new InvalidDClassException(i); }
0 0 0 0 0
runtime (Domain) InvalidTTLException
public class InvalidTTLException extends IllegalArgumentException {

public
InvalidTTLException(long ttl) {
	super("Invalid DNS TTL: " + ttl);
}

}
1
            
// in org/xbill/DNS/TTL.java
static void check(long i) { if (i < 0 || i > MAX_VALUE) throw new InvalidTTLException(i); }
0 0 0 0 0
runtime (Domain) InvalidTypeException
public class InvalidTypeException extends IllegalArgumentException {

public
InvalidTypeException(int type) {
	super("Invalid DNS type: " + type);
}

}
1
            
// in org/xbill/DNS/Type.java
public static void check(int val) { if (val < 0 || val > 0xFFFF) throw new InvalidTypeException(val); }
0 0 0 0 0
checked (Domain) KeyMismatchException
public static class KeyMismatchException extends DNSSECException {
	private KEYBase key;
	private SIGBase sig;

	KeyMismatchException(KEYBase key, SIGBase sig) {
		super("key " +
		      key.getName() + "/" +
		      DNSSEC.Algorithm.string(key.getAlgorithm()) + "/" +
		      key.getFootprint() + " " +
		      "does not match signature " +
		      sig.getSigner() + "/" +
		      DNSSEC.Algorithm.string(sig.getAlgorithm()) + "/" +
		      sig.getFootprint());
	}
}
2
            
// in org/xbill/DNS/DNSSEC.java
public static void verify(RRset rrset, RRSIGRecord rrsig, DNSKEYRecord key) throws DNSSECException { if (!matches(rrsig, key)) throw new KeyMismatchException(key, rrsig); Date now = new Date(); if (now.compareTo(rrsig.getExpire()) > 0) throw new SignatureExpiredException(rrsig.getExpire(), now); if (now.compareTo(rrsig.getTimeSigned()) < 0) throw new SignatureNotYetValidException(rrsig.getTimeSigned(), now); verify(key.getPublicKey(), rrsig.getAlgorithm(), digestRRset(rrsig, rrset), rrsig.getSignature()); }
// in org/xbill/DNS/DNSSEC.java
static void verifyMessage(Message message, byte [] bytes, SIGRecord sig, SIGRecord previous, KEYRecord key) throws DNSSECException { if (!matches(sig, key)) throw new KeyMismatchException(key, sig); Date now = new Date(); if (now.compareTo(sig.getExpire()) > 0) throw new SignatureExpiredException(sig.getExpire(), now); if (now.compareTo(sig.getTimeSigned()) < 0) throw new SignatureNotYetValidException(sig.getTimeSigned(), now); DNSOutput out = new DNSOutput(); digestSIG(out, sig); if (previous != null) out.writeByteArray(previous.getSignature()); Header header = (Header) message.getHeader().clone(); header.decCount(Section.ADDITIONAL); out.writeByteArray(header.toWire()); out.writeByteArray(bytes, Header.LENGTH, message.sig0start - Header.LENGTH); verify(key.getPublicKey(), sig.getAlgorithm(), out.toByteArray(), sig.getSignature()); }
0 0 0 0 0
checked (Domain) MalformedKeyException
public static class MalformedKeyException extends DNSSECException {
	MalformedKeyException(KEYBase rec) {
		super("Invalid key data: " + rec.rdataToString());
	}
}
2
            
// in org/xbill/DNS/DNSSEC.java
private static PublicKey toDSAPublicKey(KEYBase r) throws IOException, GeneralSecurityException, MalformedKeyException { DNSInput in = new DNSInput(r.getKey()); int t = in.readU8(); if (t > 8) throw new MalformedKeyException(r); BigInteger q = readBigInteger(in, 20); BigInteger p = readBigInteger(in, 64 + t*8); BigInteger g = readBigInteger(in, 64 + t*8); BigInteger y = readBigInteger(in, 64 + t*8); KeyFactory factory = KeyFactory.getInstance("DSA"); return factory.generatePublic(new DSAPublicKeySpec(y, p, q, g)); }
// in org/xbill/DNS/DNSSEC.java
static PublicKey toPublicKey(KEYBase r) throws DNSSECException { int alg = r.getAlgorithm(); try { switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: return toRSAPublicKey(r); case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: return toDSAPublicKey(r); default: throw new UnsupportedAlgorithmException(alg); } } catch (IOException e) { throw new MalformedKeyException(r); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } }
1
            
// in org/xbill/DNS/DNSSEC.java
catch (IOException e) { throw new MalformedKeyException(r); }
1
            
// in org/xbill/DNS/DNSSEC.java
private static PublicKey toDSAPublicKey(KEYBase r) throws IOException, GeneralSecurityException, MalformedKeyException { DNSInput in = new DNSInput(r.getKey()); int t = in.readU8(); if (t > 8) throw new MalformedKeyException(r); BigInteger q = readBigInteger(in, 20); BigInteger p = readBigInteger(in, 64 + t*8); BigInteger g = readBigInteger(in, 64 + t*8); BigInteger y = readBigInteger(in, 64 + t*8); KeyFactory factory = KeyFactory.getInstance("DSA"); return factory.generatePublic(new DSAPublicKeySpec(y, p, q, g)); }
0 0 0
checked (Domain) NameTooLongException
public class NameTooLongException extends WireParseException {

public
NameTooLongException() {
	super();
}

public
NameTooLongException(String s) {
	super(s);
}

}
2
            
// in org/xbill/DNS/Name.java
private final void append(byte [] array, int start, int n) throws NameTooLongException { int length = (name == null ? 0 : (name.length - offset(0))); int alength = 0; for (int i = 0, pos = start; i < n; i++) { int len = array[pos]; if (len > MAXLABEL) throw new IllegalStateException("invalid label"); len++; pos += len; alength += len; } int newlength = length + alength; if (newlength > MAXNAME) throw new NameTooLongException(); int labels = getlabels(); int newlabels = labels + n; if (newlabels > MAXLABELS) throw new IllegalStateException("too many labels"); byte [] newname = new byte[newlength]; if (length != 0) System.arraycopy(name, offset(0), newname, 0, length); System.arraycopy(array, start, newname, length, alength); name = newname; for (int i = 0, pos = length; i < n; i++) { setoffset(labels + i, pos); pos += (newname[pos] + 1); } setlabels(newlabels); }
// in org/xbill/DNS/Name.java
public Name fromDNAME(DNAMERecord dname) throws NameTooLongException { Name dnameowner = dname.getName(); Name dnametarget = dname.getTarget(); if (!subdomain(dnameowner)) return null; int plabels = labels() - dnameowner.labels(); int plength = length() - dnameowner.length(); int pstart = offset(0); int dlabels = dnametarget.labels(); int dlength = dnametarget.length(); if (plength + dlength > MAXNAME) throw new NameTooLongException(); Name newname = new Name(); newname.setlabels(plabels + dlabels); newname.name = new byte[plength + dlength]; System.arraycopy(name, pstart, newname.name, 0, plength); System.arraycopy(dnametarget.name, 0, newname.name, plength, dlength); for (int i = 0, pos = 0; i < MAXOFFSETS && i < plabels + dlabels; i++) { newname.setoffset(i, pos); pos += (newname.name[pos] + 1); } return newname; }
0 3
            
// in org/xbill/DNS/Name.java
private final void append(byte [] array, int start, int n) throws NameTooLongException { int length = (name == null ? 0 : (name.length - offset(0))); int alength = 0; for (int i = 0, pos = start; i < n; i++) { int len = array[pos]; if (len > MAXLABEL) throw new IllegalStateException("invalid label"); len++; pos += len; alength += len; } int newlength = length + alength; if (newlength > MAXNAME) throw new NameTooLongException(); int labels = getlabels(); int newlabels = labels + n; if (newlabels > MAXLABELS) throw new IllegalStateException("too many labels"); byte [] newname = new byte[newlength]; if (length != 0) System.arraycopy(name, offset(0), newname, 0, length); System.arraycopy(array, start, newname, length, alength); name = newname; for (int i = 0, pos = length; i < n; i++) { setoffset(labels + i, pos); pos += (newname[pos] + 1); } setlabels(newlabels); }
// in org/xbill/DNS/Name.java
public static Name concatenate(Name prefix, Name suffix) throws NameTooLongException { if (prefix.isAbsolute()) return (prefix); Name newname = new Name(); copy(prefix, newname); newname.append(suffix.name, suffix.offset(0), suffix.getlabels()); return newname; }
// in org/xbill/DNS/Name.java
public Name fromDNAME(DNAMERecord dname) throws NameTooLongException { Name dnameowner = dname.getName(); Name dnametarget = dname.getTarget(); if (!subdomain(dnameowner)) return null; int plabels = labels() - dnameowner.labels(); int plength = length() - dnameowner.length(); int pstart = offset(0); int dlabels = dnametarget.labels(); int dlength = dnametarget.length(); if (plength + dlength > MAXNAME) throw new NameTooLongException(); Name newname = new Name(); newname.setlabels(plabels + dlabels); newname.name = new byte[plength + dlength]; System.arraycopy(name, pstart, newname.name, 0, plength); System.arraycopy(dnametarget.name, 0, newname.name, plength, dlength); for (int i = 0, pos = 0; i < MAXOFFSETS && i < plabels + dlabels; i++) { newname.setoffset(i, pos); pos += (newname.name[pos] + 1); } return newname; }
7
            
// in org/xbill/DNS/Name.java
catch (NameTooLongException e) { throw parseException(fullName, "Name too long"); }
// in org/xbill/DNS/Name.java
catch (NameTooLongException e) { }
// in org/xbill/DNS/Name.java
catch (NameTooLongException e) { throw new IllegalStateException ("Name.wild: concatenate failed"); }
// in org/xbill/DNS/Cache.java
catch (NameTooLongException e) { break; }
// in org/xbill/DNS/ZoneTransferIn.java
catch (NameTooLongException e) { throw new IllegalArgumentException("ZoneTransferIn: " + "name too long"); }
// in org/xbill/DNS/Lookup.java
catch (NameTooLongException e) { result = UNRECOVERABLE; error = "Invalid DNAME target"; done = true; }
// in org/xbill/DNS/Lookup.java
catch (NameTooLongException e) { nametoolong = true; return; }
3
            
// in org/xbill/DNS/Name.java
catch (NameTooLongException e) { throw parseException(fullName, "Name too long"); }
// in org/xbill/DNS/Name.java
catch (NameTooLongException e) { throw new IllegalStateException ("Name.wild: concatenate failed"); }
// in org/xbill/DNS/ZoneTransferIn.java
catch (NameTooLongException e) { throw new IllegalArgumentException("ZoneTransferIn: " + "name too long"); }
2
unknown (Lib) NoSuchAlgorithmException 1
            
// in org/xbill/DNS/NSEC3Record.java
static byte [] hashName(Name name, int hashAlg, int iterations, byte [] salt) throws NoSuchAlgorithmException { MessageDigest digest; switch (hashAlg) { case Digest.SHA1: digest = MessageDigest.getInstance("sha-1"); break; default: throw new NoSuchAlgorithmException("Unknown NSEC3 algorithm" + "identifier: " + hashAlg); } byte [] hash = null; for (int i = 0; i <= iterations; i++) { digest.reset(); if (i == 0) digest.update(name.toWireCanonical()); else digest.update(hash); if (salt != null) digest.update(salt); hash = digest.digest(); } return hash; }
0 3
            
// in org/xbill/DNS/NSEC3PARAMRecord.java
public byte [] hashName(Name name) throws NoSuchAlgorithmException { return NSEC3Record.hashName(name, hashAlg, iterations, salt); }
// in org/xbill/DNS/NSEC3Record.java
static byte [] hashName(Name name, int hashAlg, int iterations, byte [] salt) throws NoSuchAlgorithmException { MessageDigest digest; switch (hashAlg) { case Digest.SHA1: digest = MessageDigest.getInstance("sha-1"); break; default: throw new NoSuchAlgorithmException("Unknown NSEC3 algorithm" + "identifier: " + hashAlg); } byte [] hash = null; for (int i = 0; i <= iterations; i++) { digest.reset(); if (i == 0) digest.update(name.toWireCanonical()); else digest.update(hash); if (salt != null) digest.update(salt); hash = digest.digest(); } return hash; }
// in org/xbill/DNS/NSEC3Record.java
public byte [] hashName(Name name) throws NoSuchAlgorithmException { return hashName(name, hashAlg, iterations, salt); }
2
            
// in org/xbill/DNS/utils/HMAC.java
catch (NoSuchAlgorithmException e) { throw new IllegalArgumentException("unknown digest algorithm " + digestName); }
// in org/xbill/DNS/DNSSEC.java
catch (NoSuchAlgorithmException e) { throw new IllegalStateException("no message digest support"); }
2
            
// in org/xbill/DNS/utils/HMAC.java
catch (NoSuchAlgorithmException e) { throw new IllegalArgumentException("unknown digest algorithm " + digestName); }
// in org/xbill/DNS/DNSSEC.java
catch (NoSuchAlgorithmException e) { throw new IllegalStateException("no message digest support"); }
2
unknown (Lib) NoSuchElementException 1
            
// in org/xbill/DNS/Zone.java
public Object next() { if (!hasNext()) { throw new NoSuchElementException(); } if (current == null) { wantLastSOA = false; return oneRRset(originNode, Type.SOA); } Object set = current[count++]; if (count == current.length) { current = null; while (zentries.hasNext()) { Map.Entry entry = (Map.Entry) zentries.next(); if (entry.getKey().equals(origin)) continue; RRset [] sets = allRRsets(entry.getValue()); if (sets.length == 0) continue; current = sets; count = 0; break; } } return set; }
0 0 0 0 0
unknown (Lib) NumberFormatException 6
            
// in org/xbill/DNS/TTL.java
public static long parse(String s, boolean clamp) { if (s == null || s.length() == 0 || !Character.isDigit(s.charAt(0))) throw new NumberFormatException(); long value = 0; long ttl = 0; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); long oldvalue = value; if (Character.isDigit(c)) { value = (value * 10) + Character.getNumericValue(c); if (value < oldvalue) throw new NumberFormatException(); } else { switch (Character.toUpperCase(c)) { case 'W': value *= 7; case 'D': value *= 24; case 'H': value *= 60; case 'M': value *= 60; case 'S': break; default: throw new NumberFormatException(); } ttl += value; value = 0; if (ttl > 0xFFFFFFFFL) throw new NumberFormatException(); } } if (ttl == 0) ttl = value; if (ttl > 0xFFFFFFFFL) throw new NumberFormatException(); else if (ttl > MAX_VALUE && clamp) ttl = MAX_VALUE; return ttl; }
// in org/xbill/DNS/LOCRecord.java
private double parseFixedPoint(String s) { if (s.matches("^-?\\d+$")) return Integer.parseInt(s); else if (s.matches("^-?\\d+\\.\\d*$")) { String [] parts = s.split("\\."); double value = Integer.parseInt(parts[0]); double fraction = Integer.parseInt(parts[1]); if (value < 0) fraction *= -1; int digits = parts[1].length(); return value + (fraction / Math.pow(10, digits)); } else throw new NumberFormatException(); }
0 0 15
            
// in org/xbill/DNS/APLRecord.java
catch (NumberFormatException e) { throw st.exception("invalid family"); }
// in org/xbill/DNS/APLRecord.java
catch (NumberFormatException e) { throw st.exception("invalid prefix length"); }
// in org/xbill/DNS/FormattedTime.java
catch (NumberFormatException e) { throw new TextParseException("Invalid time encoding: " + s); }
// in org/xbill/DNS/Mnemonic.java
catch (NumberFormatException e) { }
// in org/xbill/DNS/Master.java
catch (NumberFormatException e) { if (defaultTTL >= 0) currentTTL = defaultTTL; else if (last != null) currentTTL = last.getTTL(); }
// in org/xbill/DNS/Master.java
catch (NumberFormatException e) { return -1; }
// in org/xbill/DNS/Tokenizer.java
catch (NumberFormatException e) { throw exception("expected an integer"); }
// in org/xbill/DNS/Tokenizer.java
catch (NumberFormatException e) { throw exception("expected a TTL value"); }
// in org/xbill/DNS/Tokenizer.java
catch (NumberFormatException e) { throw exception("expected a TTL-like value"); }
// in org/xbill/DNS/ResolverConfig.java
catch (NumberFormatException e) { }
// in org/xbill/DNS/Address.java
catch (NumberFormatException e) { return null; }
// in org/xbill/DNS/Options.java
catch (NumberFormatException e) { }
// in org/xbill/DNS/KEYRecord.java
catch (NumberFormatException e) { }
// in org/xbill/DNS/LOCRecord.java
catch (NumberFormatException e) { }
// in org/xbill/DNS/LOCRecord.java
catch (NumberFormatException e) { throw st.exception("Invalid LOC " + type); }
7
            
// in org/xbill/DNS/APLRecord.java
catch (NumberFormatException e) { throw st.exception("invalid family"); }
// in org/xbill/DNS/APLRecord.java
catch (NumberFormatException e) { throw st.exception("invalid prefix length"); }
// in org/xbill/DNS/FormattedTime.java
catch (NumberFormatException e) { throw new TextParseException("Invalid time encoding: " + s); }
// in org/xbill/DNS/Tokenizer.java
catch (NumberFormatException e) { throw exception("expected an integer"); }
// in org/xbill/DNS/Tokenizer.java
catch (NumberFormatException e) { throw exception("expected a TTL value"); }
// in org/xbill/DNS/Tokenizer.java
catch (NumberFormatException e) { throw exception("expected a TTL-like value"); }
// in org/xbill/DNS/LOCRecord.java
catch (NumberFormatException e) { throw st.exception("Invalid LOC " + type); }
0
runtime (Domain) RelativeNameException
public class RelativeNameException extends IllegalArgumentException {

public
RelativeNameException(Name name) {
	super("'" + name + "' is not an absolute name");
}

public
RelativeNameException(String s) {
	super(s);
}

}
10
            
// in org/xbill/DNS/Record.java
public static Record newRecord(Name name, int type, int dclass, long ttl, int length, byte [] data) { if (!name.isAbsolute()) throw new RelativeNameException(name); Type.check(type); DClass.check(dclass); TTL.check(ttl); DNSInput in; if (data != null) in = new DNSInput(data); else in = null; try { return newRecord(name, type, dclass, ttl, length, in); } catch (IOException e) { return null; } }
// in org/xbill/DNS/Record.java
public static Record newRecord(Name name, int type, int dclass, long ttl) { if (!name.isAbsolute()) throw new RelativeNameException(name); Type.check(type); DClass.check(dclass); TTL.check(ttl); return getEmptyRecord(name, type, dclass, ttl, false); }
// in org/xbill/DNS/Record.java
public static Record fromString(Name name, int type, int dclass, long ttl, Tokenizer st, Name origin) throws IOException { Record rec; if (!name.isAbsolute()) throw new RelativeNameException(name); Type.check(type); DClass.check(dclass); TTL.check(ttl); Tokenizer.Token t = st.get(); if (t.type == Tokenizer.IDENTIFIER && t.value.equals("\\#")) { int length = st.getUInt16(); byte [] data = st.getHex(); if (data == null) { data = new byte[0]; } if (length != data.length) throw st.exception("invalid unknown RR encoding: " + "length mismatch"); DNSInput in = new DNSInput(data); return newRecord(name, type, dclass, ttl, length, in); } st.unget(); rec = getEmptyRecord(name, type, dclass, ttl, true); rec.rdataFromString(st, origin); t = st.get(); if (t.type != Tokenizer.EOL && t.type != Tokenizer.EOF) { throw st.exception("unexpected tokens at end of record"); } return rec; }
// in org/xbill/DNS/Record.java
public Record withName(Name name) { if (!name.isAbsolute()) throw new RelativeNameException(name); Record rec = cloneRecord(); rec.name = name; return rec; }
// in org/xbill/DNS/Record.java
static Name checkName(String field, Name name) { if (!name.isAbsolute()) throw new RelativeNameException(name); return name; }
// in org/xbill/DNS/Tokenizer.java
public Name getName(Name origin) throws IOException { String next = _getIdentifier("a name"); try { Name name = Name.fromString(next, origin); if (!name.isAbsolute()) throw new RelativeNameException(name); return name; } catch (TextParseException e) { throw exception(e.getMessage()); } }
0 0 0 0 0
runtime (Lib) RuntimeException 1
            
// in org/xbill/DNS/Lookup.java
public static synchronized void refreshDefault() { try { defaultResolver = new ExtendedResolver(); } catch (UnknownHostException e) { throw new RuntimeException("Failed to initialize resolver"); } defaultSearchPath = ResolverConfig.getCurrentConfig().searchPath(); defaultCaches = new HashMap(); defaultNdots = ResolverConfig.getCurrentConfig().ndots(); }
1
            
// in org/xbill/DNS/Lookup.java
catch (UnknownHostException e) { throw new RuntimeException("Failed to initialize resolver"); }
0 0 0 0
unknown (Lib) SecurityException 0 0 0 1
            
// in org/xbill/DNS/Options.java
catch (SecurityException e) { }
0 0
checked (Domain) SignatureExpiredException
public static class SignatureExpiredException extends DNSSECException {
	private Date when, now;

	SignatureExpiredException(Date when, Date now) {
		super("signature expired");
		this.when = when;
		this.now = now;
	}

	/**
	 * @return When the signature expired
	 */
	public Date
	getExpiration() {
		return when;
	}

	/**
	 * @return When the verification was attempted
	 */
	public Date
	getVerifyTime() {
		return now;
	}
}
2
            
// in org/xbill/DNS/DNSSEC.java
public static void verify(RRset rrset, RRSIGRecord rrsig, DNSKEYRecord key) throws DNSSECException { if (!matches(rrsig, key)) throw new KeyMismatchException(key, rrsig); Date now = new Date(); if (now.compareTo(rrsig.getExpire()) > 0) throw new SignatureExpiredException(rrsig.getExpire(), now); if (now.compareTo(rrsig.getTimeSigned()) < 0) throw new SignatureNotYetValidException(rrsig.getTimeSigned(), now); verify(key.getPublicKey(), rrsig.getAlgorithm(), digestRRset(rrsig, rrset), rrsig.getSignature()); }
// in org/xbill/DNS/DNSSEC.java
static void verifyMessage(Message message, byte [] bytes, SIGRecord sig, SIGRecord previous, KEYRecord key) throws DNSSECException { if (!matches(sig, key)) throw new KeyMismatchException(key, sig); Date now = new Date(); if (now.compareTo(sig.getExpire()) > 0) throw new SignatureExpiredException(sig.getExpire(), now); if (now.compareTo(sig.getTimeSigned()) < 0) throw new SignatureNotYetValidException(sig.getTimeSigned(), now); DNSOutput out = new DNSOutput(); digestSIG(out, sig); if (previous != null) out.writeByteArray(previous.getSignature()); Header header = (Header) message.getHeader().clone(); header.decCount(Section.ADDITIONAL); out.writeByteArray(header.toWire()); out.writeByteArray(bytes, Header.LENGTH, message.sig0start - Header.LENGTH); verify(key.getPublicKey(), sig.getAlgorithm(), out.toByteArray(), sig.getSignature()); }
0 0 0 0 0
checked (Domain) SignatureNotYetValidException
public static class SignatureNotYetValidException extends DNSSECException {
	private Date when, now;

	SignatureNotYetValidException(Date when, Date now) {
		super("signature is not yet valid");
		this.when = when;
		this.now = now;
	}

	/**
	 * @return When the signature will become valid
	 */
	public Date
	getExpiration() {
		return when;
	}

	/**
	 * @return When the verification was attempted
	 */
	public Date
	getVerifyTime() {
		return now;
	}
}
2
            
// in org/xbill/DNS/DNSSEC.java
public static void verify(RRset rrset, RRSIGRecord rrsig, DNSKEYRecord key) throws DNSSECException { if (!matches(rrsig, key)) throw new KeyMismatchException(key, rrsig); Date now = new Date(); if (now.compareTo(rrsig.getExpire()) > 0) throw new SignatureExpiredException(rrsig.getExpire(), now); if (now.compareTo(rrsig.getTimeSigned()) < 0) throw new SignatureNotYetValidException(rrsig.getTimeSigned(), now); verify(key.getPublicKey(), rrsig.getAlgorithm(), digestRRset(rrsig, rrset), rrsig.getSignature()); }
// in org/xbill/DNS/DNSSEC.java
static void verifyMessage(Message message, byte [] bytes, SIGRecord sig, SIGRecord previous, KEYRecord key) throws DNSSECException { if (!matches(sig, key)) throw new KeyMismatchException(key, sig); Date now = new Date(); if (now.compareTo(sig.getExpire()) > 0) throw new SignatureExpiredException(sig.getExpire(), now); if (now.compareTo(sig.getTimeSigned()) < 0) throw new SignatureNotYetValidException(sig.getTimeSigned(), now); DNSOutput out = new DNSOutput(); digestSIG(out, sig); if (previous != null) out.writeByteArray(previous.getSignature()); Header header = (Header) message.getHeader().clone(); header.decCount(Section.ADDITIONAL); out.writeByteArray(header.toWire()); out.writeByteArray(bytes, Header.LENGTH, message.sig0start - Header.LENGTH); verify(key.getPublicKey(), sig.getAlgorithm(), out.toByteArray(), sig.getSignature()); }
0 0 0 0 0
checked (Domain) SignatureVerificationException
public static class SignatureVerificationException extends DNSSECException {
	SignatureVerificationException() {
		super("signature verification failed");
	}
}
2
            
// in org/xbill/DNS/DNSSEC.java
private static byte [] DSASignaturefromDNS(byte [] dns) throws DNSSECException, IOException { if (dns.length != 1 + DSA_LEN * 2) throw new SignatureVerificationException(); DNSInput in = new DNSInput(dns); DNSOutput out = new DNSOutput(); int t = in.readU8(); byte [] r = in.readByteArray(DSA_LEN); int rlen = DSA_LEN; if (r[0] < 0) rlen++; byte [] s = in.readByteArray(DSA_LEN); int slen = DSA_LEN; if (s[0] < 0) slen++; out.writeU8(ASN1_SEQ); out.writeU8(rlen + slen + 4); out.writeU8(ASN1_INT); out.writeU8(rlen); if (rlen > DSA_LEN) out.writeU8(0); out.writeByteArray(r); out.writeU8(ASN1_INT); out.writeU8(slen); if (slen > DSA_LEN) out.writeU8(0); out.writeByteArray(s); return out.toByteArray(); }
// in org/xbill/DNS/DNSSEC.java
private static void verify(PublicKey key, int alg, byte [] data, byte [] signature) throws DNSSECException { if (key instanceof DSAPublicKey) { try { signature = DSASignaturefromDNS(signature); } catch (IOException e) { throw new IllegalStateException(); } } try { Signature s = Signature.getInstance(algString(alg)); s.initVerify(key); s.update(data); if (!s.verify(signature)) throw new SignatureVerificationException(); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } }
0 0 0 0 0
unknown (Lib) SocketException 0 0 0 1
            
// in org/xbill/DNS/UDPClient.java
catch (SocketException e) { }
0 0
unknown (Lib) SocketTimeoutException 3
            
// in org/xbill/DNS/Client.java
static protected void blockUntil(SelectionKey key, long endTime) throws IOException { long timeout = endTime - System.currentTimeMillis(); int nkeys = 0; if (timeout > 0) nkeys = key.selector().select(timeout); else if (timeout == 0) nkeys = key.selector().selectNow(); if (nkeys == 0) throw new SocketTimeoutException(); }
// in org/xbill/DNS/TCPClient.java
void send(byte [] data) throws IOException { SocketChannel channel = (SocketChannel) key.channel(); verboseLog("TCP write", data); byte [] lengthArray = new byte[2]; lengthArray[0] = (byte)(data.length >>> 8); lengthArray[1] = (byte)(data.length & 0xFF); ByteBuffer [] buffers = new ByteBuffer[2]; buffers[0] = ByteBuffer.wrap(lengthArray); buffers[1] = ByteBuffer.wrap(data); int nsent = 0; key.interestOps(SelectionKey.OP_WRITE); try { while (nsent < data.length + 2) { if (key.isWritable()) { long n = channel.write(buffers); if (n < 0) throw new EOFException(); nsent += (int) n; if (nsent < data.length + 2 && System.currentTimeMillis() > endTime) throw new SocketTimeoutException(); } else blockUntil(key, endTime); } } finally { if (key.isValid()) key.interestOps(0); } }
// in org/xbill/DNS/TCPClient.java
private byte [] _recv(int length) throws IOException { SocketChannel channel = (SocketChannel) key.channel(); int nrecvd = 0; byte [] data = new byte[length]; ByteBuffer buffer = ByteBuffer.wrap(data); key.interestOps(SelectionKey.OP_READ); try { while (nrecvd < length) { if (key.isReadable()) { long n = channel.read(buffer); if (n < 0) throw new EOFException(); nrecvd += (int) n; if (nrecvd < length && System.currentTimeMillis() > endTime) throw new SocketTimeoutException(); } else blockUntil(key, endTime); } } finally { if (key.isValid()) key.interestOps(0); } return data; }
0 0 0 0 0
checked (Domain) TextParseException
public class TextParseException extends IOException {

public
TextParseException() {
	super();
}

public
TextParseException(String s) {
	super(s);
}

}
14
            
// in org/xbill/DNS/FormattedTime.java
public static Date parse(String s) throws TextParseException { if (s.length() != 14) { throw new TextParseException("Invalid time encoding: " + s); } Calendar c = new GregorianCalendar(TimeZone.getTimeZone("UTC")); c.clear(); try { int year = Integer.parseInt(s.substring(0, 4)); int month = Integer.parseInt(s.substring(4, 6)) - 1; int date = Integer.parseInt(s.substring(6, 8)); int hour = Integer.parseInt(s.substring(8, 10)); int minute = Integer.parseInt(s.substring(10, 12)); int second = Integer.parseInt(s.substring(12, 14)); c.set(year, month, date, hour, minute, second); } catch (NumberFormatException e) { throw new TextParseException("Invalid time encoding: " + s); } return c.getTime(); }
// in org/xbill/DNS/Record.java
protected static byte [] byteArrayFromString(String s) throws TextParseException { byte [] array = s.getBytes(); boolean escaped = false; boolean hasEscapes = false; for (int i = 0; i < array.length; i++) { if (array[i] == '\\') { hasEscapes = true; break; } } if (!hasEscapes) { if (array.length > 255) { throw new TextParseException("text string too long"); } return array; } ByteArrayOutputStream os = new ByteArrayOutputStream(); int digits = 0; int intval = 0; for (int i = 0; i < array.length; i++) { byte b = array[i]; if (escaped) { if (b >= '0' && b <= '9' && digits < 3) { digits++; intval *= 10; intval += (b - '0'); if (intval > 255) throw new TextParseException ("bad escape"); if (digits < 3) continue; b = (byte) intval; } else if (digits > 0 && digits < 3) throw new TextParseException("bad escape"); os.write(b); escaped = false; } else if (array[i] == '\\') { escaped = true; digits = 0; intval = 0; } else os.write(array[i]); } if (digits > 0 && digits < 3) throw new TextParseException("bad escape"); array = os.toByteArray(); if (array.length > 255) { throw new TextParseException("text string too long"); } return os.toByteArray(); }
// in org/xbill/DNS/Generator.java
private String substitute(String spec, long n) throws IOException { boolean escaped = false; byte [] str = spec.getBytes(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < str.length; i++) { char c = (char)(str[i] & 0xFF); if (escaped) { sb.append(c); escaped = false; } else if (c == '\\') { if (i + 1 == str.length) throw new TextParseException ("invalid escape character"); escaped = true; } else if (c == '$') { boolean negative = false; long offset = 0; long width = 0; long base = 10; boolean wantUpperCase = false; if (i + 1 < str.length && str[i + 1] == '$') { // '$$' == literal '$' for backwards // compatibility with old versions of BIND. c = (char)(str[++i] & 0xFF); sb.append(c); continue; } else if (i + 1 < str.length && str[i + 1] == '{') { // It's a substitution with modifiers. i++; if (i + 1 < str.length && str[i + 1] == '-') { negative = true; i++; } while (i + 1 < str.length) { c = (char)(str[++i] & 0xFF); if (c == ',' || c == '}') break; if (c < '0' || c > '9') throw new TextParseException( "invalid offset"); c -= '0'; offset *= 10; offset += c; } if (negative) offset = -offset; if (c == ',') { while (i + 1 < str.length) { c = (char)(str[++i] & 0xFF); if (c == ',' || c == '}') break; if (c < '0' || c > '9') throw new TextParseException( "invalid width"); c -= '0'; width *= 10; width += c; } } if (c == ',') { if (i + 1 == str.length) throw new TextParseException( "invalid base"); c = (char)(str[++i] & 0xFF); if (c == 'o') base = 8; else if (c == 'x') base = 16; else if (c == 'X') { base = 16; wantUpperCase = true; } else if (c != 'd') throw new TextParseException( "invalid base"); } if (i + 1 == str.length || str[i + 1] != '}') throw new TextParseException ("invalid modifiers"); i++; } long v = n + offset; if (v < 0) throw new TextParseException ("invalid offset expansion"); String number; if (base == 8) number = Long.toOctalString(v); else if (base == 16) number = Long.toHexString(v); else number = Long.toString(v); if (wantUpperCase) number = number.toUpperCase(); if (width != 0 && width > number.length()) { int zeros = (int)width - number.length(); while (zeros-- > 0) sb.append('0'); } sb.append(number); } else { sb.append(c); } } return sb.toString(); }
// in org/xbill/DNS/IPSECKEYRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { precedence = st.getUInt8(); gatewayType = st.getUInt8(); algorithmType = st.getUInt8(); switch (gatewayType) { case Gateway.None: String s = st.getString(); if (!s.equals(".")) throw new TextParseException("invalid gateway format"); gateway = null; break; case Gateway.IPv4: gateway = st.getAddress(Address.IPv4); break; case Gateway.IPv6: gateway = st.getAddress(Address.IPv6); break; case Gateway.Name: gateway = st.getName(origin); break; default: throw new WireParseException("invalid gateway type"); } key = st.getBase64(false); }
1
            
// in org/xbill/DNS/FormattedTime.java
catch (NumberFormatException e) { throw new TextParseException("Invalid time encoding: " + s); }
14
            
// in org/xbill/DNS/FormattedTime.java
public static Date parse(String s) throws TextParseException { if (s.length() != 14) { throw new TextParseException("Invalid time encoding: " + s); } Calendar c = new GregorianCalendar(TimeZone.getTimeZone("UTC")); c.clear(); try { int year = Integer.parseInt(s.substring(0, 4)); int month = Integer.parseInt(s.substring(4, 6)) - 1; int date = Integer.parseInt(s.substring(6, 8)); int hour = Integer.parseInt(s.substring(8, 10)); int minute = Integer.parseInt(s.substring(10, 12)); int second = Integer.parseInt(s.substring(12, 14)); c.set(year, month, date, hour, minute, second); } catch (NumberFormatException e) { throw new TextParseException("Invalid time encoding: " + s); } return c.getTime(); }
// in org/xbill/DNS/Record.java
protected static byte [] byteArrayFromString(String s) throws TextParseException { byte [] array = s.getBytes(); boolean escaped = false; boolean hasEscapes = false; for (int i = 0; i < array.length; i++) { if (array[i] == '\\') { hasEscapes = true; break; } } if (!hasEscapes) { if (array.length > 255) { throw new TextParseException("text string too long"); } return array; } ByteArrayOutputStream os = new ByteArrayOutputStream(); int digits = 0; int intval = 0; for (int i = 0; i < array.length; i++) { byte b = array[i]; if (escaped) { if (b >= '0' && b <= '9' && digits < 3) { digits++; intval *= 10; intval += (b - '0'); if (intval > 255) throw new TextParseException ("bad escape"); if (digits < 3) continue; b = (byte) intval; } else if (digits > 0 && digits < 3) throw new TextParseException("bad escape"); os.write(b); escaped = false; } else if (array[i] == '\\') { escaped = true; digits = 0; intval = 0; } else os.write(array[i]); } if (digits > 0 && digits < 3) throw new TextParseException("bad escape"); array = os.toByteArray(); if (array.length > 255) { throw new TextParseException("text string too long"); } return os.toByteArray(); }
// in org/xbill/DNS/Name.java
private final void appendFromString(String fullName, byte [] array, int start, int n) throws TextParseException { try { append(array, start, n); } catch (NameTooLongException e) { throw parseException(fullName, "Name too long"); } }
// in org/xbill/DNS/Name.java
public static Name fromString(String s, Name origin) throws TextParseException { if (s.equals("@") && origin != null) return origin; else if (s.equals(".")) return (root); return new Name(s, origin); }
// in org/xbill/DNS/Name.java
public static Name fromString(String s) throws TextParseException { return fromString(s, null); }
// in org/xbill/DNS/Master.java
private Name parseName(String s, Name origin) throws TextParseException { try { return Name.fromString(s, origin); } catch (TextParseException e) { throw st.exception(e.getMessage()); } }
// in org/xbill/DNS/Tokenizer.java
private void checkUnbalancedParens() throws TextParseException { if (multiline > 0) throw exception("unbalanced parentheses"); }
// in org/xbill/DNS/Lookup.java
public static synchronized void setDefaultSearchPath(String [] domains) throws TextParseException { if (domains == null) { defaultSearchPath = null; return; } Name [] newdomains = new Name[domains.length]; for (int i = 0; i < domains.length; i++) newdomains[i] = Name.fromString(domains[i], Name.root); defaultSearchPath = newdomains; }
// in org/xbill/DNS/Lookup.java
public void setSearchPath(String [] domains) throws TextParseException { if (domains == null) { this.searchPath = null; return; } Name [] newdomains = new Name[domains.length]; for (int i = 0; i < domains.length; i++) newdomains[i] = Name.fromString(domains[i], Name.root); this.searchPath = newdomains; }
21
            
// in org/xbill/DNS/ISDNRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/ISDNRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/HINFORecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/HINFORecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/Name.java
catch (TextParseException e) { throw new IllegalArgumentException("Invalid name '" + s + "'"); }
// in org/xbill/DNS/Master.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/Master.java
catch (TextParseException e) { throw st.exception("Parsing $GENERATE: " + e.getMessage()); }
// in org/xbill/DNS/ReverseMap.java
catch (TextParseException e) { throw new IllegalStateException("name cannot be invalid"); }
// in org/xbill/DNS/TXTBase.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/TXTBase.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (TextParseException e) { System.err.println("DNSJavaNameService: invalid " + domainProperty); }
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (TextParseException e) { throw new UnknownHostException(host); }
// in org/xbill/DNS/Tokenizer.java
catch (TextParseException e) { throw exception(e.getMessage()); }
// in org/xbill/DNS/TSIG.java
catch (TextParseException e) { throw new IllegalArgumentException("Invalid TSIG key name"); }
// in org/xbill/DNS/ResolverConfig.java
catch (TextParseException e) { return; }
// in org/xbill/DNS/ResolverConfig.java
catch (TextParseException e) { continue; }
// in org/xbill/DNS/Address.java
catch (TextParseException e) { throw new UnknownHostException("invalid name"); }
// in org/xbill/DNS/GPOSRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/GPOSRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/NAPTRRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/NAPTRRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
18
            
// in org/xbill/DNS/ISDNRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/ISDNRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/HINFORecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/HINFORecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/Name.java
catch (TextParseException e) { throw new IllegalArgumentException("Invalid name '" + s + "'"); }
// in org/xbill/DNS/Master.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/Master.java
catch (TextParseException e) { throw st.exception("Parsing $GENERATE: " + e.getMessage()); }
// in org/xbill/DNS/ReverseMap.java
catch (TextParseException e) { throw new IllegalStateException("name cannot be invalid"); }
// in org/xbill/DNS/TXTBase.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/TXTBase.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (TextParseException e) { throw new UnknownHostException(host); }
// in org/xbill/DNS/Tokenizer.java
catch (TextParseException e) { throw exception(e.getMessage()); }
// in org/xbill/DNS/TSIG.java
catch (TextParseException e) { throw new IllegalArgumentException("Invalid TSIG key name"); }
// in org/xbill/DNS/Address.java
catch (TextParseException e) { throw new UnknownHostException("invalid name"); }
// in org/xbill/DNS/GPOSRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/GPOSRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
// in org/xbill/DNS/NAPTRRecord.java
catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); }
// in org/xbill/DNS/NAPTRRecord.java
catch (TextParseException e) { throw st.exception(e.getMessage()); }
8
checked (Lib) Throwable 0 0 1
            
// in org/xbill/DNS/spi/DNSJavaNameService.java
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { if (method.getName().equals("getHostByAddr")) { return this.getHostByAddr((byte[]) args[0]); } else if (method.getName().equals("lookupAllHostAddr")) { InetAddress[] addresses; addresses = this.lookupAllHostAddr((String) args[0]); Class returnType = method.getReturnType(); if (returnType.equals(InetAddress[].class)) { // method for Java >= 1.6 return addresses; } else if (returnType.equals(byte[][].class)) { // method for Java <= 1.5 int naddrs = addresses.length; byte [][] byteAddresses = new byte[naddrs][]; byte [] addr; for (int i = 0; i < naddrs; i++) { addr = addresses[i].getAddress(); byteAddresses[i] = addr; } return byteAddresses; } } } catch (Throwable e) { System.err.println("DNSJavaNameService: Unexpected error."); e.printStackTrace(); throw e; } throw new IllegalArgumentException( "Unknown function name or arguments."); }
2
            
// in org/xbill/DNS/ExtendedResolver.java
catch (Throwable t) { synchronized (this) { thrown = t; done = true; if (listener == null) { notifyAll(); return; } } }
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (Throwable e) { System.err.println("DNSJavaNameService: Unexpected error."); e.printStackTrace(); throw e; }
1
            
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (Throwable e) { System.err.println("DNSJavaNameService: Unexpected error."); e.printStackTrace(); throw e; }
0
checked (Domain) TokenizerException
static class TokenizerException extends TextParseException {
	String message;

	public
	TokenizerException(String filename, int line, String message) {
		super(filename + ":" + line + ": " + message);
		this.message = message;
	}

	public String
	getBaseMessage() {
		return message;
	}
}
0 0 0 1
            
// in org/xbill/DNS/Master.java
catch (Tokenizer.TokenizerException e) { throw st.exception("Parsing $GENERATE: " + e.getBaseMessage()); }
1
            
// in org/xbill/DNS/Master.java
catch (Tokenizer.TokenizerException e) { throw st.exception("Parsing $GENERATE: " + e.getBaseMessage()); }
0
unknown (Lib) UnknownHostException 10
            
// in org/xbill/DNS/ReverseMap.java
public static Name fromAddress(String addr, int family) throws UnknownHostException { byte [] array = Address.toByteArray(addr, family); if (array == null) throw new UnknownHostException("Invalid IP address"); return fromAddress(array); }
// in org/xbill/DNS/ReverseMap.java
public static Name fromAddress(String addr) throws UnknownHostException { byte [] array = Address.toByteArray(addr, Address.IPv4); if (array == null) array = Address.toByteArray(addr, Address.IPv6); if (array == null) throw new UnknownHostException("Invalid IP address"); return fromAddress(array); }
// in org/xbill/DNS/spi/DNSJavaNameService.java
public InetAddress [] lookupAllHostAddr(String host) throws UnknownHostException { Name name = null; try { name = new Name(host); } catch (TextParseException e) { throw new UnknownHostException(host); } Record [] records = null; if (preferV6) records = new Lookup(name, Type.AAAA).run(); if (records == null) records = new Lookup(name, Type.A).run(); if (records == null && !preferV6) records = new Lookup(name, Type.AAAA).run(); if (records == null) throw new UnknownHostException(host); InetAddress[] array = new InetAddress[records.length]; for (int i = 0; i < records.length; i++) { Record record = records[i]; if (records[i] instanceof ARecord) { ARecord a = (ARecord) records[i]; array[i] = a.getAddress(); } else { AAAARecord aaaa = (AAAARecord) records[i]; array[i] = aaaa.getAddress(); } } return array; }
// in org/xbill/DNS/spi/DNSJavaNameService.java
public String getHostByAddr(byte [] addr) throws UnknownHostException { Name name = ReverseMap.fromAddress(InetAddress.getByAddress(addr)); Record [] records = new Lookup(name, Type.PTR).run(); if (records == null) throw new UnknownHostException(); return ((PTRRecord) records[0]).getTarget().toString(); }
// in org/xbill/DNS/Address.java
private static Record [] lookupHostName(String name) throws UnknownHostException { try { Record [] records = new Lookup(name).run(); if (records == null) throw new UnknownHostException("unknown host"); return records; } catch (TextParseException e) { throw new UnknownHostException("invalid name"); } }
// in org/xbill/DNS/Address.java
public static InetAddress getByAddress(String addr) throws UnknownHostException { byte [] bytes; bytes = toByteArray(addr, IPv4); if (bytes != null) return InetAddress.getByAddress(bytes); bytes = toByteArray(addr, IPv6); if (bytes != null) return InetAddress.getByAddress(bytes); throw new UnknownHostException("Invalid address: " + addr); }
// in org/xbill/DNS/Address.java
public static InetAddress getByAddress(String addr, int family) throws UnknownHostException { if (family != IPv4 && family != IPv6) throw new IllegalArgumentException("unknown address family"); byte [] bytes; bytes = toByteArray(addr, family); if (bytes != null) return InetAddress.getByAddress(bytes); throw new UnknownHostException("Invalid address: " + addr); }
// in org/xbill/DNS/Address.java
public static String getHostName(InetAddress addr) throws UnknownHostException { Name name = ReverseMap.fromAddress(addr); Record [] records = new Lookup(name, Type.PTR).run(); if (records == null) throw new UnknownHostException("unknown address"); PTRRecord ptr = (PTRRecord) records[0]; return ptr.getTarget().toString(); }
2
            
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (TextParseException e) { throw new UnknownHostException(host); }
// in org/xbill/DNS/Address.java
catch (TextParseException e) { throw new UnknownHostException("invalid name"); }
20
            
// in org/xbill/DNS/ReverseMap.java
public static Name fromAddress(String addr, int family) throws UnknownHostException { byte [] array = Address.toByteArray(addr, family); if (array == null) throw new UnknownHostException("Invalid IP address"); return fromAddress(array); }
// in org/xbill/DNS/ReverseMap.java
public static Name fromAddress(String addr) throws UnknownHostException { byte [] array = Address.toByteArray(addr, Address.IPv4); if (array == null) array = Address.toByteArray(addr, Address.IPv6); if (array == null) throw new UnknownHostException("Invalid IP address"); return fromAddress(array); }
// in org/xbill/DNS/spi/DNSJavaNameService.java
public InetAddress [] lookupAllHostAddr(String host) throws UnknownHostException { Name name = null; try { name = new Name(host); } catch (TextParseException e) { throw new UnknownHostException(host); } Record [] records = null; if (preferV6) records = new Lookup(name, Type.AAAA).run(); if (records == null) records = new Lookup(name, Type.A).run(); if (records == null && !preferV6) records = new Lookup(name, Type.AAAA).run(); if (records == null) throw new UnknownHostException(host); InetAddress[] array = new InetAddress[records.length]; for (int i = 0; i < records.length; i++) { Record record = records[i]; if (records[i] instanceof ARecord) { ARecord a = (ARecord) records[i]; array[i] = a.getAddress(); } else { AAAARecord aaaa = (AAAARecord) records[i]; array[i] = aaaa.getAddress(); } } return array; }
// in org/xbill/DNS/spi/DNSJavaNameService.java
public String getHostByAddr(byte [] addr) throws UnknownHostException { Name name = ReverseMap.fromAddress(InetAddress.getByAddress(addr)); Record [] records = new Lookup(name, Type.PTR).run(); if (records == null) throw new UnknownHostException(); return ((PTRRecord) records[0]).getTarget().toString(); }
// in org/xbill/DNS/Address.java
private static Record [] lookupHostName(String name) throws UnknownHostException { try { Record [] records = new Lookup(name).run(); if (records == null) throw new UnknownHostException("unknown host"); return records; } catch (TextParseException e) { throw new UnknownHostException("invalid name"); } }
// in org/xbill/DNS/Address.java
private static InetAddress addrFromRecord(String name, Record r) throws UnknownHostException { ARecord a = (ARecord) r; return InetAddress.getByAddress(name, a.getAddress().getAddress()); }
// in org/xbill/DNS/Address.java
public static InetAddress getByName(String name) throws UnknownHostException { try { return getByAddress(name); } catch (UnknownHostException e) { Record [] records = lookupHostName(name); return addrFromRecord(name, records[0]); } }
// in org/xbill/DNS/Address.java
public static InetAddress [] getAllByName(String name) throws UnknownHostException { try { InetAddress addr = getByAddress(name); return new InetAddress[] {addr}; } catch (UnknownHostException e) { Record [] records = lookupHostName(name); InetAddress [] addrs = new InetAddress[records.length]; for (int i = 0; i < records.length; i++) addrs[i] = addrFromRecord(name, records[i]); return addrs; } }
// in org/xbill/DNS/Address.java
public static InetAddress getByAddress(String addr) throws UnknownHostException { byte [] bytes; bytes = toByteArray(addr, IPv4); if (bytes != null) return InetAddress.getByAddress(bytes); bytes = toByteArray(addr, IPv6); if (bytes != null) return InetAddress.getByAddress(bytes); throw new UnknownHostException("Invalid address: " + addr); }
// in org/xbill/DNS/Address.java
public static InetAddress getByAddress(String addr, int family) throws UnknownHostException { if (family != IPv4 && family != IPv6) throw new IllegalArgumentException("unknown address family"); byte [] bytes; bytes = toByteArray(addr, family); if (bytes != null) return InetAddress.getByAddress(bytes); throw new UnknownHostException("Invalid address: " + addr); }
// in org/xbill/DNS/Address.java
public static String getHostName(InetAddress addr) throws UnknownHostException { Name name = ReverseMap.fromAddress(addr); Record [] records = new Lookup(name, Type.PTR).run(); if (records == null) throw new UnknownHostException("unknown address"); PTRRecord ptr = (PTRRecord) records[0]; return ptr.getTarget().toString(); }
// in org/xbill/DNS/ZoneTransferIn.java
public static ZoneTransferIn newAXFR(Name zone, String host, int port, TSIG key) throws UnknownHostException { if (port == 0) port = SimpleResolver.DEFAULT_PORT; return newAXFR(zone, new InetSocketAddress(host, port), key); }
// in org/xbill/DNS/ZoneTransferIn.java
public static ZoneTransferIn newAXFR(Name zone, String host, TSIG key) throws UnknownHostException { return newAXFR(zone, host, 0, key); }
// in org/xbill/DNS/ZoneTransferIn.java
public static ZoneTransferIn newIXFR(Name zone, long serial, boolean fallback, String host, int port, TSIG key) throws UnknownHostException { if (port == 0) port = SimpleResolver.DEFAULT_PORT; return newIXFR(zone, serial, fallback, new InetSocketAddress(host, port), key); }
// in org/xbill/DNS/ZoneTransferIn.java
public static ZoneTransferIn newIXFR(Name zone, long serial, boolean fallback, String host, TSIG key) throws UnknownHostException { return newIXFR(zone, serial, fallback, host, 0, key); }
10
            
// in org/xbill/DNS/ARecord.java
catch (UnknownHostException e) { return null; }
// in org/xbill/DNS/spi/DNSJavaNameService.java
catch (UnknownHostException e) { System.err.println("DNSJavaNameService: invalid " + nsProperty); }
// in org/xbill/DNS/Tokenizer.java
catch (UnknownHostException e) { throw exception(e.getMessage()); }
// in org/xbill/DNS/A6Record.java
catch (UnknownHostException e) { throw st.exception("invalid IPv6 address: " + s); }
// in org/xbill/DNS/Address.java
catch (UnknownHostException e) { Record [] records = lookupHostName(name); return addrFromRecord(name, records[0]); }
// in org/xbill/DNS/Address.java
catch (UnknownHostException e) { Record [] records = lookupHostName(name); InetAddress [] addrs = new InetAddress[records.length]; for (int i = 0; i < records.length; i++) addrs[i] = addrFromRecord(name, records[i]); return addrs; }
// in org/xbill/DNS/Address.java
catch (UnknownHostException e) { throw new IllegalArgumentException("invalid address"); }
// in org/xbill/DNS/ClientSubnetOption.java
catch (UnknownHostException e) { throw new WireParseException("invalid address", e); }
// in org/xbill/DNS/WKSRecord.java
catch (UnknownHostException e) { return null; }
// in org/xbill/DNS/Lookup.java
catch (UnknownHostException e) { throw new RuntimeException("Failed to initialize resolver"); }
5
            
// in org/xbill/DNS/Tokenizer.java
catch (UnknownHostException e) { throw exception(e.getMessage()); }
// in org/xbill/DNS/A6Record.java
catch (UnknownHostException e) { throw st.exception("invalid IPv6 address: " + s); }
// in org/xbill/DNS/Address.java
catch (UnknownHostException e) { throw new IllegalArgumentException("invalid address"); }
// in org/xbill/DNS/ClientSubnetOption.java
catch (UnknownHostException e) { throw new WireParseException("invalid address", e); }
// in org/xbill/DNS/Lookup.java
catch (UnknownHostException e) { throw new RuntimeException("Failed to initialize resolver"); }
2
checked (Domain) UnsupportedAlgorithmException
public static class UnsupportedAlgorithmException extends DNSSECException {
	UnsupportedAlgorithmException(int alg) {
		super("Unsupported algorithm: " + alg);
	}
}
4
            
// in org/xbill/DNS/DNSSEC.java
static PublicKey toPublicKey(KEYBase r) throws DNSSECException { int alg = r.getAlgorithm(); try { switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: return toRSAPublicKey(r); case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: return toDSAPublicKey(r); default: throw new UnsupportedAlgorithmException(alg); } } catch (IOException e) { throw new MalformedKeyException(r); } catch (GeneralSecurityException e) { throw new DNSSECException(e.toString()); } }
// in org/xbill/DNS/DNSSEC.java
static byte [] fromPublicKey(PublicKey key, int alg) throws DNSSECException { byte [] data = null; switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: if (! (key instanceof RSAPublicKey)) throw new IncompatibleKeyException(); return fromRSAPublicKey((RSAPublicKey) key); case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: if (! (key instanceof DSAPublicKey)) throw new IncompatibleKeyException(); return fromDSAPublicKey((DSAPublicKey) key); default: throw new UnsupportedAlgorithmException(alg); } }
// in org/xbill/DNS/DNSSEC.java
public static String algString(int alg) throws UnsupportedAlgorithmException { switch (alg) { case Algorithm.RSAMD5: return "MD5withRSA"; case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: return "SHA1withDSA"; case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: return "SHA1withRSA"; case Algorithm.RSASHA256: return "SHA256withRSA"; case Algorithm.RSASHA512: return "SHA512withRSA"; default: throw new UnsupportedAlgorithmException(alg); } }
// in org/xbill/DNS/DNSSEC.java
static void checkAlgorithm(PrivateKey key, int alg) throws UnsupportedAlgorithmException { switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: if (! (key instanceof RSAPrivateKey)) throw new IncompatibleKeyException(); break; case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: if (! (key instanceof DSAPrivateKey)) throw new IncompatibleKeyException(); break; default: throw new UnsupportedAlgorithmException(alg); } }
0 2
            
// in org/xbill/DNS/DNSSEC.java
public static String algString(int alg) throws UnsupportedAlgorithmException { switch (alg) { case Algorithm.RSAMD5: return "MD5withRSA"; case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: return "SHA1withDSA"; case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: return "SHA1withRSA"; case Algorithm.RSASHA256: return "SHA256withRSA"; case Algorithm.RSASHA512: return "SHA512withRSA"; default: throw new UnsupportedAlgorithmException(alg); } }
// in org/xbill/DNS/DNSSEC.java
static void checkAlgorithm(PrivateKey key, int alg) throws UnsupportedAlgorithmException { switch (alg) { case Algorithm.RSAMD5: case Algorithm.RSASHA1: case Algorithm.RSA_NSEC3_SHA1: case Algorithm.RSASHA256: case Algorithm.RSASHA512: if (! (key instanceof RSAPrivateKey)) throw new IncompatibleKeyException(); break; case Algorithm.DSA: case Algorithm.DSA_NSEC3_SHA1: if (! (key instanceof DSAPrivateKey)) throw new IncompatibleKeyException(); break; default: throw new UnsupportedAlgorithmException(alg); } }
0 0 0
runtime (Lib) UnsupportedOperationException 1
            
// in org/xbill/DNS/Zone.java
public void remove() { throw new UnsupportedOperationException(); }
0 0 0 0 0
checked (Domain) WireParseException
public class WireParseException extends IOException {

public
WireParseException() {
	super();
}

public
WireParseException(String s) {
	super(s);
}

public
WireParseException(String s, Throwable cause) {
	super(s);
	initCause(cause);
}

}
28
            
// in org/xbill/DNS/APLRecord.java
private static byte [] parseAddress(byte [] in, int length) throws WireParseException { if (in.length > length) throw new WireParseException("invalid address length"); if (in.length == length) return in; byte [] out = new byte[length]; System.arraycopy(in, 0, out, 0, in.length); return out; }
// in org/xbill/DNS/APLRecord.java
void rrFromWire(DNSInput in) throws IOException { elements = new ArrayList(1); while (in.remaining() != 0) { int family = in.readU16(); int prefix = in.readU8(); int length = in.readU8(); boolean negative = (length & 0x80) != 0; length &= ~0x80; byte [] data = in.readByteArray(length); Element element; if (!validatePrefixLength(family, prefix)) { throw new WireParseException("invalid prefix length"); } if (family == Address.IPv4 || family == Address.IPv6) { data = parseAddress(data, Address.addressLength(family)); InetAddress addr = InetAddress.getByAddress(data); element = new Element(negative, addr, prefix); } else { element = new Element(family, negative, data, prefix); } elements.add(element); } }
// in org/xbill/DNS/Record.java
private static Record newRecord(Name name, int type, int dclass, long ttl, int length, DNSInput in) throws IOException { Record rec; rec = getEmptyRecord(name, type, dclass, ttl, in != null); if (in != null) { if (in.remaining() < length) throw new WireParseException("truncated record"); in.setActive(length); rec.rrFromWire(in); if (in.remaining() > 0) throw new WireParseException("invalid record length"); in.clearActive(); } return rec; }
// in org/xbill/DNS/SimpleResolver.java
public Message send(Message query) throws IOException { if (Options.check("verbose")) System.err.println("Sending to " + address.getAddress().getHostAddress() + ":" + address.getPort()); if (query.getHeader().getOpcode() == Opcode.QUERY) { Record question = query.getQuestion(); if (question != null && question.getType() == Type.AXFR) return sendAXFR(query); } query = (Message) query.clone(); applyEDNS(query); if (tsig != null) tsig.apply(query, null); byte [] out = query.toWire(Message.MAXLENGTH); int udpSize = maxUDPSize(query); boolean tcp = false; long endTime = System.currentTimeMillis() + timeoutValue; do { byte [] in; if (useTCP || out.length > udpSize) tcp = true; if (tcp) in = TCPClient.sendrecv(localAddress, address, out, endTime); else in = UDPClient.sendrecv(localAddress, address, out, udpSize, endTime); /* * Check that the response is long enough. */ if (in.length < Header.LENGTH) { throw new WireParseException("invalid DNS header - " + "too short"); } /* * Check that the response ID matches the query ID. We want * to check this before actually parsing the message, so that * if there's a malformed response that's not ours, it * doesn't confuse us. */ int id = ((in[0] & 0xFF) << 8) + (in[1] & 0xFF); int qid = query.getHeader().getID(); if (id != qid) { String error = "invalid message id: expected " + qid + "; got id " + id; if (tcp) { throw new WireParseException(error); } else { if (Options.check("verbose")) { System.err.println(error); } continue; } } Message response = parseMessage(in); verifyTSIG(query, response, in, tsig); if (!tcp && !ignoreTruncation && response.getHeader().getFlag(Flags.TC)) { tcp = true; continue; } return response; } while (true); }
// in org/xbill/DNS/SimpleResolver.java
private Message sendAXFR(Message query) throws IOException { Name qname = query.getQuestion().getName(); ZoneTransferIn xfrin = ZoneTransferIn.newAXFR(qname, address, tsig); xfrin.setTimeout((int)(getTimeout() / 1000)); xfrin.setLocalAddress(localAddress); try { xfrin.run(); } catch (ZoneTransferException e) { throw new WireParseException(e.getMessage()); } List records = xfrin.getAXFR(); Message response = new Message(query.getHeader().getID()); response.getHeader().setFlag(Flags.AA); response.getHeader().setFlag(Flags.QR); response.addRecord(query.getQuestion(), Section.QUESTION); Iterator it = records.iterator(); while (it.hasNext()) response.addRecord((Record)it.next(), Section.ANSWER); return response; }
// in org/xbill/DNS/DNSInput.java
private void require(int n) throws WireParseException{ if (n > remaining()) { throw new WireParseException("end of input"); } }
// in org/xbill/DNS/IPSECKEYRecord.java
void rrFromWire(DNSInput in) throws IOException { precedence = in.readU8(); gatewayType = in.readU8(); algorithmType = in.readU8(); switch (gatewayType) { case Gateway.None: gateway = null; break; case Gateway.IPv4: gateway = InetAddress.getByAddress(in.readByteArray(4)); break; case Gateway.IPv6: gateway = InetAddress.getByAddress(in.readByteArray(16)); break; case Gateway.Name: gateway = new Name(in); break; default: throw new WireParseException("invalid gateway type"); } if (in.remaining() > 0) key = in.readByteArray(); }
// in org/xbill/DNS/IPSECKEYRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { precedence = st.getUInt8(); gatewayType = st.getUInt8(); algorithmType = st.getUInt8(); switch (gatewayType) { case Gateway.None: String s = st.getString(); if (!s.equals(".")) throw new TextParseException("invalid gateway format"); gateway = null; break; case Gateway.IPv4: gateway = st.getAddress(Address.IPv4); break; case Gateway.IPv6: gateway = st.getAddress(Address.IPv6); break; case Gateway.Name: gateway = st.getName(origin); break; default: throw new WireParseException("invalid gateway type"); } key = st.getBase64(false); }
// in org/xbill/DNS/GPOSRecord.java
void rrFromWire(DNSInput in) throws IOException { longitude = in.readCountedString(); latitude = in.readCountedString(); altitude = in.readCountedString(); try { validate(getLongitude(), getLatitude()); } catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); } }
// in org/xbill/DNS/GPOSRecord.java
void rdataFromString(Tokenizer st, Name origin) throws IOException { try { longitude = byteArrayFromString(st.getString()); latitude = byteArrayFromString(st.getString()); altitude = byteArrayFromString(st.getString()); } catch (TextParseException e) { throw st.exception(e.getMessage()); } try { validate(getLongitude(), getLatitude()); } catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); } }
// in org/xbill/DNS/LOCRecord.java
void rrFromWire(DNSInput in) throws IOException { int version; version = in.readU8(); if (version != 0) throw new WireParseException("Invalid LOC version"); size = parseLOCformat(in.readU8()); hPrecision = parseLOCformat(in.readU8()); vPrecision = parseLOCformat(in.readU8()); latitude = in.readU32(); longitude = in.readU32(); altitude = in.readU32(); }
// in org/xbill/DNS/LOCRecord.java
private static long parseLOCformat(int b) throws WireParseException { long out = b >> 4; int exp = b & 0xF; if (out > 9 || exp > 9) throw new WireParseException("Invalid LOC Encoding"); while (exp-- > 0) out *= 10; return (out); }
// in org/xbill/DNS/EDNSOption.java
static EDNSOption fromWire(DNSInput in) throws IOException { int code, length; code = in.readU16(); length = in.readU16(); if (in.remaining() < length) throw new WireParseException("truncated option"); int save = in.saveActive(); in.setActive(length); EDNSOption option; switch (code) { case Code.NSID: option = new NSIDOption(); break; case Code.CLIENT_SUBNET: option = new ClientSubnetOption(); break; default: option = new GenericEDNSOption(code); break; } option.optionFromWire(in); in.restoreActive(save); return option; }
// in org/xbill/DNS/ZoneTransferIn.java
private Message parseMessage(byte [] b) throws WireParseException { try { return new Message(b); } catch (IOException e) { if (e instanceof WireParseException) throw (WireParseException) e; throw new WireParseException("Error parsing message"); } }
// in org/xbill/DNS/ClientSubnetOption.java
void optionFromWire(DNSInput in) throws WireParseException { family = in.readU16(); if (family != Address.IPv4 && family != Address.IPv6) throw new WireParseException("unknown address family"); sourceNetmask = in.readU8(); if (sourceNetmask > Address.addressLength(family) * 8) throw new WireParseException("invalid source netmask"); scopeNetmask = in.readU8(); if (scopeNetmask > Address.addressLength(family) * 8) throw new WireParseException("invalid scope netmask"); // Read the truncated address byte [] addr = in.readByteArray(); if (addr.length != (sourceNetmask + 7) / 8) throw new WireParseException("invalid address"); // Convert it to a full length address. byte [] fulladdr = new byte[Address.addressLength(family)]; System.arraycopy(addr, 0, fulladdr, 0, addr.length); try { address = InetAddress.getByAddress(fulladdr); } catch (UnknownHostException e) { throw new WireParseException("invalid address", e); } InetAddress tmp = Address.truncate(address, sourceNetmask); if (!tmp.equals(address)) throw new WireParseException("invalid padding"); }
5
            
// in org/xbill/DNS/SimpleResolver.java
catch (ZoneTransferException e) { throw new WireParseException(e.getMessage()); }
// in org/xbill/DNS/GPOSRecord.java
catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); }
// in org/xbill/DNS/GPOSRecord.java
catch(IllegalArgumentException e) { throw new WireParseException(e.getMessage()); }
// in org/xbill/DNS/ZoneTransferIn.java
catch (IOException e) { if (e instanceof WireParseException) throw (WireParseException) e; throw new WireParseException("Error parsing message"); }
// in org/xbill/DNS/ClientSubnetOption.java
catch (UnknownHostException e) { throw new WireParseException("invalid address", e); }
14
            
// in org/xbill/DNS/APLRecord.java
private static byte [] parseAddress(byte [] in, int length) throws WireParseException { if (in.length > length) throw new WireParseException("invalid address length"); if (in.length == length) return in; byte [] out = new byte[length]; System.arraycopy(in, 0, out, 0, in.length); return out; }
// in org/xbill/DNS/SimpleResolver.java
private Message parseMessage(byte [] b) throws WireParseException { try { return (new Message(b)); } catch (IOException e) { if (Options.check("verbose")) e.printStackTrace(); if (!(e instanceof WireParseException)) e = new WireParseException("Error parsing message"); throw (WireParseException) e; } }
// in org/xbill/DNS/DNSInput.java
private void require(int n) throws WireParseException{ if (n > remaining()) { throw new WireParseException("end of input"); } }
// in org/xbill/DNS/DNSInput.java
public int readU8() throws WireParseException { require(1); return (array[pos++] & 0xFF); }
// in org/xbill/DNS/DNSInput.java
public int readU16() throws WireParseException { require(2); int b1 = array[pos++] & 0xFF; int b2 = array[pos++] & 0xFF; return ((b1 << 8) + b2); }
// in org/xbill/DNS/DNSInput.java
public long readU32() throws WireParseException { require(4); int b1 = array[pos++] & 0xFF; int b2 = array[pos++] & 0xFF; int b3 = array[pos++] & 0xFF; int b4 = array[pos++] & 0xFF; return (((long)b1 << 24) + (b2 << 16) + (b3 << 8) + b4); }
// in org/xbill/DNS/DNSInput.java
public void readByteArray(byte [] b, int off, int len) throws WireParseException { require(len); System.arraycopy(array, pos, b, off, len); pos += len; }
// in org/xbill/DNS/DNSInput.java
public byte [] readByteArray(int len) throws WireParseException { require(len); byte [] out = new byte[len]; System.arraycopy(array, pos, out, 0, len); pos += len; return out; }
// in org/xbill/DNS/DNSInput.java
public byte [] readCountedString() throws WireParseException { require(1); int len = array[pos++] & 0xFF; return readByteArray(len); }
// in org/xbill/DNS/LOCRecord.java
private static long parseLOCformat(int b) throws WireParseException { long out = b >> 4; int exp = b & 0xF; if (out > 9 || exp > 9) throw new WireParseException("Invalid LOC Encoding"); while (exp-- > 0) out *= 10; return (out); }
// in org/xbill/DNS/ZoneTransferIn.java
private Message parseMessage(byte [] b) throws WireParseException { try { return new Message(b); } catch (IOException e) { if (e instanceof WireParseException) throw (WireParseException) e; throw new WireParseException("Error parsing message"); } }
// in org/xbill/DNS/ClientSubnetOption.java
void optionFromWire(DNSInput in) throws WireParseException { family = in.readU16(); if (family != Address.IPv4 && family != Address.IPv6) throw new WireParseException("unknown address family"); sourceNetmask = in.readU8(); if (sourceNetmask > Address.addressLength(family) * 8) throw new WireParseException("invalid source netmask"); scopeNetmask = in.readU8(); if (scopeNetmask > Address.addressLength(family) * 8) throw new WireParseException("invalid scope netmask"); // Read the truncated address byte [] addr = in.readByteArray(); if (addr.length != (sourceNetmask + 7) / 8) throw new WireParseException("invalid address"); // Convert it to a full length address. byte [] fulladdr = new byte[Address.addressLength(family)]; System.arraycopy(addr, 0, fulladdr, 0, addr.length); try { address = InetAddress.getByAddress(fulladdr); } catch (UnknownHostException e) { throw new WireParseException("invalid address", e); } InetAddress tmp = Address.truncate(address, sourceNetmask); if (!tmp.equals(address)) throw new WireParseException("invalid padding"); }
1
            
// in org/xbill/DNS/Message.java
catch (WireParseException e) { if (!truncated) throw e; }
1
            
// in org/xbill/DNS/Message.java
catch (WireParseException e) { if (!truncated) throw e; }
0
checked (Domain) ZoneTransferException
public class ZoneTransferException extends Exception {

public
ZoneTransferException() {
	super();
}

public
ZoneTransferException(String s) {
	super(s);
}

}
1
            
// in org/xbill/DNS/ZoneTransferIn.java
private void fail(String s) throws ZoneTransferException { throw new ZoneTransferException(s); }
0 9
            
// in org/xbill/DNS/Zone.java
private void fromXFR(ZoneTransferIn xfrin) throws IOException, ZoneTransferException { data = new TreeMap(); origin = xfrin.getName(); List records = xfrin.run(); for (Iterator it = records.iterator(); it.hasNext(); ) { Record record = (Record) it.next(); maybeAddRecord(record); } if (!xfrin.isAXFR()) throw new IllegalArgumentException("zones can only be " + "created from AXFRs"); validate(); }
// in org/xbill/DNS/ZoneTransferIn.java
private void fail(String s) throws ZoneTransferException { throw new ZoneTransferException(s); }
// in org/xbill/DNS/ZoneTransferIn.java
private void fallback() throws ZoneTransferException { if (!want_fallback) fail("server doesn't support IXFR"); logxfr("falling back to AXFR"); qtype = Type.AXFR; state = INITIALSOA; }
// in org/xbill/DNS/ZoneTransferIn.java
private void parseRR(Record rec) throws ZoneTransferException { int type = rec.getType(); Delta delta; switch (state) { case INITIALSOA: if (type != Type.SOA) fail("missing initial SOA"); initialsoa = rec; // Remember the serial number in the initial SOA; we need it // to recognize the end of an IXFR. end_serial = getSOASerial(rec); if (qtype == Type.IXFR && Serial.compare(end_serial, ixfr_serial) <= 0) { logxfr("up to date"); state = END; break; } state = FIRSTDATA; break; case FIRSTDATA: // If the transfer begins with 1 SOA, it's an AXFR. // If it begins with 2 SOAs, it's an IXFR. if (qtype == Type.IXFR && type == Type.SOA && getSOASerial(rec) == ixfr_serial) { rtype = Type.IXFR; handler.startIXFR(); logxfr("got incremental response"); state = IXFR_DELSOA; } else { rtype = Type.AXFR; handler.startAXFR(); handler.handleRecord(initialsoa); logxfr("got nonincremental response"); state = AXFR; } parseRR(rec); // Restart... return; case IXFR_DELSOA: handler.startIXFRDeletes(rec); state = IXFR_DEL; break; case IXFR_DEL: if (type == Type.SOA) { current_serial = getSOASerial(rec); state = IXFR_ADDSOA; parseRR(rec); // Restart... return; } handler.handleRecord(rec); break; case IXFR_ADDSOA: handler.startIXFRAdds(rec); state = IXFR_ADD; break; case IXFR_ADD: if (type == Type.SOA) { long soa_serial = getSOASerial(rec); if (soa_serial == end_serial) { state = END; break; } else if (soa_serial != current_serial) { fail("IXFR out of sync: expected serial " + current_serial + " , got " + soa_serial); } else { state = IXFR_DELSOA; parseRR(rec); // Restart... return; } } handler.handleRecord(rec); break; case AXFR: // Old BINDs sent cross class A records for non IN classes. if (type == Type.A && rec.getDClass() != dclass) break; handler.handleRecord(rec); if (type == Type.SOA) { state = END; } break; case END: fail("extra data"); break; default: fail("invalid state"); break; } }
// in org/xbill/DNS/ZoneTransferIn.java
private void doxfr() throws IOException, ZoneTransferException { sendQuery(); while (state != END) { byte [] in = client.recv(); Message response = parseMessage(in); if (response.getHeader().getRcode() == Rcode.NOERROR && verifier != null) { TSIGRecord tsigrec = response.getTSIG(); int error = verifier.verify(response, in); if (error != Rcode.NOERROR) fail("TSIG failure"); } Record [] answers = response.getSectionArray(Section.ANSWER); if (state == INITIALSOA) { int rcode = response.getRcode(); if (rcode != Rcode.NOERROR) { if (qtype == Type.IXFR && rcode == Rcode.NOTIMP) { fallback(); doxfr(); return; } fail(Rcode.string(rcode)); } Record question = response.getQuestion(); if (question != null && question.getType() != qtype) { fail("invalid question section"); } if (answers.length == 0 && qtype == Type.IXFR) { fallback(); doxfr(); return; } } for (int i = 0; i < answers.length; i++) { parseRR(answers[i]); } if (state == END && verifier != null && !response.isVerified()) fail("last message must be signed"); } }
// in org/xbill/DNS/ZoneTransferIn.java
public void run(ZoneTransferHandler handler) throws IOException, ZoneTransferException { this.handler = handler; try { openConnection(); doxfr(); } finally { closeConnection(); } }
// in org/xbill/DNS/ZoneTransferIn.java
public List run() throws IOException, ZoneTransferException { BasicHandler handler = new BasicHandler(); run(handler); if (handler.axfr != null) return handler.axfr; return handler.ixfr; }
1
            
// in org/xbill/DNS/SimpleResolver.java
catch (ZoneTransferException e) { throw new WireParseException(e.getMessage()); }
1
            
// in org/xbill/DNS/SimpleResolver.java
catch (ZoneTransferException e) { throw new WireParseException(e.getMessage()); }
0

Miscellanous Metrics

nF = Number of Finally 9
nF = Number of Try-Finally (without catch) 9
Number of Methods with Finally (nMF) 9 / 1355 (0.7%)
Number of Finally with a Continue 0
Number of Finally with a Return 0
Number of Finally with a Throw 0
Number of Finally with a Break 0
Number of different exception types thrown 27
Number of Domain exception types thrown 16
Number of different exception types caught 18
Number of Domain exception types caught 5
Number of exception declarations in signatures 279
Number of different exceptions types declared in method signatures 15
Number of library exceptions types declared in method signatures 8
Number of Domain exceptions types declared in method signatures 7
Number of Catch with a continue 1
Number of Catch with a return 16
Number of Catch with a Break 1
nbIf = Number of If 1118
nbFor = Number of For 162
Number of Method with an if 425 / 1355
Number of Methods with a for 124 / 1355
Number of Method starting with a try 18 / 1355 (1.3%)
Number of Expressions 13797
Number of Expressions in try 866 (6.3%)