Author: deepak
Date: Sun Mar 3 10:29:37 2019 New Revision: 1854684 URL: http://svn.apache.org/viewvc?rev=1854684&view=rev Log: Preparation for JDK11 update, Updated following code to fix warning with respect to JDK11 - Replaced Class::newInstance occurrences Modified: ofbiz/ofbiz-plugins/trunk/ldap/src/main/java/org/apache/ofbiz/ldap/LdapLoginWorker.java ofbiz/ofbiz-plugins/trunk/ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java Modified: ofbiz/ofbiz-plugins/trunk/ldap/src/main/java/org/apache/ofbiz/ldap/LdapLoginWorker.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/ldap/src/main/java/org/apache/ofbiz/ldap/LdapLoginWorker.java?rev=1854684&r1=1854683&r2=1854684&view=diff ============================================================================== --- ofbiz/ofbiz-plugins/trunk/ldap/src/main/java/org/apache/ofbiz/ldap/LdapLoginWorker.java (original) +++ ofbiz/ofbiz-plugins/trunk/ldap/src/main/java/org/apache/ofbiz/ldap/LdapLoginWorker.java Sun Mar 3 10:29:37 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/trunk/ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java?rev=1854684&r1=1854683&r2=1854684&view=diff ============================================================================== --- ofbiz/ofbiz-plugins/trunk/ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java (original) +++ ofbiz/ofbiz-plugins/trunk/ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java Sun Mar 3 10:29:37 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()); } } |
Free forum by Nabble | Edit this page |