13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

21.3 What’s in a Name? An Introducti<strong>on</strong> to JNDI489Example 21.2 is what we get when we run this program against <strong>on</strong>e of theauthor’s DNS domains. 7Example 21.2 Running GetDomain against the multitool.net domain[mschwarz@cassidy simpleApp]$ java GetDomain multitool.netObject [bar<strong>on</strong>i: java.lang.Object]Object [erik: java.lang.Object]Object [www: java.lang.Object]Object [class: java.lang.Object]Object [jboss: java.lang.Object]Object [penguin: java.lang.Object]Object [mail: java.lang.Object]Object [cvs: java.lang.Object]Object [stiletto: java.lang.Object]Object [penfold: java.lang.Object]Object [ns2: java.lang.Object]Object [ns1: java.lang.Object]Object [irc: java.lang.Object][mschwarz@cassidy simpleApp]$The GetDomain main() method. This is another “single class” programexample. In this case, the main() method creates an instance of the class,passing the first command-line argument to the c<strong>on</strong>structor. We’ll cover thec<strong>on</strong>structor in the next secti<strong>on</strong>. By now, you will recognize that this is <strong>on</strong>e ofthe purely pedagogical examples. Note the complete lack of input validati<strong>on</strong>and error checking <strong>on</strong> the number and c<strong>on</strong>tent of the command-line arguments.Establishing an initial c<strong>on</strong>text. For both naming and directory services, itis necessary to establish an initial c<strong>on</strong>text. A c<strong>on</strong>text is a collected set of names.A directory system is a c<strong>on</strong>nected set of c<strong>on</strong>texts. Our example is for DNS.We must set an initial c<strong>on</strong>text for DNS. The class c<strong>on</strong>structor (lines 11–15)does that.7. Note that directory operati<strong>on</strong>s in the JNDI DNS Service Provider Interface are d<strong>on</strong>e withDNS z<strong>on</strong>e transfers. Many domains, especially large domains, disable z<strong>on</strong>e transfers either forsecurity reas<strong>on</strong>s, or because they generate a lot of network traffic and are a popular tool forDenial of Service (DoS) attacks <strong>on</strong> name servers. To put it simply: This program w<strong>on</strong>’t work<strong>on</strong> a lot of domains, especially from outside.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!