Java Doc for ProxyDispatcher.java in  » Web-Server » Jigsaw » org » w3c » www » protocol » http » proxy » 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 » Web Server » Jigsaw » org.w3c.www.protocol.http.proxy 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.w3c.www.protocol.http.proxy.ProxyDispatcher

ProxyDispatcher
public class ProxyDispatcher implements PropRequestFilter,PropertyMonitoring(Code)
The proxy dispatcher applies some rules to a request. The goal of that filter is to allow special pre-processing of requests based, on their target host, before sending them off the net.

The filter is configured through a rule file whose format is described by the following BNF: rule-file=(record)*
record=EOL|comment|rule
comment=#(^EOL)*EOL
rule=rule-lhs(SPACE)*rule-rhs
rule-lhs=(token) |(token (. token)*
rule-lhr=forbid|direct|redirect |proxy|authorization|proxyauth
forbid=FORBID|forbid
direct=DIRECT|direct
redirect=(REDIRECT|proxy) url
proxy=(PROXY|proxy) url
url=any valid URL
authorization=(AUTHORIZATION|authorization user password
proxyauth=(PROXYAUTH|proxyauth user password url

A sample rule file looks like this: # Some comments edu proxy http://class.w3.org:8001/ org proxy http://class.w3.org:8001/ fr direct www.evilsite.com redirect http://www.goodsite.com/warning.html www.w3.org direct 138.96.24 direct www.playboy.com forbid default proxy http://cache.inria.fr:8080/

The algorithm used to lookup rules is the following:

  • Split all rules left hand side into its components, eg H1.H2.H3 is splitted into { H1, H2, H3 }, then reverse the components and map that to the rule. In our example above, { org, w3, www} would be mapped to direct.
  • Split the fully qualified host name into its components, eg, A.B.C is splitted into { A, B, C } and reverse it.
  • Find the longest match in the mapping table of rules, and get apply the given rule.

In our example, a request to www.isi.edu would match the edu rule, and a request for www.w3.org would match the direct rule, for example.

Three rules are defined:

direct
Run that request directly against the target host.
forbid
Emit a forbid message, indicating that the user is not allowed to contact this host.
proxy
Run that request through the given proxy.
proxyauth
Run that request through a proxy with the right proxy credentials.

For numeric IP addresses, the most significant part is the beginning, so {A, B, C} are deducted directly. In the example { 138, 96, 24 } is mapped to direct.

If no rules are applied, then the default rule (root rule) is applied. See the example.



Field Summary
final public static  StringCHECK_RULES_LAST_MODIFIED_P
     Name of the property turning that filter in debug mode.
final public static  StringDEBUG_P
     Name of the property turning that filter in debug mode.
final public static  StringRULE_P
     Name of the property giving the rule file URL.
protected  booleancheck_rules
    
protected  booleandebug
    
final protected static  Stringdisabled
    
protected  longlastParsingTime
    
protected  ObservablePropertiesprops
     The properties we initialized ourself from.
protected  RuleNoderules
     The current set of rules to apply.

Constructor Summary
public  ProxyDispatcher()
     Empty constructor, for dynamic instantiation.

Method Summary
public  booleanexceptionFilter(Request request, HttpException ex)
     Filter requests when an error occurs during the process. This filter tries to do a direct connection if it is needed
Parameters:
  reques - The request to filter.
Parameters:
  reply - It's associated reply.
public  ReplyingoingFilter(Request request)
     Filter requests before they are emitted. Look for a matching rule, and if found apply it before continuing the process.
public  voidinitialize(HttpManager manager)
    
protected  booleanneedsParsing()
    
public  ReplyoutgoingFilter(Request request, Reply reply)
     Filter requests after processing. This filter doesn't do any post-processing.
Parameters:
  reques - The request to filter.
Parameters:
  reply - It's associated reply.
protected  voidparseRules(InputStream in)
     Parse the given input stream as a rule file.
protected  voidparseRules()
     Parse the default set of rules.
public  booleanpropertyChanged(String name)
     PropertyMonitoring implementation - Commit property changes.
Parameters:
  name - The name of the property that has changed.
public  voidsync()
     We don't maintain cached infos.

Field Detail
CHECK_RULES_LAST_MODIFIED_P
final public static String CHECK_RULES_LAST_MODIFIED_P(Code)
Name of the property turning that filter in debug mode.



DEBUG_P
final public static String DEBUG_P(Code)
Name of the property turning that filter in debug mode.



RULE_P
final public static String RULE_P(Code)
Name of the property giving the rule file URL.



check_rules
protected boolean check_rules(Code)



debug
protected boolean debug(Code)
Are we in debug mode ?



disabled
final protected static String disabled(Code)



lastParsingTime
protected long lastParsingTime(Code)



props
protected ObservableProperties props(Code)
The properties we initialized ourself from.



rules
protected RuleNode rules(Code)
The current set of rules to apply.




Constructor Detail
ProxyDispatcher
public ProxyDispatcher()(Code)
Empty constructor, for dynamic instantiation.




Method Detail
exceptionFilter
public boolean exceptionFilter(Request request, HttpException ex)(Code)
Filter requests when an error occurs during the process. This filter tries to do a direct connection if it is needed
Parameters:
  reques - The request to filter.
Parameters:
  reply - It's associated reply. Always null.



ingoingFilter
public Reply ingoingFilter(Request request)(Code)
Filter requests before they are emitted. Look for a matching rule, and if found apply it before continuing the process. If a forbid rule was apply, this method will return with a forbidden message.
Parameters:
  request - The request to filter. A Reply instance, if processing is not to be continued,falseotherwise.



initialize
public void initialize(HttpManager manager)(Code)



needsParsing
protected boolean needsParsing()(Code)



outgoingFilter
public Reply outgoingFilter(Request request, Reply reply)(Code)
Filter requests after processing. This filter doesn't do any post-processing.
Parameters:
  reques - The request to filter.
Parameters:
  reply - It's associated reply. Always null.



parseRules
protected void parseRules(InputStream in) throws IOException, RuleParserException(Code)
Parse the given input stream as a rule file.
Parameters:
  in - The input stream to parse.
exception:
  IOException - if an IO error occurs.
exception:
  RuleParserException - if parsing failed.



parseRules
protected void parseRules()(Code)
Parse the default set of rules.

IOf the rules cannot be parsed, the filter emits an error message to standard error, and turn itself into transparent mode.




propertyChanged
public boolean propertyChanged(String name)(Code)
PropertyMonitoring implementation - Commit property changes.
Parameters:
  name - The name of the property that has changed. A boolean true if change was commited, false otherwise.



sync
public void sync()(Code)
We don't maintain cached infos.



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.