Java Doc for SkinUtils.java in  » Forum » yazd » com » Yasna » forum » 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 » Forum » yazd » com.Yasna.forum.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.Yasna.forum.util.SkinUtils

SkinUtils
public class SkinUtils (Code)
A collection of utility methods for use in Yazd WebSkins. Because these methods make skin development much easier, skin authors should study them carefully.

Three major areas of funtionality are provided:

  1. Methods that simplify Authorization tasks:

  2. Methods that get and set Session and cookie values.

  3. Other methods.
All methods conform to the Servlet 1.1 and JSP 1.0 specs for maximum compatibility with application servers. This may yield deprecation warnings if you compile with a newer Servlet/JSP spec; these should be ignored. This class will periodically be updated to the newer specs as app servers mature.


Field Summary
final public static  StringYAZD_AUTH_TOKEN
    
final public static  StringYAZD_AUTOLOGIN_COOKIE
    
final public static  StringYAZD_LASTVISITED_COOKIE
    
final public static  StringYAZD_LASTVISITED_PROP
    
final public static  StringYAZD_LASTVISITED_TOKEN
    


Method Summary
public static  StringdateToText(Date date, Locale locale, TimeZone timezone)
     Returns a String describing the amount of time between now (current system time) and the passed in date time.
public static  CookiegetCookie(HttpServletRequest request, String name)
     Returns the specified Cookie object, or null if the cookie does not exist.
Parameters:
  request - The HttpServletRequest object, known as "request" in aJSP page.
Parameters:
  name - the name of the cookie.
public static  StringgetCookieValue(HttpServletRequest request, String name)
     Returns the value of the specified cookie as a String.
public static  longgetLastVisited(HttpServletRequest request, HttpServletResponse response)
     Returns the time in milliseconds that the user last visited Yazd.
public static  longgetLastVisited(HttpServletRequest request, HttpServletResponse response, boolean updateLastVisitedTime)
     Returns the time in milliseconds that the user last visited the Yazd 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  AuthorizationgetUserAuthorization(HttpServletRequest request, HttpServletResponse response, boolean checkYazdCookie)
     Returns an Authorization token for the user.
public static  AuthorizationgetUserAuthorization(HttpServletRequest request, HttpServletResponse response)
     Returns an Authorization token for the user.
public static  voidinvalidateCookie(HttpServletRequest request, HttpServletResponse response, String cookieName)
     Invalidate the specified cookie and delete it from the response object.
public static  booleanisForumAdmin(Authorization authToken)
     Returns true if the user is a forum adminstrator of any forum in the system.
public static  booleanisForumAdmin(Authorization authToken, Forum forum)
     Returns true if the user is a forum adminstrator of the given forum.
Parameters:
  authToken - the authentication token of the user
Parameters:
  forum - the forum to check administrator status on.
public static  booleanisForumModerator(Authorization authToken)
     Returns true if the user is a forum moderator of any forum in the system.
public static  booleanisForumModerator(Authorization authToken, Forum forum)
     Returns true if the user is a forum moderator of the given forum.
Parameters:
  authToken - the authentication token of the user
Parameters:
  forum - the forum to check moderator status on.
public static  booleanisGroupAdmin(Authorization authToken)
     Returns true if the user is a group administrator of any group in the system.
public static  booleanisGroupAdmin(Authorization authToken, Group group)
     Returns true if the user is a group administrator of the given group.
Parameters:
  authToken - the authentication token of the user
Parameters:
  group - the group to check administrator status on.
public static  booleanisNewMessage(ForumMessage 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  booleanisSystemAdmin(Authorization authToken)
     Returns true if the user is a system administrator.
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  voidremove(HttpServletRequest request, HttpServletResponse response, String id)
     Removes a user stored value.
public static  voidremoveUserAuthorization(HttpServletRequest request, HttpServletResponse response)
     Invalidates the cookie that otherwise lets a user auto-login.
public static  Stringretrieve(HttpServletRequest request, HttpServletResponse response, String id)
     Retrieves a user stored value.
public static  Stringretrieve(HttpServletRequest request, HttpServletResponse response, String id, boolean remove)
     Retrieves a user stored value.
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.
public static  voidstore(HttpServletRequest request, HttpServletResponse response, String id, String value)
     Persists a value for the length of the user's session.
public static  voidstore(HttpServletRequest request, HttpServletResponse response, String id, String value, int secsToLive)
    
public static  voidstore(HttpServletRequest request, HttpServletResponse response, String id, String value, int secsToLive, boolean restoreInSession)
     This method should be used in a jsp skin to store an arbritary value. For example, we could persist the name of a user so that on a form page where they enter their name, that field could be auto-filled in with the stored value.

To indicate that the data should only be persisted for a session, pass in 0 as the timeToLive.
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:
  id - The name or identifier of the data you want to persist.
Parameters:
  value - The value you wish to store.
Parameters:
  secsToLive - The length (in seconds) this value will persist.


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



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



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



YAZD_LASTVISITED_PROP
final public static String YAZD_LASTVISITED_PROP(Code)
Name of the "use last visited" property (is stored in yazd.properties)



YAZD_LASTVISITED_TOKEN
final public static String YAZD_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, Locale locale, TimeZone timezone)(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"



getCookie
public static Cookie getCookie(HttpServletRequest request, String name)(Code)
Returns the specified Cookie object, or null if the cookie does not exist.
Parameters:
  request - The HttpServletRequest object, known as "request" in aJSP page.
Parameters:
  name - the name of the cookie. the Cookie object if it exists, otherwise null.



getCookieValue
public static String getCookieValue(HttpServletRequest request, String name)(Code)
Returns the value of the specified cookie as a String. If the cookie does not exist, the method returns null.
Parameters:
  request - the HttpServletRequest object, known as "request" in aJSP page.
Parameters:
  name - the name of the cookie the value of the cookie, or null if the cookie does not exist.



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



getLastVisited
public static long getLastVisited(HttpServletRequest request, HttpServletResponse response, boolean updateLastVisitedTime)(Code)
Returns the time in milliseconds that the user last visited the Yazd 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 Yazd.



getUserAuthorization
public static Authorization getUserAuthorization(HttpServletRequest request, HttpServletResponse response, boolean checkYazdCookie)(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 Yazd authorization token. If one is found, it is returned as we assume that the user has logged in and is authorized.
  2. Check the Yazd authorization cookie for a username and password. If found, attempt to create a Yazd authorization token using that data. If successful, save the token to the session and return it. NOTE: This check can be skipped by setting checkYazdCookie 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:
  checkYazdCookie - 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 checkYazdCookieParameters:
  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.
See Also:   SkinUtils.getUserAuthorization(HttpServletRequestHttpServletResponseboolean)



invalidateCookie
public static void invalidateCookie(HttpServletRequest request, HttpServletResponse response, String cookieName)(Code)
Invalidate the specified cookie and delete it from the response object.
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:
  cookieName - The name of the cookie you want to delete.



isForumAdmin
public static boolean isForumAdmin(Authorization authToken)(Code)
Returns true if the user is a forum adminstrator of any forum in the system. For example, if there are 3 forums in the system and the user is an adminstrator of any one or more of them, this method will return true.

Use the method isForumAdmin( Authorization, Forum) to check an individual forum for administrator status.)
Parameters:
  authToken - the authentication token of the user true if the user is a forum administrator of any forum in the system.
See Also:   SkinUtils.isForumAdmin(AuthorizationForum)




isForumAdmin
public static boolean isForumAdmin(Authorization authToken, Forum forum)(Code)
Returns true if the user is a forum adminstrator of the given forum.
Parameters:
  authToken - the authentication token of the user
Parameters:
  forum - the forum to check administrator status on. true if the user is a forum administrator of the given forum.



isForumModerator
public static boolean isForumModerator(Authorization authToken)(Code)
Returns true if the user is a forum moderator of any forum in the system. For example, if there are 3 forums in the system and the user is a moderator of any one or more of them, this method will return true.

Use the method isForumModerator( Authorization, Forum) to check an individual forum for moderator status.)
Parameters:
  authToken - the authentication token of the user true if the user is a forum moderator of any forum in the system.
See Also:   SkinUtils.isForumModerator(AuthorizationForum)




isForumModerator
public static boolean isForumModerator(Authorization authToken, Forum forum)(Code)
Returns true if the user is a forum moderator of the given forum.
Parameters:
  authToken - the authentication token of the user
Parameters:
  forum - the forum to check moderator status on. true if the user is a forum moderator of the given forum.



isGroupAdmin
public static boolean isGroupAdmin(Authorization authToken)(Code)
Returns true if the user is a group administrator of any group in the system. For example, if there are 3 groups in the system and the user is an adminstrator of any one or more of them, this method will return true.

Use the method isGroupAdmin( Authorization, Group) to check an individual group for administrator status.)
See Also:   SkinUtils.isGroupAdmin(AuthorizationGroup)




isGroupAdmin
public static boolean isGroupAdmin(Authorization authToken, Group group)(Code)
Returns true if the user is a group administrator of the given group.
Parameters:
  authToken - the authentication token of the user
Parameters:
  group - the group to check administrator status on. true if the user is a group administrator of the given group.



isNewMessage
public static boolean isNewMessage(ForumMessage 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.



isSystemAdmin
public static boolean isSystemAdmin(Authorization authToken)(Code)
Returns true if the user is a system administrator.
Parameters:
  authToken - the authentication token of the user true if the user is a system administrator, false otherwise.



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.




remove
public static void remove(HttpServletRequest request, HttpServletResponse response, String id)(Code)
Removes a user stored value. Values are set using the store(...) methods.
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:
  id - the id or name of the stored value you wish to remove from persistence.



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.



retrieve
public static String retrieve(HttpServletRequest request, HttpServletResponse response, String id)(Code)
Retrieves a user stored value. Values are set using the store(...) methods.
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:
  id - The id or name of the stored value. The value of the specified id, otherwise null.



retrieve
public static String retrieve(HttpServletRequest request, HttpServletResponse response, String id, boolean remove)(Code)
Retrieves a user stored value. Values are set using the store(...) methods. If remove is true, the value is also removed from persistence.
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:
  id - The id or name of the stored value. The value of the specified id, otherwise null.



setUserAuthorization
public static Authorization setUserAuthorization(HttpServletRequest request, HttpServletResponse response, String username, String password, boolean autoLogin) throws UserNotFoundException, 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



store
public static void store(HttpServletRequest request, HttpServletResponse response, String id, String value)(Code)
Persists a value for the length of the user's session.
See Also:   SkinUtils.store(HttpServletRequestHttpServletResponseStringStringint)
See Also:    store



store
public static void store(HttpServletRequest request, HttpServletResponse response, String id, String value, int secsToLive)(Code)
Persists a value for the time (in seconds) specified
See Also:   SkinUtils.store(HttpServletRequestHttpServletResponseStringStringint)
See Also:    store



store
public static void store(HttpServletRequest request, HttpServletResponse response, String id, String value, int secsToLive, boolean restoreInSession)(Code)
This method should be used in a jsp skin to store an arbritary value. For example, we could persist the name of a user so that on a form page where they enter their name, that field could be auto-filled in with the stored value.

To indicate that the data should only be persisted for a session, pass in 0 as the timeToLive.
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:
  id - The name or identifier of the data you want to persist.
Parameters:
  value - The value you wish to store.
Parameters:
  secsToLive - The length (in seconds) this value will persist. Any value of 0 orless indicates this data should only persist for a session.




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.