Java Doc for Tools.java in  » Forum » nemesis-forum » org » nemesis » forum » webapp » front » 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 » Forum » nemesis forum » org.nemesis.forum.webapp.front 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.nemesis.forum.webapp.front.Tools

Tools
public class Tools (Code)

author:
   dlaurent


Field Summary
final public static  StringAUTH_TOKEN
    
final public static  StringAUTOLOGIN_COOKIE
    
final public static  StringLASTVISITED_COOKIE
    
final public static  StringLASTVISITED_TOKEN
    


Method Summary
public static  StringdateToText(Date date)
     Returns a String describing the amount of time between now (current system time) and the passed in date time.
public static  longgetLastVisited(HttpServletRequest request, HttpServletResponse response, boolean updateLastVisitedTime)
     Returns the time in milliseconds that the user last visited the system.
Parameters:
  request - the HttpServletRequest object, known as "request" on a JSP page.
Parameters:
  response - the HttpServletRequest object, known as "response" on a JSP page.
Parameters:
  updateLastVisitedTime - Set to true if you wish to updatethe user's last visited time to the current time; set to false otherwise.
public static  longgetLastVisited(HttpServletRequest request, HttpServletResponse response)
     Returns the time in milliseconds that the user last visited .
Parameters:
  request - the HttpServletRequest object, known as "request" on a JSP page.
Parameters:
  response - the HttpServletRequest object, known as "response" on a JSP page.
public static  AuthorizationgetUserAuthorization(HttpServletRequest request, HttpServletResponse response, boolean checkCookie)
     Returns an Authorization token for the user.
public static  AuthorizationgetUserAuthorization(HttpServletRequest request, HttpServletResponse response)
     Returns an Authorization token for the user.
public static  booleanisNewMessage(Message message, long lastVisited)
     Returns true if the message has been created or updated since the last time the user visisted.
Parameters:
  message - the message to check.
Parameters:
  lastVisted - the time the user last visisted the forum.
public static  StringquoteOriginal(String body, String delimiter, int lineLength)
     Formats the unfiltered body of a message to make it appear in the "quote original" format.
public static  voidremoveUserAuthorization(HttpServletRequest request, HttpServletResponse response)
     Invalidates the cookie that otherwise lets a user auto-login.
public static  AuthorizationsetUserAuthorization(HttpServletRequest request, HttpServletResponse response, String username, String password, boolean autoLogin)
     Validates the user and optionally enables auto-login by creating an auto-login cookie.

Field Detail
AUTH_TOKEN
final public static String AUTH_TOKEN(Code)
Name of the authentication token (is stored in the user's session)



AUTOLOGIN_COOKIE
final public static String AUTOLOGIN_COOKIE(Code)
Name of the cookie used to store user info for auto-login purposes



LASTVISITED_COOKIE
final public static String LASTVISITED_COOKIE(Code)
Name of the cookie used to store last visited timestamp



LASTVISITED_TOKEN
final public static String LASTVISITED_TOKEN(Code)
Name of the last visited token (is stored in the user's session)





Method Detail
dateToText
public static String dateToText(Date date)(Code)
Returns a String describing the amount of time between now (current system time) and the passed in date time. Example output is "5 hours ago" or "Yesterday at 3:30 pm"
Parameters:
  date - the Date to compare the current time with. a description of the difference in time, ie: "5 hours ago"or "Yesterday at 3:30pm"



getLastVisited
public static long getLastVisited(HttpServletRequest request, HttpServletResponse response, boolean updateLastVisitedTime)(Code)
Returns the time in milliseconds that the user last visited the system.
Parameters:
  request - the HttpServletRequest object, known as "request" on a JSP page.
Parameters:
  response - the HttpServletRequest object, known as "response" on a JSP page.
Parameters:
  updateLastVisitedTime - Set to true if you wish to updatethe user's last visited time to the current time; set to false otherwise. The time (in milliseconds) that the suer last visited .



getLastVisited
public static long getLastVisited(HttpServletRequest request, HttpServletResponse response)(Code)
Returns the time in milliseconds that the user last visited .
Parameters:
  request - the HttpServletRequest object, known as "request" on a JSP page.
Parameters:
  response - the HttpServletRequest object, known as "response" on a JSP page. The time (in milliseconds) that the suer last visited .



getUserAuthorization
public static Authorization getUserAuthorization(HttpServletRequest request, HttpServletResponse response, boolean checkCookie)(Code)
Returns an Authorization token for the user. The following steps are performed to determine the token:
  1. Check the session for the existence of a authorization token. If one is found, it is returned as we assume that the user has logged in and is authorized.
  2. Check the authorization cookie for a username and password. If found, attempt to create a authorization token using that data. If successful, save the token to the session and return it. NOTE: This check can be skipped by setting checkCookie to false.


Parameters:
  request - the HttpServletRequest object, known as "request" in aJSP page.
Parameters:
  response - the HttpServletResponse object, known as "response" ina JSP page.
Parameters:
  checkCookie - a boolean that indicates whether or not we wantto use a cookie for authorization. the authorization token if authenticated, otherwisenull.
See Also:   Authorization




getUserAuthorization
public static Authorization getUserAuthorization(HttpServletRequest request, HttpServletResponse response)(Code)
Returns an Authorization token for the user. This is a convenience method that that calls the other getUserAuthorization method with checkCookie set to true.
Parameters:
  request - the HttpServletRequest object, known as "request" in aJSP page.
Parameters:
  response - The HttpServletResponse object, known as "response" ina JSP page. The authorization token if authenticated, otherwisenull.



isNewMessage
public static boolean isNewMessage(Message message, long lastVisited)(Code)
Returns true if the message has been created or updated since the last time the user visisted.
Parameters:
  message - the message to check.
Parameters:
  lastVisted - the time the user last visisted the forum. true if the message has been created or updated since the user'slast visit.



quoteOriginal
public static String quoteOriginal(String body, String delimiter, int lineLength)(Code)
Formats the unfiltered body of a message to make it appear in the "quote original" format. This is simply the body of the message with the delimiter appended to the beginning of each line. The delimiter is most often "> " by convention. A desired length for each line in the returned String can be specified to aid in formatting.

This method uses message.getUnfilteredBody() in order to get the body of the message. This usually yields better results for the formatting required by this method. However, it also has the potential of being a security risk if malicious HTML code is embedded in the body. Therefore, you should always filter HTML from the result of this method before showing it in an environment where HTML is interpreted. If you are showing the results of this method in an HTML <textarea>, there is no need to worry about malicious HTML.
Parameters:
  message - the message to quote.
Parameters:
  delimiter - a String that will start each line of the quotedmessage. For example, "> ";
Parameters:
  lineLength - the desired length of each line in the quoted message. the unfiltered body of the message in the "quote original" format.




removeUserAuthorization
public static void removeUserAuthorization(HttpServletRequest request, HttpServletResponse response)(Code)
Invalidates the cookie that otherwise lets a user auto-login.
Parameters:
  request - The HttpServletRequest object, known as "request" in a JSP page.
Parameters:
  response - The HttpServletResponse object, known as "response" in a JSP page.



setUserAuthorization
public static Authorization setUserAuthorization(HttpServletRequest request, HttpServletResponse response, String username, String password, boolean autoLogin) throws NotFoundException, UnauthorizedException(Code)
Validates the user and optionally enables auto-login by creating an auto-login cookie.
Parameters:
  request - the HttpServletRequest object, known as "request" in a JSP page.
Parameters:
  response - the HttpServletResponse object, known as "response" in a JSP page.
Parameters:
  username - the username.
Parameters:
  password - the password.
Parameters:
  autoLogin - if true create a cookie that enables auto-login.
throws:
  UserNotFoundException -
throws:
  UnauthorizedException - The authorization token if authenticated, otherwisenull



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.