Java Doc for SunNetAuthHandler.java in  » Web-Server » Brazil » sunlabs » brazil » handler » 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 » Brazil » sunlabs.brazil.handler 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   sunlabs.brazil.handler.SunNetAuthHandler

SunNetAuthHandler
public class SunNetAuthHandler implements Handler(Code)
All-in-one Handler for doing supplier.net style authentication.

The purpose of this handler is to provide an authenticated "front end" to one or more web sites, using (hopefully) arbitrary challenge- response based authentication via a plug-in authentication interface. It can bridge disparate DNS domains by selectively mapping servers on one domain into another, based on the supplied credentials, by using the MultiProxyHandler .

The authentication step is expected to yield a list of roles, each of which represents permission to access a specific foreign site. Once authentication is complete, and the roles are obtained, the handler keeps a set of credentials (a lease) on behalf of the user, which can be tuned at setup time for a variety of expiration conditions. Once a lease expires, re-authentication is required.

This handler starts two sets of handlers of its own, an authentication handler - responsible for doing the authentication, and one of more virtual proxy handlers - one for each possible role. In the current implementation, the authentication handler is specified and a configuration property, and the proxy handlers are all instances of MultiProxyHandler , one per role.

Operation of the handler proceeds in the following steps:

  1. When the server starts, the handler is initialized.
    • The template file is located and read.
    • One MultiProxyHandler is started for each possible role
    • The Authentication handler is started. Its operation is defined below.
  2. Browser cookies are used as a reference to the user's credentials. If the cookie returned by the browser refers to a valid credential, the requested url is compared to the user's roles. If the requested URL is permitted, by matching one of the users's roles, the URL is forwarded to the proper virtual web site for delivery. Otherwise the URL is considered "not found".
  3. If the credentials are not valid, either because thay had expired, were removed, or there is no browser cookie, the authentication sequence is started, for the purpose of obtaining valid credentials.
    • A browser cookie is chosen at random, and a "set-cookie" request is sent to the client (in lieu of the URL requested) along with the login template. An additional random value is created, retained by the handler on behalf of this client, and made available as a parameter to the login template.
    • The next response from the client is expected to contain the information required to authenticate the client. This is normally accomplished by having the user fill out the form that is contained on the login template, and clicking the submit button.
    • The client's response (e.g. query data), along with the random number generated in the previous step, are forwarded to the authentication handler.
    • The authentication handler is expected to place a user id and a list of roles in the resulting request object if authentication is successful or an error message otherwise. If the authentication suceeds, the roles are entered into the lease, and the original URL processing is resumed. If instead an error is returned, the authentication sequence is repeated. The error message is may be displayed to the user if it is included as a parameter on the login template.

The login template is ordinary HTML, except contructs of the form:

 <insert property=xx default=yy>
 
may be used to substitute sunlabs.brazil.server.Request.props into the template. The properties challenge and Message are automatically set to indicate the random challange and error message (if any) from a previous attempt, respectively.

The following configuration parameters are recgnized:

prefix
URL prefix for proxy
authenticate
URL for authentication page
cookie
name of the cookie
roles
list of roles
proxy
prefix for proxy handler
idName
property key for token id
roleName
property key for token roles
maxIdle
maximum idle time for token (seconds)
maxAge
maximum total age for token (seconds)
maxUses
maximum total uses for token
exit
prefix to exit a session
all
"free" directory suffixes
template
login template
Currently, the "sunlabs.brazil.handler.MultiProxyHandler" class is called to do the actual proxying. (There should be a link to a sample config file for this one)

NOTE: This handler is included for historical purposes. It should be upated to take advantage of features not available when it was first written.
author:
   Stephen Uhler
version:
   1.29, 00/12/11


Inner Class :static class RoleData

Field Summary
final static  StringALL
    
final static  StringAUTH
    
final static  StringCOOKIE
    
final static  StringID_KEY
    
final static  StringLOGOUT
    
final static  StringMAX_AGE
    
final static  StringMAX_IDLE
    
final static  StringMAX_USES
    
final static  StringPREFIX
    
final static  StringPROXY
    
final static  StringPROXY_CLASS
    
final static  StringROLES
    
final static  StringROLE_KEY
    
final static  StringTEMPLATE
    
 StringUrlPrefix
    
 StringauthUrl
    
 StringcookieName
    
 StringexitString
    
 Vectorfree
    
 StringidKey
    
 intmaxAge
    
 intmaxIdle
    
 intmaxUses
    
 StringpropsPrefix
    
 Hashtableproxies
    
static  Randomrandom
    
 StringroleKey
    
 Stringtemplate
    
 HandlertokenHandler
    


Method Summary
public  booleaninit(Server server, String prefix)
    
public static  StringprocessTemplate(String template, Hashtable data)
     Process a template page, and send to the client.
public  booleanrespond(Request request)
     Act like a "gatekeeper".
public  voidreturnLogin(Request request, String message)
    

Field Detail
ALL
final static String ALL(Code)



AUTH
final static String AUTH(Code)



COOKIE
final static String COOKIE(Code)



ID_KEY
final static String ID_KEY(Code)



LOGOUT
final static String LOGOUT(Code)



MAX_AGE
final static String MAX_AGE(Code)



MAX_IDLE
final static String MAX_IDLE(Code)



MAX_USES
final static String MAX_USES(Code)



PREFIX
final static String PREFIX(Code)



PROXY
final static String PROXY(Code)



PROXY_CLASS
final static String PROXY_CLASS(Code)



ROLES
final static String ROLES(Code)



ROLE_KEY
final static String ROLE_KEY(Code)



TEMPLATE
final static String TEMPLATE(Code)



UrlPrefix
String UrlPrefix(Code)



authUrl
String authUrl(Code)



cookieName
String cookieName(Code)



exitString
String exitString(Code)



free
Vector free(Code)



idKey
String idKey(Code)



maxAge
int maxAge(Code)



maxIdle
int maxIdle(Code)



maxUses
int maxUses(Code)



propsPrefix
String propsPrefix(Code)



proxies
Hashtable proxies(Code)



random
static Random random(Code)



roleKey
String roleKey(Code)



template
String template(Code)



tokenHandler
Handler tokenHandler(Code)





Method Detail
init
public boolean init(Server server, String prefix)(Code)
Set up all of the handlers - Secure Token Services for authentication - MultiProxyHandler for dispatching to hosts



processTemplate
public static String processTemplate(String template, Hashtable data)(Code)
Process a template page, and send to the client. This should be re-done to use the template handler. Look for html tags of the form: Also look for: and replace the tag with the value of the request property.
Parameters:
  template - The template to process
Parameters:
  data - The hashtable containing the data to subst



respond
public boolean respond(Request request) throws IOException(Code)
Act like a "gatekeeper". If we have a valid browser cookie, Then dispatch to one of the proxies. If not, try to authenticate by returning the login "template", fetching the credentials, and establising a session.



returnLogin
public void returnLogin(Request request, String message)(Code)
return the login page with the appropriate message substituted in



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.