Java Doc for Proxy.java in  » Net » JGroups-2.4.1-sp3 » org » jgroups » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » JGroups 2.4.1 sp3 » org.jgroups.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jgroups.util.Proxy

Proxy
public class Proxy (Code)
Redirects incoming TCP connections to other hosts/ports. All redirections are defined in a file as for example
 127.0.0.1:8888=www.ibm.com:80
 localhost:80=pop.mail.yahoo.com:110
 
The first line forwards all requests to port 8888 on to www.ibm.com at port 80 (it also forwards the HTTP response back to the sender. The second line essentially provides a POP-3 service on port 8110, using Yahoo's POP service. This is neat when you're behind a firewall and one of the few services in the outside world that are not blocked is port 80 (HHTP).
Note that JDK 1.4 is required for this class. Also, concurrent.jar has to be on the classpath. Note that you also need to include jsse.jar/jce.jar (same location as rt.jar) if you want SSL sockets.
To create SSLServerSockets you'll need to do the following: Generate a certificate as follows:
 keytool -genkey -keystore /home/bela/.keystore -keyalg rsa -alias bela -storepass  -keypass 
 
Start the Proxy as follows:
 java -Djavax.net.ssl.keyStore=/home/bela/.keystore -Djavax.net.ssl.keyStorePassword=
 -Djavax.net.ssl.trustStore=/home/bela/.keystore -Djavax.net.ssl.trustStorePassword=
 org.jgroups.util.Proxy -file /home/bela/map.properties
 
Start client as follows:
 java -Djavax.net.ssl.trustStore=/home/bela/.keystore -Djavax.net.ssl.trustStorePassword= sslclient
 

To import a certificate into the keystore, use the following steps:
 openssl x509 -in server.crt -out server.crt.der -outform DER
 keytool -import -trustcacerts -alias  -file server.crt.der
 
This will store the server's certificate in the ${user.home}/.keystore key store.
Note that an SSL client or server can be debugged by starting it as follows:
-Djava.protocol.handler.pkgs=com.sun.net.ssl.internal.www.protocol -Djavax.net.debug=ssl

If you run a web browser, simply enter https://: as URL to connect to an SSLServerSocket
Note that we cannot use JDK 1.4's selectors for SSL sockets, as getChannel() on an SSL socket doesn't seem to work.
author:
   Bela Ban

Inner Class :static class Relayer implements Runnable
Inner Class :static class MyInetSocketAddress extends InetSocketAddress
Inner Class :class SocketAcceptor implements Runnable
Inner Class :static class Connection implements Relayer.Listener

Field Summary
final static  intBUFSIZE
    
final static  intMAX_THREAD_POOL_SIZE
    
static  booleandebug
    
 Executorexecutor
    
 intlocal_portremote_port
    
 InetAddresslocalremote
    
 Stringmapping_file
    
final  HashMapmappings
    
static  booleanverbose
    

Constructor Summary
public  Proxy(InetAddress local, int local_port, InetAddress remote, int remote_port, boolean verbose, boolean debug)
    
public  Proxy(InetAddress local, int local_port, InetAddress remote, int remote_port, boolean verbose, boolean debug, String mapping_file)
    

Method Summary
 void_handleConnection(SocketChannel in_channel, SocketChannel out_channel)
    
 voidcheck(URI u)
    
 voidclose(Selector sel, SocketChannel in_channel, SocketChannel out_channel)
    
static  voidclose(Socket in, Socket out)
    
static  voidclose(Socket sock)
    
 voidhandleConnection(SocketChannel in, SocketChannel out)
    
static  voidhelp()
    
static  voidlog(String method_name, String msg)
    
static  voidlog(String msg)
    
 voidloop(Selector selector)
    
public static  voidmain(String[] args)
    
 voidpopulateMappings(String filename)
     Populates mappings hashmap.
static  StringprintRelayedData(String from, String to, int num_bytes)
    
 StringprintSelectionOps(SelectionKey key)
    
 booleanrelay(SocketChannel from, SocketChannel to, ByteBuffer buf)
     Read all data from from and write it to to.
public  voidstart()
    
 SocketAddressstrToAddr(String input)
    
 StringtoString(SocketChannel ch)
    
 StringtoString(InetSocketAddress addr)
    

Field Detail
BUFSIZE
final static int BUFSIZE(Code)



MAX_THREAD_POOL_SIZE
final static int MAX_THREAD_POOL_SIZE(Code)



debug
static boolean debug(Code)



executor
Executor executor(Code)



local_portremote_port
int local_portremote_port(Code)



localremote
InetAddress localremote(Code)



mapping_file
String mapping_file(Code)



mappings
final HashMap mappings(Code)



verbose
static boolean verbose(Code)




Constructor Detail
Proxy
public Proxy(InetAddress local, int local_port, InetAddress remote, int remote_port, boolean verbose, boolean debug)(Code)



Proxy
public Proxy(InetAddress local, int local_port, InetAddress remote, int remote_port, boolean verbose, boolean debug, String mapping_file)(Code)




Method Detail
_handleConnection
void _handleConnection(SocketChannel in_channel, SocketChannel out_channel) throws Exception(Code)



check
void check(URI u) throws Exception(Code)
Checks whether a URI is http(s)://:



close
void close(Selector sel, SocketChannel in_channel, SocketChannel out_channel)(Code)



close
static void close(Socket in, Socket out)(Code)



close
static void close(Socket sock)(Code)



handleConnection
void handleConnection(SocketChannel in, SocketChannel out)(Code)



help
static void help()(Code)



log
static void log(String method_name, String msg)(Code)



log
static void log(String msg)(Code)



loop
void loop(Selector selector)(Code)
We handle only non-SSL connections



main
public static void main(String[] args)(Code)



populateMappings
void populateMappings(String filename) throws Exception(Code)
Populates mappings hashmap. An example of a definition file is:
 http://localhost:8888=http://www.yahoo.com:80
 https://localhost:2200=https://cvs.sourceforge.net:22
 http://localhost:8000=https://www.ibm.com:443
 
Mappings can be http-https, https-http, http-http or https-https



printRelayedData
static String printRelayedData(String from, String to, int num_bytes)(Code)



printSelectionOps
String printSelectionOps(SelectionKey key)(Code)



relay
boolean relay(SocketChannel from, SocketChannel to, ByteBuffer buf) throws Exception(Code)
Read all data from from and write it to to. Returns false if channel was closed



start
public void start() throws Exception(Code)



strToAddr
SocketAddress strToAddr(String input) throws Exception(Code)
Input is "host:port"



toString
String toString(SocketChannel ch)(Code)



toString
String toString(InetSocketAddress addr)(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.