svn commit: r1854690 - in /ofbiz/ofbiz-plugins/branches/release18.12: ./ ldap/src/main/java/org/apache/ofbiz/ldap/LdapLoginWorker.java ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1854690 - in /ofbiz/ofbiz-plugins/branches/release18.12: ./ ldap/src/main/java/org/apache/ofbiz/ldap/LdapLoginWorker.java ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java

Deepak Dixit-5
Author: deepak
Date: Sun Mar  3 10:46:27 2019
New Revision: 1854690

URL: http://svn.apache.org/viewvc?rev=1854690&view=rev
Log:
Applied fix from trunk for revision: 1854684
===

Preparation for JDK11 update, Updated following code to fix warning with respect to JDK11
- Replaced Class::newInstance occurrences
(OFBIZ-10757)

Modified:
    ofbiz/ofbiz-plugins/branches/release18.12/   (props changed)
    ofbiz/ofbiz-plugins/branches/release18.12/ldap/src/main/java/org/apache/ofbiz/ldap/LdapLoginWorker.java
    ofbiz/ofbiz-plugins/branches/release18.12/ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java

Propchange: ofbiz/ofbiz-plugins/branches/release18.12/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Mar  3 10:46:27 2019
@@ -10,4 +10,4 @@
 /ofbiz/branches/json-integration-refactoring/plugins:1634077-1635900
 /ofbiz/branches/multitenant20100310/plugins:921280-927264
 /ofbiz/branches/release13.07/plugins:1547657
-/ofbiz/ofbiz-plugins/trunk:1851002,1851009,1851068,1851135,1851139-1851140,1851185,1851316,1851885,1852988
+/ofbiz/ofbiz-plugins/trunk:1851002,1851009,1851068,1851135,1851139-1851140,1851185,1851316,1851885,1852988,1854684

Modified: ofbiz/ofbiz-plugins/branches/release18.12/ldap/src/main/java/org/apache/ofbiz/ldap/LdapLoginWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/branches/release18.12/ldap/src/main/java/org/apache/ofbiz/ldap/LdapLoginWorker.java?rev=1854690&r1=1854689&r2=1854690&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/branches/release18.12/ldap/src/main/java/org/apache/ofbiz/ldap/LdapLoginWorker.java (original)
+++ ofbiz/ofbiz-plugins/branches/release18.12/ldap/src/main/java/org/apache/ofbiz/ldap/LdapLoginWorker.java Sun Mar  3 10:46:27 2019
@@ -73,23 +73,8 @@ public class LdapLoginWorker extends Log
                 String className = UtilXml.childElementValue(rootElement, "AuthenticationHandler", "org.apache.ofbiz.ldap.openldap.OFBizLdapAuthenticationHandler");
                 try {
                     Class<?> handlerClass = Class.forName(className);
-                    InterfaceOFBizAuthenticationHandler authenticationHandler = (InterfaceOFBizAuthenticationHandler) handlerClass.newInstance();
+                    InterfaceOFBizAuthenticationHandler authenticationHandler = (InterfaceOFBizAuthenticationHandler) handlerClass.getDeclaredConstructor().newInstance();
                     hasLdapLoggedOut = authenticationHandler.hasLdapLoggedOut(request, response, rootElement);
-                } catch (ClassNotFoundException e) {
-                    Debug.logError(e, "Error calling checkLogin service", module);
-                    Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
-                    String errMsg = UtilProperties.getMessage(resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request));
-                    request.setAttribute("_ERROR_MESSAGE_", errMsg);
-                } catch (InstantiationException e) {
-                    Debug.logError(e, "Error calling checkLogin service", module);
-                    Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
-                    String errMsg = UtilProperties.getMessage(resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request));
-                    request.setAttribute("_ERROR_MESSAGE_", errMsg);
-                } catch (IllegalAccessException e) {
-                    Debug.logError(e, "Error calling checkLogin service", module);
-                    Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
-                    String errMsg = UtilProperties.getMessage(resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request));
-                    request.setAttribute("_ERROR_MESSAGE_", errMsg);
                 } catch (Exception e) {
                     Debug.logError(e, "Error calling checkLogin service", module);
                     Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
@@ -128,28 +113,8 @@ public class LdapLoginWorker extends Log
             String className = UtilXml.childElementValue(rootElement, "AuthenticationHandler", "org.apache.ofbiz.ldap.openldap.OFBizLdapAuthenticationHandler");
             try {
                 Class<?> handlerClass = Class.forName(className);
-                InterfaceOFBizAuthenticationHandler authenticationHandler = (InterfaceOFBizAuthenticationHandler) handlerClass.newInstance();
+                InterfaceOFBizAuthenticationHandler authenticationHandler = (InterfaceOFBizAuthenticationHandler) handlerClass.getDeclaredConstructor().newInstance();
                 result = authenticationHandler.login(request, response, rootElement);
-            } catch (ClassNotFoundException e) {
-                Debug.logError(e, "Error calling userLogin service", module);
-                Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
-                String errMsg = UtilProperties.getMessage(resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request));
-                request.setAttribute("_ERROR_MESSAGE_", errMsg);
-            } catch (InstantiationException e) {
-                Debug.logError(e, "Error calling userLogin service", module);
-                Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
-                String errMsg = UtilProperties.getMessage(resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request));
-                request.setAttribute("_ERROR_MESSAGE_", errMsg);
-            } catch (IllegalAccessException e) {
-                Debug.logError(e, "Error calling userLogin service", module);
-                Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
-                String errMsg = UtilProperties.getMessage(resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request));
-                request.setAttribute("_ERROR_MESSAGE_", errMsg);
-            } catch (NamingException e) {
-                Debug.logError(e, "Error calling userLogin service", module);
-                Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
-                String errMsg = UtilProperties.getMessage(resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request));
-                request.setAttribute("_ERROR_MESSAGE_", errMsg);
             } catch (Exception e) {
                 Debug.logError(e, "Error calling userLogin service", module);
                 Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
@@ -192,23 +157,8 @@ public class LdapLoginWorker extends Log
             String className = UtilXml.childElementValue(rootElement, "AuthenticationHandler", "org.apache.ofbiz.ldap.openldap.OFBizLdapAuthenticationHandler");
             try {
                 Class<?> handlerClass = Class.forName(className);
-                InterfaceOFBizAuthenticationHandler authenticationHandler = (InterfaceOFBizAuthenticationHandler) handlerClass.newInstance();
+                InterfaceOFBizAuthenticationHandler authenticationHandler = (InterfaceOFBizAuthenticationHandler) handlerClass.getDeclaredConstructor().newInstance();
                 result = authenticationHandler.logout(request, response, rootElement);
-            } catch (ClassNotFoundException e) {
-                Debug.logError(e, "Error calling userLogin service", module);
-                Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
-                String errMsg = UtilProperties.getMessage(resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request));
-                request.setAttribute("_ERROR_MESSAGE_", errMsg);
-            } catch (InstantiationException e) {
-                Debug.logError(e, "Error calling userLogin service", module);
-                Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
-                String errMsg = UtilProperties.getMessage(resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request));
-                request.setAttribute("_ERROR_MESSAGE_", errMsg);
-            } catch (IllegalAccessException e) {
-                Debug.logError(e, "Error calling userLogin service", module);
-                Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
-                String errMsg = UtilProperties.getMessage(resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request));
-                request.setAttribute("_ERROR_MESSAGE_", errMsg);
             } catch (Exception e) {
                 Debug.logError(e, "Error calling userLogin service", module);
                 Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());

Modified: ofbiz/ofbiz-plugins/branches/release18.12/ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/branches/release18.12/ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java?rev=1854690&r1=1854689&r2=1854690&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/branches/release18.12/ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java (original)
+++ ofbiz/ofbiz-plugins/branches/release18.12/ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java Sun Mar  3 10:46:27 2019
@@ -163,13 +163,9 @@ public final class OFBizCasAuthenticatio
         String className = UtilXml.childElementValue(rootElement, "CasLdapHandler", "org.apache.ofbiz.ldap.openldap.OFBizLdapAuthenticationHandler");
         try {
             Class<?> handlerClass = Class.forName(className);
-            InterfaceOFBizAuthenticationHandler casLdapHandler = (InterfaceOFBizAuthenticationHandler) handlerClass.newInstance();
+            InterfaceOFBizAuthenticationHandler casLdapHandler = (InterfaceOFBizAuthenticationHandler) handlerClass.getDeclaredConstructor().newInstance();
             return casLdapHandler.getLdapSearchResult(username, password, rootElement, bindRequired);
-        } catch (ClassNotFoundException e) {
-            throw new NamingException(e.getLocalizedMessage());
-        } catch (InstantiationException e) {
-            throw new NamingException(e.getLocalizedMessage());
-        } catch (IllegalAccessException e) {
+        } catch (ReflectiveOperationException e) {
             throw new NamingException(e.getLocalizedMessage());
         }
     }