Author: erodriguez Date: Fri Jan 21 14:19:28 2005 New Revision: 125971 URL: http://svn.apache.org/viewcvs?view=rev&rev=125971 Log: Basic implementations of the standard DNS record types. Added: incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/CanonicalNameRecord.java incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/HostInformationRecord.java incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/MailExchangeRecord.java incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/MailInformationRecord.java incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/NameServerRecord.java incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/PointerRecord.java incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/StartOfAuthorityRecord.java incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/TextRecord.java
Added: incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/CanonicalNameRecord.java Url: http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/CanonicalNameRecord.java?view=auto&rev=125971 ============================================================================== --- (empty file) +++ incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/CanonicalNameRecord.java Fri Jan 21 14:19:28 2005 @@ -0,0 +1,67 @@ +/* + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.dns.records.standard; + +import org.apache.dns.records.InternetResource; +import org.apache.dns.records.RecordType; +import org.apache.dns.records.ResourceRecord; + +/** + * 3.3.1. CNAME RDATA format + * + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * / CNAME / + * / / + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * + * where: + * + * CNAME A <domain-name> which specifies the canonical or primary + * name for the owner. The owner name is an alias. + * + * CNAME RRs cause no additional section processing, but name servers may + * choose to restart the query at the canonical name in certain cases. See + * the description of name server logic in [RFC-1034] for details. + */ +public class CanonicalNameRecord extends InternetResource +{ + /** + * Basic ResourceRecord constructor. + */ + public CanonicalNameRecord( String domainName, int timeToLive, byte[] resourceData ) + { + super( domainName, RecordType.CNAME, timeToLive, resourceData ); + } + + /** + * Static factory method, type-conversion operator. + */ + public static ResourceRecord valueOf( String domainName, int timeToLive, String canonicalName ) + { + return new CanonicalNameRecord( domainName, timeToLive, domainNameToByteArray( canonicalName ) ); + } + + /** + * Lazy accessor. + */ + public String getCanonicalName() + { + return byteArrayToDomainName( resourceData ); + } +} + Added: incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/HostInformationRecord.java Url: http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/HostInformationRecord.java?view=auto&rev=125971 ============================================================================== --- (empty file) +++ incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/HostInformationRecord.java Fri Jan 21 14:19:28 2005 @@ -0,0 +1,52 @@ +/* + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.dns.records.standard; + +import org.apache.dns.records.InternetResource; +import org.apache.dns.records.RecordType; + +/** + * 3.3.2. HINFO RDATA format + * + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * / CPU / + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * / OS / + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * + * where: + * + * CPU A <character-string> which specifies the CPU type. + * + * OS A <character-string> which specifies the operating + * system type. + * + * Standard values for CPU and OS can be found in [RFC-1010]. + * + * HINFO records are used to acquire general information about a host. The + * main use is for protocols such as FTP that can use special procedures + * when talking between machines or operating systems of the same type. + */ +public class HostInformationRecord extends InternetResource +{ + public HostInformationRecord( String domainName, int timeToLive, byte[] resourceData ) + { + super( domainName, RecordType.HINFO, timeToLive, resourceData ); + } +} + Added: incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/MailExchangeRecord.java Url: http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/MailExchangeRecord.java?view=auto&rev=125971 ============================================================================== --- (empty file) +++ incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/MailExchangeRecord.java Fri Jan 21 14:19:28 2005 @@ -0,0 +1,100 @@ +/* + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.dns.records.standard; + +import org.apache.dns.records.InternetResource; +import org.apache.dns.records.RecordType; +import org.apache.dns.records.ResourceRecord; + +/** + * 3.3.9. MX RDATA format + * + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * | PREFERENCE | + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * / EXCHANGE / + * / / + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * + * where: + * + * PREFERENCE A 16 bit integer which specifies the preference given to + * this RR among others at the same owner. Lower values + * are preferred. + * + * EXCHANGE A <domain-name> which specifies a host willing to act as + * a mail exchange for the owner name. + * + * MX records cause type A additional section processing for the host + * specified by EXCHANGE. The use of MX RRs is explained in detail in + * [RFC-974]. + */ +public class MailExchangeRecord extends InternetResource +{ + /** + * Basic ResourceRecord constructor. + */ + public MailExchangeRecord( String domainName, int timeToLive, byte[] resourceData ) + { + super( domainName, RecordType.MX, timeToLive, resourceData ); + } + + /** + * Static factory method, type-conversion operator. + */ + public static ResourceRecord valueOf( String domainName, int timeToLive, int preference, String exchange ) + { + byte[] exchangeBytes = exchange.getBytes(); + + byte[] resourceData = new byte[ 2 + exchangeBytes.length ]; + + resourceData[0] = (byte)( preference & 0x000000FF ); + resourceData[1] = (byte)( preference & 0x0000FF00 ); + + for ( int ii = 0; ii < exchangeBytes.length; ii++ ) + { + resourceData[ ii + 2 ] = exchangeBytes[ ii ]; + } + + return new MailExchangeRecord( domainName, timeToLive, resourceData ); + } + + /** + * Lazy accessor for the MX preference. + */ + public int getPreference() + { + return ( resourceData[1] * 256 ) + ( resourceData[0] * 1 ); + } + + /** + * Lazy accessor for the MX domain name. + */ + public String getMailExchange() + { + byte[] exchange = new byte[ resourceData.length - 2 ]; + + for ( int ii = 0; ii < resourceData.length - 2; ii++ ) + { + exchange[ ii ] = resourceData[ ii + 2 ]; + } + + return new String( exchange ); + } +} + Added: incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/MailInformationRecord.java Url: http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/MailInformationRecord.java?view=auto&rev=125971 ============================================================================== --- (empty file) +++ incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/MailInformationRecord.java Fri Jan 21 14:19:28 2005 @@ -0,0 +1,60 @@ +/* + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.dns.records.standard; + +import org.apache.dns.records.InternetResource; +import org.apache.dns.records.RecordType; + +/** + * 3.3.7. MINFO RDATA format (EXPERIMENTAL) + * + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * / RMAILBX / + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * / EMAILBX / + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * + * where: + * + * RMAILBX A <domain-name> which specifies a mailbox which is + * responsible for the mailing list or mailbox. If this + * domain name names the root, the owner of the MINFO RR is + * responsible for itself. Note that many existing mailing + * lists use a mailbox X-request for the RMAILBX field of + * mailing list X, e.g., Msgroup-request for Msgroup. This + * field provides a more general mechanism. + * + * EMAILBX A <domain-name> which specifies a mailbox which is to + * receive error messages related to the mailing list or + * mailbox specified by the owner of the MINFO RR (similar + * to the ERRORS-TO: field which has been proposed). If + * this domain name names the root, errors should be + * returned to the sender of the message. + * + * MINFO records cause no additional section processing. Although these + * records can be associated with a simple mailbox, they are usually used + * with a mailing list. + */ +public class MailInformationRecord extends InternetResource +{ + public MailInformationRecord( String domainName, int timeToLive, byte[] resourceData ) + { + super( domainName, RecordType.MINFO, timeToLive, resourceData ); + } +} + Added: incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/NameServerRecord.java Url: http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/NameServerRecord.java?view=auto&rev=125971 ============================================================================== --- (empty file) +++ incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/NameServerRecord.java Fri Jan 21 14:19:28 2005 @@ -0,0 +1,74 @@ +/* + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.dns.records.standard; + +import org.apache.dns.records.InternetResource; +import org.apache.dns.records.RecordType; +import org.apache.dns.records.ResourceRecord; + +/** + * 3.3.11. NS RDATA format + * + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * / NSDNAME / + * / / + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * + * where: + * + * NSDNAME A <domain-name> which specifies a host which should be + * authoritative for the specified class and domain. + * + * NS records cause both the usual additional section processing to locate + * a type A record, and, when used in a referral, a special search of the + * zone in which they reside for glue information. + * + * The NS RR states that the named host should be expected to have a zone + * starting at owner name of the specified class. Note that the class may + * not indicate the protocol family which should be used to communicate + * with the host, although it is typically a strong hint. For example, + * hosts which are name servers for either Internet (IN) or Hesiod (HS) + * class information are normally queried using IN class protocols. + */ +public class NameServerRecord extends InternetResource +{ + /** + * Basic ResourceRecord constructor. + */ + public NameServerRecord( String domainName, int timeToLive, byte[] resourceData ) + { + super( domainName, RecordType.NS, timeToLive, resourceData ); + } + + /** + * Static factory method, type-conversion operator. + */ + public static ResourceRecord valueOf( String domainName, int timeToLive, String nameServer ) + { + return new NameServerRecord( domainName, timeToLive, domainNameToByteArray( nameServer ) ); + } + + /** + * Lazy accessor. + */ + public String getNameServer() + { + return byteArrayToDomainName( resourceData ); + } +} + Added: incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/PointerRecord.java Url: http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/PointerRecord.java?view=auto&rev=125971 ============================================================================== --- (empty file) +++ incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/PointerRecord.java Fri Jan 21 14:19:28 2005 @@ -0,0 +1,68 @@ +/* + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.dns.records.standard; + +import org.apache.dns.records.InternetResource; +import org.apache.dns.records.RecordType; +import org.apache.dns.records.ResourceRecord; + +/** + * 3.3.12. PTR RDATA format + * + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * / PTRDNAME / + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * + * where: + * + * PTRDNAME A <domain-name> which points to some location in the + * domain name space. + * + * PTR records cause no additional section processing. These RRs are used + * in special domains to point to some other location in the domain space. + * These records are simple data, and don't imply any special processing + * similar to that performed by CNAME, which identifies aliases. See the + * description of the IN-ADDR.ARPA domain for an example. + */ +public class PointerRecord extends InternetResource +{ + /** + * Basic ResourceRecord constructor. + */ + public PointerRecord( String domainName, int timeToLive, byte[] resourceData ) + { + super( domainName, RecordType.PTR, timeToLive, resourceData ); + } + + /** + * Static factory method, type-conversion operator. + */ + public static ResourceRecord valueOf( String domainName, int timeToLive, String pointer ) + { + return new PointerRecord( domainName, timeToLive, domainNameToByteArray( pointer ) ); + } + + /** + * Lazy accessor. + */ + public String getPointer() + { + return byteArrayToDomainName( resourceData ); + } +} + Added: incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/StartOfAuthorityRecord.java Url: http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/StartOfAuthorityRecord.java?view=auto&rev=125971 ============================================================================== --- (empty file) +++ incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/StartOfAuthorityRecord.java Fri Jan 21 14:19:28 2005 @@ -0,0 +1,96 @@ +/* + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.dns.records.standard; + +import org.apache.dns.records.InternetResource; +import org.apache.dns.records.RecordType; + +/** + * 3.3.13. SOA RDATA format + * + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * / MNAME / + * / / + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * / RNAME / + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * | SERIAL | + * | | + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * | REFRESH | + * | | + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * | RETRY | + * | | + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * | EXPIRE | + * | | + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * | MINIMUM | + * | | + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * + * where: + * + * MNAME The <domain-name> of the name server that was the + * original or primary source of data for this zone. + * + * RNAME A <domain-name> which specifies the mailbox of the + * person responsible for this zone. + * + * SERIAL The unsigned 32 bit version number of the original copy + * of the zone. Zone transfers preserve this value. This + * value wraps and should be compared using sequence space + * arithmetic. + * + * REFRESH A 32 bit time interval before the zone should be + * refreshed. + * + * RETRY A 32 bit time interval that should elapse before a + * failed refresh should be retried. + * + * EXPIRE A 32 bit time value that specifies the upper limit on + * the time interval that can elapse before the zone is no + * longer authoritative. + * + * MINIMUM The unsigned 32 bit minimum TTL field that should be + * exported with any RR from this zone. + * + * SOA records cause no additional section processing. + * + * All times are in units of seconds. + * + * Most of these fields are pertinent only for name server maintenance + * operations. However, MINIMUM is used in all query operations that + * retrieve RRs from a zone. Whenever a RR is sent in a response to a + * query, the TTL field is set to the maximum of the TTL field from the RR + * and the MINIMUM field in the appropriate SOA. Thus MINIMUM is a lower + * bound on the TTL field for all RRs in a zone. Note that this use of + * MINIMUM should occur when the RRs are copied into the response and not + * when the zone is loaded from a master file or via a zone transfer. The + * reason for this provison is to allow future dynamic update facilities to + * change the SOA RR with known semantics. + */ +public class StartOfAuthorityRecord extends InternetResource +{ + public StartOfAuthorityRecord( String domainName, int timeToLive, byte[] resourceData ) + { + super( domainName, RecordType.SOA, timeToLive, resourceData ); + } +} + Added: incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/TextRecord.java Url: http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/TextRecord.java?view=auto&rev=125971 ============================================================================== --- (empty file) +++ incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/standard/TextRecord.java Fri Jan 21 14:19:28 2005 @@ -0,0 +1,64 @@ +/* + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.dns.records.standard; + +import org.apache.dns.records.InternetResource; +import org.apache.dns.records.RecordType; +import org.apache.dns.records.ResourceRecord; + +/** + * 3.3.14. TXT RDATA format + * + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * / TXT-DATA / + * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + * + * where: + * + * TXT-DATA One or more <character-string>s. + * + * TXT RRs are used to hold descriptive text. The semantics of the text + * depends on the domain where it is found. + */ +public class TextRecord extends InternetResource +{ + /** + * Basic ResourceRecord constructor. + */ + public TextRecord( String domainName, int timeToLive, byte[] resourceData ) + { + super( domainName, RecordType.TXT, timeToLive, resourceData ); + } + + /** + * Static factory method, type-conversion operator. + */ + public static ResourceRecord valueOf( String domainName, int timeToLive, String text ) + { + return new TextRecord( domainName, timeToLive, text.getBytes() ); + } + + /** + * Lazy accessor. + */ + public String getText() + { + return new String( resourceData ); + } +} +
