User and Group Databases are now loaded like other Providers, using ClassUtil.getWikiProvider()
git-svn-id: https://svn.apache.org/repos/asf/jspwiki/branches/JSPWIKI_2_10_PICO_BRANCH@1688328 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/jspwiki-war/src/main/java/org/apache/wiki/auth/SecurityVerifier.java b/jspwiki-war/src/main/java/org/apache/wiki/auth/SecurityVerifier.java
index e71afe8..7fe11a5 100644
--- a/jspwiki-war/src/main/java/org/apache/wiki/auth/SecurityVerifier.java
+++ b/jspwiki-war/src/main/java/org/apache/wiki/auth/SecurityVerifier.java
@@ -504,7 +504,7 @@
{
db = m_engine.getGroupManager().getGroupDatabase();
}
- catch ( WikiSecurityException e )
+ catch ( WikiException e )
{
m_session.addMessage( ERROR_GROUPS, "Could not retrieve GroupManager: " + e.getMessage() );
}
diff --git a/jspwiki-war/src/main/java/org/apache/wiki/auth/UserManager.java b/jspwiki-war/src/main/java/org/apache/wiki/auth/UserManager.java
index 98d7f0e..1fa6677 100644
--- a/jspwiki-war/src/main/java/org/apache/wiki/auth/UserManager.java
+++ b/jspwiki-war/src/main/java/org/apache/wiki/auth/UserManager.java
@@ -154,19 +154,26 @@
try
{
- dbClassName = TextUtil.getRequiredProperty( m_engine.getWikiProperties(),
- PROP_DATABASE );
+ dbClassName = TextUtil.getRequiredProperty( m_engine.getWikiProperties(), PROP_DATABASE );
log.info("Attempting to load user database class "+dbClassName);
- Class<?> dbClass = ClassUtil.findClass( USERDATABASE_PACKAGE, dbClassName );
- m_database = (UserDatabase) dbClass.newInstance();
- m_database.initialize( m_engine, m_engine.getWikiProperties() );
+
+ m_database = ClassUtil.getWikiProvider(UserDatabase.class, m_engine, m_engine.getWikiProperties(), USERDATABASE_PACKAGE, dbClassName, new DummyUserDatabase(), true);
+
+// Class<?> dbClass = ClassUtil.findClass( USERDATABASE_PACKAGE, dbClassName );
+// m_database = (UserDatabase) dbClass.newInstance();
+// m_database.initialize( m_engine, m_engine.getWikiProperties() );
log.info("UserDatabase initialized.");
}
catch( NoRequiredPropertyException e )
{
log.error( "You have not set the '"+PROP_DATABASE+"'. You need to do this if you want to enable user management by JSPWiki." );
}
+ catch( WikiException e )
+ {
+ log.error( "Exception initializing user database: " + e.getMessage() );
+ }
+/*
catch( ClassNotFoundException e )
{
log.error( "UserDatabase class " + dbClassName + " cannot be found", e );
@@ -183,6 +190,7 @@
{
log.error( "Exception initializing user database: " + e.getMessage() );
}
+*/
finally
{
if( m_database == null )
diff --git a/jspwiki-war/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java b/jspwiki-war/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java
index e044f63..c279235 100644
--- a/jspwiki-war/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java
+++ b/jspwiki-war/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java
@@ -123,12 +123,12 @@
* it could not be initialized. In that case, this method throws
* a {@link org.apache.wiki.api.exceptions.WikiException}. The GroupDatabase
* is lazily initialized.
- * @throws org.apache.wiki.auth.WikiSecurityException if the GroupDatabase could
+ * @throws org.apache.wiki.auth.WikiException if the GroupDatabase could
* not be initialized
* @return the current GroupDatabase
* @since 2.3
*/
- public GroupDatabase getGroupDatabase() throws WikiSecurityException
+ public GroupDatabase getGroupDatabase() throws WikiException
{
if ( m_groupDatabase != null )
{
@@ -147,11 +147,14 @@
dbClassName = XMLGroupDatabase.class.getName();
}
log.info( "Attempting to load group database class " + dbClassName );
- Class<?> dbClass = ClassUtil.findClass( "org.apache.wiki.auth.authorize", dbClassName );
- m_groupDatabase = (GroupDatabase) dbClass.newInstance();
- m_groupDatabase.initialize( m_engine, m_engine.getWikiProperties() );
+ m_groupDatabase = ClassUtil.getWikiProvider(GroupDatabase.class, m_engine, m_engine.getWikiProperties(), "org.apache.wiki.auth.authorize", dbClassName, null, true);
+
+// Class<?> dbClass = ClassUtil.findClass( "org.apache.wiki.auth.authorize", dbClassName );
+// m_groupDatabase = (GroupDatabase) dbClass.newInstance();
+// m_groupDatabase.initialize( m_engine, m_engine.getWikiProperties() );
log.info( "Group database initialized." );
}
+/*
catch( ClassNotFoundException e )
{
log.error( "GroupDatabase class " + dbClassName + " cannot be found.", e );
@@ -170,13 +173,13 @@
dbInstantiationError = "Access GroupDatabase class " + dbClassName + " denied";
cause = e;
}
+*/
catch( NoRequiredPropertyException e )
{
log.error( "Missing property: " + e.getMessage() + "." );
dbInstantiationError = "Missing property: " + e.getMessage();
cause = e;
}
-
if( dbInstantiationError != null )
{
throw new WikiSecurityException( dbInstantiationError + " Cause: " + (cause != null ? cause.getMessage() : ""), cause );