|
|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TOP THREE LINKS YOU MUST CLICK ON Virtualization
Using Virtual Sockets To Fix Software Broken by Firewalls
Without violating security
Feb. 27, 2007 12:15 PM
Digg This!
A character on the TV show "L.A. Law" once said, "It was the 60s. Safe sex meant keeping the parking brake on." In the early days of public networks security carried a similar sense of urgency. In fact, the network was its own best defense. One of the authors remembers accommodating a colleague by spending an afternoon plotting the hops, gateways, and contorted syntax necessary to send an e-mail from Brooklyn to Michigan. (How many computer scientists does it take to send an e-mail?)
JBoss Remoting Two of the primary design goals of Remoting, which is envisioned as the unified communications framework for the JBoss Enterprise Middleware Suite (JEMS) of software products, including the JBoss Application Server, are (1) to support a variety of communication models, and (2) to allow any combination of pluggable components to be exchanged for any other purely through configuration changes, leaving the application code untouched. A variety of protocols are implemented at the transport level, each by a pair of descendants of the RemoteClientInvoker and ServerInvoker classes, which, as their names imply, run on the client and server, respectively. These pairs of classes work together to transmit a method invocation from the client to an application-specific handler on the server and return the hander's response to the calling program on the client. Together they constitute an invoker. For example, the socket invoker is comprised of the SocketClientInvoker and SocketServerInvoker classes, and HTTPClientInvoker and HTTPServerInvoker make up the HTTP invoker. Callbacks are handled by the same components with an inversion of client and server roles.
The Multiplex Sub-Project
Public Multiplex Classes
Virtual Socket Groups Multiplexing a single TCP/IP connection between two actual sockets s1 and s2 is achieved by commingling the communications of multiple pairs (v1, v'1), ..., (vn, v'n) of virtual sockets. The sets {v1,...,vn} and {v'1,...,v'n} are called virtual socket groups, where the members of one set are based on s1 and the members of the other are based on s2. These sets are denoted G(s1) and G(s2), respectively. A virtual socket group is built in two stages, (1) creating the actual socket on which it's based and installing its first member, and (2) populating it with additional virtual sockets, and each stage is affected by the interaction of a virtual socket constructor with an instance of one of the two virtual server socket classes. The first stage involves the creation of a real socket and, accordingly, the accept() method of the MasterServerSocket inherits much of its functionality from super.accept(). When a virtual socket constructor finds no existing virtual socket group to join and it connects to a MasterServerSocket, the following sequence of events occurs:
The difference between the two classes of server sockets may be expressed succinctly by categorizing their public methods.
MasterServerSocket
VirtualServerSocket The striking thing here is the existence of the delegated methods and connection-oriented methods in the VirtualServerSocket class, both of which seem out of place for a server socket. In fact, they reveal the true, rather hybrid, nature of VirtualServerSocket, which uses a real socket to implement the behavior of a server socket. The important functional implication is that, like a socket, a VirtualServerSocket has a connection to another host, and so it can accept connect requests only from virtual sockets on that host. The rules for creating and joining socket groups are spelled out in detail in the Multiplex documentation (see http://labs.jboss.com/portal/jbossremoting/docs/multiplex/multiplex.html), including a discussion of the accidental connection problem, which necessitates the constructors and methods that support binding and connecting in a single atomic action.
The Prime Scenario Every Muliplex scenario begins with a MasterServerSocket that creates the underlying actual socket. Figure 3 illustrates the first step in creating the Prime Scenario, in which a virtual socket v1 connects to a MasterServerSocket that creates and returns a reference to a new virtual socket v2. In Figure 3 we have a connection between v1 and v2, which can support synchronous communication but which offers nothing not provided by actual sockets. To create a second connection for callbacks, we add a VirtualServerSocket to the client's socket group. The second step in constructing the Prime Scenario is illustrated in Figure 4, in which the constructor (or factory method, which calls a constructor) is called on the server to create virtual socket v3 to support callbacks. The constructor sends a connection request to the VirtualServerSocket on the client, which creates new virtual socket v4 and sends a reference to v4 back to v3. At this point we have a socket group on the client with two virtual sockets and a VirtualServerSocket, a socket group on the server with two virtual sockets, and the Prime Scenario is set up. A sample client and a sample server for the Prime Scenario are given in Listing 1 and Listing 2 which can be downloaded from the online version of this article.
FTP Case Study We made the changes in Listing 3 for the client. Note that red lines were deleted, green lines were inserted, and the yellow lines are particularly relevant to our discussion. For the server, we made the changes shown in Listing 4 (Listings 4 and additional source code can be downloaded from the online version of this article.) And we can make the following observations about our experiment:
The Multiplex sub-project of JBoss Remoting provides multiplexing versions of various classes in the standard java.net and javax.net packages, allowing multiple virtual network connections to share a single real TCP/IP connection. Though they were developed to support a JBoss Remoting feature request, these classes can be applied independently and, in particular, they can be used to open connections to anonymous ports in the presence of a firewall while violating neither the letter nor the spirit of any security policy. For this article we selected an Open Source FTP client and an Open Source FTP server and modified them slightly, replacing standard sockets and server sockets with their virtual counterparts. We found that if the target code is sufficiently configurable, the use of socket and server socket factories can almost eliminate the need to change existing code. We found one necessary code change that can't be configured away. We can derive from this observation that a desirable feature for the next JBoss Remoting release would be default behavior that allows a VirtualSocket or VirtualServerSocket that binds to port 0 to join an arbitrary existing socket group. In the current case the new VirtualServerSocket would find exactly one existing socket group and join it, which is just what we want. Which shows that there's no substitute for kicking the tires and taking it for a drive. LATEST JAVA STORIES & POSTS
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING JAVA NEWS
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||