You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2006/02/20 04:58:21 UTC
svn commit: r379013 [34/45] - in /directory/trunks/apacheds: ./ core-plugin/
core-plugin/src/main/java/org/apache/directory/server/core/tools/schema/
core-plugin/src/test/java/org/apache/directory/server/core/tools/schema/
core-shared/ core-shared/src/...
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsDecoder.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsDecoder.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsDecoder.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsDecoder.java Sun Feb 19 19:57:02 2006
@@ -1,246 +1,264 @@
-/*
- * 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.directory.server.dns.protocol;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.directory.server.dns.io.decoder.Decoder;
-import org.apache.directory.server.dns.messages.DnsMessage;
-import org.apache.directory.server.dns.messages.DnsMessageModifier;
-import org.apache.directory.server.dns.messages.MessageType;
-import org.apache.directory.server.dns.messages.OpCode;
-import org.apache.directory.server.dns.messages.QuestionRecord;
-import org.apache.directory.server.dns.messages.QuestionRecords;
-import org.apache.directory.server.dns.messages.RecordClass;
-import org.apache.directory.server.dns.messages.RecordType;
-import org.apache.directory.server.dns.messages.ResourceRecordImpl;
-import org.apache.directory.server.dns.messages.ResourceRecords;
-import org.apache.directory.server.dns.messages.ResponseCode;
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.codec.ProtocolDecoder;
-import org.apache.mina.filter.codec.ProtocolDecoderOutput;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DnsDecoder implements ProtocolDecoder
-{
- /** the log for this class */
- private static final Logger log = LoggerFactory.getLogger( DnsDecoder.class );
-
- /**
- * A Hashed Adapter mapping record types to their encoders.
- */
- private static final Map DEFAULT_DECODERS;
-
- static
- {
- Map map = new HashMap();
-
- // map.put( RecordType.SOA, new StartOfAuthorityRecordEncoder() );
-
- DEFAULT_DECODERS = Collections.unmodifiableMap( map );
- }
-
- public void decode( IoSession session, ByteBuffer in, ProtocolDecoderOutput out )
- {
- out.write( decode( in ) );
- }
-
- DnsMessage decode( ByteBuffer in )
- {
- DnsMessageModifier modifier = new DnsMessageModifier();
-
- modifier.setTransactionId( in.getShort() );
-
- byte header = in.get();
- modifier.setMessageType( decodeMessageType( header ) );
- modifier.setOpCode( decodeOpCode( header ) );
- modifier.setAuthoritativeAnswer( decodeAuthoritativeAnswer( header ) );
- modifier.setTruncated( decodeTruncated( header ) );
- modifier.setRecursionDesired( decodeRecursionDesired( header ) );
-
- header = in.get();
- modifier.setRecursionAvailable( decodeRecursionAvailable( header ) );
- modifier.setResponseCode( decodeResponseCode( header ) );
-
- short questionCount = in.getShort();
- short answerCount = in.getShort();
- short authorityCount = in.getShort();
- short additionalCount = in.getShort();
-
- modifier.setQuestionRecords( decodeQuestions( questionCount, in ) );
- modifier.setAnswerRecords( decodeRecords( answerCount, in ) );
- modifier.setAuthorityRecords( decodeRecords( authorityCount, in ) );
- modifier.setAdditionalRecords( decodeRecords( additionalCount, in ) );
-
- return modifier.getDnsMessage();
- }
-
- private ResourceRecords decodeRecords( short recordCount, ByteBuffer byteBuffer )
- {
- ResourceRecords records = new ResourceRecords( recordCount );
-
- for ( int ii = 0; ii < recordCount; ii++ )
- {
- String domainName = decodeDomainName( byteBuffer );
-
- RecordType recordType = RecordType.getTypeByOrdinal( byteBuffer.getShort() );
- RecordClass recordClass = RecordClass.getTypeByOrdinal( byteBuffer.getShort() );
-
- int timeToLive = byteBuffer.getInt();
- short dataLength = byteBuffer.getShort();
-
- byte[] data = new byte[ dataLength ];
- byteBuffer.get( data );
-
- try
- {
- Map attributes = decode( recordType, data );
- records.add( new ResourceRecordImpl( domainName, recordType, recordClass, timeToLive, attributes ) );
- }
- catch ( IOException ioe )
- {
- log.error( ioe.getMessage(), ioe );
- }
- }
-
- return records;
- }
-
- private Map decode( RecordType type, byte[] resourceData ) throws IOException
- {
- Decoder decoder = (Decoder) DEFAULT_DECODERS.get( type );
-
- if ( decoder == null )
- {
- throw new IOException( "Decoder unavailable for " + type );
- }
-
- return decoder.decode( resourceData );
- }
-
- private QuestionRecords decodeQuestions( short questionCount, ByteBuffer byteBuffer )
- {
- QuestionRecords questions = new QuestionRecords( questionCount );
-
- for ( int ii = 0; ii < questionCount; ii++ )
- {
- String domainName = decodeDomainName( byteBuffer );
-
- RecordType recordType = RecordType.getTypeByOrdinal( byteBuffer.getShort() );
- RecordClass recordClass = RecordClass.getTypeByOrdinal( byteBuffer.getShort() );
-
- questions.add( new QuestionRecord( domainName, recordType, recordClass ) );
- }
-
- return questions;
- }
-
- private String decodeDomainName( ByteBuffer byteBuffer )
- {
- StringBuffer domainName = new StringBuffer();
- recurseDomainName( domainName, byteBuffer );
-
- return domainName.toString();
- }
-
- private void recurseDomainName( StringBuffer domainName, ByteBuffer byteBuffer )
- {
- byte currentByte = byteBuffer.get();
-
- boolean isCompressed = ( ( currentByte & (byte) 0xc0 ) == (byte) 0xc0 );
- boolean isLabelLength = ( ( currentByte != 0 ) && !isCompressed );
-
- if ( isCompressed )
- {
- int position = byteBuffer.get();
- int originalPosition = byteBuffer.position();
- byteBuffer.position( position );
-
- int labelLength = byteBuffer.get();
- getLabel( labelLength, byteBuffer, domainName );
- recurseDomainName( domainName, byteBuffer );
-
- byteBuffer.position( originalPosition );
- }
-
- if ( isLabelLength )
- {
- int labelLength = currentByte;
- getLabel( labelLength, byteBuffer, domainName );
- recurseDomainName( domainName, byteBuffer );
- }
- }
-
- private void getLabel( int labelLength, ByteBuffer byteBuffer, StringBuffer domainName )
- {
- for ( int jj = 0; jj < labelLength; jj++ )
- {
- char character = (char) byteBuffer.get();
- domainName.append( character );
- }
-
- if ( byteBuffer.get( byteBuffer.position() ) != 0 )
- {
- domainName.append( "." );
- }
- }
-
- private MessageType decodeMessageType( byte header )
- {
- return MessageType.getTypeByOrdinal( ( header & 0x80 ) >>> 7 );
- }
-
- private OpCode decodeOpCode( byte header )
- {
- return OpCode.getTypeByOrdinal( ( header & 0x78 ) >>> 3 );
- }
-
- private boolean decodeAuthoritativeAnswer( byte header )
- {
- return ( ( header & 0x04 ) >>> 2 ) == 1;
- }
-
- private boolean decodeTruncated( byte header )
- {
- return ( ( header & 0x02 ) >>> 1 ) == 1;
- }
-
- private boolean decodeRecursionDesired( byte header )
- {
- return ( ( header & 0x01 ) ) == 1;
- }
-
- private boolean decodeRecursionAvailable( byte header )
- {
- return ( ( header & 0x80 ) >>> 7 ) == 1;
- }
-
- private ResponseCode decodeResponseCode( byte header )
- {
- return ResponseCode.getTypeByOrdinal( header & 0x0F );
- }
-
- public void dispose( IoSession arg0 ) throws Exception
- {
- }
-}
+/*
+ * 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.directory.server.dns.protocol;
+
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.directory.server.dns.io.decoder.Decoder;
+import org.apache.directory.server.dns.messages.DnsMessage;
+import org.apache.directory.server.dns.messages.DnsMessageModifier;
+import org.apache.directory.server.dns.messages.MessageType;
+import org.apache.directory.server.dns.messages.OpCode;
+import org.apache.directory.server.dns.messages.QuestionRecord;
+import org.apache.directory.server.dns.messages.QuestionRecords;
+import org.apache.directory.server.dns.messages.RecordClass;
+import org.apache.directory.server.dns.messages.RecordType;
+import org.apache.directory.server.dns.messages.ResourceRecordImpl;
+import org.apache.directory.server.dns.messages.ResourceRecords;
+import org.apache.directory.server.dns.messages.ResponseCode;
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class DnsDecoder implements ProtocolDecoder
+{
+ /** the log for this class */
+ private static final Logger log = LoggerFactory.getLogger( DnsDecoder.class );
+
+ /**
+ * A Hashed Adapter mapping record types to their encoders.
+ */
+ private static final Map DEFAULT_DECODERS;
+
+ static
+ {
+ Map map = new HashMap();
+
+ // map.put( RecordType.SOA, new StartOfAuthorityRecordEncoder() );
+
+ DEFAULT_DECODERS = Collections.unmodifiableMap( map );
+ }
+
+
+ public void decode( IoSession session, ByteBuffer in, ProtocolDecoderOutput out )
+ {
+ out.write( decode( in ) );
+ }
+
+
+ DnsMessage decode( ByteBuffer in )
+ {
+ DnsMessageModifier modifier = new DnsMessageModifier();
+
+ modifier.setTransactionId( in.getShort() );
+
+ byte header = in.get();
+ modifier.setMessageType( decodeMessageType( header ) );
+ modifier.setOpCode( decodeOpCode( header ) );
+ modifier.setAuthoritativeAnswer( decodeAuthoritativeAnswer( header ) );
+ modifier.setTruncated( decodeTruncated( header ) );
+ modifier.setRecursionDesired( decodeRecursionDesired( header ) );
+
+ header = in.get();
+ modifier.setRecursionAvailable( decodeRecursionAvailable( header ) );
+ modifier.setResponseCode( decodeResponseCode( header ) );
+
+ short questionCount = in.getShort();
+ short answerCount = in.getShort();
+ short authorityCount = in.getShort();
+ short additionalCount = in.getShort();
+
+ modifier.setQuestionRecords( decodeQuestions( questionCount, in ) );
+ modifier.setAnswerRecords( decodeRecords( answerCount, in ) );
+ modifier.setAuthorityRecords( decodeRecords( authorityCount, in ) );
+ modifier.setAdditionalRecords( decodeRecords( additionalCount, in ) );
+
+ return modifier.getDnsMessage();
+ }
+
+
+ private ResourceRecords decodeRecords( short recordCount, ByteBuffer byteBuffer )
+ {
+ ResourceRecords records = new ResourceRecords( recordCount );
+
+ for ( int ii = 0; ii < recordCount; ii++ )
+ {
+ String domainName = decodeDomainName( byteBuffer );
+
+ RecordType recordType = RecordType.getTypeByOrdinal( byteBuffer.getShort() );
+ RecordClass recordClass = RecordClass.getTypeByOrdinal( byteBuffer.getShort() );
+
+ int timeToLive = byteBuffer.getInt();
+ short dataLength = byteBuffer.getShort();
+
+ byte[] data = new byte[dataLength];
+ byteBuffer.get( data );
+
+ try
+ {
+ Map attributes = decode( recordType, data );
+ records.add( new ResourceRecordImpl( domainName, recordType, recordClass, timeToLive, attributes ) );
+ }
+ catch ( IOException ioe )
+ {
+ log.error( ioe.getMessage(), ioe );
+ }
+ }
+
+ return records;
+ }
+
+
+ private Map decode( RecordType type, byte[] resourceData ) throws IOException
+ {
+ Decoder decoder = ( Decoder ) DEFAULT_DECODERS.get( type );
+
+ if ( decoder == null )
+ {
+ throw new IOException( "Decoder unavailable for " + type );
+ }
+
+ return decoder.decode( resourceData );
+ }
+
+
+ private QuestionRecords decodeQuestions( short questionCount, ByteBuffer byteBuffer )
+ {
+ QuestionRecords questions = new QuestionRecords( questionCount );
+
+ for ( int ii = 0; ii < questionCount; ii++ )
+ {
+ String domainName = decodeDomainName( byteBuffer );
+
+ RecordType recordType = RecordType.getTypeByOrdinal( byteBuffer.getShort() );
+ RecordClass recordClass = RecordClass.getTypeByOrdinal( byteBuffer.getShort() );
+
+ questions.add( new QuestionRecord( domainName, recordType, recordClass ) );
+ }
+
+ return questions;
+ }
+
+
+ private String decodeDomainName( ByteBuffer byteBuffer )
+ {
+ StringBuffer domainName = new StringBuffer();
+ recurseDomainName( domainName, byteBuffer );
+
+ return domainName.toString();
+ }
+
+
+ private void recurseDomainName( StringBuffer domainName, ByteBuffer byteBuffer )
+ {
+ byte currentByte = byteBuffer.get();
+
+ boolean isCompressed = ( ( currentByte & ( byte ) 0xc0 ) == ( byte ) 0xc0 );
+ boolean isLabelLength = ( ( currentByte != 0 ) && !isCompressed );
+
+ if ( isCompressed )
+ {
+ int position = byteBuffer.get();
+ int originalPosition = byteBuffer.position();
+ byteBuffer.position( position );
+
+ int labelLength = byteBuffer.get();
+ getLabel( labelLength, byteBuffer, domainName );
+ recurseDomainName( domainName, byteBuffer );
+
+ byteBuffer.position( originalPosition );
+ }
+
+ if ( isLabelLength )
+ {
+ int labelLength = currentByte;
+ getLabel( labelLength, byteBuffer, domainName );
+ recurseDomainName( domainName, byteBuffer );
+ }
+ }
+
+
+ private void getLabel( int labelLength, ByteBuffer byteBuffer, StringBuffer domainName )
+ {
+ for ( int jj = 0; jj < labelLength; jj++ )
+ {
+ char character = ( char ) byteBuffer.get();
+ domainName.append( character );
+ }
+
+ if ( byteBuffer.get( byteBuffer.position() ) != 0 )
+ {
+ domainName.append( "." );
+ }
+ }
+
+
+ private MessageType decodeMessageType( byte header )
+ {
+ return MessageType.getTypeByOrdinal( ( header & 0x80 ) >>> 7 );
+ }
+
+
+ private OpCode decodeOpCode( byte header )
+ {
+ return OpCode.getTypeByOrdinal( ( header & 0x78 ) >>> 3 );
+ }
+
+
+ private boolean decodeAuthoritativeAnswer( byte header )
+ {
+ return ( ( header & 0x04 ) >>> 2 ) == 1;
+ }
+
+
+ private boolean decodeTruncated( byte header )
+ {
+ return ( ( header & 0x02 ) >>> 1 ) == 1;
+ }
+
+
+ private boolean decodeRecursionDesired( byte header )
+ {
+ return ( ( header & 0x01 ) ) == 1;
+ }
+
+
+ private boolean decodeRecursionAvailable( byte header )
+ {
+ return ( ( header & 0x80 ) >>> 7 ) == 1;
+ }
+
+
+ private ResponseCode decodeResponseCode( byte header )
+ {
+ return ResponseCode.getTypeByOrdinal( header & 0x0F );
+ }
+
+
+ public void dispose( IoSession arg0 ) throws Exception
+ {
+ }
+}
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsDecoder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsDecoder.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsEncoder.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsEncoder.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsEncoder.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsEncoder.java Sun Feb 19 19:57:02 2006
@@ -1,219 +1,234 @@
-/*
- * 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.directory.server.dns.protocol;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.directory.server.dns.io.encoder.AddressRecordEncoder;
-import org.apache.directory.server.dns.io.encoder.CanonicalNameRecordEncoder;
-import org.apache.directory.server.dns.io.encoder.MailExchangeRecordEncoder;
-import org.apache.directory.server.dns.io.encoder.NameServerRecordEncoder;
-import org.apache.directory.server.dns.io.encoder.PointerRecordEncoder;
-import org.apache.directory.server.dns.io.encoder.QuestionRecordEncoder;
-import org.apache.directory.server.dns.io.encoder.RecordEncoder;
-import org.apache.directory.server.dns.io.encoder.ServerSelectionRecordEncoder;
-import org.apache.directory.server.dns.io.encoder.StartOfAuthorityRecordEncoder;
-import org.apache.directory.server.dns.io.encoder.TextRecordEncoder;
-import org.apache.directory.server.dns.messages.DnsMessage;
-import org.apache.directory.server.dns.messages.MessageType;
-import org.apache.directory.server.dns.messages.OpCode;
-import org.apache.directory.server.dns.messages.QuestionRecord;
-import org.apache.directory.server.dns.messages.QuestionRecords;
-import org.apache.directory.server.dns.messages.RecordType;
-import org.apache.directory.server.dns.messages.ResourceRecord;
-import org.apache.directory.server.dns.messages.ResourceRecords;
-import org.apache.directory.server.dns.messages.ResponseCode;
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.codec.ProtocolEncoder;
-import org.apache.mina.filter.codec.ProtocolEncoderOutput;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DnsEncoder implements ProtocolEncoder
-{
- /** the log for this class */
- private static final Logger log = LoggerFactory.getLogger( DnsEncoder.class );
-
- /**
- * A Hashed Adapter mapping record types to their encoders.
- */
- private static final Map DEFAULT_ENCODERS;
-
- static
- {
- Map map = new HashMap();
-
- map.put( RecordType.SOA, new StartOfAuthorityRecordEncoder() );
- map.put( RecordType.A, new AddressRecordEncoder() );
- map.put( RecordType.NS, new NameServerRecordEncoder() );
- map.put( RecordType.CNAME, new CanonicalNameRecordEncoder() );
- map.put( RecordType.PTR, new PointerRecordEncoder() );
- map.put( RecordType.MX, new MailExchangeRecordEncoder() );
- map.put( RecordType.SRV, new ServerSelectionRecordEncoder() );
- map.put( RecordType.TXT, new TextRecordEncoder() );
-
- DEFAULT_ENCODERS = Collections.unmodifiableMap( map );
- }
-
- public void encode( IoSession session, Object message, ProtocolEncoderOutput out )
- {
- ByteBuffer buf = ByteBuffer.allocate( 1024 );
- encode( buf, (DnsMessage) message );
-
- buf.flip();
-
- out.write( buf );
- }
-
- public void encode( ByteBuffer byteBuffer, DnsMessage message )
- {
- byteBuffer.putShort( message.getTransactionId() );
-
- byte header = (byte) 0x00;
- header = encodeMessageType( message.getMessageType(), header );
- header = encodeOpCode( message.getOpCode(), header );
- header = encodeAuthoritativeAnswer( message.isAuthoritativeAnswer(), header );
- header = encodeTruncated( message.isTruncated(), header );
- header = encodeRecursionDesired( message.isRecursionDesired(), header );
- byteBuffer.put( header );
-
- header = (byte) 0x00;
- header = encodeRecursionAvailable( message.isRecursionAvailable(), header );
- header = encodeResponseCode( message.getResponseCode(), header );
- byteBuffer.put( header );
-
- byteBuffer.putShort( (short) message.getQuestionRecords().size() );
- byteBuffer.putShort( (short) message.getAnswerRecords().size() );
- byteBuffer.putShort( (short) message.getAuthorityRecords().size() );
- byteBuffer.putShort( (short) message.getAdditionalRecords().size() );
-
- encodeRecords( message.getQuestionRecords(), byteBuffer );
- encodeRecords( message.getAnswerRecords(), byteBuffer );
- encodeRecords( message.getAuthorityRecords(), byteBuffer );
- encodeRecords( message.getAdditionalRecords(), byteBuffer );
- }
-
- private void encodeRecords( QuestionRecords questions, ByteBuffer byteBuffer )
- {
- QuestionRecordEncoder encoder = new QuestionRecordEncoder();
-
- Iterator it = questions.iterator();
-
- while ( it.hasNext() )
- {
- QuestionRecord question = (QuestionRecord) it.next();
- encoder.encode( byteBuffer, question );
- }
- }
-
- private void encodeRecords( ResourceRecords records, ByteBuffer byteBuffer )
- {
- Iterator it = records.iterator();
-
- while ( it.hasNext() )
- {
- ResourceRecord record = (ResourceRecord) it.next();
-
- try
- {
- encode( byteBuffer, record );
- }
- catch ( IOException ioe )
- {
- log.error( ioe.getMessage(), ioe );
- }
- }
- }
-
- private void encode( ByteBuffer out, ResourceRecord record ) throws IOException
- {
- RecordType type = record.getRecordType();
-
- RecordEncoder encoder = (RecordEncoder) DEFAULT_ENCODERS.get( type );
-
- if ( encoder == null )
- {
- throw new IOException( "Encoder unavailable for " + type );
- }
-
- encoder.encode( out, record );
- }
-
- private byte encodeMessageType( MessageType messageType, byte header )
- {
- byte oneBit = (byte) ( messageType.getOrdinal() & 0x01 );
- return (byte) ( ( oneBit << 7 ) | header );
- }
-
- private byte encodeOpCode( OpCode opCode, byte header )
- {
- byte fourBits = (byte) ( opCode.getOrdinal() & 0x0F );
- return (byte) ( ( fourBits << 3 ) | header );
- }
-
- private byte encodeAuthoritativeAnswer( boolean authoritative, byte header )
- {
- if ( authoritative )
- {
- header = (byte) ( ( (byte) 0x01 << 2 ) | header );
- }
- return header;
- }
-
- private byte encodeTruncated( boolean truncated, byte header )
- {
- if ( truncated )
- {
- header = (byte) ( ( (byte) 0x01 << 1 ) | header );
- }
- return header;
- }
-
- private byte encodeRecursionDesired( boolean recursionDesired, byte header )
- {
- if ( recursionDesired )
- {
- header = (byte) ( ( (byte) 0x01 ) | header );
- }
- return header;
- }
-
- private byte encodeRecursionAvailable( boolean recursionAvailable, byte header )
- {
- if ( recursionAvailable )
- {
- header = (byte) ( ( (byte) 0x01 << 7 ) | header );
- }
- return header;
- }
-
- private byte encodeResponseCode( ResponseCode responseCode, byte header )
- {
- byte fourBits = (byte) ( responseCode.getOrdinal() & 0x0F );
- return (byte) ( fourBits | header );
- }
-
- public void dispose( IoSession arg0 ) throws Exception
- {
- }
-}
+/*
+ * 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.directory.server.dns.protocol;
+
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.directory.server.dns.io.encoder.AddressRecordEncoder;
+import org.apache.directory.server.dns.io.encoder.CanonicalNameRecordEncoder;
+import org.apache.directory.server.dns.io.encoder.MailExchangeRecordEncoder;
+import org.apache.directory.server.dns.io.encoder.NameServerRecordEncoder;
+import org.apache.directory.server.dns.io.encoder.PointerRecordEncoder;
+import org.apache.directory.server.dns.io.encoder.QuestionRecordEncoder;
+import org.apache.directory.server.dns.io.encoder.RecordEncoder;
+import org.apache.directory.server.dns.io.encoder.ServerSelectionRecordEncoder;
+import org.apache.directory.server.dns.io.encoder.StartOfAuthorityRecordEncoder;
+import org.apache.directory.server.dns.io.encoder.TextRecordEncoder;
+import org.apache.directory.server.dns.messages.DnsMessage;
+import org.apache.directory.server.dns.messages.MessageType;
+import org.apache.directory.server.dns.messages.OpCode;
+import org.apache.directory.server.dns.messages.QuestionRecord;
+import org.apache.directory.server.dns.messages.QuestionRecords;
+import org.apache.directory.server.dns.messages.RecordType;
+import org.apache.directory.server.dns.messages.ResourceRecord;
+import org.apache.directory.server.dns.messages.ResourceRecords;
+import org.apache.directory.server.dns.messages.ResponseCode;
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolEncoder;
+import org.apache.mina.filter.codec.ProtocolEncoderOutput;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class DnsEncoder implements ProtocolEncoder
+{
+ /** the log for this class */
+ private static final Logger log = LoggerFactory.getLogger( DnsEncoder.class );
+
+ /**
+ * A Hashed Adapter mapping record types to their encoders.
+ */
+ private static final Map DEFAULT_ENCODERS;
+
+ static
+ {
+ Map map = new HashMap();
+
+ map.put( RecordType.SOA, new StartOfAuthorityRecordEncoder() );
+ map.put( RecordType.A, new AddressRecordEncoder() );
+ map.put( RecordType.NS, new NameServerRecordEncoder() );
+ map.put( RecordType.CNAME, new CanonicalNameRecordEncoder() );
+ map.put( RecordType.PTR, new PointerRecordEncoder() );
+ map.put( RecordType.MX, new MailExchangeRecordEncoder() );
+ map.put( RecordType.SRV, new ServerSelectionRecordEncoder() );
+ map.put( RecordType.TXT, new TextRecordEncoder() );
+
+ DEFAULT_ENCODERS = Collections.unmodifiableMap( map );
+ }
+
+
+ public void encode( IoSession session, Object message, ProtocolEncoderOutput out )
+ {
+ ByteBuffer buf = ByteBuffer.allocate( 1024 );
+ encode( buf, ( DnsMessage ) message );
+
+ buf.flip();
+
+ out.write( buf );
+ }
+
+
+ public void encode( ByteBuffer byteBuffer, DnsMessage message )
+ {
+ byteBuffer.putShort( message.getTransactionId() );
+
+ byte header = ( byte ) 0x00;
+ header = encodeMessageType( message.getMessageType(), header );
+ header = encodeOpCode( message.getOpCode(), header );
+ header = encodeAuthoritativeAnswer( message.isAuthoritativeAnswer(), header );
+ header = encodeTruncated( message.isTruncated(), header );
+ header = encodeRecursionDesired( message.isRecursionDesired(), header );
+ byteBuffer.put( header );
+
+ header = ( byte ) 0x00;
+ header = encodeRecursionAvailable( message.isRecursionAvailable(), header );
+ header = encodeResponseCode( message.getResponseCode(), header );
+ byteBuffer.put( header );
+
+ byteBuffer.putShort( ( short ) message.getQuestionRecords().size() );
+ byteBuffer.putShort( ( short ) message.getAnswerRecords().size() );
+ byteBuffer.putShort( ( short ) message.getAuthorityRecords().size() );
+ byteBuffer.putShort( ( short ) message.getAdditionalRecords().size() );
+
+ encodeRecords( message.getQuestionRecords(), byteBuffer );
+ encodeRecords( message.getAnswerRecords(), byteBuffer );
+ encodeRecords( message.getAuthorityRecords(), byteBuffer );
+ encodeRecords( message.getAdditionalRecords(), byteBuffer );
+ }
+
+
+ private void encodeRecords( QuestionRecords questions, ByteBuffer byteBuffer )
+ {
+ QuestionRecordEncoder encoder = new QuestionRecordEncoder();
+
+ Iterator it = questions.iterator();
+
+ while ( it.hasNext() )
+ {
+ QuestionRecord question = ( QuestionRecord ) it.next();
+ encoder.encode( byteBuffer, question );
+ }
+ }
+
+
+ private void encodeRecords( ResourceRecords records, ByteBuffer byteBuffer )
+ {
+ Iterator it = records.iterator();
+
+ while ( it.hasNext() )
+ {
+ ResourceRecord record = ( ResourceRecord ) it.next();
+
+ try
+ {
+ encode( byteBuffer, record );
+ }
+ catch ( IOException ioe )
+ {
+ log.error( ioe.getMessage(), ioe );
+ }
+ }
+ }
+
+
+ private void encode( ByteBuffer out, ResourceRecord record ) throws IOException
+ {
+ RecordType type = record.getRecordType();
+
+ RecordEncoder encoder = ( RecordEncoder ) DEFAULT_ENCODERS.get( type );
+
+ if ( encoder == null )
+ {
+ throw new IOException( "Encoder unavailable for " + type );
+ }
+
+ encoder.encode( out, record );
+ }
+
+
+ private byte encodeMessageType( MessageType messageType, byte header )
+ {
+ byte oneBit = ( byte ) ( messageType.getOrdinal() & 0x01 );
+ return ( byte ) ( ( oneBit << 7 ) | header );
+ }
+
+
+ private byte encodeOpCode( OpCode opCode, byte header )
+ {
+ byte fourBits = ( byte ) ( opCode.getOrdinal() & 0x0F );
+ return ( byte ) ( ( fourBits << 3 ) | header );
+ }
+
+
+ private byte encodeAuthoritativeAnswer( boolean authoritative, byte header )
+ {
+ if ( authoritative )
+ {
+ header = ( byte ) ( ( ( byte ) 0x01 << 2 ) | header );
+ }
+ return header;
+ }
+
+
+ private byte encodeTruncated( boolean truncated, byte header )
+ {
+ if ( truncated )
+ {
+ header = ( byte ) ( ( ( byte ) 0x01 << 1 ) | header );
+ }
+ return header;
+ }
+
+
+ private byte encodeRecursionDesired( boolean recursionDesired, byte header )
+ {
+ if ( recursionDesired )
+ {
+ header = ( byte ) ( ( ( byte ) 0x01 ) | header );
+ }
+ return header;
+ }
+
+
+ private byte encodeRecursionAvailable( boolean recursionAvailable, byte header )
+ {
+ if ( recursionAvailable )
+ {
+ header = ( byte ) ( ( ( byte ) 0x01 << 7 ) | header );
+ }
+ return header;
+ }
+
+
+ private byte encodeResponseCode( ResponseCode responseCode, byte header )
+ {
+ byte fourBits = ( byte ) ( responseCode.getOrdinal() & 0x0F );
+ return ( byte ) ( fourBits | header );
+ }
+
+
+ public void dispose( IoSession arg0 ) throws Exception
+ {
+ }
+}
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsEncoder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsEncoder.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsProtocolCodecFactory.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsProtocolCodecFactory.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsProtocolCodecFactory.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsProtocolCodecFactory.java Sun Feb 19 19:57:02 2006
@@ -1,49 +1,54 @@
-/*
- * 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.directory.server.dns.protocol;
-
-import org.apache.mina.filter.codec.ProtocolCodecFactory;
-import org.apache.mina.filter.codec.ProtocolDecoder;
-import org.apache.mina.filter.codec.ProtocolEncoder;
-
-public class DnsProtocolCodecFactory implements ProtocolCodecFactory
-{
- private static final DnsProtocolCodecFactory INSTANCE =
- new DnsProtocolCodecFactory();
-
- public static DnsProtocolCodecFactory getInstance()
- {
- return INSTANCE;
- }
-
- private DnsProtocolCodecFactory()
- {
- }
-
- public ProtocolEncoder getEncoder()
- {
- // Create a new encoder.
- return new DnsEncoder();
- }
-
- public ProtocolDecoder getDecoder()
- {
- // Create a new decoder.
- return new DnsDecoder();
- }
-}
+/*
+ * 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.directory.server.dns.protocol;
+
+
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolEncoder;
+
+
+public class DnsProtocolCodecFactory implements ProtocolCodecFactory
+{
+ private static final DnsProtocolCodecFactory INSTANCE = new DnsProtocolCodecFactory();
+
+
+ public static DnsProtocolCodecFactory getInstance()
+ {
+ return INSTANCE;
+ }
+
+
+ private DnsProtocolCodecFactory()
+ {
+ }
+
+
+ public ProtocolEncoder getEncoder()
+ {
+ // Create a new encoder.
+ return new DnsEncoder();
+ }
+
+
+ public ProtocolDecoder getDecoder()
+ {
+ // Create a new decoder.
+ return new DnsDecoder();
+ }
+}
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsProtocolCodecFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsProtocolCodecFactory.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsProtocolHandler.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsProtocolHandler.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsProtocolHandler.java Sun Feb 19 19:57:02 2006
@@ -1,107 +1,115 @@
-/*
- * 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.directory.server.dns.protocol;
-
-import org.apache.directory.server.dns.DnsConfiguration;
-import org.apache.directory.server.dns.messages.DnsMessage;
-import org.apache.directory.server.dns.service.DnsContext;
-import org.apache.directory.server.dns.service.DomainNameServiceChain;
-import org.apache.directory.server.dns.store.RecordStore;
-import org.apache.directory.server.protocol.shared.chain.Command;
-import org.apache.mina.common.IdleStatus;
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.codec.ProtocolCodecFilter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DnsProtocolHandler implements IoHandler
-{
- private static final Logger log = LoggerFactory.getLogger( DnsProtocolHandler.class );
-
- private DnsConfiguration config;
- private RecordStore store;
-
- private Command dnsService;
-
- public DnsProtocolHandler( DnsConfiguration config, RecordStore store )
- {
- this.config = config;
- this.store = store;
-
- dnsService = new DomainNameServiceChain();
- }
-
- public void sessionCreated( IoSession session ) throws Exception
- {
- log.debug( "{} CREATED", session.getRemoteAddress() );
-
- session.getFilterChain().addFirst(
- "codec",
- new ProtocolCodecFilter( DnsProtocolCodecFactory.getInstance() ) );
- }
-
- public void sessionOpened( IoSession session )
- {
- log.debug( "{} OPENED", session.getRemoteAddress() );
- }
-
- public void sessionClosed( IoSession session )
- {
- log.debug( "{} CLOSED", session.getRemoteAddress() );
- }
-
- public void sessionIdle( IoSession session, IdleStatus status )
- {
- log.debug( "{} IDLE({})", session.getRemoteAddress(), status );
- }
-
- public void exceptionCaught( IoSession session, Throwable cause )
- {
- log.error( session.getRemoteAddress() + " EXCEPTION", cause );
- session.close();
- }
-
- public void messageReceived( IoSession session, Object message )
- {
- log.debug( "{} RCVD: {}", session.getRemoteAddress(), message );
-
- DnsMessage request = (DnsMessage) message;
-
- try
- {
- DnsContext dnsContext = new DnsContext();
- dnsContext.setConfig( config );
- dnsContext.setStore( store );
- dnsContext.setRequest( request );
-
- dnsService.execute( dnsContext );
-
- session.write( dnsContext.getReply() );
- }
- catch ( Exception e )
- {
- log.error( e.getMessage(), e );
- }
- }
-
- public void messageSent( IoSession session, Object message )
- {
- log.debug( "{} SENT: {}", session.getRemoteAddress(), message );
- }
-}
+/*
+ * 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.directory.server.dns.protocol;
+
+
+import org.apache.directory.server.dns.DnsConfiguration;
+import org.apache.directory.server.dns.messages.DnsMessage;
+import org.apache.directory.server.dns.service.DnsContext;
+import org.apache.directory.server.dns.service.DomainNameServiceChain;
+import org.apache.directory.server.dns.store.RecordStore;
+import org.apache.directory.server.protocol.shared.chain.Command;
+import org.apache.mina.common.IdleStatus;
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class DnsProtocolHandler implements IoHandler
+{
+ private static final Logger log = LoggerFactory.getLogger( DnsProtocolHandler.class );
+
+ private DnsConfiguration config;
+ private RecordStore store;
+
+ private Command dnsService;
+
+
+ public DnsProtocolHandler(DnsConfiguration config, RecordStore store)
+ {
+ this.config = config;
+ this.store = store;
+
+ dnsService = new DomainNameServiceChain();
+ }
+
+
+ public void sessionCreated( IoSession session ) throws Exception
+ {
+ log.debug( "{} CREATED", session.getRemoteAddress() );
+
+ session.getFilterChain().addFirst( "codec", new ProtocolCodecFilter( DnsProtocolCodecFactory.getInstance() ) );
+ }
+
+
+ public void sessionOpened( IoSession session )
+ {
+ log.debug( "{} OPENED", session.getRemoteAddress() );
+ }
+
+
+ public void sessionClosed( IoSession session )
+ {
+ log.debug( "{} CLOSED", session.getRemoteAddress() );
+ }
+
+
+ public void sessionIdle( IoSession session, IdleStatus status )
+ {
+ log.debug( "{} IDLE({})", session.getRemoteAddress(), status );
+ }
+
+
+ public void exceptionCaught( IoSession session, Throwable cause )
+ {
+ log.error( session.getRemoteAddress() + " EXCEPTION", cause );
+ session.close();
+ }
+
+
+ public void messageReceived( IoSession session, Object message )
+ {
+ log.debug( "{} RCVD: {}", session.getRemoteAddress(), message );
+
+ DnsMessage request = ( DnsMessage ) message;
+
+ try
+ {
+ DnsContext dnsContext = new DnsContext();
+ dnsContext.setConfig( config );
+ dnsContext.setStore( store );
+ dnsContext.setRequest( request );
+
+ dnsService.execute( dnsContext );
+
+ session.write( dnsContext.getReply() );
+ }
+ catch ( Exception e )
+ {
+ log.error( e.getMessage(), e );
+ }
+ }
+
+
+ public void messageSent( IoSession session, Object message )
+ {
+ log.debug( "{} SENT: {}", session.getRemoteAddress(), message );
+ }
+}
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsProtocolHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/protocol/DnsProtocolHandler.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/BuildReply.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/BuildReply.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/BuildReply.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/BuildReply.java Sun Feb 19 19:57:02 2006
@@ -16,6 +16,7 @@
*/
package org.apache.directory.server.dns.service;
+
import org.apache.directory.server.dns.messages.DnsMessage;
import org.apache.directory.server.dns.messages.DnsMessageModifier;
import org.apache.directory.server.dns.messages.MessageType;
@@ -25,11 +26,12 @@
import org.apache.directory.server.protocol.shared.chain.Context;
import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+
public class BuildReply extends CommandBase
{
public boolean execute( Context context ) throws Exception
{
- DnsContext dnsContext = (DnsContext) context;
+ DnsContext dnsContext = ( DnsContext ) context;
ResourceRecords records = dnsContext.getResourceRecords();
DnsMessage request = dnsContext.getRequest();
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/BuildReply.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/DnsContext.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/DnsContext.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/DnsContext.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/DnsContext.java Sun Feb 19 19:57:02 2006
@@ -16,6 +16,7 @@
*/
package org.apache.directory.server.dns.service;
+
import java.util.Collection;
import org.apache.directory.server.dns.DnsConfiguration;
@@ -25,6 +26,7 @@
import org.apache.directory.server.dns.store.RecordStore;
import org.apache.directory.server.protocol.shared.chain.impl.ContextBase;
+
public class DnsContext extends ContextBase
{
private static final long serialVersionUID = -5911142975867852436L;
@@ -35,6 +37,7 @@
private DnsMessage reply;
private ResourceRecords records = new ResourceRecords();
+
/**
* @return Returns the recordEntry.
*/
@@ -43,6 +46,7 @@
return records;
}
+
/**
* @param resourceRecord The resourceRecord to add.
*/
@@ -51,6 +55,7 @@
this.records.add( resourceRecord );
}
+
/**
* @param resourceRecords The resourceRecords to add.
*/
@@ -59,6 +64,7 @@
this.records.addAll( resourceRecords );
}
+
/**
* @return Returns the config.
*/
@@ -67,6 +73,7 @@
return config;
}
+
/**
* @param config The config to set.
*/
@@ -75,6 +82,7 @@
this.config = config;
}
+
/**
* @return Returns the reply.
*/
@@ -83,6 +91,7 @@
return reply;
}
+
/**
* @param reply The reply to set.
*/
@@ -91,6 +100,7 @@
this.reply = reply;
}
+
/**
* @return Returns the request.
*/
@@ -99,6 +109,7 @@
return request;
}
+
/**
* @param request The request to set.
*/
@@ -107,6 +118,7 @@
this.request = request;
}
+
/**
* @return Returns the store.
*/
@@ -114,6 +126,7 @@
{
return store;
}
+
/**
* @param store The store to set.
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/DnsContext.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/DnsExceptionHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/DnsExceptionHandler.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/DnsExceptionHandler.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/DnsExceptionHandler.java Sun Feb 19 19:57:02 2006
@@ -16,6 +16,7 @@
*/
package org.apache.directory.server.dns.service;
+
import org.apache.directory.server.dns.DnsException;
import org.apache.directory.server.dns.messages.DnsMessage;
import org.apache.directory.server.dns.messages.DnsMessageModifier;
@@ -29,16 +30,19 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
public class DnsExceptionHandler extends CommandBase implements Filter
{
/** the log for this class */
private static final Logger log = LoggerFactory.getLogger( DnsExceptionHandler.class );
+
public boolean execute( Context context ) throws Exception
{
return CONTINUE_CHAIN;
}
+
public boolean postprocess( Context context, Exception exception )
{
if ( exception == null )
@@ -46,8 +50,8 @@
return CONTINUE_CHAIN;
}
- DnsContext dnsContext = (DnsContext) context;
- DnsException de = (DnsException) exception;
+ DnsContext dnsContext = ( DnsContext ) context;
+ DnsException de = ( DnsException ) exception;
DnsMessage message = dnsContext.getRequest();
if ( log.isDebugEnabled() )
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/DnsExceptionHandler.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/DomainNameServiceChain.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/DomainNameServiceChain.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/DomainNameServiceChain.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/DomainNameServiceChain.java Sun Feb 19 19:57:02 2006
@@ -16,10 +16,12 @@
*/
package org.apache.directory.server.dns.service;
+
import org.apache.directory.server.protocol.shared.chain.impl.ChainBase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
/**
* Domain Name Service (DNS) Protocol (RFC 1034, 1035)
*/
@@ -27,6 +29,7 @@
{
/** the log for this class */
private static final Logger log = LoggerFactory.getLogger( DomainNameServiceChain.class );
+
public DomainNameServiceChain()
{
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/DomainNameServiceChain.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/GetResourceRecords.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/GetResourceRecords.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/GetResourceRecords.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/GetResourceRecords.java Sun Feb 19 19:57:02 2006
@@ -16,6 +16,7 @@
*/
package org.apache.directory.server.dns.service;
+
import java.util.Iterator;
import java.util.Set;
@@ -27,11 +28,12 @@
import org.apache.directory.server.protocol.shared.chain.Context;
import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+
public class GetResourceRecords extends CommandBase
{
public boolean execute( Context context ) throws Exception
{
- DnsContext dnsContext = (DnsContext) context;
+ DnsContext dnsContext = ( DnsContext ) context;
RecordStore store = dnsContext.getStore();
QuestionRecords questions = dnsContext.getRequest().getQuestionRecords();
@@ -40,11 +42,12 @@
while ( it.hasNext() )
{
- dnsContext.addResourceRecords( getEntry( store, (QuestionRecord) it.next() ) );
+ dnsContext.addResourceRecords( getEntry( store, ( QuestionRecord ) it.next() ) );
}
return CONTINUE_CHAIN;
}
+
public Set getEntry( RecordStore store, QuestionRecord question ) throws Exception
{
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/GetResourceRecords.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorContext.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorContext.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorContext.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorContext.java Sun Feb 19 19:57:02 2006
@@ -16,6 +16,7 @@
*/
package org.apache.directory.server.dns.service;
+
import org.apache.directory.server.dns.messages.ResourceRecords;
import org.apache.directory.server.dns.store.RecordStore;
import org.apache.directory.server.protocol.shared.chain.Context;
@@ -23,18 +24,20 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
public class MonitorContext extends CommandBase
{
/** the log for this class */
private static final Logger log = LoggerFactory.getLogger( MonitorContext.class );
+
public boolean execute( Context context ) throws Exception
{
if ( log.isDebugEnabled() )
{
try
{
- DnsContext dnsContext = (DnsContext) context;
+ DnsContext dnsContext = ( DnsContext ) context;
RecordStore store = dnsContext.getStore();
ResourceRecords records = dnsContext.getResourceRecords();
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorContext.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorMessage.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorMessage.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorMessage.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorMessage.java Sun Feb 19 19:57:02 2006
@@ -16,12 +16,14 @@
*/
package org.apache.directory.server.dns.service;
+
import org.apache.directory.server.dns.messages.DnsMessage;
import org.apache.directory.server.dns.messages.MessageType;
import org.apache.directory.server.dns.messages.OpCode;
import org.apache.directory.server.dns.messages.QuestionRecords;
import org.apache.directory.server.dns.messages.ResponseCode;
import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+
public abstract class MonitorMessage extends CommandBase
{
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorMessage.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorReply.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorReply.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorReply.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorReply.java Sun Feb 19 19:57:02 2006
@@ -16,22 +16,25 @@
*/
package org.apache.directory.server.dns.service;
+
import org.apache.directory.server.protocol.shared.chain.Context;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
public class MonitorReply extends MonitorMessage
{
/** the log for this class */
private static final Logger log = LoggerFactory.getLogger( MonitorReply.class );
+
public boolean execute( Context context ) throws Exception
{
if ( log.isDebugEnabled() )
{
try
{
- DnsContext dnsContext = (DnsContext) context;
+ DnsContext dnsContext = ( DnsContext ) context;
log.debug( monitorMessage( dnsContext.getReply(), "reply" ) );
}
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorReply.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorRequest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorRequest.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorRequest.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorRequest.java Sun Feb 19 19:57:02 2006
@@ -16,22 +16,25 @@
*/
package org.apache.directory.server.dns.service;
+
import org.apache.directory.server.protocol.shared.chain.Context;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
public class MonitorRequest extends MonitorMessage
{
/** the log for this class */
private static final Logger log = LoggerFactory.getLogger( MonitorRequest.class );
+
public boolean execute( Context context ) throws Exception
{
if ( log.isDebugEnabled() )
{
try
{
- DnsContext dnsContext = (DnsContext) context;
+ DnsContext dnsContext = ( DnsContext ) context;
log.debug( monitorMessage( dnsContext.getRequest(), "request" ) );
}
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/service/MonitorRequest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/DnsAttribute.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/DnsAttribute.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/DnsAttribute.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/DnsAttribute.java Sun Feb 19 19:57:02 2006
@@ -16,6 +16,7 @@
*/
package org.apache.directory.server.dns.store;
+
/**
* Constants representing the DNS attribute ids as defined by the Apache DNS schema.
*
@@ -82,10 +83,10 @@
/** the apachedns schema apacheDnsServicePriority */
public static final String SERVICE_PRIORITY = "apacheDnsServicePriority";
-
+
/** the apachedns schema apacheDnsServiceWeight */
public static final String SERVICE_WEIGHT = "apacheDnsServiceWeight";
-
+
/** the apachedns schema apacheDnsServicePort */
public static final String SERVICE_PORT = "apacheDnsServicePort";
}
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/DnsAttribute.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/DnsCatalog.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/DnsCatalog.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/DnsCatalog.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/DnsCatalog.java Sun Feb 19 19:57:02 2006
@@ -17,10 +17,12 @@
package org.apache.directory.server.dns.store;
+
import java.util.Map;
import org.apache.directory.server.protocol.shared.catalog.Catalog;
+
/**
* A catalog for mapping DNS zones to search base DN's.
*
@@ -31,11 +33,13 @@
{
private Map map;
- public DnsCatalog( Map map )
+
+ public DnsCatalog(Map map)
{
this.map = map;
}
+
public String getBaseDn( String name )
{
if ( name.endsWith( "." ) )
@@ -46,7 +50,7 @@
while ( !name.equals( "" ) && name != null )
{
- String candidate = (String) map.get( name );
+ String candidate = ( String ) map.get( name );
if ( candidate != null )
{
return candidate;
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/DnsCatalog.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/JndiRecordStoreImpl.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/JndiRecordStoreImpl.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/JndiRecordStoreImpl.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/JndiRecordStoreImpl.java Sun Feb 19 19:57:02 2006
@@ -16,6 +16,7 @@
*/
package org.apache.directory.server.dns.store;
+
import java.util.Set;
import javax.naming.spi.InitialContextFactory;
@@ -23,6 +24,7 @@
import org.apache.directory.server.dns.DnsConfiguration;
import org.apache.directory.server.dns.messages.QuestionRecord;
+
/**
* A JNDI-backed implementation of the RecordStore interface. This RecordStore uses
* the Strategy pattern to either serve records based on a single base DN or to lookup
@@ -40,7 +42,8 @@
/** a handle on the searchh strategy */
private SearchStrategy strategy;
- public JndiRecordStoreImpl( DnsConfiguration config, InitialContextFactory factory )
+
+ public JndiRecordStoreImpl(DnsConfiguration config, InitialContextFactory factory)
{
this.config = config;
this.factory = factory;
@@ -48,10 +51,12 @@
strategy = getSearchStrategy();
}
+
public Set getRecords( QuestionRecord question ) throws Exception
{
return strategy.getRecords( question );
}
+
private SearchStrategy getSearchStrategy()
{
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/JndiRecordStoreImpl.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/MultiBaseSearch.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/MultiBaseSearch.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/MultiBaseSearch.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/MultiBaseSearch.java Sun Feb 19 19:57:02 2006
@@ -17,6 +17,7 @@
package org.apache.directory.server.dns.store;
+
import java.util.Hashtable;
import java.util.Map;
import java.util.Set;
@@ -36,6 +37,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
/**
* A JNDI-backed search strategy implementation. This search strategy builds a catalog
* from directory configuration to determine where zones are to search for
@@ -54,7 +56,8 @@
private Catalog catalog;
- MultiBaseSearch( DnsConfiguration config, InitialContextFactory factory )
+
+ MultiBaseSearch(DnsConfiguration config, InitialContextFactory factory)
{
this.factory = factory;
@@ -64,33 +67,35 @@
try
{
- DirContext ctx = (DirContext) factory.getInitialContext( env );
- catalog = new DnsCatalog( (Map) execute( ctx, new GetCatalog() ) );
+ DirContext ctx = ( DirContext ) factory.getInitialContext( env );
+ catalog = new DnsCatalog( ( Map ) execute( ctx, new GetCatalog() ) );
}
catch ( Exception e )
{
log.error( e.getMessage(), e );
- String message = "Failed to get catalog context " + (String) env.get( Context.PROVIDER_URL );
+ String message = "Failed to get catalog context " + ( String ) env.get( Context.PROVIDER_URL );
throw new ConfigurationException( message, e );
}
}
+
public Set getRecords( QuestionRecord question ) throws Exception
{
env.put( Context.PROVIDER_URL, catalog.getBaseDn( question.getDomainName() ) );
try
{
- DirContext ctx = (DirContext) factory.getInitialContext( env );
- return (Set) execute( ctx, new GetRecords( question ) );
+ DirContext ctx = ( DirContext ) factory.getInitialContext( env );
+ return ( Set ) execute( ctx, new GetRecords( question ) );
}
catch ( NamingException ne )
{
log.error( ne.getMessage(), ne );
- String message = "Failed to get initial context " + (String) env.get( Context.PROVIDER_URL );
+ String message = "Failed to get initial context " + ( String ) env.get( Context.PROVIDER_URL );
throw new ConfigurationException( message, ne );
}
}
+
private Object execute( DirContext ctx, ContextOperation operation ) throws Exception
{
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/MultiBaseSearch.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/RecordStore.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/RecordStore.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/RecordStore.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/RecordStore.java Sun Feb 19 19:57:02 2006
@@ -16,15 +16,17 @@
*/
package org.apache.directory.server.dns.store;
+
import java.util.Set;
import org.apache.directory.server.dns.messages.QuestionRecord;
+
/**
* The store interface used by the DNS protocol to lookup resource records.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev: 329063 $, $Date$
+ * @version $Rev$, $Date$
*/
public interface RecordStore
{
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/RecordStore.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/SearchStrategy.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/SearchStrategy.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/SearchStrategy.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/SearchStrategy.java Sun Feb 19 19:57:02 2006
@@ -17,9 +17,11 @@
package org.apache.directory.server.dns.store;
+
import java.util.Set;
import org.apache.directory.server.dns.messages.QuestionRecord;
+
/**
* Interface for search strategies. The DNS protocol may search a single
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/SearchStrategy.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/SingleBaseSearch.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/SingleBaseSearch.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/SingleBaseSearch.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/SingleBaseSearch.java Sun Feb 19 19:57:02 2006
@@ -17,6 +17,7 @@
package org.apache.directory.server.dns.store;
+
import java.util.Hashtable;
import java.util.Set;
@@ -33,6 +34,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
/**
* A JNDI-backed search strategy implementation. This search strategy searches a
* single base DN for resource records.
@@ -47,7 +49,8 @@
private DirContext ctx;
- SingleBaseSearch( DnsConfiguration config, InitialContextFactory factory )
+
+ SingleBaseSearch(DnsConfiguration config, InitialContextFactory factory)
{
Hashtable env = new Hashtable( config.toJndiEnvironment() );
env.put( Context.INITIAL_CONTEXT_FACTORY, config.getInitialContextFactory() );
@@ -55,20 +58,22 @@
try
{
- ctx = (DirContext) factory.getInitialContext( env );
+ ctx = ( DirContext ) factory.getInitialContext( env );
}
catch ( NamingException ne )
{
log.error( ne.getMessage(), ne );
- String message = "Failed to get initial context " + (String) env.get( Context.PROVIDER_URL );
+ String message = "Failed to get initial context " + ( String ) env.get( Context.PROVIDER_URL );
throw new ConfigurationException( message, ne );
}
}
+
public Set getRecords( QuestionRecord question ) throws Exception
{
- return (Set) execute( new GetRecords( question ) );
+ return ( Set ) execute( new GetRecords( question ) );
}
+
private Object execute( ContextOperation operation ) throws Exception
{
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/SingleBaseSearch.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/operations/GetFlatRecord.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/operations/GetFlatRecord.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/operations/GetFlatRecord.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/operations/GetFlatRecord.java Sun Feb 19 19:57:02 2006
@@ -16,6 +16,7 @@
*/
package org.apache.directory.server.dns.store.operations;
+
import javax.naming.Name;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
@@ -34,6 +35,7 @@
import org.apache.directory.server.dns.store.DnsAttribute;
import org.apache.directory.server.protocol.shared.store.ContextOperation;
+
/**
* A JNDI context operation for looking up a Resource Record with flat attributes.
*
@@ -47,14 +49,16 @@
/** The name of the question to get. */
private final QuestionRecord question;
+
/**
* Creates the action to be used against the embedded JNDI provider.
*/
- public GetFlatRecord( QuestionRecord question )
+ public GetFlatRecord(QuestionRecord question)
{
this.question = question;
}
+
/**
* Note that the base is a relative path from the exiting context.
* It is not a DN.
@@ -78,7 +82,7 @@
if ( answer.hasMore() )
{
- SearchResult result = (SearchResult) answer.next();
+ SearchResult result = ( SearchResult ) answer.next();
Attributes attrs = result.getAttributes();
@@ -93,6 +97,7 @@
return record;
}
+
/**
* Marshals a RecordStoreEntry from an Attributes object.
*
@@ -106,10 +111,10 @@
Attribute attr;
- String dnsName = ( attr = attrs.get( DnsAttribute.NAME ) ) != null ? (String) attr.get() : null;
- String dnsType = ( attr = attrs.get( DnsAttribute.TYPE ) ) != null ? (String) attr.get() : null;
- String dnsClass = ( attr = attrs.get( DnsAttribute.CLASS ) ) != null ? (String) attr.get() : null;
- String dnsTtl = ( attr = attrs.get( DnsAttribute.TTL ) ) != null ? (String) attr.get() : null;
+ String dnsName = ( attr = attrs.get( DnsAttribute.NAME ) ) != null ? ( String ) attr.get() : null;
+ String dnsType = ( attr = attrs.get( DnsAttribute.TYPE ) ) != null ? ( String ) attr.get() : null;
+ String dnsClass = ( attr = attrs.get( DnsAttribute.CLASS ) ) != null ? ( String ) attr.get() : null;
+ String dnsTtl = ( attr = attrs.get( DnsAttribute.TTL ) ) != null ? ( String ) attr.get() : null;
modifier.setDnsName( dnsName );
modifier.setDnsType( RecordType.getTypeByName( dnsType ) );
@@ -120,8 +125,8 @@
while ( ids.hasMore() )
{
- String id = (String) ids.next();
- modifier.put( id, (String) attrs.get( id ).get() );
+ String id = ( String ) ids.next();
+ modifier.put( id, ( String ) attrs.get( id ).get() );
}
return modifier.getEntry();
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/operations/GetFlatRecord.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/operations/GetRecords.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/operations/GetRecords.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/operations/GetRecords.java (original)
+++ directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/operations/GetRecords.java Sun Feb 19 19:57:02 2006
@@ -17,6 +17,7 @@
package org.apache.directory.server.dns.store.operations;
+
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -42,6 +43,7 @@
import org.apache.directory.server.dns.store.DnsAttribute;
import org.apache.directory.server.protocol.shared.store.ContextOperation;
+
/**
* A JNDI context operation for looking up Resource Records from an embedded JNDI provider.
*
@@ -55,10 +57,11 @@
/** The name of the question to get. */
private final QuestionRecord question;
+
/**
* Creates the action to be used against the embedded JNDI provider.
*/
- public GetRecords( QuestionRecord question )
+ public GetRecords(QuestionRecord question)
{
this.question = question;
}
@@ -105,6 +108,7 @@
OBJECTCLASS_TO_TYPE = Collections.unmodifiableMap( objectClassToType );
}
+
/**
* Note that the base is a relative path from the exiting context.
* It is not a DN.
@@ -122,7 +126,7 @@
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
- String filter = "(objectClass=" + (String) TYPE_TO_OBJECTCLASS.get( type ) + ")";
+ String filter = "(objectClass=" + ( String ) TYPE_TO_OBJECTCLASS.get( type ) + ")";
NamingEnumeration list = ctx.search( transformDomainName( name ), filter, controls );
@@ -130,7 +134,7 @@
while ( list.hasMore() )
{
- SearchResult result = (SearchResult) list.next();
+ SearchResult result = ( SearchResult ) list.next();
Name relative = getRelativeName( ctx.getNameInNamespace(), result.getName() );
set.add( getRecord( result.getAttributes(), relative ) );
@@ -139,6 +143,7 @@
return set;
}
+
/**
* Marshals a RecordStoreEntry from an Attributes object.
*
@@ -160,7 +165,7 @@
if ( attr != null )
{
- modifier.setDnsName( (String) attr.get() );
+ modifier.setDnsName( ( String ) attr.get() );
}
else
{
@@ -176,7 +181,7 @@
if ( attr != null )
{
- modifier.setDnsType( RecordType.getTypeByName( (String) attr.get() ) );
+ modifier.setDnsType( RecordType.getTypeByName( ( String ) attr.get() ) );
}
else
{
@@ -184,24 +189,25 @@
}
// class defaults to SOA CLASS
- String dnsClass = ( attr = attrs.get( DnsAttribute.CLASS ) ) != null ? (String) attr.get() : SOA_CLASS;
+ String dnsClass = ( attr = attrs.get( DnsAttribute.CLASS ) ) != null ? ( String ) attr.get() : SOA_CLASS;
modifier.setDnsClass( RecordClass.getTypeByName( dnsClass ) );
// ttl defaults to SOA MINIMUM
- String dnsTtl = ( attr = attrs.get( DnsAttribute.TTL ) ) != null ? (String) attr.get() : SOA_MINIMUM;
+ String dnsTtl = ( attr = attrs.get( DnsAttribute.TTL ) ) != null ? ( String ) attr.get() : SOA_MINIMUM;
modifier.setDnsTtl( Integer.parseInt( dnsTtl ) );
NamingEnumeration ids = attrs.getIDs();
while ( ids.hasMore() )
{
- String id = (String) ids.next();
- modifier.put( id, (String) attrs.get( id ).get() );
+ String id = ( String ) ids.next();
+ modifier.put( id, ( String ) attrs.get( id ).get() );
}
return modifier.getEntry();
}
+
/**
* Uses the algorithm in <a href="http://www.faqs.org/rfcs/rfc2247.html">RFC 2247</a>
* to transform any Internet domain name into a distinguished name.
@@ -224,6 +230,7 @@
return buf.toString();
}
+
/**
* Uses the algorithm in <a href="http://www.faqs.org/rfcs/rfc2247.html">RFC 2247</a>
* to transform a distinguished name into an Internet domain name.
@@ -244,17 +251,18 @@
return domainName;
}
+
private RecordType getType( Attribute objectClass ) throws NamingException
{
NamingEnumeration list = objectClass.getAll();
while ( list.hasMore() )
{
- String value = (String) list.next();
+ String value = ( String ) list.next();
if ( !value.equals( "apacheDnsAbstractRecord" ) )
{
- RecordType type = (RecordType) OBJECTCLASS_TO_TYPE.get( value );
+ RecordType type = ( RecordType ) OBJECTCLASS_TO_TYPE.get( value );
if ( type == null )
{
@@ -268,6 +276,7 @@
throw new NamingException( "ResourceRecord requires STRUCTURAL objectClass" );
}
+
private Name getRelativeName( String nameInNamespace, String baseDn ) throws NamingException
{
Properties props = new Properties();
@@ -293,6 +302,7 @@
return searchBaseDn;
}
+
private Name getDomainComponents( Name name ) throws NamingException
{
Propchange: directory/trunks/apacheds/protocol-dns/src/main/java/org/apache/directory/server/dns/store/operations/GetRecords.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id