[nhin-d] push by gm2...@cerner.com - Creating tag for dns-1.2.5 on 2015-01-26 14:04 GMT

2 views
Skip to first unread message

nhi...@googlecode.com

unread,
Jan 26, 2015, 9:04:51 AM1/26/15
to nhindirec...@googlegroups.com
Revision: c23291678ba0
Branch: default
Author: gm2552
Date: Mon Jan 26 14:04:30 2015 UTC
Log: Creating tag for dns-1.2.5
https://code.google.com/p/nhin-d/source/detail?r=c23291678ba0

Added:
/java/tags/dns-1.2.5/pom.xml
/java/tags/dns-1.2.5/report/findbugs-exclude.xml
/java/tags/dns-1.2.5/src/books/users-guide.xml
/java/tags/dns-1.2.5/src/books/users-guide/deploy-intro.confluence
/java/tags/dns-1.2.5/src/books/users-guide/dns-godad-config.confluence
/java/tags/dns-1.2.5/src/books/users-guide/dns-proto-config.confluence
/java/tags/dns-1.2.5/src/books/users-guide/dns-record-config.confluence
/java/tags/dns-1.2.5/src/books/users-guide/dns-serv-depl.confluence
/java/tags/dns-1.2.5/src/books/users-guide/images/WSConfigARecords.png
/java/tags/dns-1.2.5/src/books/users-guide/images/WSConfigDNSHome.png
/java/tags/dns-1.2.5/src/books/users-guide/images/WSConfigDomainSearch.png
/java/tags/dns-1.2.5/src/books/users-guide/images/WSConfigMXRecords.png
/java/tags/dns-1.2.5/src/books/users-guide/images/WSConfigSOARecords.png
/java/tags/dns-1.2.5/src/books/users-guide/images/dnsconfigsetting.png
/java/tags/dns-1.2.5/src/books/users-guide/images/winservices.png
/java/tags/dns-1.2.5/src/books/users-guide/preface.apt
/java/tags/dns-1.2.5/src/descriptors/distribution.xml
/java/tags/dns-1.2.5/src/logs/wrapper.txt

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/ConfigServiceDNSStore.java
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSError.java
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSException.java
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSResponder.java
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSResponderTCP.java
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSResponderUDP.java
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSServer.java
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSServerFactory.java
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSServerMBean.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSServerSettings.java
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSSocketServer.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSSocketServerMBean.java
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSStore.java
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/ProxyDNSStore.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/SocketServerSettings.java
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/TCPServer.java
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/UDPServer.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/annotation/ConfigServiceURL.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/annotation/package-info.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/config/DNSServerConfig.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/config/WSDNSServerConfig.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/config/package-info.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/module/DNSServerConfigModule.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/module/DNSServerModule.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/module/package-info.java
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/package-info.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/provider/AbstractConfigDNSStoreProvider.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/provider/BasicDNSServerSettingsProvider.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/provider/ConfigServiceDNSStoreProvider.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/provider/WSDNSServerConfigProvider.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/provider/package-info.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/service/DNSServerService.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/service/SimpleServiceRunner.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/service/package-info.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/tools/CertCommands.java
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/tools/DNSManager.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/tools/DNSRecordCommands.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/tools/DNSRecordParser.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/tools/DNSRecordPrinter.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/tools/DefaultDNSRecordPrinter.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/tools/package-info.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/tools/printers/AbstractRecordPrinter.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/tools/printers/CertRecordPrinter.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/tools/printers/RecordPrinter.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/tools/utils/Action.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/tools/utils/Command.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/tools/utils/CommandDef.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/tools/utils/CommandUsage.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/tools/utils/Commands.java

/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/tools/utils/StringArrayUtil.java
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/utils/CertUtils.java
/java/tags/dns-1.2.5/src/site/resources/css/site.css
/java/tags/dns-1.2.5/src/site/resources/images/logo.png
/java/tags/dns-1.2.5/src/site/site.xml
/java/tags/dns-1.2.5/src/site/xdoc/index.xml

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/DNSConnectionTest.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/DNSServer_Function_Test.java
/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/MockDNSStore.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/provider/MockConfigDNSStoreProvider.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/provider/MockDNSStoreProvider.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/service/DNSServerService_constructTest.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tool/AddHardcodedRecord.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/CertCommands_addIPKIXCert_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/CertCommands_importPrivateCert_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/CertCommands_importPublicCert_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/CertCommands_listCertsByAddress_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/CertCommands_listCerts_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/CertCommands_removeCert_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/CertRecordCounterPrinter.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/DNSManager_functional_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/DNSRecordCommands_addARecords_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/DNSRecordCommands_addMXRecords_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/DNSRecordCommands_addSAORecords_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/DNSRecordCommands_ensureARecords_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/DNSRecordCommands_ensureMXRecords_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/DNSRecordCommands_ensureSAORecords_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/DNSRecordCommands_getAll_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/DNSRecordCommands_getByRecordId_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/DNSRecordCommands_importRecords_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/DNSRecordCommands_matchARecords_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/DNSRecordCommands_matchAllTypes_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/DNSRecordCommands_matchMXRecords_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/DNSRecordCommands_matchSOARecords_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/DNSRecordCommands_removeRecords_Test.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/tools/MockDNSRecordPrinter.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/util/BaseTestPlan.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/util/ConfigServiceRunner.java

/java/tags/dns-1.2.5/src/test/java/org/nhindirect/dns/util/DNSRecordUtil.java
/java/tags/dns-1.2.5/src/test/resources/certs/bob.der
/java/tags/dns-1.2.5/src/test/resources/certs/certCheckA.p12
/java/tags/dns-1.2.5/src/test/resources/certs/gm2552.der
/java/tags/dns-1.2.5/src/test/resources/certs/mshost.der
/java/tags/dns-1.2.5/src/test/resources/certs/ryan.der
/java/tags/dns-1.2.5/src/test/resources/certs/umesh.der
/java/tags/dns-1.2.5/src/test/resources/dnsrecords/example.domain.com.a

/java/tags/dns-1.2.5/src/test/resources/dnsrecords/example.domain.com.corrupt
/java/tags/dns-1.2.5/src/test/resources/dnsrecords/example.domain.com.mx
/java/tags/dns-1.2.5/src/test/resources/dnsrecords/example.domain.com.soa

=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/pom.xml Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,700 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd ">
+ <groupId>org.nhind</groupId>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>dns</artifactId>
+ <name>Direct Project DNS services</name>
+ <version>1.2.5</version>
+ <description>Direct Project DNS services</description>
+ <inceptionYear>2010</inceptionYear>
+
<url>http://api.nhindirect.org/x/www/api.nhindirect.org/java/site/dns/${project.version}</url>
+ <developers>
+ <developer>
+ <name>Greg Meyer</name>
+ <id>GM2552</id>
+ <email>gm2...@cerner.com</email>
+ <roles>
+ <role>owner</role>
+ </roles>
+ </developer>
+ </developers>
+ <organization>
+ <name>The Direct Project</name>
+ <url>http://nhindirect.org</url>
+ </organization>
+ <prerequisites>
+ <maven>2.0.4</maven>
+ </prerequisites>
+ <scm>
+ <url>http://code.google.com/p/nhin-d/source/browse/#hg/java/dns</url>
+
<connection>scm:hg:https://nhin-d.googlecode.com/hg/nhin-d/java/dns</connection>
+ </scm>
+ <issueManagement>
+ <system>Google Code</system>
+ <url>http://code.google.com/p/nhin-d/issues/list</url>
+ </issueManagement>
+ <licenses>
+ <license>
+ <name>New BSD License</name>
+ <url>http://nhindirect.org/BSDLicense</url>
+ </license>
+ </licenses>
+ <dependencies>
+ <dependency>
+ <groupId>com.google.inject</groupId>
+ <artifactId>guice</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>bouncycastle</groupId>
+ <artifactId>bcprov-jdk15</artifactId>
+ <version>140</version>
+ </dependency>
+ <dependency>
+ <groupId>dnsjava</groupId>
+ <artifactId>dnsjava</artifactId>
+ <version>2.0.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nhind</groupId>
+ <artifactId>config-service-client</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nhind</groupId>
+ <artifactId>agent</artifactId>
+ <version>2.0.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.james</groupId>
+ <artifactId>apache-jsieve-mailet</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.nhind</groupId>
+ <artifactId>config-store</artifactId>
+ <version>1.2</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-asm</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-tx</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-orm</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-annotations</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.mina</groupId>
+ <artifactId>mina-core</artifactId>
+ <version>1.0.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.8.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-servlet-tester</artifactId>
+ <version>6.1.14</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-webdav</artifactId>
+ <version>RELEASE</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ssh-external</artifactId>
+ <version>1.0-beta-6</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ssh</artifactId>
+ <version>1.0-beta-6</version>
+ </extension>
+ </extensions>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <targetPath>lib</targetPath>
+ <directory>${project.basedir}/lib</directory>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ <testResource>
+ <targetPath>lib</targetPath>
+ <directory>${project.basedir}/lib</directory>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.nhind</groupId>
+ <artifactId>config-service</artifactId>
+ <version>1.3</version>
+ <type>war</type>
+ <overWrite>true</overWrite>
+ <destFileName>config-service.war</destFileName>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>
+ ${project.basedir}/war
+ </outputDirectory>
+ <overWriteReleases>true</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>testCompile</goal>
+ </goals>
+ <phase>compile</phase>
+ </execution>
+ </executions>
+ <configuration>
+ <fork>true</fork>
+ <optimize>true</optimize>
+ <showDeprecation>true</showDeprecation>
+ <encoding>UTF-8</encoding>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.0.3</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.atlassian.maven.plugins</groupId>
+ <artifactId>maven-clover2-plugin</artifactId>
+ <version>3.0.2</version>
+ <configuration>
+ <jdk>1.6</jdk>
+ <licenseLocation>
+ ${project.basedir}/../licenses/clover.license
+ </licenseLocation>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>pre-site</phase>
+ <goals>
+ <goal>instrument</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <index>true</index>
+
<!--<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+-->
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.2</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>appassembler-maven-plugin</artifactId>
+ <version>1.3.1</version>
+ <executions>
+ <execution>
+ <id>generate-jsw-scripts</id>
+ <phase>package</phase>
+ <configuration>
+ <target>${project.build.directory}/appassembler</target>
+ <repoPath>jsw/DirectDNSServer/lib</repoPath>
+ <binFileExtensions>
+ <linux>.sh</linux>
+ </binFileExtensions>
+ <repositoryName>jsw/DirectDNSServer/lib</repositoryName>
+ <repositoryLayout>flat</repositoryLayout>
+ <defaultJvmSettings>
+ <initialMemorySize>256M</initialMemorySize>
+ <maxMemorySize>1024M</maxMemorySize>
+ <systemProperties>
+
<systemProperty>java.security.policy=conf/policy.all</systemProperty>
+
<systemProperty>org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog</systemProperty>
+
<systemProperty>org.apache.commons.logging.simplelog.defaultlog=info</systemProperty>
+ </systemProperties>
+ </defaultJvmSettings>
+ <daemons>
+ <daemon>
+ <id>DirectDNSServer</id>
+
<mainClass>org.nhindirect.dns.service.SimpleServiceRunner</mainClass>
+ <commandLineArguments>
+ <commandLineArgument>-p</commandLineArgument>
+ <commandLineArgument>53</commandLineArgument>
+ <commandLineArgument>-b</commandLineArgument>
+ <commandLineArgument>0.0.0.0</commandLineArgument>
+ <commandLineArgument>-u</commandLineArgument>
+
<commandLineArgument>http://localhost:8081/config-service/ConfigurationService</commandLineArgument>
+ <commandLineArgument>-m</commandLineArgument>
+ <commandLineArgument>SERVER</commandLineArgument>
+ </commandLineArguments>
+ <platforms>
+ <platform>jsw</platform>
+ </platforms>
+ <generatorConfigurations>
+ <generatorConfiguration>
+ <generator>jsw</generator>
+ <includes>
+ <include>linux-x86-32</include>
+ <include>linux-x86-64</include>
+ <include>windows-x86-32</include>
+ <include>solaris-x86-32</include>
+ <include>macosx-universal-32</include>
+ </includes>
+ <configuration>
+ <property>
+ <name>set.default.REPO_DIR</name>
+ <value>lib</value>
+ </property>
+ <property>
+ <name>wrapper.logfile</name>
+ <value>logs/wrapper.txt</value>
+ </property>
+ </configuration>
+ </generatorConfiguration>
+ </generatorConfigurations>
+ </daemon>
+ </daemons>
+ </configuration>
+ <goals>
+ <!-- <goal>assemble</goal> -->
+ <goal>generate-daemons</goal>
+ <goal>create-repository</goal>
+ </goals>
+ </execution>
+ <execution>
+ <configuration>
+
<assembleDirectory>${project.build.directory}/appassembler/app/DNSMgmtConsole</assembleDirectory>
+ <repositoryName>lib</repositoryName>
+ <repositoryLayout>flat</repositoryLayout>
+
<extraJvmArguments>-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
-Dorg.apache.commons.logging.simplelog.defaultlog=error</extraJvmArguments>
+
+ <programs>
+ <program>
+ <mainClass>org.nhindirect.dns.tools.DNSManager</mainClass>
+ <name>DNSMgmtConsole</name>
+ </program>
+ </programs>
+
+ </configuration>
+ <goals>
+ <goal>assemble</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- DOXIA does not yet copy resources to the generated-site or
site location. Bug
+ DOXIA-355 was submitted in July of 09 and is listed to be resolved
in DOXIA 1.2.
+ This plugin a is work around for copying the resources from the
book source to
+ the generate site.
+-->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-logs</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <copy
todir="${project.build.directory}/appassembler/jsw/DirectDNSServer/logs">
+ <fileset dir="${basedir}/src/logs/" />
+ </copy>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>books</id>
+ <phase>pre-site</phase>
+ <configuration>
+ <tasks>
+ <copy
todir="${project.build.directory}/generated-site/xdoc/users-guide/images/">
+ <fileset
dir="${basedir}/src/books/users-guide/images/" />
+ </copy>
+ <copy
todir="${project.build.directory}/site/users-guide/images/">
+ <fileset
dir="${basedir}/src/books/users-guide/images/" />
+ </copy>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.doxia</groupId>
+ <artifactId>doxia-maven-plugin</artifactId>
+ <version>1.1.3</version>
+ <executions>
+ <execution>
+ <phase>pre-site</phase>
+ <goals>
+ <goal>render-books</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <books>
+ <book>
+ <directory>src/books/users-guide</directory>
+ <descriptor>src/books/users-guide.xml</descriptor>
+ <formats>
+ <format>
+ <id>xdoc</id>
+ </format>
+ </formats>
+ </book>
+ </books>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.5.12</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.doxia</groupId>
+ <artifactId>doxia-module-confluence</artifactId>
+ <version>1.1.3</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <includeModuleDirectory>false</includeModuleDirectory>
+ <finalName>dnsServices-${project.version}</finalName>
+ <descriptors>
+
<descriptor>src/descriptors/distribution.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.6.1</version>
+ <configuration>
+ <charset>UTF-8</charset>
+ <docencoding>UTF-8</docencoding>
+ <docfilessubdirs>true</docfilessubdirs>
+ <detectJavaApiLink>true</detectJavaApiLink>
+ <detectLinks>true</detectLinks>
+ <source>1.6</source>
+ <show>public</show>
+ <excludePackageNames>
+ org.nhindirect.dns.tools.utils
+ </excludePackageNames>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-gpg-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>sign-artifacts</id>
+ <phase>package</phase>
+ <goals>
+ <goal>sign</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.0</version>
+ <configuration>
+
<tagBase>scm:hg:https://nhin-d.googlecode.com/hg/nhin-d/java/tags</tagBase>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>2.1.1</version>
+ <dependencies>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>2.1.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.6.1</version>
+ <configuration>
+ <charset>UTF-8</charset>
+ <docencoding>UTF-8</docencoding>
+ <docfilessubdirs>true</docfilessubdirs>
+ <detectJavaApiLink>true</detectJavaApiLink>
+ <detectLinks>true</detectLinks>
+ <source>1.6</source>
+ <show>public</show>
+ <excludePackageNames>
+ org.nhindirect.dns.tools.utils
+ </excludePackageNames>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <configuration>
+ <targetJdk>1.6</targetJdk>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-changelog-plugin</artifactId>
+ <configuration>
+ <dates>
+ <!-- Insert the date of the most recent release -->
+ <date>2010-12-01</date>
+ </dates>
+ <outputEncoding>UTF-8</outputEncoding>
+ <type>date</type>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>clirr-maven-plugin</artifactId>
+ <configuration>
+ <minSeverity>info</minSeverity>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>1.2</version>
+ <configuration>
+ <effort>Max</effort>
+
<excludeFilterFile>${project.basedir}/report/findbugs-exclude.xml</excludeFilterFile>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>taglist-maven-plugin</artifactId>
+ <configuration>
+ <tags>
+ <tag>FIXME</tag>
+ <tag>TODO</tag>
+ <tag>WARN</tag>
+ <tag>@deprecated</tag>
+ </tags>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>com.atlassian.maven.plugins</groupId>
+ <artifactId>maven-clover2-plugin</artifactId>
+ <version>3.0.2</version>
+ <configuration>
+ <licenseLocation>
+ ${project.basedir}/../licenses/clover.license
+ </licenseLocation>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+ <distributionManagement>
+ <site>
+ <id>nhind-site</id>
+ <name>NHIN Direct API publication site</name>
+
<url>sftp://api.nhindirect.org/x/www/api.nhindirect.org/java/site/dns/${project.version}</url>
+ </site>
+ <snapshotRepository>
+ <id>sonatype-snapshot</id>
+ <name>Sonatype OSS Maven SNAPSHOT Repository</name>
+ <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
+ <uniqueVersion>false</uniqueVersion>
+ </snapshotRepository>
+ <repository>
+ <id>sonatype-release</id>
+ <name>Sonatype OSS Maven Release Repositor</name>
+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
+ <uniqueVersion>false</uniqueVersion>
+ </repository>
+ </distributionManagement>
+</project>
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/report/findbugs-exclude.xml Mon Jan 26 14:04:30
2015 UTC
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<FindBugsFilter>
+ <Match>
+ <Class name="~.*Test.*" />
+ </Match>
+ <Match>
+ <Bug pattern="DLS_DEAD_LOCAL_STORE" />
+ </Match>
+</FindBugsFilter>
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/books/users-guide.xml Mon Jan 26 14:04:30 2015
UTC
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<book xmlns="http://maven.apache.org/BOOK/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/BOOK/1.0.0 ../../../doxia/doxia-book/target/generated-site/xsd/book-1.0.0.xsd">
+ <id>users-guide</id>
+ <title>DNS Services Users Guide</title>
+ <chapters>
+ <chapter>
+ <id>preface</id>
+ <title>Preface</title>
+ <sections>
+ <section>
+ <id>preface</id>
+ </section>
+ </sections>
+ </chapter>
+ <chapter>
+ <id>deploy</id>
+ <title>Deployment Guide</title>
+ <sections>
+ <section>
+ <id>deploy-intro</id>
+ </section>
+ <section>
+ <id>dns-serv-depl</id>
+ </section>
+ <section>
+ <id>dns-proto-config</id>
+ </section>
+ <section>
+ <id>dns-record-config</id>
+ </section>
+ <section>
+ <id>dns-godad-config</id>
+ </section>
+ </sections>
+ </chapter>
+ </chapters>
+</book>
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/books/users-guide/deploy-intro.confluence Mon
Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,27 @@
+h1. About this Chapter
+
+This chapters describes the different deployment and configuration options
for the DNS services.
+
+h2. Purpose and Overview
+
+The Direct Project Simple Health [Transport|
http://wiki.directproject.org/Simple+Health+Transport] specification
outlines requirements for using DNS to resolve public certificates for the
purpose of message encryption. Although the requirements are not enforced
with the MUST verbiage, the underlying goal is to define a universal and
ubiquitous method to distribute and resolve public certificates.
+
+Several open source and commercial DNS services are already widely
available, however they differ in both their support of the full DNS
specification and the tooling available to configure and manage the DNS
solution. The challenge is finding a solution the meets the needs of the
domain both in terms of functional support and ease of use (good tooling).
So why does the Direct Project provides its own DNS solution when are there
already so many viable options. The simple answer is the use of the CERT
record type. Investigation has shown that many popular, commercially
available DNS services (both organizational and third party hosting, ex:
GoDaddy) do not support CERT records. Conversely many of the open source
services support a broader range of the DNS spec, however tooling and
configuration support is limited. In some solutions, tooling is limited to
editing a raw configuration file with a plain text editor. Text editor
support is not a viable solution for large deployments where thousands of
entries may exist.
+
+The Direct Project DNS services are not intended to be a one stop shop for
all DNS needs, but to compliment existing DNS service and fill the
functional gaps not provided by existing solutions. In practice, the
functional abilities of the Direct DNS services are limited to meet a small
number of use cases. Specifically they provide a simple solution to respond
to public cert requests (and a few other request types) and tooling to
manage certificate storage and DNS record entries. In addition the services
not intended to host primary DNS zones; instead they are deployed in a sub
zone that is generally intended only for Direct Project implementations.
+
+h2. Service Deployment
+
+DNS deployment consists of installing the services using operating system
specific service installation methods and configuring the location of the
DNS record store.
+
+* [DNS Service Deployment|./dns-serv-depl.html]
+
+h2. Service Configuration
+
+Configuration is broken into two logical part: configuring the DNS
specific protocol parameters and configuring/managing DNS records. The
latter configuration may be dependent on the DNS hosting solution of the
primary domain name.
+
+* [DNS Protocol Configuration|./dns-proto-config.html]
+
+* [DNS Record Configuration|./dns-record-config.html]
+
+* [GoDaddy Domain Hosting|./dns-godad-config.html]
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/books/users-guide/dns-godad-config.confluence
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,6 @@
+h1. Integration With GoDaddy
+
+[GoDaddy|http://www.godaddy.com] is a popular domain hosting service. You
can use your existing GoDaddy domain to host a Direct message domain.
Typically you will create a sub domain/zone from your registered domain and
configure GoDaddy to use your DNS server as the name server. The following
links describe creating a sub domain from your existing domain and how to
configure GoDaddy to use your name server with the sub domain.
+
+* [Direct Project DNS Configuration Guide|
http://wiki.directproject.org/DNS+Configuration+Guide]
+* [DNS Configuration On GoDaddy|
http://wiki.directproject.org/Configuring+DNS+on+GoDaddy]
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/books/users-guide/dns-proto-config.confluence
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,22 @@
+h1. DNS Protocol Configuration
+
+The DNS server has several configuration parameters for tuning the DNS
communication protocol. Some of the basic settings are configurable in the
services configuration [file|./dns-serv-depl.html], however the service can
be tuned at a more granular level using the configuration UI web tool.
Settings in the configuration UI take precedence over those in the
configuration file.
+
+h2. Protocol Configuration Parameters
+
+Protocol configuration parameters are set using the same section of the
configuration UI web tool as SMTP server [settings|
http://api.nhindirect.org/java/site/gateway/1.5/users-guide/smtp-depl-wsconfig.html#Anchors].
+
+!images/dnsconfigsetting.png!
+
+
+||Setting||Description||
+|DNSServerBindings|The IP addressed on the local machine that the service
will bind to. Multiple IP addresses are separated with a comma. The
default is 0.0.0.0 which means the service will bind to all IP addresses on
the machine (including the loopback address of 127.0.0.1)|
+|DNSServerPort|The IP port that the DNS server will use for listening for
DNS queries. The default is 53. \\NOTE: Some operating systems may
require the service to run with elevated account privileges to open ports
in this range.|
+|DNSServerMaxRequestSize|The maximum size in bytes for an query request.
The default is 16K.|
+|DNSServerMaxConnectionBacklog|The maximum number of connections that are
in the IP socket accept backlog. Socket backlog is only relevant for TCP
session based connections. Setting this value to high can overload the IP
stack or result in DNS client timeouts. The default value is 64.|
+|DNSServerMaxActiveRequests|The maximum number of concurrent requests that
can be processed by the server at any give time. Setting this value to
high may result in overloading the system. Setting this value to low can
limit throughput. The default is 64.|
+|DNSServerMaxOutstandingRequests|The maximum number of requests that can
be accepted by the server, but not yet committed to a processing thread.
Setting this value to high may result in DNS clients timing out due to
outstanding requests waiting to long for a processing thread. The default
is 16 requests.|
+|DNSServerMaxRequestBuffer|The maximum size request buffer size in bytes.
The default value is 1024 bytes.|
+|DNSServerSendTimeout|The socket timeout in milliseconds for sending
responses. Setting this value to high can result in performance
degradation if multiple clients abandon their sessions. Setting this value
to low can result in clients not receiving responses in high latency
environments. The default value is 5000 milliseconds.|
+|DNSServerRecieveTimeout|The socket timeout in milliseconds for receiving
or reading request. Setting this value to high can result in performance
degradation if multiple clients abandon their sessions. Setting this value
to low can result in the server not fully reading request data in high
latency environments. The default value is 5000 milliseconds.|
+|DNSServerSocketCloseTimeout|The timeout in milliseconds for closing a
socket connection. The default value is 5000 milliseconds.|
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/books/users-guide/dns-record-config.confluence
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,128 @@
+h1. DNS Record Configuration
+
+The primary purpose of the DNS service is to respond to DNS queries with
appropriate DNS record responses. By design, the DNS service can store any
type of DNS record defined by the DNS RFC, however it is tuned only to
respond to a few types of records.
+
+The DNS service stores all DNS records in the Direct Project
configurations services and accesses them over the web service interface.
The the public facing DNS interface does not allow for records to be added
or changed in anyway. Instead, the configuration UI tool is used to manage
and maintain DNS records.
+
+h2. Managing Records
+
+The configuration UI and config management command console tools are used
to add, update, and delete all record types.
+
+h3. Config UI
+
+The Configuration UI tool is used to managed DNS records in the web UI.
To managed records load the Configuration UI tool is a browser, login, and
press the DNS Entries button.
+
+!images/WSConfigDomainSearch.png!
+
+!images/WSConfigDNSHome.png!
+
+h3. Config Management Console
+
+*NOTE* The DNS Management console has been deprecated and all DNS
configuration commands are now available in the Config Management Console.
+
+The Config Management console is command line tool for managing all
configuration aspects of the DirectProject Java reference implementation
including DNS records. To run the console:
+
+# Launch a command shell and navigate to the ConfigMgmtConsole/bin
directory.
+# Run the command _ConfigMgmtConsole_ (./ConfigMgmtConsole for unix based
systems).
+
+The console connects to the Direct Project configuration service and
manages records using the configuration service proxy module. By default
it uses the url
_http://localhost:8081/config-service/ConfigurationService_, but can be
overridden using the configURL command line parameter.
+
+{code}
+ ConfigMgmtConsole configURL
http://confserver/config-service/ConfigurationService
+{code}
+
+*NOTE* The configURL must be the first parameter on the command line to
change the configuration service URL.
+
+The management console can either take command directly on the command
line or run interactively. If no arguments or commands are passed on the
command line (with the exception of the configURL), then console runs
interactively. For a list of supported commands, simple type _help all_
either as command line arguments or when running interactively.
+
+h3. SOA Records
+
+The [SOA|http://support.microsoft.com/kb/163971] (start of authority)
record defines (amongst other attributes) the host that is the
authoritative server for a DNS zone/domain. Each domain managed by the DNS
server should have a SOA record associated with it.
+
+*Config UI*
+
+SOA records are added by entering the required SOA record information in
the Config UI tool on the _DNS Resolver Configuration_ page.
+
+!images/WSConfigSOARecords.png!
+
+*Management Console*
+
+SOA records are added using either of the following commands:
+* DNS&#95;SOA&#95;ADD
+* DNS&#95;SOA&#95;ENSURE
+
+{code}
+ Add a new SOA dns record if an identical one does not exist.
+ domainname primarysourcedomain responsibleemail serialnumber ttl
[refresh] [retry] [expire] [minimum]
+ domainname: The domain name of the name server that was the
primary source for this zone
+ responsibleemail: Email mailbox of the hostmaster
+ serialnumber: Version number of the original copy of the zone.
+ ttl: time to live in seconds, 32bit int
+ [refresh]: Number of seconds before the zone should be refreshed.
+ [retry]: Number of seconds before failed refresh should be retried.
+ [expire]: Number of seconds before records should be expired if
not refreshed
+ [minimum]: Minimum TTL for this zone.
+{code}
+
+h3. A Records
+
+A records maps a host name to an IP4 address.
+
+*Config UI*
+
+A records are added by entering the required A record information in the
Config UI tool on the _DNS Resolver Configuration_ page.
+
+!images/WSConfigARecords.png!
+
+*Management Console*
+
+A records are added using either of the following commands:
+* DNS&#95;ANAME&#95;ADD
+* DNS&#95;ANAME&#95;ENSURE
+
+{code}
+ Add a new A dns record if an identical one does not exist.
+ hostname ipaddress ttl
+ hostname: host name for the record
+ ipaddress: IP address in dot notation
+ ttl: time to live in seconds, 32bit int
+{code}
+
+h3. MX Records
+
+MX records map a domain to one of more servers or message transfer agents
for that domain. The records are returned are generally are cononical
names which means they must have A or CNAME records in the DNS server.
+
+*Config UI*
+
+MX records are added by entering the required MX record information in the
Config UI tool on the _DNS Resolver Configuration_ page.
+
+!images/WSConfigMXRecords.png!
+
+*Management Console*
+
+A records are added using either of the following commands:
+* DNS&#95;MX&#95;ADD
+* DNS&#95;MX&#95;ENSURE
+
+{code}
+ Adds a new MX dns record if an identical one does't already exist.
+ domainname exchange ttl [priority]
+ domainname: email domain name for the record
+ exchange: smtp server host name for the domain
+ ttl: time to live in seconds
+ [priority]: short value indicating preference of the record
+{code}
+
+h3. CERT Records
+[Cert|http://tools.ietf.org/html/rfc4398] records store a certificate with
a DNS name entry. The Direct Project DNS server only stores x.509 public
certificates. *NOTE* The DNS server does not automatically resolve
organizational level certificate resolution as defined by the security and
trust specification; it only responds with the exact matches to a DNS
query. The DNS client is responsibly for sending an org level query if the
server does not respond with certificate to user level certificate query.
+
+Unlike all other DNS record types, the DNS service uses the configuration
services certificate store to find certificates. Certificates are added to
the store using the certificates button in the configuration UI web tool.
See the SMTP web deployment [guide|
http://api.nhindirect.org/java/site/gateway/1.5/users-guide/smtp-depl-wsconfig.html#PrivateCertStore]
for instruction on importing certificates into the configuration UI tool.
*NOTE* Even though certificates in your domain will have the private key
stored with the certificates, the DNS service only returns public
certificate information for CERT record queries.
+
+h2. Required DNS Configuration
+
+Typically your domain registration service will allow you to define an NS
(name service) record that will point the server running your DNS service.
Your DNS service is then responsible for handling all queries for your
domain(s). Depending on your deployment, you will need the following
minimal set of DNS records for your Direct messaging implementation:
+
+* An SOA record for each domain managed by your server.
+* An A record for each of you email servers.
+* An MX record for each of you email servers server a domain.
+* Either an org level certificate for each domain or individual
certificates per email address (this should already be configured as part
of you SMTP agent/gateway installation).
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/books/users-guide/dns-serv-depl.confluence Mon
Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,166 @@
+h1. DNS Service Deployment
+
+The DNS services are deployable on a number of different operating
environments and can be launched either interactively (for debugging) or as
a background service. Although each OS configures and runs background
services differently, the DNS service package contains OS specific script
files that normalize the deployment process.
+
+h2. Service Package Layout
+
+The DNS services are assembled and packaged as a zipped tar ball. In side
the package, the services are bundled using in the following directory
structure.
+
+{code}
+ +-- DirectDNSServer
+ +-- bin
+ +-- conf
+ +-- lib
+ +-- logs
+{code}
+
+*Directory Contents*
+
+* bin - Contains installation and service launching/shutdown scripts.
+* conf - Contains service configuration files.
+* lib - Contains the binary code packages.
+* logs - Contains service execution log files.
+
+h2. Service Installation
+
+Installation of the DNS services is slightly different for each operating
system, however each case uses the same assembly. To install, first
download the Direct Project [assembly|
http://repo2.maven.org/maven2/org/nhind/direct-project-stock/1.3.2/direct-project-stock-1.3.2.tar.gz]
and unpack the contents into the desired location using your archiver of
choice (tar, WinZip, WinRar, File Roller, etc).
+
+h3. Windows Installation
+
+The DNS server runs as Windows service on Windows deployments. To install
as a service:
+
+# Launch a command shell and navigate to the DirectDNSServer/bin directory.
+# Run the command _DirectDNSServer install_
+
+This will install as the server as a windows service that starts
automatically on system boot up. You should be able to see the service in
the Windows service control panel (services.msc).
+
+!images/winservices.png!
+
+To start the server, use one of the following methods:
+
+* Right click on the service in the service control panel and click
_start_.
+* In a command shell, run the command _DirectDNSServer start_.
+
+To stop the server, use one of the following methods:
+
+* Right click on the service in the service control panel and click _stop_.
+* In a command shell, run the command _DirectDNSServer stop_.
+
+To uninstall the server:
+
+# Stop the service using of the method described above.
+# Launch a command shell and navigate to the DirectDNSServer/bin directory.
+# Run the command _DirectDNSServer remove_
+
+*NOTE:* The service runs as process named _wrapper-windows-x86-32.exe_.
If for some reason the service hangs or will not stop, you can terminate it
manually by killing this process.
+
+h3. Linux Installation
+
+The DNS server runs as a background process on Linux based systems and can
be optionally configured to run as a service daemon. To start the service
manually:
+
+# Open a terminal shell and navigate to the DirectDNSServer/bin directory.
+# Run the command _./DirectDNSServer start_
+
+*NOTE:* If you get an error of "Permissioned denied" you will need to set
the executable flag on the script files:
+
+{code}
+ chmod +x DirectDNSServer
+ chmod +x wrapper-linux-x86-32 (or wrapper-linux-x86-64 depending if you
are using a 64 or bit linux installation).
+{code}
+
+To stop the server:
+
+# Open a terminal shell and navigate to the DirectDNSServer/bin directory.
+# Run the command _DirectDNSServer stop_.
+
+You can also optionally configure the server as a service. There are
different ways to do this depending on your linux distribution. On
possibility is to create a script file in the /etc/init.d directory.
+
+Assuming you have deployed the server in the /opt directory and you are
running Ubuntu, create the file /etc/init.d/DirectDNSServer using the
editor of you choice paste the following content:
+
+{code}
+ # DirectDNSServer auto-start
+ #
+ # description: Auto-starts the DirectDNSServer
+
+ case $1 in
+ start)
+ sh /opt/DirectDNSServer/bin/DirectDNSServer start
+ ;;
+ stop)
+ sh /opt/DirectDNSServer/bin/DirectDNSServer stop
+ ;;
+ restart)
+ sh /opt/DirectDNSServer/bin/DirectDNSServer start
+ sh /opt/DirectDNSServer/bin/DirectDNSServer stop
+ ;;
+
+ esac
+ exit 0
+{code}
+
+Make the script executable using the following command:
+
+{code}
+sudo chmod 755 /etc/init.d/DirectDNSServer
+{code}
+
+You can then start the service by running the command:
+
+{code}
+service DirectDNSServer start
+{code}
+
+Conversely you can stop the service by running the command:
+
+{code}
+service DirectDNSServer stop
+{code}
+
+h3. Running Interactively
+
+For debugging or troubleshooting purposes, you may need to run the service
interactively. Running interactively is the same across all platforms.
+
+# Open a terminal shell and navigate to the DirectDNSServer/bin directory.
+# Run the command _DirectDNSServer console_.
+
+The service will output all logging to the current console and the log
file. To terminate the interactive service, simply press _CTRL+C_ (Control
C).
+
+h2. Service Deployment Configuration
+
+The service deployment is configured using a file named _wrapper.conf_
found in the ./conf directory of the service's directory structure. The
service script files read this configuration file to set runtime attributes
such as classpath, logging locations and thresholds, JVM arguments, and
application arguments. The service itself is just a plain Java
application, but is wrapped by a series of deployment classes that are
intialized and launched by the service script.
+
+The configuration file in most cases does not need a lot of modification,
however there a few settings that will need adjustment depending on your
deployment.
+
+{code}
+# Java Additional Parameters
+wrapper.java.additional.1=-Djava.security.policy=conf/policy.all
+wrapper.java.additional.2=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
+wrapper.java.additional.3=-Dorg.apache.commons.logging.simplelog.defaultlog=info
+.
+.
+.
+# Application parameters. Add parameters as needed starting from 1
+wrapper.app.parameter.1=org.nhindirect.dns.service.SimpleServiceRunner
+wrapper.app.parameter.2=-p
+wrapper.app.parameter.3=53
+wrapper.app.parameter.4=-b
+wrapper.app.parameter.5=0.0.0.0
+wrapper.app.parameter.6=-u
+wrapper.app.parameter.7=http://localhost:8081/config-service/ConfigurationService
+wrapper.app.parameter.8=-m
+wrapper.app.parameter.9=SERVER
+{code}
+
+Typical settings that may need adjustment.
+
+||Setting||Description||
+|-Dorg.apache.commons.logging.simplelog.defaultlog|The logging threshold.
Valid value: \\ \\fatal: Severe errors that cause premature
termination\\error: Other runtime errors or unexpected conditions.\\warn:
Use of deprecated APIs, poor use of API, 'almost' errors, other runtime
situations that are undesirable or unexpected, but not
necessarily "wrong".\\info (default): Interesting runtime events such as
startup/shutdown.\\debug: Detailed information on flow of through the
system.\\trace: Even more detailed information such as entering and exiting
methods.|
+|wrapper.app.parameter.2=-p|The IP port that the DNS server will use for
listening for DNS queries. The default is 53. \\NOTE: Some operating
systems may require the service to run with elevated account privileges to
open ports in this range.|
+|wrapper.app.parameter.4=-b|The IP addressed on the local machine that the
service will bind to. Multiple IP addresses are separated with a comma.
The default is 0.0.0.0 which means the service will bind to all IP
addresses on the machine (including the loopback address of 127.0.0.1)|
+|wrapper.app.parameter.6=-u|This is the URL of the location of the DNS
records. Generally this will be the URL of the Direct Project
configuration web service.|
+
+Some of these parameters can be over ridden with settings in the
configuration service. See the protocol
[configuration|./dns-proto-config.html] for more details.
+
+h2. Service Logging
+
+The service logs are written to the file _wrapper.txt_ found in the ./logs
directory of the service's directory structure. Logging threshold
configuration is described in the previous section.
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/books/users-guide/images/WSConfigARecords.png
Mon Jan 26 14:04:30 2015 UTC
Binary file, no diff available.
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/books/users-guide/images/WSConfigDNSHome.png
Mon Jan 26 14:04:30 2015 UTC
Binary file, no diff available.
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/books/users-guide/images/WSConfigDomainSearch.png
Mon Jan 26 14:04:30 2015 UTC
Binary file, no diff available.
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/books/users-guide/images/WSConfigMXRecords.png
Mon Jan 26 14:04:30 2015 UTC
Binary file, no diff available.
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/books/users-guide/images/WSConfigSOARecords.png
Mon Jan 26 14:04:30 2015 UTC
Binary file, no diff available.
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/books/users-guide/images/dnsconfigsetting.png
Mon Jan 26 14:04:30 2015 UTC
Binary file, no diff available.
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/books/users-guide/images/winservices.png Mon
Jan 26 14:04:30 2015 UTC
Binary file, no diff available.
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/books/users-guide/preface.apt Mon Jan 26
14:04:30 2015 UTC
@@ -0,0 +1,11 @@
+ -----
+ Introduction
+ -----
+ Greg Meyer
+ -----
+
+About this Document
+
+ This document describes how to implement and configure the Direct
Project Java DNS server for certificate distribution.
+
+ * {{{./deploy-intro.html}Development Guide}} - This section describes
how deploy and configure the DNS services.
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/descriptors/distribution.xml Mon Jan 26
14:04:30 2015 UTC
@@ -0,0 +1,19 @@
+<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>assembly</id>
+ <baseDirectory>DirectDNSServices</baseDirectory>
+ <formats>
+ <format>tar.gz</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+
<directory>${project.build.directory}/appassembler/jsw/DirectDNSServer</directory>
+ <outputDirectory>/DirectDNSServer</outputDirectory>
+ </fileSet>
+ <fileSet>
+
<directory>${project.build.directory}/appassembler/app/DNSMgmtConsole</directory>
+ <outputDirectory>/DNSMgmtConsole</outputDirectory>
+ </fileSet>
+ </fileSets>
+</assembly>
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/ConfigServiceDNSStore.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,597 @@
+/*
+ Copyright (c) 2010, Direct Project
+ All rights reserved.
+
+ Authors:
+ Umesh Madan ume...@microsoft.com
+ Chris Lomonico chris.l...@surescripts.com
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
+Neither the name of The Direct Project (directproject.org) nor the names
of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import java.security.KeyStore;
+import java.security.Security;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.security.interfaces.RSAKey;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nhind.config.Certificate;
+import org.nhind.config.ConfigurationServiceProxy;
+import org.nhind.config.DnsRecord;
+import org.nhindirect.dns.annotation.ConfigServiceURL;
+import org.xbill.DNS.CERTRecord;
+import org.xbill.DNS.DClass;
+import org.xbill.DNS.Flags;
+import org.xbill.DNS.Header;
+import org.xbill.DNS.Message;
+import org.xbill.DNS.Name;
+import org.xbill.DNS.Opcode;
+import org.xbill.DNS.RRset;
+import org.xbill.DNS.Rcode;
+import org.xbill.DNS.Record;
+import org.xbill.DNS.Section;
+import org.xbill.DNS.Type;
+
+
+import com.google.inject.Inject;
+
+/**
+ * Implementation of the the {@link DNStore} interface that uses the
Direct Project configuration web service to store
+ * DNS records.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+public class ConfigServiceDNSStore implements DNSStore
+{
+
+ protected static final String DEFAULT_JCE_PROVIDER_STRING = "BC";
+ protected static final String JCE_PROVIDER_STRING_SYS_PARAM
= "org.nhindirect.dns.JCEProviderName";
+
+ protected static final Log LOGGER =
LogFactory.getFactory().getInstance(ConfigServiceDNSStore.class);
+
+ protected Map<String, Record> soaRecords = null;
+
+ /**
+ * Gets the configured JCE crypto provider string for crypto operations.
This is configured using the
+ * -Dorg.nhindirect.dns.JCEProviderName JVM parameters. If the parameter
is not set or is empty,
+ * then the default string "BC" (BouncyCastle provider) is returned. By
default the agent installs the BouncyCastle provider.
+ * @return The name of the JCE provider string.
+ */
+ public static String getJCEProviderName()
+ {
+ String retVal = System.getProperty(JCE_PROVIDER_STRING_SYS_PARAM);
+
+ if (retVal == null || retVal.isEmpty())
+ retVal = DEFAULT_JCE_PROVIDER_STRING;
+
+ return retVal;
+ }
+
+ /**
+ * Overrides the configured JCE crypto provider string. If the name is
empty or null, the default string "BC" (BouncyCastle provider)
+ * is used.
+ * @param name The name of the JCE provider.
+ */
+ public static void setJCEProviderName(String name)
+ {
+ if (name == null || name.isEmpty())
+ System.setProperty(JCE_PROVIDER_STRING_SYS_PARAM,
DEFAULT_JCE_PROVIDER_STRING);
+ else
+ System.setProperty(JCE_PROVIDER_STRING_SYS_PARAM, name);
+ }
+
+ static
+ {
+ Security.addProvider(new
org.bouncycastle.jce.provider.BouncyCastleProvider());
+ }
+
+ final ConfigurationServiceProxy proxy;
+
+ /**
+ * Creates a store using the provided URL to lookup DNS records in the
configuration service.
+ * @param serviceURL The URL of the configuration service.
+ */
+ @Inject
+ public ConfigServiceDNSStore(@ConfigServiceURL URL serviceURL)
+ {
+ proxy = new ConfigurationServiceProxy(serviceURL.toString());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public Message get(Message request) throws DNSException
+ {
+ LOGGER.trace("get(Message) Entered");
+
+ if (request == null)
+ throw new DNSException(DNSError.newError(Rcode.FORMERR));
+
+ Header header = request.getHeader();
+ if (header.getFlag(Flags.QR) || header.getRcode() != Rcode.NOERROR)
+ throw new DNSException(DNSError.newError(Rcode.FORMERR));
+
+ if (header.getOpcode() != Opcode.QUERY)
+ throw new DNSException(DNSError.newError(Rcode.NOTIMP));
+
+ Record question = request.getQuestion();
+
+ if (question == null || question.getDClass() != DClass.IN)
+ {
+ throw new DNSException(DNSError.newError(Rcode.NOTIMP));
+ }
+
+ Record queryRecord = request.getQuestion();
+ Name name = queryRecord.getName();
+ int type = queryRecord.getType();
+
+ if (LOGGER.isDebugEnabled())
+ {
+ StringBuilder builder = new StringBuilder("Recieved Query Request:");
+ builder.append("\r\n\tName: " + name.toString());
+ builder.append("\r\n\tType: " + type);
+ builder.append("\r\n\tDClass: " + queryRecord.getDClass());
+ LOGGER.debug(builder.toString());
+ }
+
+ Collection<Record> lookupRecords= null;
+ switch (question.getType())
+ {
+ case Type.A:
+ case Type.MX:
+ case Type.SOA:
+ case Type.SRV:
+ case Type.NS:
+ case Type.CNAME:
+ {
+ try
+ {
+ final RRset set = processGenericRecordRequest(name.toString(),
type);
+
+ if (set != null)
+ {
+ lookupRecords = new ArrayList<Record>();
+ Iterator<Record> iter = set.rrs();
+ while (iter.hasNext())
+ lookupRecords.add(iter.next());
+ }
+
+ }
+ catch (Exception e)
+ {
+ throw new DNSException(DNSError.newError(Rcode.SERVFAIL), "DNS
service proxy call failed: " + e.getMessage(), e);
+ }
+ break;
+ }
+ case Type.CERT:
+ {
+ final RRset set = processCERTRecordRequest(name.toString());
+
+ if (set != null)
+ {
+ lookupRecords = new ArrayList<Record>();
+ Iterator<Record> iter = set.rrs();
+ while (iter.hasNext())
+ lookupRecords.add(iter.next());
+ }
+
+ break;
+ }
+ case Type.ANY:
+ {
+
+ Collection<Record> genRecs =
processGenericANYRecordRequest(name.toString());
+ RRset certRecs = processCERTRecordRequest(name.toString());
+
+ if (genRecs != null || certRecs != null)
+ {
+ lookupRecords = new ArrayList<Record>();
+ if (genRecs != null)
+ lookupRecords.addAll(genRecs);
+
+ if (certRecs != null)
+ {
+ Iterator<Record> iter = certRecs.rrs();
+ while (iter.hasNext())
+ lookupRecords.add(iter.next());
+ }
+ }
+
+ break;
+ }
+ default:
+ {
+ LOGGER.debug("Query Type " + type + " not implemented");
+ throw new DNSException(DNSError.newError(Rcode.NOTIMP), "Query
Type " + type + " not implemented");
+ }
+ }
+
+
+ if (lookupRecords == null || lookupRecords.size() == 0)
+ {
+ LOGGER.debug("No records found.");
+ return null;
+ }
+
+ Message response = new Message(request.getHeader().getID());
+ response.getHeader().setFlag(Flags.QR);
+ if (request.getHeader().getFlag(Flags.RD))
+ response.getHeader().setFlag(Flags.RD);
+ response.addRecord(queryRecord, Section.QUESTION);
+
+
+ Iterator<Record> iter = lookupRecords.iterator();
+ while (iter.hasNext())
+ response.addRecord(iter.next(), Section.ANSWER);
+
+ // we are authoritative only
+ response.getHeader().setFlag(Flags.AA);
+ // look for an SOA record
+ Record soaRecord = checkForSoaRecord(name.toString());
+ if (soaRecord != null)
+ response.addRecord(soaRecord, Section.AUTHORITY);
+
+ LOGGER.trace("get(Message) Exit");
+
+ return response;
+ }
+
+ /**
+ * Processes all DNS requests except CERT records.
+ * @param name The record name.
+ * @param type The record type.
+ * @return Returns a set of record responses to the request.
+ * @throws DNSException
+ */
+ protected RRset processGenericRecordRequest(String name, int type) throws
DNSException
+ {
+ DnsRecord records[];
+
+ try
+ {
+ records = proxy.getDNSByNameAndType(name, type);
+ }
+ catch (Exception e)
+ {
+ throw new DNSException(DNSError.newError(Rcode.SERVFAIL), "DNS service
proxy call for DNS records failed: " + e.getMessage(), e);
+ }
+
+ if (records == null || records.length == 0)
+ return null;
+
+ RRset retVal = new RRset();
+ try
+ {
+ for (DnsRecord record : records)
+ {
+ Record rec = Record.newRecord(Name.fromString(record.getName()),
record.getType(),
+ record.getDclass(), record.getTtl(), record.getData());
+
+ retVal.addRR(rec);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new DNSException(DNSError.newError(Rcode.SERVFAIL), "Failure
while parsing generic record data: " + e.getMessage(), e);
+ }
+
+ return retVal;
+ }
+
+ protected Collection<Record> processGenericANYRecordRequest(String name)
throws DNSException
+ {
+ DnsRecord records[];
+
+ try
+ {
+ records = proxy.getDNSByNameAndType(name, Type.ANY);
+ }
+ catch (Exception e)
+ {
+ throw new DNSException(DNSError.newError(Rcode.SERVFAIL), "DNS service
proxy call for DNS records failed: " + e.getMessage(), e);
+ }
+
+ if (records == null || records.length == 0)
+ return null;
+
+ Collection<Record> retVal = new ArrayList<Record>();
+ try
+ {
+ for (DnsRecord record : records)
+ {
+ Record rec = Record.newRecord(Name.fromString(record.getName()),
record.getType(),
+ record.getDclass(), record.getTtl(), record.getData());
+
+ retVal.add(rec);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new DNSException(DNSError.newError(Rcode.SERVFAIL), "Failure
while parsing generic record data: " + e.getMessage(), e);
+ }
+
+ return retVal;
+ }
+
+ /**
+ * Processes all DNS CERT requests.
+ * @param name The record name. In many cases this a email address.
+ * @return Returns a set of record responses to the request.
+ * @throws DNSException
+ */
+ @SuppressWarnings("unused")
+ protected RRset processCERTRecordRequest(String name) throws DNSException
+ {
+ if (name.endsWith("."))
+ name = name.substring(0, name.length() - 1);
+
+ Certificate[] certs;
+
+ // use the certificate configuration service
+ try
+ {
+ certs = proxy.getCertificatesForOwner(name, null);
+ }
+ catch (Exception e)
+ {
+ throw new DNSException(DNSError.newError(Rcode.SERVFAIL), "DNS service
proxy call for certificates failed: " + e.getMessage(), e);
+ }
+
+ if (certs == null || certs.length == 0)
+ {
+ // unless the call above was for an org level cert, it will probably
always fail because the
+ // "name" parameter has had all instances of "@" replaced with ".".
The certificate service
+ // stores owners using "@".
+ // This is horrible, but try hitting the cert service replacing
each "." with "@" one by one.
+ // Start at the beginning of the address because this is more than
likely where the "@" character
+ // will be.
+ int previousIndex = 0;
+ int replaceIndex = 0;
+ while ((replaceIndex = name.indexOf(".", previousIndex)) > -1)
+ {
+ char[] chars = name.toCharArray();
+ chars[replaceIndex] = '@';
+ try
+ {
+ certs = proxy.getCertificatesForOwner(String.copyValueOf(chars),
null);
+ }
+ catch (Exception e)
+ {
+ throw new DNSException(DNSError.newError(Rcode.SERVFAIL), "DNS
service proxy call for certificates failed: " + e.getMessage(), e);
+ }
+ if (certs != null && certs.length > 0)
+ break;
+
+ if (replaceIndex >= (name.length() - 1))
+ break;
+
+ previousIndex = replaceIndex + 1;
+ }
+ }
+
+ if (certs == null || certs.length == 0)
+ return null;
+
+ if (!name.endsWith("."))
+ name += ".";
+
+ RRset retVal = new RRset();
+ try
+ {
+ for (Certificate cert : certs)
+ {
+ int certRecordType = CERTRecord.PKIX;
+ byte[] retData = null;
+
+ X509Certificate xCert = null;
+ try
+ {
+ xCert = dataToCert(cert.getData());
+ retData = xCert.getEncoded();
+ }
+ catch (DNSException e)
+ {
+ // probably not a Certificate... might be a URL
+ }
+
+
+ if (xCert == null)
+ {
+ // see if it's a URL
+ try
+ {
+ retData = cert.getData();
+ URL url = new URL(new String(retData));
+ certRecordType = CERTRecord.URI;
+ }
+ catch (Exception e)
+ {
+ throw new DNSException(DNSError.newError(Rcode.SERVFAIL), "Failure
while parsing CERT record data: " + e.getMessage(), e);
+ }
+ }
+
+ int keyTag = 0;
+ int alg = 0;
+ if (xCert != null && xCert.getPublicKey() instanceof RSAKey)
+ {
+ RSAKey key = (RSAKey)xCert.getPublicKey();
+ byte[] modulus = key.getModulus().toByteArray();
+
+ keyTag = (modulus[modulus.length - 2] << 8) & 0xFF00;
+
+ keyTag |= modulus[modulus.length - 1] & 0xFF;
+ alg = 5;
+ }
+
+ CERTRecord rec = new CERTRecord(Name.fromString(name), DClass.IN,
86400L, certRecordType, keyTag,
+ alg /*public key alg, RFC 4034*/, retData);
+
+ retVal.addRR(rec);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new DNSException(DNSError.newError(Rcode.SERVFAIL), "Failure
while parsing CERT record data: " + e.getMessage(), e);
+ }
+
+ return retVal;
+ }
+
+ /*
+ * It's possible we could be getting data from a p12 file which contains
the private key. This methods
+ * ensures that both p12 and X509 formats are decoded properly and only
public certificates are returned.
+ */
+ protected X509Certificate dataToCert(byte[] data) throws DNSException
+ {
+ ByteArrayInputStream bais = null;
+ X509Certificate retVal = null;
+ try
+ {
+ bais = new ByteArrayInputStream(data);
+
+ // lets try this a as a PKCS12 data stream first
+ try
+ {
+ KeyStore localKeyStore = KeyStore.getInstance("PKCS12",
getJCEProviderName());
+
+ localKeyStore.load(bais, "".toCharArray());
+ Enumeration<String> aliases = localKeyStore.aliases();
+
+
+ // we are really expecting only one alias
+ if (aliases.hasMoreElements())
+ {
+ String alias = aliases.nextElement();
+ retVal = (X509Certificate)localKeyStore.getCertificate(alias);
+ }
+ }
+ catch (Exception e)
+ {
+ // must not be a PKCS12 stream, go on to next step
+ }
+ finally
+ {
+ if (bais != null)
+ {
+ try
+ {
+ bais.close();
+ bais = null;
+ }
+ catch (IOException e) {/* no-op */}
+ }
+ }
+
+ if (retVal == null)
+ {
+ //try X509 certificate factory next
+ bais = new ByteArrayInputStream(data);
+
+ retVal = (X509Certificate)
CertificateFactory.getInstance("X.509").generateCertificate(bais);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new DNSException("Data cannot be converted to a valid
X.509 Certificate");
+ }
+ finally
+ {
+ if (bais != null)
+ {
+ try
+ {
+ bais.close();
+ }
+ catch (IOException e) {/* no-op */}
+ }
+ }
+
+ return retVal;
+ }
+
+
+ /*
+ * Look for SOA records corresponding to the request
+ * TODO: Add cache coherency to SOA records?
+ */
+ protected synchronized Record checkForSoaRecord(String questionName)
+ {
+ if (!questionName.endsWith("."))
+ questionName += ".";
+
+ if (soaRecords == null)
+ {
+ DnsRecord[] getRecs = null;
+ // load all SOA records...
+ try
+ {
+ getRecs = proxy.getDNSByType(Type.SOA);
+
+ if (getRecs == null || getRecs.length == 0)
+ soaRecords = Collections.emptyMap();
+ else
+ {
+ soaRecords = new HashMap<String, Record>();
+
+ for (DnsRecord rec : getRecs)
+ {
+ Record newRec = Record.newRecord(Name.fromString(rec.getName()),
Type.SOA,
+ rec.getDclass(), rec.getTtl(), rec.getData());
+
+ soaRecords.put(newRec.getName().toString(), newRec);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ LOGGER.error("Failed to load SOA records from config service.");
+ }
+ }
+
+ Record retVal = null;
+ if (soaRecords.size() > 0)
+ {
+ // look for the record by question name
+
+ retVal = soaRecords.get(questionName);
+ if (retVal == null)
+ {
+ // start taking apart the question name . by .
+ int index = -1;
+ while ((index = questionName.indexOf(".")) > 0 && index <
(questionName.length() - 1))
+ {
+ questionName = questionName.substring(index + 1);
+ retVal = soaRecords.get(questionName);
+ if (retVal != null)
+ break;
+ }
+ }
+ }
+
+ return retVal;
+ }
+}
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSError.java Mon
Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,72 @@
+/*
+Copyright (c) 2010, NHIN Direct Project
+All rights reserved.
+
+Authors:
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
distribution. Neither the name of the The NHIN Direct Project
(nhindirect.org).
+nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns;
+
+/**
+ * Container for a DNS error code.
+ * @author Greg Meyer
+ *
+ * @param <T> The error type. Typically a long or integer describing an
error code.
+ * @since 1.0
+ */
+public class DNSError<T>
+{
+ /**
+ * Creates a new DNSError with an internal error code.
+ * @param <T> The error Type. Typically a long or integer describing an
error code.
+ * @param error The error describing the error condition.
+ * @return
+ */
+ public static <T> DNSError<T> newError(T error)
+ {
+ return new DNSError<T>(error);
+ }
+
+ private final T error;
+
+ /**
+ * Constructs a new DNSError.
+ * @param error The error describing the error condition.
+ */
+ public DNSError(T error)
+ {
+ this.error = error;
+ }
+
+ /**
+ * Gets the internal error. The error is typically a long or integer
describing an error code.
+ * @return The internal error.
+ */
+ public T getError()
+ {
+ return error;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return error.toString();
+ }
+}
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSException.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,95 @@
+/*
+Copyright (c) 2010, NHIN Direct Project
+All rights reserved.
+
+Authors:
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
distribution. Neither the name of the The NHIN Direct Project
(nhindirect.org).
+nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns;
+
+/**
+ * Exception for DNS server errors.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+public class DNSException extends Exception
+{
+
+ static final long serialVersionUID = 1852021431664662496L;
+
+
+ private DNSError<?> error;
+
+ /**
+ * Construct an exception with an error message.
+ * @param error The error message.
+ */
+ public DNSException(String error)
+ {
+ super(error);
+ }
+
+ /**
+ * Construct an exception with a given DNS error.
+ * @param error The DNS error.
+ */
+ public DNSException(DNSError<?> error)
+ {
+ this(error, "");
+ }
+
+ /**
+ * Constructs an exception with a message and the DNS error.
+ * @param error The DNS error
+ * @param msg The exception message.
+ */
+ public DNSException(DNSError<?> error, String message)
+ {
+ this(error,message,null);
+ }
+
+ /**
+ * Constructs an exception with the DNS error and the exception that
caused the error.
+ * @param error The DNS error.
+ * @param innerException The exception that caused the error.
+ */
+ public DNSException(DNSError<?> error, Exception innerException)
+ {
+ this(error, "", innerException);
+ }
+
+ /**
+ * Constructs an exception with the DNS error, a message, and the
exception that caused the error.
+ * @param error The DNS error.
+ * @param msg The exception message.
+ * @param innerException The exception that caused the error.
+ */
+ public DNSException(DNSError<?> error, String message, Exception
innerException)
+ {
+ super(message, innerException);
+ this.error = error;
+ }
+
+ /**
+ * Gets the internal DNSError.
+ * @return The internal DNSError.
+ */
+ public DNSError<?> getError()
+ {
+ return this.error;
+ }
+}
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSResponder.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,189 @@
+/*
+ Copyright (c) 2010, Direct Project
+ All rights reserved.
+
+ Authors:
+ Umesh Madan ume...@microsoft.com
+ Chris Lomonico chris.l...@surescripts.com
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
+Neither the name of The Direct Project (directproject.org) nor the names
of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns;
+
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xbill.DNS.Flags;
+import org.xbill.DNS.Header;
+import org.xbill.DNS.Message;
+import org.xbill.DNS.Rcode;
+import org.xbill.DNS.Section;
+
+/**
+ * Abstract DNSResponder for DNS requests. It implements common methods
for calling the DNS store and handling error conditions. Protocol specific
+ * (UDP, TCP, etc) messaging handling is implemented in concrete
implementations.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+public abstract class DNSResponder
+{
+ private static final Log LOGGER =
LogFactory.getFactory().getInstance(DNSResponder.class);
+
+ protected DNSServerSettings settings;
+ protected DNSStore store;
+
+ /**
+ * Creates a DNS responder using the provided settings and DNS store.
The responder will not handle requests
+ * until {@link #start()} is called.
+ * @param settings The DNS server settings.
+ * @param store The DNS store that holds the DNS record information.
+ * @throws DNSException
+ */
+ public DNSResponder(DNSServerSettings settings, DNSStore store) throws
DNSException
+ {
+ this.settings = settings;
+ this.store = store;
+ }
+
+ /**
+ * Starts the responder. Concrete implementation bind their protocol
specific handlers and start accepting DNS requests.
+ * @throws DNSException
+ */
+ public abstract void start() throws DNSException;
+
+ /**
+ * Stops the responder. The responder will not londer accept DNS
requests after stop has been called.
+ * @throws DNSException
+ */
+ public abstract void stop() throws DNSException;
+
+ /**
+ * Processes a DNS request and returns a DNS response. The request is in
raw DNS wire protocol format.
+ * @param rawMessage The raw DNS wire protocol format of the request.
+ * @return A response to the DNS request.
+ * @throws DNSException
+ */
+ public Message processRequest(byte[] rawMessage) throws DNSException
+ {
+ if (rawMessage == null || rawMessage.length == 0)
+ throw new DNSException(DNSError.newError(Rcode.FORMERR), "Message
cannot be null or empty.");
+
+ Message msg;
+ try
+ {
+ msg = new Message(rawMessage);
+ }
+ catch (IOException e)
+ {
+ throw new DNSException(DNSError.newError(Rcode.FORMERR), "IO Exception
reading raw message.", e);
+ }
+
+ return processRequest(msg);
+ }
+
+ /**
+ * Processes a DNS request and returns a DNS response.
+ * @param request The DNS request message.
+ * @return A response to the DNS request.
+ */
+ public Message processRequest(Message request)
+ {
+ if (request == null)
+ throw new IllegalArgumentException("Missing request. Request cannot be
null.");
+
+ Message response;
+ try
+ {
+ response = store.get(request);
+ if (response == null || response.getHeader() == null)
+ {
+
+ response = processError(request,
DNSError.newError(Rcode.NXDOMAIN));
+ }
+ else if (response.getHeader().getRcode() != Rcode.NOERROR)
+ response = processError(request,
DNSError.newError(response.getHeader().getRcode()));
+ }
+ catch (DNSException e)
+ {
+ // don't log as an error if it's just a non implemented query type
+ if (!e.getError().getError().equals(Rcode.NOTIMP))
+ {
+ LOGGER.error("Error processing DNS request: " + e.getMessage(), e);
+ }
+ response = processError(request, e.getError());
+ }
+
+ return response;
+ }
+
+ /**
+ * Processes a DNS error condition and creates an appropriate DNS
response.
+ * @param request The original DNS request.
+ * @param error The error condition that occured.
+ * @return A response to the DNS request.
+ */
+ protected Message processError(Message request, DNSError<?> error)
+ {
+ Message errorResponse = null;
+ try
+ {
+ Header respHeader = new Header(request.toWire());
+ Message response = new Message();
+ response.setHeader(respHeader);
+
+ for (int i = 0; i < 4; i++)
+ response.removeAllRecords(i);
+
+ response.addRecord(request.getQuestion(), Section.QUESTION);
+
+ response.getHeader().setFlag(Flags.QR);
+ if (request.getHeader().getFlag(Flags.RD))
+ response.getHeader().setFlag(Flags.RD);
+ respHeader.setRcode(Integer.parseInt(error.getError().toString()));
+
+ return response;
+ }
+ catch (IOException e) {}
+
+ return errorResponse;
+ }
+
+ /**
+ * Converts a raw DNS wire protocol format message to a Message
structure.
+ * @param buffer The raw DNS wire protocol format.
+ * @return A Message object converted from the buffer.
+ * @throws DNSException
+ */
+ protected Message toMessage(byte[] buffer) throws DNSException
+ {
+ if (buffer.length <= 0 || buffer.length >
settings.getMaxRequestSize())
+ throw new DNSException(DNSError.newError(Rcode.REFUSED), "Invalid
request size " + buffer.length);
+
+ try
+ {
+ return new Message(buffer);
+ }
+ catch (IOException e)
+ {
+ throw new DNSException(DNSError.newError(Rcode.FORMERR), "Failed to
deserialize raw byte message.");
+ }
+ }
+
+ /**
+ * Converts a Message object to a raw DNS wire format byte array.
+ * @param msg The message to convert.
+ * @return A byte array representing the raw DNS wire format of the
message.
+ */
+ protected byte[] toBytes(Message msg)
+ {
+ return msg.toWire();
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSResponderTCP.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,58 @@
+/*
+ Copyright (c) 2010, Direct Project
+ All rights reserved.
+
+ Authors:
+ Umesh Madan ume...@microsoft.com
+ Chris Lomonico chris.l...@surescripts.com
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
+Neither the name of The Direct Project (directproject.org) nor the names
of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns;
+
+/**
+ * TCP/IP implementation of the {@link DNSReponser) interface. The
responder binds to the addresses and port
+ * provided in the {@link DNSServerSettings} object.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+public class DNSResponderTCP extends DNSResponder
+{
+ private final DNSSocketServer socketServer;
+
+ /**
+ * {@inheritDoc}
+ */
+ public DNSResponderTCP(DNSServerSettings settings, DNSStore store) throws
DNSException
+ {
+ super(settings, store);
+ socketServer = new TCPServer(settings, this);
+ }
+
+
+ /**
+ * {@inheritDoc}}
+ */
+ @Override
+ public void start() throws DNSException
+ {
+ socketServer.start();
+ }
+
+
+ /**
+ * {@inheritDoc}}
+ */
+ @Override
+ public void stop() throws DNSException
+ {
+ socketServer.stop();
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSResponderUDP.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,58 @@
+/*
+ Copyright (c) 2010, Direct Project
+ All rights reserved.
+
+ Authors:
+ Umesh Madan ume...@microsoft.com
+ Chris Lomonico chris.l...@surescripts.com
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
+Neither the name of The Direct Project (directproject.org) nor the names
of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns;
+
+/**
+ * UDP/IP implementation of the {@link DNSReponser) interface. The
responder binds to the addresses and port
+ * provided in the {@link DNSServerSettings} object.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+public class DNSResponderUDP extends DNSResponder
+{
+ private final DNSSocketServer socketServer;
+
+ /**
+ * {@inheritDoc}}
+ */
+ public DNSResponderUDP(DNSServerSettings settings, DNSStore store) throws
DNSException
+ {
+ super(settings, store);
+ socketServer = new UDPServer(settings, this);
+ }
+
+
+ /**
+ * {@inheritDoc}}
+ */
+ @Override
+ public void start() throws DNSException
+ {
+ socketServer.start();
+ }
+
+
+ /**
+ * {@inheritDoc}}
+ */
+ @Override
+ public void stop() throws DNSException
+ {
+ socketServer.stop();
+ }
+}
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSServer.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,213 @@
+/*
+Copyright (c) 2010, NHIN Direct Project
+All rights reserved.
+
+Authors:
+ Umesh Madan ume...@microsoft.com
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
distribution. Neither the name of the The NHIN Direct Project
(nhindirect.org).
+nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+package org.nhindirect.dns;
+
+import java.lang.management.ManagementFactory;
+import java.util.UUID;
+
+import javax.management.JMException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.inject.Inject;
+
+/**
+ * The DNS server creates the UDP and TCP responders and manages their
life cycles. DNS queries are delegated
+ * the responders which use the {@link DNSStore} to lookup entries.
+ * <p>
+ * To run a server, an instance of a server is created followed by calling
the {@link #start()} method.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+public class DNSServer implements DNSServerMBean
+{
+ private static final Log LOGGER =
LogFactory.getFactory().getInstance(DNSServer.class);
+
+ private DNSResponder tcpResponder;
+ private DNSResponder updResponder;
+ private CompositeData settingsData;
+ private final String dnsStoreImplName;
+
+ /**
+ * Create a new DNSServer
+ * @param store The storage medium of the DNS records.
+ * @param settings DNS server specific settings such as UDP/TCP ports, IP
bindings, and thread tuning parameters.
+ */
+ @Inject
+ public DNSServer(DNSStore store, DNSServerSettings settings)
+ {
+ try
+ {
+ tcpResponder = new DNSResponderTCP(settings, store);
+ }
+ catch (DNSException e)
+ {
+ LOGGER.error("Failed to create TCP responder: " +
e.getLocalizedMessage(), e);
+ }
+
+ try
+ {
+ updResponder = new DNSResponderUDP(settings, store);
+ }
+ catch (DNSException e)
+ {
+ LOGGER.error("Failed to create UDP responder: " +
e.getLocalizedMessage(), e);
+ }
+
+ dnsStoreImplName = store.getClass().getName();
+
+ registerMBean(settings);
+ }
+
+ /**
+ * Register the MBean
+ */
+ private void registerMBean(DNSServerSettings settings)
+ {
+ String[] itemNames = {"Port", "Bind Address", "Max Request Size", "Max
Outstanding Accepts", "Max Active Accepts", "Max Connection Backlog",
+ "Read Buffer Size", "Send Timeout", "Receive Timeout", "Socket Close
Timeout"};
+
+ String[] itemDesc = {"Port", "Bind Address", "Max Request Size", "Max
Outstanding Accepts", "Max Active Accepts", "Max Connection Backlog",
+ "Read Buffer Size", "Send Timeout", "Receive Timeout", "Socket Close
Timeout"};
+
+ OpenType<?>[] types = {SimpleType.INTEGER, SimpleType.STRING,
SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER,
SimpleType.INTEGER, SimpleType.INTEGER,
+ SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER};
+
+ Object[] settingsValues = {settings.getPort(),
settings.getBindAddress(), settings.getMaxRequestSize(),
settings.getMaxOutstandingAccepts(),
+ settings.getMaxActiveRequests(), settings.getMaxConnectionBacklog(),
settings.getReadBufferSize(), settings.getSendTimeout(),
+ settings.getReceiveTimeout(), settings.getSocketCloseTimeout()};
+
+ try
+ {
+ CompositeType settingsType = new
CompositeType(DNSServerSettings.class.getSimpleName(), "DNS server
settings.", itemNames, itemDesc, types);
+ settingsData = new CompositeDataSupport(settingsType, itemNames,
settingsValues);
+ }
+ catch (OpenDataException e)
+ {
+ LOGGER.error("Failed to create settings composite type: " +
e.getLocalizedMessage(), e);
+ return;
+ }
+
+
+ Class<?> clazz = this.getClass();
+ final StringBuilder objectNameBuilder = new
StringBuilder(clazz.getPackage().getName());
+ objectNameBuilder.append(":type=").append(clazz.getSimpleName());
+ objectNameBuilder.append(",name=").append(UUID.randomUUID());
+
+ try
+ {
+ final StandardMBean mbean = new StandardMBean(this,
DNSServerMBean.class);
+
+ final MBeanServer mbeanServer =
ManagementFactory.getPlatformMBeanServer();
+ mbeanServer.registerMBean(mbean, new
ObjectName(objectNameBuilder.toString()));
+ }
+ catch (JMException e)
+ {
+ LOGGER.error("Unable to register the DNSServer MBean", e);
+ }
+ }
+
+ /**
+ * Starts the DNS server by initializing and launching the TCP and UDP
listeners.
+ * @throws DNSException Thrown if the internal listeners could not be
started.
+ */
+ public void start() throws DNSException
+ {
+ tcpResponder.start();
+ updResponder.start();
+ }
+
+ /**
+ * Stops the server and shuts down the TCP and UPD listeners.
+ * @throws DNSException Thrown if the internal listeners could not be
stopped.
+ */
+ public void stop() throws DNSException
+ {
+ tcpResponder.stop();
+ updResponder.stop();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public CompositeData getServerSettings()
+ {
+
+ return settingsData;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void startServer()
+ {
+ LOGGER.info("Received request to start server.");
+ try
+ {
+ start();
+ }
+ catch (DNSException e)
+ {
+ LOGGER.error("Failed to start server: " + e.getMessage(), e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void stopServer()
+ {
+ LOGGER.info("Received request to stop server.");
+ try
+ {
+ stop();
+ }
+ catch (DNSException e)
+ {
+ LOGGER.error("Failed to stop server: " + e.getMessage(), e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getDNSStoreImplName()
+ {
+ return dnsStoreImplName;
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSServerFactory.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,98 @@
+/*
+Copyright (c) 2010, NHIN Direct Project
+All rights reserved.
+
+Authors:
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
distribution. Neither the name of the The NHIN Direct Project
(nhindirect.org).
+nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns;
+
+import java.net.URL;
+
+import org.nhindirect.dns.config.DNSServerConfig;
+import org.nhindirect.dns.module.DNSServerConfigModule;
+
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Provider;
+
+
+/**
+ * The DNSServerFactory is a bootstrapper for creating instances of the
{@link DNSServer) based on configuration information. Configurations
+ * are loaded from a URL that may take the form of any addressable
resource such as a file, HTTP resource, LDAP store, or database. Based on
the
+ * URL protocol, an appropriate configuration loader and parser is
instantiated which creates an injector used to provide instance of the
DNSServer.
+ * Optionally specific configuration and {@link DNSStore} providers can be
passed for specific object creation. This is generally useful
+ * for creating mock implementations for testing.
+ * @author Greg Meyer
+ *
+ * @since 1.0
+ */
+public class DNSServerFactory
+{
+ /**
+ * Creates an instance of a {@link DNSServer} using the configuration
information stored at the configuration location.
+ * @param configLocation The URL of the configuration information. The
URL may refer to any addressable resource.
+ * @return An initialized instance of a DNSServer.
+ * @throws DNSException Thrown if an error occurs while creating the
DNSServer.
+ */
+ public synchronized static DNSServer createDNSServer(URL configLocation)
throws DNSException
+ {
+ return createDNSServer(configLocation, null, null);
+ }
+
+ /**
+ * Creates an instance of a {@link DNSServer} using the configuration
information stored at the configuration location. An
+ * optional {@link DNSStore> provider can be passed for initializing the
server with a specific record store.
+ * @param configLocation The URL of the configuration information. The
URL may refer to any addressable resource.
+ * @param dnsStore Optional provider that will create an instance of a
specific {@link DNSStore} type. If this is null, the
+ * system will create a default store.
+ * @param settings Optional DNS server settings. Overridden by settings
from the configuration service.
+ * @return An initialized instance of a DNSServer.
+ * @throws DNSException Thrown if an error occurs while creating the
DNSServer.
+ */
+ public synchronized static DNSServer createDNSServer(URL configLocation,
Provider<DNSStore> dnsStore, Provider<DNSServerSettings> settings) throws
DNSException
+ {
+ DNSServer retVal = null;
+
+ try
+ {
+ Injector agentInjector = buildServerInjector(configLocation, dnsStore,
settings);
+ retVal = agentInjector.getInstance(DNSServer.class);
+
+ }
+ catch (Exception t)
+ {
+ // catch all
+ throw new DNSException(DNSError.newError(-1), "DNSServer creation
failed: " + t.getMessage(), t);
+ }
+
+ return retVal;
+ }
+
+ /*
+ * Creates an injector for getting SmtpAgent instances
+ */
+ private static Injector buildServerInjector(URL configLocation,
Provider<DNSStore> storeProvider, Provider<DNSServerSettings> settings)
+ {
+ Injector configInjector =
Guice.createInjector(DNSServerConfigModule.create(configLocation,
storeProvider, settings));
+
+ DNSServerConfig config =
configInjector.getInstance(DNSServerConfig.class);
+
+ return config.getServerInjector();
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSServerMBean.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,50 @@
+/*
+ Copyright (c) 2010, Direct Project
+ All rights reserved.
+
+ Authors:
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
+Neither the name of The Direct Project (directproject.org) nor the names
of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns;
+
+import javax.management.openmbean.CompositeData;
+
+/**
+ * MBean interface definition for monitoring and managing the DNS server.
+ * @author Greg Meyer
+ *
+ * @since 1.1.0
+ */
+public interface DNSServerMBean
+{
+
+ /**
+ * Gets the DNS server settings.
+ * @return The DNS server settings.
+ */
+ public CompositeData getServerSettings();
+
+ /**
+ * Initializes the DNS server socket listeners are begins accepting
requests.
+ */
+ public void startServer();
+
+ /**
+ * Shutdown the DNS server socket listeners and stops accepting requests.
+ */
+ public void stopServer();
+
+ /**
+ * Gets the fully qualified class name of the DNS store.
+ * @return The fully qualified class name of the DNS store.
+ */
+ public String getDNSStoreImplName();
+}
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSServerSettings.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,106 @@
+/*
+ Copyright (c) 2010, Direct Project
+ All rights reserved.
+
+ Authors:
+ Umesh Madan ume...@microsoft.com
+ Chris Lomonico chris.l...@surescripts.com
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
+Neither the name of The Direct Project (directproject.org) nor the names
of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns;
+
+
+/**
+ * Tuning parameters for the DNS server.
+ *
+ * @author Greg Meyer
+ * @author Umesh Madan
+ * @author Chris Lomonico
+ *
+ * @since 1.0
+ */
+public class DNSServerSettings extends SocketServerSettings
+{
+ private static final int DEFAULT_PORT = 53;
+ private static final String DEFAULT_BIND_ADDRESS = "0.0.0.0"; // bind to
all adapters
+ public static final int DAFAULT_MAX_REQUEST_SIZE = 1024 * 16;
+
+ private int port;
+ private String bindAddress;
+ private int maxRequestSize;
+
+ /**
+ * Create default DNS server settings
+ */
+ public DNSServerSettings()
+ {
+ super();
+ port = DEFAULT_PORT;
+ bindAddress = DEFAULT_BIND_ADDRESS;
+ maxRequestSize = DAFAULT_MAX_REQUEST_SIZE;
+ }
+
+ /**
+ * Gets the IP port that the server will be listening on. The default is
53.
+ * @return The IP port that the server will be listening on.
+ */
+ public int getPort()
+ {
+ return port;
+ }
+
+ /**
+ * Sets the IP port that the server will be listening on.
+ * @param port The IP port that the server will be listening on.
+ *
+ */
+ public void setPort(int port)
+ {
+ this.port = port;
+ }
+
+ /**
+ * Gets the IP4 addresses that the server will be bound to. The string
is comma delimited list of IP addresses. The default is 0.0.0.0
+ * which means that the server will bind to add IP addresses available on
the local machine.
+ * @return The IP4 addresses that the server will be bound to.
+ */
+ public String getBindAddress()
+ {
+ return bindAddress;
+ }
+
+ /**
+ * Sets the IP4 addresses that the server will be bound to.
+ * @param bindAddress The IP4 addresses that the server will be bound to.
+ */
+ public void setBindAddress(String bindAddress)
+ {
+ this.bindAddress = bindAddress;
+ }
+
+ /**
+ * Gets the maximum size in bytes of a request. The default size is 16K.
+ * @return The maximum size in bytes of a request.
+ */
+ public int getMaxRequestSize()
+ {
+ return maxRequestSize;
+ }
+
+ /**
+ * Sets the maximum size in bytes of a request.
+ * @param maxRequestSize The maximum size in bytes of a request.
+ */
+ public void setMaxRequestSize(int maxRequestSize)
+ {
+ this.maxRequestSize = maxRequestSize;
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSSocketServer.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,308 @@
+/*
+ Copyright (c) 2010, Direct Project
+ All rights reserved.
+
+ Authors:
+ Umesh Madan ume...@microsoft.com
+ Chris Lomonico chris.l...@surescripts.com
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
+Neither the name of The Direct Project (directproject.org) nor the names
of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns;
+
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.net.Socket;
+import java.util.UUID;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import javax.management.JMException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+/**
+ * The socket server is an IP protocol agnostic server that manages
threading/concurrency and message dispatching to the
+ * concrete socket implementation. It utilizes a "smart" thread pool for
efficiently managing processing threads.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+public abstract class DNSSocketServer implements DNSSocketServerMBean
+{
+ private static final Log LOGGER =
LogFactory.getFactory().getInstance(DNSSocketServer.class);
+
+ protected final DNSServerSettings settings;
+ protected final DNSResponder responder;
+
+ protected ExecutorService socketAcceptService;
+ protected ThreadPoolExecutor dnsRequestService;
+
+ protected final AtomicBoolean running;
+
+ private long serverStartTime = Long.MAX_VALUE;
+ private volatile long rejectedCount = 0;
+ private volatile long requestCount = 0;
+ private TemporalCountBucket countBuckets[] = {new TemporalCountBucket(),
new TemporalCountBucket(),
+ new TemporalCountBucket(), new TemporalCountBucket(), new
TemporalCountBucket()};
+
+
+ /**
+ * Creates a socket server. The server will not start accepting messages
until the {@link #start()} method is called.
+ * @param settings The server settings. The settings contain specific
IP and socket configuration parameters.
+ * @param responsder The DNS responder that will handle lookups.
+ * @throws DNSException
+ */
+ public DNSSocketServer(DNSServerSettings settings, DNSResponder
responsder) throws DNSException
+ {
+ running = new AtomicBoolean(false);
+
+ this.settings = settings;
+ this.responder = responsder;
+
+ // create the server socket
+ createServerSocket();
+ }
+
+ protected void registerMBean(Class<?> clazz)
+ {
+ final StringBuilder objectNameBuilder = new
StringBuilder(clazz.getPackage().getName());
+ objectNameBuilder.append(":type=").append(clazz.getSimpleName());
+ objectNameBuilder.append(",name=").append(UUID.randomUUID());
+
+ try
+ {
+ final StandardMBean mbean = new StandardMBean(this,
DNSSocketServerMBean.class);
+
+ final MBeanServer mbeanServer =
ManagementFactory.getPlatformMBeanServer();
+ mbeanServer.registerMBean(mbean, new
ObjectName(objectNameBuilder.toString()));
+ }
+ catch (JMException e)
+ {
+ LOGGER.error("Unable to register the DNSSocketServer MBean", e);
+ }
+ }
+
+ /**
+ * Starts the socket server and initializes the dispatch threads. After
this method has been called, the server will start accepting
+ * DNS requests.
+ * @throws DNSException
+ */
+ public void start() throws DNSException
+ {
+ if (running.get() != true)
+ {
+ // create the accept thread
+ running.set(true);
+
+ dnsRequestService = new ThreadPoolExecutor(0,
settings.getMaxActiveRequests(),
+ 120L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>());
+
+
+ socketAcceptService = Executors.newSingleThreadExecutor();
+ socketAcceptService.execute(getSocketAcceptTask());
+
+ serverStartTime = System.currentTimeMillis();
+ }
+ else
+ LOGGER.info("Start requested, but socket server is already running.");
+
+ }
+
+ /**
+ * Shuts down the socket server and terminates the server from accepting
additional requests. The server attempts to gracefully
+ * shutdown the processing threads and gives currently running processing
threads a chance to finish.
+ * @throws DNSException
+ */
+ public void stop() throws DNSException
+ {
+ running.set(false);
+
+ socketAcceptService.shutdown();
+
+ dnsRequestService.shutdown();
+
+ }
+
+ protected void waitForGracefulStop()
+ {
+ try
+ {
+ socketAcceptService.awaitTermination(10, TimeUnit.SECONDS);
+ }
+ catch (InterruptedException e) {/* no op */}
+
+ try
+ {
+ dnsRequestService.awaitTermination(10, TimeUnit.SECONDS);
+ }
+ catch (InterruptedException e) {/* no op */}
+ }
+
+ /**
+ * Creates and initializes the socket implementation that will accept
incoming requests.
+ * @throws DNSException
+ */
+ public abstract void createServerSocket() throws DNSException;
+
+ /**
+ * Gets the Runnable task that will be responsible for accepting
connections. This task
+ * is placed in a single thread, so it should loop until the running flag
is set to false.
+ * @return The Runnable task that will be responsible for accepting
connections
+ */
+ public abstract Runnable getSocketAcceptTask();
+
+ /**
+ * Gets the Runnable task that will process a DNS request. Each accepted
request will create a new instance
+ * of the Runnable task and run it in its own thread.
+ * @param s An arbitrary parameter passed to the Runnable task. This
parameter generally contain the DNS request information.
+ * This may be the TCP socket from the accept() server socket call or a
UDP datagram packet.
+ * @return The Runnable task that will process a DNS request
+ */
+ public abstract Runnable getDNSRequestTask(Object s);
+
+ /**
+ * Submits the DNS request to a runnable task.
+ * @param s An arbitrary parameter passed to the Runnable task. This
parameter generally contain the DNS request information.
+ * This may be the TCP socket from the accept() server socket call or a
UDP datagram packet.
+ */
+ protected void submitDNSRequest(Object s)
+ {
+
+ updateCountMetrics();
+ if (dnsRequestService.getActiveCount() < settings.getMaxActiveRequests())
+ dnsRequestService.execute(getDNSRequestTask(s));
+ else
+ {
+
+ ++rejectedCount;
+ // just close the socket... we're too busy to handle anything
+ try
+ {
+ if (s instanceof Socket)
+ ((Socket)s).close();
+ }
+ catch (IOException e) {}
+ }
+ }
+
+ private void updateCountMetrics()
+ {
+ ++requestCount;
+ long curTime = System.currentTimeMillis();
+ int bucketIndex = (int)((curTime / 1000) % 5);
+
+ synchronized (countBuckets)
+ {
+ TemporalCountBucket bucket = countBuckets[bucketIndex];
+ bucket.increment(curTime);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Long getUptime()
+ {
+ if (running.get() == false || serverStartTime == Long.MAX_VALUE)
+ return -1L;
+ else
+ return (System.currentTimeMillis() - serverStartTime);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Long getRejectedRequestCount()
+ {
+ return rejectedCount;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Long getResourceRequestCount()
+ {
+ return requestCount;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getResourceRequestLoad()
+ {
+ // this is an approximation over the last 5 seconds converted to
requests per second
+ long curTime = System.currentTimeMillis();
+ int numTransactions = 0;
+ synchronized (countBuckets)
+ {
+ for (TemporalCountBucket bucket : countBuckets)
+ {
+ numTransactions += bucket.getCount(curTime);
+ }
+ }
+
+ // can get a little better accuracy if we take into consideration that
the last full second of the 5 second time range has not yet passed
+ double div = 4.0 + ((curTime % 1000) / 1000);
+
+ int aveTransLoad = (int)((double)(numTransactions) / (div));
+
+ return aveTransLoad + "/sec";
+ }
+
+ /*
+ * class used to hold request count within a 1 second time range
+ */
+ private static class TemporalCountBucket
+ {
+ private volatile long count = 0;
+ private volatile long firstAddedTime = 0;
+
+ /*
+ * increment the access count... if the access time is outside
+ * of the 5 second time range, then reset the counter
+ */
+ public synchronized void increment(long accessTime)
+ {
+ if ((accessTime - firstAddedTime) > 5000)
+ {
+ // round down to nearest 1000
+ firstAddedTime = accessTime - (accessTime % 1000);
+ count = 1;
+ }
+ else
+ ++count;
+ }
+
+ /*
+ * get the access count... if the access time is outside of the
+ * 5 second range, then return 0
+ */
+ public synchronized long getCount(long accessTime)
+ {
+ if (firstAddedTime == 0)
+ return 0;
+
+ return ((accessTime - firstAddedTime) > 5000) ? 0 : count;
+ }
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSSocketServerMBean.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,68 @@
+/*
+ Copyright (c) 2010, Direct Project
+ All rights reserved.
+
+ Authors:
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
+Neither the name of The Direct Project (directproject.org) nor the names
of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns;
+
+/**
+ * MBean interface definition for monitoring and managing a DNS socket
server.
+ * @author Greg Meyer
+ *
+ * @since 1.1.0
+ */
+public interface DNSSocketServerMBean
+{
+ /**
+ * Gets the number of DNS requests received by the server.
+ * @return The number of DNS requests received by the server.
+ */
+ public Long getResourceRequestCount();
+
+ /**
+ * Gets the request load of the server. Load is returned in number of
requests per second averaged over the last 5 seconds.
+ * @return The request load of the server.
+ */
+ public String getResourceRequestLoad();
+
+ /**
+ * Gets the time in milliseconds that the server has been running since
its last start.
+ * @return The time in milliseconds that the server has been running
since its last start.
+ */
+ public Long getUptime();
+
+ /**
+ * Gets the number of requests that returned without error. NXDOMAIN
statuses qualify as successful requests.
+ * @return The number of requests that returned without error.
+ */
+ public Long getSuccessfulRequestCount();
+
+ /**
+ * Gets the number of requests that resulted in an error.
+ * @return The number of requests that resulted in an error.
+ */
+ public Long getErrorRequestCount();
+
+ /**
+ * Gets the number of requests that returned no records without error.
+ * @return The number of request that returned no records without error.
+ */
+ public Long getMissedRequestCount();
+
+ /**
+ * Gets the number of requests that were rejected by the server due to
being to busy. A high number of rejected requests indicates that the server
+ * should be reconfigured to accept a higher load.
+ * @return The number of requests that were rejected by the server due to
being to busy.
+ */
+ public Long getRejectedRequestCount();
+}
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/DNSStore.java Mon
Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,43 @@
+/*
+ Copyright (c) 2010, Direct Project
+ All rights reserved.
+
+ Authors:
+ Umesh Madan ume...@microsoft.com
+ Chris Lomonico chris.l...@surescripts.com
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
+Neither the name of The Direct Project (directproject.org) nor the names
of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns;
+
+import org.xbill.DNS.Message;
+
+import com.google.inject.ImplementedBy;
+
+/**
+ * A DNSStore encapsulates the physical medium that stores DNS records
such as a files, databases, or web services. A store processes DNS
requests,
+ * executes the lookup or operational request (such as zone transfers)
logic, and returns an appropriate response.
+ * @author Greg Meyer
+ * @author Umesh Madan
+ *
+ * @since 1.0
+ */
+@ImplementedBy(ConfigServiceDNSStore.class)
+public interface DNSStore
+{
+ /**
+ * Processes a lookup request for DNS records.
+ * @param dnsMsg The DSN request message.
+ * @return The DNS response message. Returns null for lookup requests if
a matching record cannot be found.
+ * @throws DNSException Thrown is the request fails due to sever failure
such as illegal request parameters or
+ * a failure accessing the physical record medium.
+ */
+ public Message get(Message dnsMsg) throws DNSException;
+}
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/ProxyDNSStore.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,147 @@
+/*
+ Copyright (c) 2010, Direct Project
+ All rights reserved.
+
+ Authors:
+ Umesh Madan ume...@microsoft.com
+ Chris Lomonico chris.l...@surescripts.com
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
+Neither the name of The Direct Project (directproject.org) nor the names
of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.Collection;
+
+import org.xbill.DNS.ExtendedResolver;
+import org.xbill.DNS.Message;
+import org.xbill.DNS.ResolverConfig;
+
+/**
+ * Proxy DNS store that delegates all requests to another set of DNS
servers.
+ * The store defaults to using port 53 and the machine's configured DNS
servers.
+ * @author Greg Meyer
+ *
+ * @since 1.0
+ */
+public class ProxyDNSStore implements DNSStore
+{
+ private static final int DEFAULT_RESOLVER_PORT = 53;
+
+ private final String[] servers;
+ private final int port;
+
+ /**
+ * Creates a default proxy store.
+ */
+ public ProxyDNSStore()
+ {
+ this(DEFAULT_RESOLVER_PORT);
+ }
+
+ /**
+ * Creates a proxy store delegating requests to the provided port.
+ * @param port The IP port to use when calling the proxy DNS server.
+ */
+ public ProxyDNSStore(int port)
+ {
+ this(null, DEFAULT_RESOLVER_PORT);
+ }
+
+ /**
+ * Creates a proxy using the the provided servers for delegating requests.
+ * @param servers A collections of IP4 addresses (as strings) that the
proxy will delegate request to.
+ */
+ public ProxyDNSStore(Collection<String> servers)
+ {
+ this(servers, DEFAULT_RESOLVER_PORT);
+ }
+
+ /**
+ * Creates a proxy using the provided servers and port for delegating
requests.
+ * @param servers A collections of IP4 addresses (as strings) that the
proxy will delegate request to.
+ * @param port The IP port to use when calling the proxy DNS server.
+ */
+ public ProxyDNSStore(Collection<String> servers, int port)
+ {
+ if (servers == null || servers.size() == 0)
+ {
+
+ String[] configedServers = ResolverConfig.getCurrentConfig().servers();
+
+ if (configedServers != null)
+ {
+ this.servers = configedServers;
+ }
+ else
+ this.servers = null;
+ }
+ else
+ {
+ this.servers = new String[servers.size()];
+ servers.toArray(this.servers);
+ }
+
+ this.port = port;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Message get(Message dnsMsg) throws DNSException
+ {
+ ExtendedResolver resolver = createExResolver(servers, port, 2, 2000);
+ // try UPD first
+
+ Message response = null;
+ try
+ {
+ response = resolver.send(dnsMsg);
+ }
+ catch (IOException e)
+ {
+ /* no-op */
+ }
+
+ if (response == null)
+ {
+ // try TCP
+ resolver.setTCP(true);
+ try
+ {
+ response = resolver.send(dnsMsg);
+ }
+ catch (IOException e)
+ {
+ /* no-op */
+ }
+ }
+
+ return response;
+ }
+
+ /*
+ * Create the resolver that will do the DNS requests.
+ */
+ private ExtendedResolver createExResolver(String[] servers, int port, int
retries, int timeout)
+ {
+ ExtendedResolver retVal = null;
+ try
+ {
+ retVal = new ExtendedResolver(servers);
+ retVal.setRetries(retries);
+ retVal.setTimeout(timeout);
+ }
+ catch (UnknownHostException e) {/* no-op */}
+ return retVal;
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/SocketServerSettings.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,206 @@
+/*
+ Copyright (c) 2010, Direct Project
+ All rights reserved.
+
+ Authors:
+ Umesh Madan ume...@microsoft.com
+ Chris Lomonico chris.l...@surescripts.com
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
+Neither the name of The Direct Project (directproject.org) nor the names
of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns;
+
+/**
+ * Tuning parameters for the DNS server socket connections. Tuning
parameters are important to maximize the performance
+ * of the DNS server or to prevent the server machine from becoming over
loaded.
+ *
+ * @author Greg Meyer
+ * @author Umesh Madan
+ * @author Chris Lomonico
+ *
+ * @since 1.0
+ */
+public class SocketServerSettings
+{
+
+ private static final int DEFAULT_MAX_CONNECTION_BACKLOG = 64;
+ private static final int DEFAULT_MAX_ACTIVE_REQUESTS = 64;
+ private static final int DEFAULT_MAX_OUTSTANDING_ACCEPTS = 16;
+ private static final int DEFAULT_READ_BUFFER_SIZE = 1024;
+ private static final int DEFAULT_SEND_TIMEOUT = 5000;
+ private static final int DEFAULT_RECEIVE_TIMEOUT = 50000;
+ private static final int DEFAULT_SOCKET_CLOSE_TIMEOUT = 5000;
+
+ private int maxOutstandingAccepts;
+ private int maxActiveRequests;
+ private int maxConnectionBacklog;
+ private int readBufferSize;
+ private int sendTimeout;
+ private int receiveTimeout;
+ private int socketCloseTimeout;
+
+ /**
+ * Creates a default set of socket parameters.
+ */
+ public SocketServerSettings()
+ {
+ maxOutstandingAccepts = DEFAULT_MAX_OUTSTANDING_ACCEPTS;
+ maxActiveRequests = DEFAULT_MAX_ACTIVE_REQUESTS;
+ maxConnectionBacklog = DEFAULT_MAX_CONNECTION_BACKLOG;
+ readBufferSize = DEFAULT_READ_BUFFER_SIZE;
+ sendTimeout = DEFAULT_SEND_TIMEOUT;
+ receiveTimeout = DEFAULT_RECEIVE_TIMEOUT;
+ socketCloseTimeout = DEFAULT_SOCKET_CLOSE_TIMEOUT;
+ }
+
+ /**
+ * Gets the maximum number of requests that can be accepted by the
server, but not yet
+ * committed to a processing thread. Setting this value to high may
result in DNS clients
+ * timing out due to outstanding requests waiting to long for a
processing thread. The
+ * default is 16 requests.
+ * @return The maximum number of requests that can be excepted by the
server, but not yet
+ * committed to a processing thread.
+ */
+ public int getMaxOutstandingAccepts()
+ {
+ return maxOutstandingAccepts;
+ }
+
+ /**
+ * Sets the maximum number of requests that can be accepted by the
server, but not yet
+ * committed to a processing thread.
+ * @param maxOutstandingAccepts The maximum number of requests that can
be accepted by the server, but not yet
+ * committed to a processing thread.
+ */
+ public void setMaxOutstandingAccepts(int maxOutstandingAccepts)
+ {
+ this.maxOutstandingAccepts = maxOutstandingAccepts;
+ }
+
+ /**
+ * Gets the maximum number of concurrent requests that can be processed
by the server at any give time. Setting this
+ * value to high may result in overloading the system. Setting this
value to low can limit throughput. The default
+ * 64.
+ * @return The maximum number of concurrent requests that can be
processed by the server at any give time.
+ */
+ public int getMaxActiveRequests()
+ {
+ return maxActiveRequests;
+ }
+
+ /**
+ * Sets the maximum number of concurrent requests that can be processed
by the server at any give time.
+ * @param maxActiveRequests The maximum number of concurrent requests
that can be processed by the server at any give time.
+ */
+ public void setMaxActiveRequests(int maxActiveRequests)
+ {
+ this.maxActiveRequests = maxActiveRequests;
+ }
+
+ /**
+ * Gets the maximum number of connections that are in the IP socket
accept backlog. Socket backlog is only relevant
+ * for TCP session based connections. Setting this value to high can
overload the IP stack or result in DNS
+ * client timeouts. The default value is 64.
+ *
+ * @return The maximum number of connections that are in the IP socket
accept backlog.
+ */
+ public int getMaxConnectionBacklog()
+ {
+ return maxConnectionBacklog;
+ }
+
+ /**
+ * Sets the maximum number of connections that are in the IP socket
accept backlog.
+ * @param maxConnectionBacklog The maximum number of connections that are
in the IP socket accept backlog.
+ */
+ public void setMaxConnectionBacklog(int maxConnectionBacklog)
+ {
+ this.maxConnectionBacklog = maxConnectionBacklog;
+ }
+
+ /**
+ * Gets the maximum size request buffer size in bytes. The default value
is 1024 bytes.
+ * @return The maximum size request buffer size in bytes.
+ */
+ public int getReadBufferSize()
+ {
+ return readBufferSize;
+ }
+
+ /**
+ * Sets the maximum size request buffer size in bytes.
+ * @param readBufferSize The maximum size request buffer size in bytes.
+ */
+ public void setReadBufferSize(int readBufferSize)
+ {
+ this.readBufferSize = readBufferSize;
+ }
+
+ /**
+ * Gets the socket timeout in milliseconds for sending responses.
Setting this value to high can
+ * result in performance degradation if multiple clients abandon their
sessions. Setting this value
+ * to low can result in clients not receiving responses in high latency
environments. The default value is
+ * 5000 milliseconds.
+ * @return The socket timeout in milliseconds for sending responses
+ */
+ public int getSendTimeout()
+ {
+ return sendTimeout;
+ }
+
+ /**
+ * Sets the socket timeout in milliseconds for sending responses.
+ * @param sendTimeout Sets the socket timeout in milliseconds for
sending responses.
+ */
+ public void setSendTimeout(int sendTimeout)
+ {
+ this.sendTimeout = sendTimeout;
+ }
+
+ /**
+ * Gets the socket timeout in milliseconds for receiving or reading
request. Setting this value to high can
+ * result in performance degradation if multiple clients abandon their
sessions. Setting this value
+ * to low can result in the server not fully reading request data in high
latency environments. The default value is
+ * 5000 milliseconds.
+ * @return The socket timeout in milliseconds for receiving or reading
requests.
+ */
+ public int getReceiveTimeout()
+ {
+ return receiveTimeout;
+ }
+
+ /**
+ * Sets the socket timeout in milliseconds for receiving or reading
request.
+ * @param receiveTimeout The socket timeout in milliseconds for receiving
or reading request.
+ */
+ public void setReceiveTimeout(int receiveTimeout)
+ {
+ this.receiveTimeout = receiveTimeout;
+ }
+
+ /**
+ * Gets the timeout in milliseconds for closing a socket connection. The
default value is 5000 milliseconds.
+ * @return The timeout in milliseconds for closing a socket connection.
+ */
+ public int getSocketCloseTimeout()
+ {
+ return socketCloseTimeout;
+ }
+
+ /**
+ * Sets the timeout in milliseconds for closing a socket connection. The
default value is 5000 milliseconds.
+ * @param socketCloseTimeout The timeout in milliseconds for closing a
socket connection.
+ */
+ public void setSocketCloseTimeout(int socketCloseTimeout)
+ {
+ this.socketCloseTimeout = socketCloseTimeout;
+ }
+
+}
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/TCPServer.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,318 @@
+/*
+ Copyright (c) 2010, Direct Project
+ All rights reserved.
+
+ Authors:
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
+Neither the name of The Direct Project (directproject.org) nor the names
of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.Inet4Address;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xbill.DNS.Message;
+import org.xbill.DNS.Rcode;
+import org.xbill.DNS.Section;
+
+/**
+ * TCP socket server that handled DNS requests over TCP.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+public class TCPServer extends DNSSocketServer
+{
+
+ private static final Log LOGGER =
LogFactory.getFactory().getInstance(TCPServer.class);
+
+ private ServerSocket serverSocket;
+
+ private volatile long missCount = 0;
+ private volatile long errorCount = 0;
+ private volatile long successCount = 0;
+
+ /**
+ * Creates a TCP socket server. The server will not start accepting
messages until the {@link #start()} method is called.
+ * @param settings The server settings. The settings contain specific
IP and socket configuration parameters.
+ * @param responsder The DNS responder that will handle lookups.
+ * @throws DNSException
+ */
+ public TCPServer(DNSServerSettings settings, DNSResponder responder)
throws DNSException
+ {
+ super(settings, responder);
+
+ registerMBean(this.getClass());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void start() throws DNSException
+ {
+ LOGGER.info("DNS TCP Server Starting");
+ super.start();
+
+ if (LOGGER.isInfoEnabled())
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("DNS TCP Server Startup Complete\r\n\tBind
Address: ").append(settings.getBindAddress());
+ builder.append("\r\n\tBind Port: ").append(settings.getPort());
+ LOGGER.info(builder.toString());
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void stop() throws DNSException
+ {
+ super.stop();
+
+ try
+ {
+ serverSocket.close();
+ }
+ catch (IOException e) {/* no-op */}
+
+ waitForGracefulStop();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void createServerSocket() throws DNSException
+ {
+
+ try
+ {
+ serverSocket = new ServerSocket(settings.getPort(),
settings.getMaxConnectionBacklog(),
+ Inet4Address.getByName(settings.getBindAddress()));
+
+ }
+ catch (Exception e)
+ {
+ throw new DNSException(null, "Failed to create TCP server socket: " +
e.getMessage(), e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Runnable getSocketAcceptTask()
+ {
+ return new AcceptTask();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Runnable getDNSRequestTask(Object s)
+ {
+ return new RequestTask((Socket)s);
+ }
+
+ /*
+ * Thread that accepts socket connections
+ */
+ private class AcceptTask implements Runnable
+ {
+ public void run()
+ {
+ while(running.get())
+ {
+
+ try
+ {
+ Socket s = serverSocket.accept();
+
+ s.setReceiveBufferSize(settings.getMaxRequestSize());
+ s.setSoTimeout(settings.getReceiveTimeout());
+ submitDNSRequest(s);
+ }
+ catch (IOException e)
+ {
+ if (running.get())
+ {
+ LOGGER.error("DNS TCP server socket dropped:" + e.getMessage());
+ reconnect();
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * In the case that the server loses it connections, the accept socket
needs to be re-established.
+ */
+ private void reconnect()
+ {
+ // socket may already be closed, but clean up to be thorough.
+ try
+ {
+ serverSocket.close();
+ } catch (IOException e) {/* no-op */}
+
+ serverSocket = null;
+ while (serverSocket == null && running.get())
+ {
+ try
+ {
+ createServerSocket();
+ LOGGER.error("DNS TCP server socket re-established");
+ }
+ catch (DNSException ex)
+ {
+ LOGGER.error("DNS TCP server socket failed to rebind. Trying again in
5 seconds.");
+
+ // the socket creation failed....
+ // sleep 5 seconds and come back around and try again
+ try
+ {
+ Thread.sleep(5000);
+ }
+ catch (InterruptedException iex) {/* no-op */}
+ }
+ }
+ }
+
+ /*
+ * Task that handles incoming tasks
+ */
+ private class RequestTask implements Runnable
+ {
+ private Socket requestSocket;
+
+ public RequestTask(Socket s)
+ {
+ requestSocket = s;
+ }
+
+ @SuppressWarnings("unused")
+ public void run()
+ {
+ Message response = null;
+ Message query = null;
+ int inLength;
+ DataInputStream dataIn;
+ DataOutputStream dataOut;
+ byte [] in;
+
+ try
+ {
+ InputStream is = null;
+ try
+ {
+ is = requestSocket.getInputStream();
+ dataIn = new DataInputStream(is);
+ inLength = dataIn.readUnsignedShort();
+ }
+ catch (Exception e)
+ {
+ // don't fill up my logs due to input stream errors that can happen
+ // from DOS attaches
+ try
+ {
+ requestSocket.close();
+ }
+ catch (IOException e2) {/* no-op */}
+ return;
+ }
+ in = new byte[inLength];
+ dataIn.readFully(in);
+
+ //LOGGER.info("Valid message... moving on.");
+
+ try
+ {
+ query = responder.toMessage(in);
+
+ response = responder.processRequest(query);
+ }
+ catch (DNSException e)
+ {
+ //LOGGER.info("TCP server error response.");
+ if (query != null)
+ response = responder.processError(query, e.getError());
+ }
+
+ if (response != null)
+ {
+ if (response.getRcode() == Rcode.NOERROR || response.getRcode() ==
Rcode.NXDOMAIN)
+ {
+ ++successCount;
+ if (response.getSectionArray(Section.ANSWER).length == 0)
+ ++missCount;
+ }
+ else
+ ++errorCount;
+
+ //LOGGER.info("Sending back valid response.");
+
+ dataOut = new DataOutputStream(requestSocket.getOutputStream());
+ byte[] writeBytes = response.toWire();
+ dataOut.writeShort(writeBytes.length);
+ dataOut.write(writeBytes);
+ }
+ else
+ ++errorCount;
+ }
+ catch (IOException e)
+ {
+ LOGGER.error("Wire/connection protocol error handing DNS request: " +
e.getMessage(), e);
+ }
+ finally
+ {
+ try
+ {
+ requestSocket.close();
+ }
+ catch (IOException e) {/* no-op */}
+ }
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Long getMissedRequestCount()
+ {
+ return missCount;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Long getSuccessfulRequestCount()
+ {
+ return successCount;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Long getErrorRequestCount()
+ {
+ return errorCount;
+ }
+}
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/UDPServer.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,287 @@
+/*
+ Copyright (c) 2010, Direct Project
+ All rights reserved.
+
+ Authors:
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
+Neither the name of The Direct Project (directproject.org) nor the names
of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+package org.nhindirect.dns;
+
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.Inet4Address;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xbill.DNS.Message;
+import org.xbill.DNS.Rcode;
+import org.xbill.DNS.Section;
+
+/**
+ * UDP socket server that handled DNS requests over UDP.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+public class UDPServer extends DNSSocketServer
+{
+ private static final Log LOGGER =
LogFactory.getFactory().getInstance(UDPServer.class);
+
+ private static final int MAX_WIRE_SIZE = 512;
+
+
+ private DatagramSocket serverSock;
+
+ private volatile long missCount = 0;
+ private volatile long errorCount = 0;
+ private volatile long successCount = 0;
+
+ /**
+ * Creates a UDP server that listens to datagram packets. The server
will not start accepting messages until the {@link #start()} method is
called.
+ * @param settings The server settings. The settings contain specific
IP and socket configuration parameters.
+ * @param responsder The DNS responder that will handle lookups.
+ * @throws DNSException
+ */
+ public UDPServer(DNSServerSettings settings, DNSResponder responder)
throws DNSException
+ {
+ super(settings, responder);
+
+ registerMBean(this.getClass());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void start() throws DNSException
+ {
+ LOGGER.info("DNS UPD Server Starting");
+ super.start();
+
+ if (LOGGER.isInfoEnabled())
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("DNS UDP Server Startup Complete\r\n\tBind
Address: ").append(settings.getBindAddress());
+ builder.append("\r\n\tBind Port: ").append(settings.getPort());
+ LOGGER.info(builder.toString());
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void stop() throws DNSException
+ {
+ super.stop();
+
+ serverSock.close();
+
+ waitForGracefulStop();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void createServerSocket() throws DNSException
+ {
+
+ try
+ {
+ serverSock = new DatagramSocket(settings.getPort(),
Inet4Address.getByName(settings.getBindAddress()));
+ serverSock.setReceiveBufferSize(settings.getMaxRequestSize());
+ serverSock.setSoTimeout(settings.getReceiveTimeout());
+ }
+ catch (Exception e)
+ {
+ throw new DNSException(null, "Failed to create UDP server socket: " +
e.getMessage(), e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Runnable getSocketAcceptTask()
+ {
+ return new ReceiveTask();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Runnable getDNSRequestTask(Object packet)
+ {
+ return new RequestTask((DatagramPacket)packet);
+ }
+
+ /*
+ * Task that listens for datagram packets
+ */
+ private class ReceiveTask implements Runnable
+ {
+ public void run()
+ {
+
+ while(running.get())
+ {
+
+ try
+ {
+ byte[] inBuffer = new byte[settings.getMaxRequestSize()];
+ DatagramPacket inPacket = new DatagramPacket(inBuffer,
inBuffer.length);
+
+ serverSock.receive(inPacket);
+
+ submitDNSRequest(inPacket);
+ }
+ catch (IOException e)
+ {
+ // udp has no state, so we can just call receive again
+ // unless it was closed
+ if (serverSock.isClosed() && running.get())
+ {
+ LOGGER.error("DNS UDP server socket dropped:" + e.getMessage());
+ reconnect();
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * In the event that the server drops its connection, we need to open up
a new
+ * datagram socket to listen for datagram packets.
+ */
+ private void reconnect()
+ {
+ // socket may already be closed, but clean up to be thorough.
+ serverSock.close();
+
+ serverSock = null;
+ while (serverSock == null && running.get())
+ {
+ try
+ {
+ createServerSocket();
+ LOGGER.error("DNS UDP server socket re-established");
+ }
+ catch (DNSException ex)
+ {
+ LOGGER.error("DNS UDP server socket failed to rebind. Trying again in
5 seconds.");
+
+ // the socket creation failed....
+ // sleep 5 seconds and come back around and try again
+ try
+ {
+ Thread.sleep(5000);
+ }
+ catch (InterruptedException iex) {/* no-op */}
+ }
+ }
+ }
+
+ /*
+ * Task that handles DNS requests.
+ */
+ public class RequestTask implements Runnable
+ {
+ private DatagramPacket inPacket;
+
+ public RequestTask(DatagramPacket inPacket)
+ {
+ this.inPacket = inPacket;
+ }
+
+ @SuppressWarnings("unused")
+ public void run()
+ {
+ Message query = null;
+ Message response = null;
+ DatagramPacket outPacket = null;
+
+ try
+ {
+
+ try
+ {
+ //LOGGER.info("Got UDP DNS query. Translating");
+ query = responder.toMessage(inPacket.getData());
+ //LOGGER.info("Send UDP DNS query to service.");
+ response = responder.processRequest(query);
+ //LOGGER.info("UDP query returned from config service");
+ }
+ catch (DNSException e)
+ {
+ //LOGGER.info("Sending UDP error response");
+ if (query != null)
+ response = responder.processError(query, e.getError());
+ }
+
+ if (response != null)
+ {
+ if (response.getRcode() == Rcode.NOERROR || response.getRcode() ==
Rcode.NXDOMAIN)
+ {
+ ++successCount;
+ if (response.getSectionArray(Section.ANSWER).length == 0)
+ ++missCount;
+ }
+ else
+ ++errorCount;
+
+ byte[] writeBytes = response.toWire(MAX_WIRE_SIZE);
+ outPacket = new DatagramPacket(writeBytes,
+ writeBytes.length,
+ inPacket.getAddress(),
+ inPacket.getPort());
+
+ //LOGGER.info("Sending UDP query valid response");
+ serverSock.send(outPacket);
+ }
+ else
+ ++errorCount;
+ }
+ catch (IOException e)
+ {
+ LOGGER.error("Wire/connection protocol error handing DNS request: " +
e.getMessage(), e);
+ }
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Long getMissedRequestCount()
+ {
+ return missCount;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Long getSuccessfulRequestCount()
+ {
+ return successCount;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Long getErrorRequestCount()
+ {
+ return errorCount;
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/annotation/ConfigServiceURL.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,41 @@
+/*
+Copyright (c) 2010, NHIN Direct Project
+All rights reserved.
+
+Authors:
+ Umesh Madan ume...@microsoft.com
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
distribution. Neither the name of the The NHIN Direct Project
(nhindirect.org).
+nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns.annotation;
+
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import com.google.inject.BindingAnnotation;
+
+/**
+ * Guice annotation for the location of the configuration service.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target( {ElementType.FIELD, ElementType.PARAMETER})
+@BindingAnnotation
+public @interface ConfigServiceURL {}
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/annotation/package-info.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,4 @@
+/**
+ * Guice annotations.
+ */
+package org.nhindirect.dns.annotation;
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/config/DNSServerConfig.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,40 @@
+/*
+Copyright (c) 2010, NHIN Direct Project
+All rights reserved.
+
+Authors:
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
distribution. Neither the name of the The NHIN Direct Project
(nhindirect.org).
+nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns.config;
+
+import com.google.inject.Injector;
+
+/**
+ * The DNSServerConfig is responsible for loading configuration
information from a URL and creating an injector that will subsequently
+ * be used to create instances of a {@link DNSServer}.
+ * @author Greg Meyer
+ *
+ * @since 1.0
+ */
+public interface DNSServerConfig
+{
+ /**
+ * Gets a Guide Injector that can be used to create {@link DNSServer}
objects based on configuration information.
+ * @return A Guide Injector that can be used to create {@link DNSServer}
objects.
+ */
+ public Injector getServerInjector();
+}
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/config/WSDNSServerConfig.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,137 @@
+/*
+ Copyright (c) 2010, Direct Project
+ All rights reserved.
+
+ Authors:
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
+Neither the name of The Direct Project (directproject.org) nor the names
of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns.config;
+
+import java.net.URL;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nhind.config.ConfigurationServiceProxy;
+import org.nhind.config.Setting;
+import org.nhindirect.dns.DNSServerSettings;
+import org.nhindirect.dns.DNSStore;
+import org.nhindirect.dns.module.DNSServerModule;
+import org.nhindirect.dns.provider.BasicDNSServerSettingsProvider;
+import org.nhindirect.dns.provider.ConfigServiceDNSStoreProvider;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Provider;
+
+/**
+ * Loads DNS server configuration settings from the configuration service
to create the injector.
+ * @author Greg Meyer
+ *
+ * @since 1.0
+ */
+public class WSDNSServerConfig implements DNSServerConfig
+{
+ private static final Log LOGGER =
LogFactory.getFactory().getInstance(WSDNSServerConfig.class);
+
+ private static final String DNS_SERVER_BINDING = "DNSServerBindings";
+ private static final String DNS_SERVER_PORT = "DNSServerPort";
+
+ private Provider<DNSStore> storeProvider;
+ private Provider<DNSServerSettings> settings;
+
+
+ private final ConfigurationServiceProxy cfService;
+ private final URL configServiceLocation;
+
+ /**
+ * Construct and configuration component with the location of the
configuration file and an optional provider for creating
+ * instances of the DNSServer.
+ * @param configFile The full path of the XML configuration file.
+ * @param storeProvider An option provider used for creating instances of
the {@link DNSStore}. If the provider is
+ * null, a default provider is used.
+ */
+ public WSDNSServerConfig(URL configServiceLocation, Provider<DNSStore>
storeProvider, Provider<DNSServerSettings> settings)
+ {
+ this.storeProvider = storeProvider;
+ this.configServiceLocation = configServiceLocation;
+ this.settings = settings;
+
+ cfService = new
ConfigurationServiceProxy(configServiceLocation.toExternalForm());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Injector getServerInjector()
+ {
+ LOGGER.info("Looking up DNS server configuration info from location " +
configServiceLocation.toExternalForm());
+
+ Provider<DNSServerSettings> settingsProv = getServerSettings();
+
+ if (storeProvider == null)
+ storeProvider = new
ConfigServiceDNSStoreProvider(configServiceLocation);
+
+ DNSServerModule module = DNSServerModule.create(storeProvider,
settingsProv);
+
+ return Guice.createInjector(module);
+ }
+
+ /*
+ * Just use the basic settings provider for now. Will only allow setting
the port and IP bindings.
+ */
+ private Provider<DNSServerSettings> getServerSettings()
+ {
+ String ipBindings = "";
+ int port = 0;
+
+ try
+ {
+ Setting[] settings = cfService.getSettingsByNames(new String[]
{DNS_SERVER_BINDING, DNS_SERVER_PORT});
+
+ if (settings != null && settings.length > 0)
+ {
+ for (Setting setting : settings)
+ {
+ if (setting.getName().equalsIgnoreCase(DNS_SERVER_BINDING))
+ {
+ ipBindings = setting.getValue();
+ }
+ else if (setting.getName().equalsIgnoreCase(DNS_SERVER_PORT))
+ {
+ String sPort = setting.getValue();
+ try
+ {
+ port = Integer.parseInt(sPort);
+ }
+ catch (Exception e)
+ {
+ LOGGER.warn("Could not parse port setting " + port + " from
configuration service");
+ }
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ LOGGER.warn("Could not get DNS setting from web service.");
+ }
+
+ if ((ipBindings == null || ipBindings.length() == 0) && port == 0 &&
settings != null)
+ {
+ LOGGER.info("Using DNS server settings from injected provider.");
+ return settings;
+ }
+
+ LOGGER.info("Using DNS server settings from configuration service.");
+ return new BasicDNSServerSettingsProvider(ipBindings, port);
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/config/package-info.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,4 @@
+/**
+ * Utility class used by Guice modules for getting DNS server
configuration information.
+ */
+package org.nhindirect.dns.config;
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/module/DNSServerConfigModule.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,92 @@
+/*
+Copyright (c) 2010, NHIN Direct Project
+All rights reserved.
+
+Authors:
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
distribution. Neither the name of the The NHIN Direct Project
(nhindirect.org).
+nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns.module;
+
+import java.net.URL;
+
+import org.nhindirect.dns.DNSServerSettings;
+import org.nhindirect.dns.DNSStore;
+import org.nhindirect.dns.config.DNSServerConfig;
+import org.nhindirect.dns.provider.WSDNSServerConfigProvider;
+
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provider;
+
+/**
+ * Guice module for generating a configuration provider based on the URL
protocol.
+ * @author Greg Meyer
+ *
+ * @since 1.0
+ */
+public class DNSServerConfigModule extends AbstractModule
+{
+ private final URL configLocation;
+ private final Provider<DNSStore> storeProvider;
+ private final Provider<DNSServerSettings> settings;
+
+ /**
+ * Creates a DNSServerConfigModule that is used by a Guice to create a
{@link DNSServerConfig} object. The DNSServerConfig
+ * object is subsequently used to create {@link DNSServer} objects.
+ * @param configLocation The URL that the {@link DNSServerConfig} will
use to lookup configuration information.
+ * @param storeProvider An optional {@link DNSStore} provider that will
create instances of DNSStore objects.
+ * @param settings Optional DNS server settings. Overridden by settings
from the configuration service.
+ * @return A configured Guice module used for create {@link
DNSServerConfig} objects.
+ */
+ public static DNSServerConfigModule create(URL configLocation,
Provider<DNSStore> storeProvider, Provider<DNSServerSettings> settings)
+ {
+ return new DNSServerConfigModule(configLocation, storeProvider,
settings);
+ }
+
+ /*
+ * Private constructor.
+ */
+ private DNSServerConfigModule(URL configLocation, Provider<DNSStore>
storeProvider, Provider<DNSServerSettings> settings)
+ {
+ this.configLocation = configLocation;
+ this.storeProvider = storeProvider;
+ this.settings = settings;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void configure()
+ {
+ Provider<DNSServerConfig> provider = null;
+
+ if (provider == null)
+ {
+ if (configLocation.getProtocol().equalsIgnoreCase("HTTP") ||
configLocation.getProtocol().equalsIgnoreCase("HTTPS"))
+ {
+ // web services based
+ provider = new WSDNSServerConfigProvider(configLocation,
storeProvider, settings);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Configuration URL uses an
unsupported protocol: " + configLocation.getProtocol());
+ }
+ }
+ bind(DNSServerConfig.class).toProvider(provider);
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/module/DNSServerModule.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,112 @@
+/*
+ Copyright (c) 2010, Direct Project
+ All rights reserved.
+
+ Authors:
+ Umesh Madan ume...@microsoft.com
+ Chris Lomonico chris.l...@surescripts.com
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
+Neither the name of The Direct Project (directproject.org) nor the names
of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns.module;
+
+import java.net.URL;
+
+import org.nhindirect.dns.DNSServerSettings;
+import org.nhindirect.dns.DNSStore;
+import org.nhindirect.dns.annotation.ConfigServiceURL;
+import org.nhindirect.dns.provider.BasicDNSServerSettingsProvider;
+
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provider;
+
+/**
+ * Guice module for configuring and creating {@link DNSServer} instances.
Allows configuration either using just a URL to
+ * a configuration service, or more advanced options by using {@link
Provider providers}.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+public class DNSServerModule extends AbstractModule
+{
+ private final URL configServiceURL;
+ private final Provider<DNSStore> dnsStore;
+ private final Provider<DNSServerSettings> settings;
+
+ /**
+ * Creates a module using just a configuration URL. The server is
created using the ConfigServiceDNSStore class with
+ * default server settings.
+ * @param configServiceURL A URL that provides the location to the
configuration service.
+ * @return A DNSServerModule used to create instances of the DNS server.
+ */
+ public static DNSServerModule create(URL configServiceURL)
+ {
+ if (configServiceURL == null)
+ throw new IllegalArgumentException("URL cannot be null.");
+
+ return new DNSServerModule(configServiceURL, null, null);
+ }
+
+ /**
+ * Creates a module using a specific {@link DNSStore} provider and
default server settings.
+ * @param dnsStore A provider used to create instances of the {@link
DNSStore}.
+ * @return A DNSServerModule used to create instances of the DNS server.
+ */
+ public static DNSServerModule create(Provider<DNSStore> dnsStore)
+ {
+ if (dnsStore == null)
+ throw new IllegalArgumentException("dnsStore cannot be null.");
+
+ return new DNSServerModule(null, dnsStore, new
BasicDNSServerSettingsProvider());
+ }
+
+ /**
+ * Creates a module using specific {@link DNSStore} and {@link
DNSServerSettings} providers
+ * @param dnsStore A provider used to create instances of the {@link
DNSStore}.
+ * @param settings A provider used to create instances of the {@link
DNSServerSettings}.
+ * @return A DNSServerModule used to create instances of the DNS server.
+ */
+ public static DNSServerModule create(Provider<DNSStore> dnsStore,
Provider<DNSServerSettings> settings)
+ {
+ if (dnsStore == null)
+ throw new IllegalArgumentException("dnsStore cannot be null.");
+
+ if (settings == null)
+ settings = new BasicDNSServerSettingsProvider();
+
+ return new DNSServerModule(null, dnsStore, settings);
+ }
+
+ /*
+ * Private constructor.
+ */
+ private DNSServerModule(URL configServiceURL, Provider<DNSStore>
dnsStore, Provider<DNSServerSettings> settings)
+ {
+ this.configServiceURL = configServiceURL;
+ this.dnsStore = dnsStore;
+ this.settings = settings;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void configure()
+ {
+ if (configServiceURL != null)
+
this.bind(URL.class).annotatedWith(ConfigServiceURL.class).toInstance(configServiceURL);
+ else
+ {
+ this.bind(DNSStore.class).toProvider(dnsStore);
+ this.bind(DNSServerSettings.class).toProvider(settings);
+ }
+ }
+}
+
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/module/package-info.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,4 @@
+/**
+ * Guice modules for configuration and creating DNS server instances.
+ */
+package org.nhindirect.dns.module;
=======================================
--- /dev/null
+++ /java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/package-info.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,4 @@
+/**
+ * Direct project DNS services and responders.
+ */
+package org.nhindirect.dns;
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/provider/AbstractConfigDNSStoreProvider.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,29 @@
+package org.nhindirect.dns.provider;
+
+import java.net.URL;
+
+import org.nhindirect.dns.DNSStore;
+
+import com.google.inject.Provider;
+
+/**
+ * Abstract Guice provider for DNSStoreProviders that use the
configuration service to retrieve runtime configuration information.
+ * @author Greg Meyer
+ *
+ * @since 1.0
+ */
+
+public abstract class AbstractConfigDNSStoreProvider implements
Provider<DNSStore>
+{
+ protected final URL configServiceURL;
+
+ /**
+ * Provider constructor.
+ * @param configServiceURL A URL to the location of the DNS
configuration service.
+ */
+ public AbstractConfigDNSStoreProvider(URL configServiceURL)
+ {
+ this.configServiceURL = configServiceURL;
+ }
+
+}
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/provider/BasicDNSServerSettingsProvider.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,68 @@
+/*
+ Copyright (c) 2010, Direct Project
+ All rights reserved.
+
+ Authors:
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
+Neither the name of The Direct Project (directproject.org) nor the names
of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns.provider;
+
+
+import org.nhindirect.dns.DNSServerSettings;
+
+import com.google.inject.Provider;
+
+/** Guice provider for configuring a minimal set of DNSServer settings.
+ * @author Greg Meyer
+ *
+ * @since 1.0
+ */
+public class BasicDNSServerSettingsProvider implements
Provider<DNSServerSettings>
+{
+
+ private final String bindings;
+ private final int port;
+
+ /**
+ * Creates a provider using the default DNS server settings.
+ */
+ public BasicDNSServerSettingsProvider()
+ {
+ this(null, 0);
+ }
+
+ /**
+ * Creates a provider allowing the IP binding addresses and port to be
overridden.
+ * @param bindings A comma delimited list of IP binding addresses.
+ * @param port The IP port that the server will use to listen for DNS
requests.
+ */
+ public BasicDNSServerSettingsProvider(String bindings, int port)
+ {
+ this.bindings = bindings;
+ this.port = port;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public DNSServerSettings get()
+ {
+ DNSServerSettings settings = new DNSServerSettings();
+ if (port > 0)
+ settings.setPort(port);
+
+ if (bindings != null && !bindings.isEmpty())
+ settings.setBindAddress(bindings);
+
+ return settings;
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/provider/ConfigServiceDNSStoreProvider.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,50 @@
+/*
+ Copyright (c) 2010, Direct Project
+ All rights reserved.
+
+ Authors:
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
+Neither the name of The Direct Project (directproject.org) nor the names
of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns.provider;
+
+import java.net.URL;
+
+import org.nhindirect.dns.ConfigServiceDNSStore;
+import org.nhindirect.dns.DNSStore;
+
+
+/**
+ * Guice provider for creating {@link ConfigServiceDNSStore} instances.
+ * @author Greg Meyer
+ *
+ * @since 1.0
+ */
+public class ConfigServiceDNSStoreProvider extends
AbstractConfigDNSStoreProvider
+{
+
+ /**
+ * Provider constructor.
+ * @param configServiceURL A URL to the location of the DNS
configuration service.
+ */
+ public ConfigServiceDNSStoreProvider(URL configServiceURL)
+ {
+ super(configServiceURL);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public DNSStore get()
+ {
+ return new ConfigServiceDNSStore(configServiceURL);
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/provider/WSDNSServerConfigProvider.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,67 @@
+/*
+Copyright (c) 2010, NHIN Direct Project
+All rights reserved.
+
+Authors:
+ Umesh Madan ume...@microsoft.com
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
distribution. Neither the name of the The NHIN Direct Project
(nhindirect.org).
+nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.dns.provider;
+
+import java.net.URL;
+
+import org.nhindirect.dns.DNSServerSettings;
+import org.nhindirect.dns.DNSStore;
+import org.nhindirect.dns.config.DNSServerConfig;
+import org.nhindirect.dns.config.WSDNSServerConfig;
+
+import com.google.inject.Provider;
+
+/**
+ * Configuration provider for web service based configuration of the DNS
Server.
+ * @author Greg Meyer
+ *
+ * @since 1.0
+ */
+public class WSDNSServerConfigProvider implements Provider<DNSServerConfig>
+{
+ private final URL configURL;
+ private final Provider<DNSStore> storeProvider;
+ private final Provider<DNSServerSettings> settings;
+
+ /**
+ * Creates a provider with the location of the configuration service and
an optional {@link DNSStore} provider.
+ * @param configURL A URL that contains the location of the configuration
service.
+ * @param storeProvider An option provider used for creating specific
instances of a {@link DNSStore}
+ * @param settings Optional DNS server settings. Overridden by settings
from the configuration service.
+ */
+ public WSDNSServerConfigProvider(URL configURL, Provider<DNSStore>
storeProvider, Provider<DNSServerSettings> settings)
+ {
+ this.configURL = configURL;
+ this.storeProvider = storeProvider;
+ this.settings = settings;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public DNSServerConfig get()
+ {
+ return new WSDNSServerConfig(configURL, storeProvider, settings);
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/provider/package-info.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,4 @@
+/**
+ * Guice providers for creating DNS server configuration and server
classes.
+ */
+package org.nhindirect.dns.provider;
=======================================
--- /dev/null
+++
/java/tags/dns-1.2.5/src/main/java/org/nhindirect/dns/service/DNSServerService.java
Mon Jan 26 14:04:30 2015 UTC
@@ -0,0 +1,151 @@
+/*
+Copyright (c) 2010, NHIN Direct Project
+All rights reserved.
+
+Authors:
+ Greg Meyer gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
distribution. Neither the name of the The NHIN Direct Project
(nhindirect.org).
+nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+package org.nhindirect.dns.service;
+
+import java.net.URL;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nhindirect.dns.DNSException;
+import org.nhindirect.dns.DNSServer;
+import org.nhindirect.dns.DNSServerFactory;
+import org.nhindirect.dns.DNSServerSettings;
+import org.nhindirect.dns.DNSStore;
+import org.nhindirect.dns.provider.AbstractConfigDNSStoreProvider;
+import org.nhindirect.dns.provider.BasicDNSServerSettingsProvider;
+
+import com.google.inject.Provider;
+
+/**
+ * Service wrapper that instantiates and configures the DNS server.
+ * @author Greg Meyer
+ *
+ * @since 1.0
+ */
+public class DNSServerService
+{
+ protected static final String DNS_STORE_PROVIDER_VAR
= "org.nhindirect.dns.DNSStoreProviderClass";
+
+ private static final Log LOGGER =
LogFactory.getFactory().getInstance(DNSServerService.class);
+
+ protected final DNSServer server;
+
+ /**
+ * Creates the service wrapper with the location of the configuration
service and server settings.
+ * @param configLocation URL with the location of the configuration
service.
+ * @param settings Default settings for the server. Settings in the
configuration service can over ride these settings.
+ * @throws DNSException
+ *
+ * @since 1.0
+ */
+ public DNSServerService(URL configLocation, DNSServerSettings settings)
throws DNSException
+ {
+ LOGGER.info("Creating the DNSServer using configuration location " +
configLocation.toExternalForm());
+
+
+ BasicDNSServerSettingsProvider settingsProv = new
BasicDNSServerSettingsProvider(settings.getBindAddress(),
settings.getPort());
+
+ Provider<DNSStore> dnsStoreProvider =
getDNSStoreProvider(configLocation);
+
+ server = DNSServerFactory.createDNSServer(configLocation,
dnsStoreProvider, settingsProv);
+
+ LOGGER.info("DNS Server created. Starting server.");
+ server.start();
+
+ Runtime.getRuntime().addShutdownHook(new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ LOGGER.info("Shutdown hook detected. Intiate server shutdown.");
+ stopService();
+ }
+ catch (DNSException e) {/* no-op */}
+
+ }
+ });
+ }
+
+ /**
+ * Creates a {@link Provider<DNSStore>} instance based on the system
property
+ * org.nhindirect.dns.DNSStoreProviderClass. This property is the fully
qualified class name
+ * of the provider. If the provider extends the {@link
AbstractConfigDNSStoreProvider} class, then the configuration service
+ * location will be passed at construction time.
+ * @param configLocation The URL of the configuration service.
+ * @return A constructed instance of a provider. If the system cannot
locate the Provider class specified by the
+ * org.nhindirect.dns.DNSStoreProviderClass system property of if the
property does not exist, the method
+ * will return null.
+ *
+ */
+ @SuppressWarnings("unchecked")
+ protected Provider<DNSStore> getDNSStoreProvider(URL configLocation)
+ {
+ Provider<DNSStore> retVal = null;
+
+ // get the system property
+ String className = System.getProperty(DNS_STORE_PROVIDER_VAR);
+ if (className != null && !className.isEmpty())
+ {
+ try
+ {
+ Class<?> loadedClazz =
DNSServerService.class.getClassLoader().loadClass(className);
+
+ if (AbstractConfigDNSStoreProvider.class.isAssignableFrom(loadedClazz))
+ {
+ // this provider takes a URL for the constructor
+ retVal =
(Provider<DNSStore>)loadedClazz.getConstructor(URL.class).newInstance(configLocation);
+ }
+ else
+ retVal = (Provider<DNSStore>)loadedClazz.newInstance();
+
+ LOGGER.info("Loaded Provider<DNSStore> class " + className + " for
creating the DNSStore");
+ }
+ catch(Throwable e)
+ {
+ LOGGER.error("Could not load or construct instance of
Provider<DNSStore> class " + className + " A default " +
+ "provider will be used." , e);
+ }
+ }
+ else
+ LOGGER.info("A DNSStore provider class was not set. A default provider
will be used.");
+
+ return retVal;
+ }
+
+ /**
+ * Stops and shutdown the service.
+ * @throws DNSException
+ *
+ * @since 1.0
+ */
+ public synchronized void stopService() throws DNSException
+ {
+ if (server != null)
+ {
+ LOGGER.info("Shutting down DNS server.");
+ server.stop();
+ }
+
+ }
+}
=======================================
***Additional files exist in this changeset.***
Reply all
Reply to author
Forward
0 new messages