Java Doc for JDBCUserDatabase.java in  » Wiki-Engine » JSPWiki » com » ecyrd » jspwiki » auth » user » 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 » Wiki Engine » JSPWiki » com.ecyrd.jspwiki.auth.user 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.ecyrd.jspwiki.auth.user.AbstractUserDatabase
      com.ecyrd.jspwiki.auth.user.JDBCUserDatabase

JDBCUserDatabase
public class JDBCUserDatabase extends AbstractUserDatabase (Code)

Implementation of UserDatabase that persists DefaultUserProfile objects to a JDBC DataSource, as might typically be provided by a web container. This implementation looks up the JDBC DataSource using JNDI. The JNDI name of the datasource, backing table and mapped columns used by this class are configured via settings in jspwiki.properties.

Configurable properties are these:

Property Default Definition
jspwiki.userdatabase.datasource jdbc/UserDatabase The JNDI name of the DataSource
jspwiki.userdatabase.table users The table that stores the user profiles
jspwiki.userdatabase.created created The column containing the profile's creation timestamp
jspwiki.userdatabase.email email The column containing the user's e-mail address
jspwiki.userdatabase.fullName full_name The column containing the user's full name
jspwiki.userdatabase.loginName login_name The column containing the user's login id
jspwiki.userdatabase.password password The column containing the user's password
jspwiki.userdatabase.modified modified The column containing the profile's last-modified timestamp
jspwiki.userdatabase.wikiName wiki_name The column containing the user's wiki name
jspwiki.userdatabase.roleTable roles The table that stores user roles. When a new user is created, a new record is inserted containing user's initial role. The table will have an ID column whose name and values correspond to the contents of the user table's login name column. It will also contain a role column (see next row).
jspwiki.userdatabase.role role The column in the role table that stores user roles. When a new user is created, this column will be populated with the value Authenticated. Once created, JDBCUserDatabase does not use this column again; it is provided strictly for the convenience of container-managed authentication services.
jspwiki.userdatabase.hashPrefix true Whether or not to prepend a prefix for the hash algorithm, e.g., {SHA}.

This class hashes passwords using SHA-1. All of the underying SQL commands used by this class are implemented using prepared statements, so it is immune to SQL injection attacks.

This class is typically used in conjunction with a web container's JNDI resource factory. For example, Tomcat versions 4 and higher provide a basic JNDI factory for registering DataSources. To give JSPWiki access to the JNDI resource named by , you would declare the datasource resource similar to this:

<Context ...>
  ...
  <Resource name="jdbc/UserDatabase" auth="Container"
    type="javax.sql.DataSource" username="dbusername" password="dbpassword"
    driverClassName="org.hsql.jdbcDriver" url="jdbc:HypersonicSQL:database"
    maxActive="8" maxIdle="4"/>
 ...
</Context>

JDBC driver JARs should be added to Tomcat's common/lib directory. For more Tomcat 5.5 JNDI configuration examples, see http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html.

JDBCUserDatabase commits changes as transactions if the back-end database supports them. If the database supports transactions, user profile changes are saved to permanent storage only when the JDBCUserDatabase.commit() method is called. If the database does not support transactions, then changes are made immediately (during the JDBCUserDatabase.save(UserProfile) method), and the method no-ops. Thus, callers should always call the method after saving a profile to guarantee that changes are applied.


author:
   Andrew R. Jaquith
since:
   2.3


Field Summary
final public static  StringDEFAULT_DB_CREATED
    
final public static  StringDEFAULT_DB_EMAIL
    
final public static  StringDEFAULT_DB_FULL_NAME
    
final public static  StringDEFAULT_DB_HASH_PREFIX
    
final public static  StringDEFAULT_DB_JNDI_NAME
    
final public static  StringDEFAULT_DB_LOGIN_NAME
    
final public static  StringDEFAULT_DB_MODIFIED
    
final public static  StringDEFAULT_DB_PASSWORD
    
final public static  StringDEFAULT_DB_ROLE
    
final public static  StringDEFAULT_DB_ROLE_TABLE
    
final public static  StringDEFAULT_DB_TABLE
    
final public static  StringDEFAULT_DB_WIKI_NAME
    
final public static  StringPROP_DB_CREATED
    
final public static  StringPROP_DB_DATASOURCE
    
final public static  StringPROP_DB_EMAIL
    
final public static  StringPROP_DB_FULL_NAME
    
final public static  StringPROP_DB_HASH_PREFIX
    
final public static  StringPROP_DB_LOGIN_NAME
    
final public static  StringPROP_DB_MODIFIED
    
final public static  StringPROP_DB_PASSWORD
    
final public static  StringPROP_DB_ROLE
    
final public static  StringPROP_DB_ROLE_TABLE
    
final public static  StringPROP_DB_TABLE
    
final public static  StringPROP_DB_WIKI_NAME
    


Method Summary
public  voiddeleteByLoginName(String loginName)
     Looks up and deletes the first UserProfile in the user database that matches a profile having a given login name.
public  UserProfilefindByEmail(String index)
    
public  UserProfilefindByFullName(String index)
    
public  UserProfilefindByLoginName(String index)
    
public  UserProfilefindByWikiName(String index)
    
public  Principal[]getWikiNames()
     Returns all WikiNames that are stored in the UserDatabase as an array of WikiPrincipal objects.
public  voidinitialize(WikiEngine engine, Properties props)
    
public  booleanisSharedWithContainer()
     Determines whether the user database shares user/password data with the web container; returns true if the JSPWiki property jspwiki.userdatabase.isSharedWithContainer is true.
public  voidrename(String loginName, String newName)
    
public  voidsave(UserProfile profile)
    

Field Detail
DEFAULT_DB_CREATED
final public static String DEFAULT_DB_CREATED(Code)



DEFAULT_DB_EMAIL
final public static String DEFAULT_DB_EMAIL(Code)



DEFAULT_DB_FULL_NAME
final public static String DEFAULT_DB_FULL_NAME(Code)



DEFAULT_DB_HASH_PREFIX
final public static String DEFAULT_DB_HASH_PREFIX(Code)



DEFAULT_DB_JNDI_NAME
final public static String DEFAULT_DB_JNDI_NAME(Code)



DEFAULT_DB_LOGIN_NAME
final public static String DEFAULT_DB_LOGIN_NAME(Code)



DEFAULT_DB_MODIFIED
final public static String DEFAULT_DB_MODIFIED(Code)



DEFAULT_DB_PASSWORD
final public static String DEFAULT_DB_PASSWORD(Code)



DEFAULT_DB_ROLE
final public static String DEFAULT_DB_ROLE(Code)



DEFAULT_DB_ROLE_TABLE
final public static String DEFAULT_DB_ROLE_TABLE(Code)



DEFAULT_DB_TABLE
final public static String DEFAULT_DB_TABLE(Code)



DEFAULT_DB_WIKI_NAME
final public static String DEFAULT_DB_WIKI_NAME(Code)



PROP_DB_CREATED
final public static String PROP_DB_CREATED(Code)



PROP_DB_DATASOURCE
final public static String PROP_DB_DATASOURCE(Code)



PROP_DB_EMAIL
final public static String PROP_DB_EMAIL(Code)



PROP_DB_FULL_NAME
final public static String PROP_DB_FULL_NAME(Code)



PROP_DB_HASH_PREFIX
final public static String PROP_DB_HASH_PREFIX(Code)



PROP_DB_LOGIN_NAME
final public static String PROP_DB_LOGIN_NAME(Code)



PROP_DB_MODIFIED
final public static String PROP_DB_MODIFIED(Code)



PROP_DB_PASSWORD
final public static String PROP_DB_PASSWORD(Code)



PROP_DB_ROLE
final public static String PROP_DB_ROLE(Code)



PROP_DB_ROLE_TABLE
final public static String PROP_DB_ROLE_TABLE(Code)



PROP_DB_TABLE
final public static String PROP_DB_TABLE(Code)



PROP_DB_WIKI_NAME
final public static String PROP_DB_WIKI_NAME(Code)





Method Detail
deleteByLoginName
public void deleteByLoginName(String loginName) throws NoSuchPrincipalException, WikiSecurityException(Code)
Looks up and deletes the first UserProfile in the user database that matches a profile having a given login name. If the user database does not contain a user with a matching attribute, throws a NoSuchPrincipalException . This method is intended to be atomic; results cannot be partially committed. If the commit fails, it should roll back its state appropriately. Implementing classes that persist to the file system may wish to make this method synchronized.
Parameters:
  loginName - the login name of the user profile that shall be deleted



findByEmail
public UserProfile findByEmail(String index) throws NoSuchPrincipalException(Code)

See Also:   com.ecyrd.jspwiki.auth.user.UserDatabase.findByEmail(java.lang.String)



findByFullName
public UserProfile findByFullName(String index) throws NoSuchPrincipalException(Code)

See Also:   com.ecyrd.jspwiki.auth.user.UserDatabase.findByFullName(java.lang.String)



findByLoginName
public UserProfile findByLoginName(String index) throws NoSuchPrincipalException(Code)

See Also:   com.ecyrd.jspwiki.auth.user.UserDatabase.findByLoginName(java.lang.String)



findByWikiName
public UserProfile findByWikiName(String index) throws NoSuchPrincipalException(Code)

See Also:   com.ecyrd.jspwiki.auth.user.UserDatabase.findByWikiName(String)



getWikiNames
public Principal[] getWikiNames() throws WikiSecurityException(Code)
Returns all WikiNames that are stored in the UserDatabase as an array of WikiPrincipal objects. If the database does not contain any profiles, this method will return a zero-length array. the WikiNames



initialize
public void initialize(WikiEngine engine, Properties props) throws NoRequiredPropertyException(Code)

See Also:   com.ecyrd.jspwiki.auth.user.UserDatabase.initialize(com.ecyrd.jspwiki.WikiEnginejava.util.Properties)



isSharedWithContainer
public boolean isSharedWithContainer()(Code)
Determines whether the user database shares user/password data with the web container; returns true if the JSPWiki property jspwiki.userdatabase.isSharedWithContainer is true.
See Also:   com.ecyrd.jspwiki.auth.user.UserDatabase.isSharedWithContainer



rename
public void rename(String loginName, String newName) throws NoSuchPrincipalException, DuplicateUserException, WikiSecurityException(Code)

See Also:   com.ecyrd.jspwiki.auth.user.UserDatabase.rename(StringString)



save
public void save(UserProfile profile) throws WikiSecurityException(Code)

See Also:   com.ecyrd.jspwiki.auth.user.UserDatabase.save(com.ecyrd.jspwiki.auth.user.UserProfile)



Fields inherited from com.ecyrd.jspwiki.auth.user.AbstractUserDatabase
final protected static String PROP_SHARED_WITH_CONTAINER(Code)(Java Doc)
final protected static String SHA_PREFIX(Code)(Java Doc)
final protected static Logger log(Code)(Java Doc)

Methods inherited from com.ecyrd.jspwiki.auth.user.AbstractUserDatabase
public synchronized void commit() throws WikiSecurityException(Code)(Java Doc)
public UserProfile find(String index) throws NoSuchPrincipalException(Code)(Java Doc)
abstract public UserProfile findByEmail(String index) throws NoSuchPrincipalException(Code)(Java Doc)
abstract public UserProfile findByFullName(String index) throws NoSuchPrincipalException(Code)(Java Doc)
abstract public UserProfile findByLoginName(String index) throws NoSuchPrincipalException(Code)(Java Doc)
abstract public UserProfile findByWikiName(String index) throws NoSuchPrincipalException(Code)(Java Doc)
protected String getHash(String text)(Code)(Java Doc)
public Principal[] getPrincipals(String identifier) throws NoSuchPrincipalException(Code)(Java Doc)
abstract public void initialize(WikiEngine engine, Properties props) throws NoRequiredPropertyException(Code)(Java Doc)
public UserProfile newProfile()(Code)(Java Doc)
abstract public void save(UserProfile profile) throws WikiSecurityException(Code)(Java Doc)
public boolean validatePassword(String loginName, String password)(Code)(Java Doc)

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.