details:   /erp/devel/pi/rev/3bf5295a7f03
changeset: 12524:3bf5295a7f03
user:      Stefan Hühner <stefan.huehner <at> openbravo.com>
date:      Fri May 27 17:45:12 2011 +0200
summary:   Fixed 16775: Improve error handling if defined 
authentication.manager is missing
In case the defined authentication.manager can't be loaded log an error message
and use the default one instead of crashing with ClassNotFoundException.
Also improve error message in that case pointing to config option in config file

diffstat:

 src/index.jsp                                              |  12 ++++++++++--
 src/org/openbravo/base/secureApp/HttpSecureAppServlet.java |   6 ++----
 2 files changed, 12 insertions(+), 6 deletions(-)

diffs (59 lines):

diff -r b1d467810763 -r 3bf5295a7f03 src/index.jsp
--- a/src/index.jsp     Fri May 27 14:48:16 2011 +0200
+++ b/src/index.jsp     Fri May 27 17:45:12 2011 +0200
@@ -3,6 +3,7 @@
 <%@ page import="org.openbravo.base.util.OBClassLoader" %>
 <%@ page import="org.openbravo.base.session.OBPropertiesProvider" %>
 <%@ page import="org.openbravo.authentication.AuthenticationManager" %>
+<%@ page import="org.apache.log4j.Logger" %>
 <%@ page contentType="text/html; charset=UTF-8" %>
 <%
 /*
@@ -23,7 +24,8 @@
  * Contributor(s):  ______________________________________.
  ************************************************************************
  */
- 
+
+Logger log = 
Logger.getLogger(org.openbravo.authentication.AuthenticationManager.class); 
 Properties obProperties = 
OBPropertiesProvider.getInstance().getOpenbravoProperties();
 String authClass = obProperties.getProperty("authentication.class");
 
@@ -31,7 +33,13 @@
   authClass = 
"org.openbravo.authentication.basic.DefaultAuthenticationManager";
 }
 
-AuthenticationManager authManager = (AuthenticationManager) 
OBClassLoader.getInstance().loadClass(authClass).newInstance();
+AuthenticationManager authManager = null;
+try {
+  authManager = (AuthenticationManager) 
OBClassLoader.getInstance().loadClass(authClass).newInstance();
+} catch (ClassNotFoundException cnfe) {
+  log.error("Defined authentication manager cannot be loaded. Verify the 
'authentication.class' entry in Openbravo.properties");
+  authManager = new 
org.openbravo.authentication.basic.DefaultAuthenticationManager();
+}
 
 HttpBaseServlet s = new HttpBaseServlet(); // required for ConnectionProvider
 s.init(getServletConfig());
diff -r b1d467810763 -r 3bf5295a7f03 
src/org/openbravo/base/secureApp/HttpSecureAppServlet.java
--- a/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java        Fri May 
27 14:48:16 2011 +0200
+++ b/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java        Fri May 
27 17:45:12 2011 +0200
@@ -129,9 +129,6 @@
   public void init(ServletConfig config) {
     super.init(config);
 
-    // Authentication manager load
-    // String sAuthManagerClass =
-    // config.getServletContext().getInitParameter("AuthenticationManager");
     String sAuthManagerClass = 
globalParameters.getOBProperty("authentication.class");
     if (sAuthManagerClass == null || sAuthManagerClass.equals("")) {
       // If not defined, load default
@@ -141,7 +138,8 @@
     try {
       m_AuthManager = (AuthenticationManager) 
Class.forName(sAuthManagerClass).newInstance();
     } catch (final Exception e) {
-      log4j.error("Authentication manager not defined", e);
+      log4j
+          .error("Defined authentication manager cannot be loaded. Verify the 
'authentication.class' entry in Openbravo.properties");
       m_AuthManager = new DefaultAuthenticationManager();
     }
 

------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery, 
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now. 
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to