public static String login(HttpServletRequest request,HttpServletResponse response){
  Element rootElement=getRootElement(request);
  String result="error";
  if (rootElement != null) {
    String className=UtilXml.childElementValue(rootElement,"AuthenticationHandler","org.ofbiz.ldap.openldap.OFBizLdapAuthenticationHandler");
    try {
      Class<?> handlerClass=Class.forName(className);
      InterfaceOFBizAuthenticationHandler authenticationHandler=(InterfaceOFBizAuthenticationHandler)handlerClass.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());
      String errMsg=UtilProperties.getMessage(resourceWebapp,"loginevents.following_error_occurred_during_login",messageMap,UtilHttp.getLocale(request));
      request.setAttribute("_ERROR_MESSAGE_",errMsg);
    }
  }
  if (result.equals("error")) {
    boolean useOFBizLoginWhenFail=Boolean.getBoolean(UtilXml.childElementValue(rootElement,"UseOFBizLoginWhenLDAPFail","false"));
    if (useOFBizLoginWhenFail) {
      return LoginWorker.login(request,response);
    }
  }
  return result;
}

public static String login ( HttpServletRequest request , HttpServletResponse response ) { Element rootElement = getRootElement ( request ) ; String result = "error" ; if ( rootElement != null ) { String className = UtilXml . childElementValue ( rootElement , "AuthenticationHandler" , "org.ofbiz.ldap.openldap.OFBizLdapAuthenticationHandler" ) ; try { Class < ? > handlerClass = Class . forName ( className ) ; InterfaceOFBizAuthenticationHandler authenticationHandler = ( InterfaceOFBizAuthenticationHandler ) handlerClass . 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 ( ) ) ; String errMsg = UtilProperties . getMessage ( resourceWebapp , "loginevents.following_error_occurred_during_login" , messageMap , UtilHttp . getLocale ( request ) ) ; request . setAttribute ( "_ERROR_MESSAGE_" , errMsg ) ; } } if ( result . equals ( "error" ) ) { boolean useOFBizLoginWhenFail = Boolean . getBoolean ( UtilXml . childElementValue ( rootElement , "UseOFBizLoginWhenLDAPFail" , "false" ) ) ; if ( useOFBizLoginWhenFail ) { return LoginWorker . login ( request , response ) ; } } return result ; }
an http webevent handler that logs in a userlogin . this should run before the security check .
