浏览代码

FIXED: #82248 - VerifyUser method is needed by ECL IDE

Add VerifyUser method to ws_account.

Signed-off-by: Kevin Wang <kevin.wang@lexisnexis.com>
Kevin Wang 14 年之前
父节点
当前提交
2bdf37ebd2

+ 1 - 0
esp/scm/additional.cmake

@@ -29,6 +29,7 @@ GET_TARGET_PROPERTY(ESDL_EXE esdl LOCATION)
 set ( ESPSCM_SRCS 
       ws_config.ecm
       ws_fileio.ecm
+      ws_account.ecm
       ##### LIST FOR ESPECL
       WsDeploy.ecm
     )

+ 38 - 0
esp/scm/ws_account.ecm

@@ -0,0 +1,38 @@
+/*##############################################################################
+
+    Copyright (C) <2010>  <LexisNexis Risk Data Management Inc.>
+
+    All rights reserved. This program is NOT PRESENTLY free software: you can NOT redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as
+    published by the Free Software Foundation, either version 3 of the
+    License, or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Affero General Public License for more details.
+
+    You should have received a copy of the GNU Affero General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+############################################################################## */
+
+ESPrequest VerifyUserRequest
+{
+	string application;
+	string version;
+};
+
+ESPresponse [exceptions_inline] VerifyUserResponse
+{
+	int retcode;
+};
+
+ESPservice [exceptions_inline("./smc_xslt/exceptions.xslt")] ws_account
+{
+	ESPmethod VerifyUser(VerifyUserRequest, VerifyUserResponse);
+};
+
+
+SCMexportdef(ws_account);
+
+SCMapi(ws_account) IClientws_account *createws_accountClient();

+ 1 - 0
esp/services/ws_account/CMakeLists.txt

@@ -28,6 +28,7 @@ project( ws_account )
 include(${HPCC_SOURCE_DIR}/esp/scm/additional.cmake)
 
 set (    SRCS 
+         ${ESPSCM_GENERATED_DIR}/ws_account_esp.cpp
          ws_accountPlugin.cpp 
          ws_accountService.cpp 
     )

+ 14 - 14
esp/services/ws_account/ws_accountPlugin.cpp

@@ -33,26 +33,26 @@ extern "C"
 // Change the function names when we stick with dynamic loading.
 ESP_FACTORY IEspService * esp_service_factory(const char *name, const char* type, IPropertyTree *cfg, const char *process)
 {
-   if (strcmp(type, "ws_account")==0)
-   {
-      Cws_account* service = new Cws_account;
+    if (strcmp(type, "ws_account")==0)
+    {
+        Cws_accountEx* service = new Cws_accountEx;
         service->init(cfg, process, name);
-      return service;
-   }
-   return NULL;
+        return service;
+    }
+    return NULL;
 }
- 
-   
+
+
 
 ESP_FACTORY IEspRpcBinding * esp_binding_factory(const char *name, const char* type, IPropertyTree *cfg, const char *process)
 {
-   if (strcmp(type, "ws_accountSoapBinding")==0)
-   {
-        Cws_accountSoapBinding* binding = new Cws_accountSoapBinding(cfg, name, process);
-      return binding;
-   }
+    if (strcmp(type, "ws_accountSoapBinding")==0)
+    {
+        Cws_accountSoapBindingEx* binding = new Cws_accountSoapBindingEx(cfg, name, process);
+        return binding;
+    }
 
-   return NULL;
+    return NULL;
 }
 
 

+ 66 - 2
esp/services/ws_account/ws_accountService.cpp

@@ -16,7 +16,71 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ############################################################################## */
 
-#pragma warning (disable : 4786)
-
 #include "ws_accountService.hpp"
+#include "exception_util.hpp"
+
+const int CUTOFF_MAJOR = 533;
+const int CUTOFF_MINOR = 6;
+
+bool Cws_accountEx::onVerifyUser(IEspContext &context, IEspVerifyUserRequest &req, IEspVerifyUserResponse &resp)
+{
+    try
+    {
+        ISecUser* usr = context.queryUser();
+        if(!usr || !usr->isAuthenticated())
+        {
+            resp.setRetcode(-1);
+            return false;
+        }
+
+        const char* ver = req.getVersion();
+        if (!ver || !*ver)
+        {
+            throw MakeStringException(ECLWATCH_OLD_CLIENT_VERSION, "Client version not found");
+        }
+
+        int minor = 0;
+        int major = 0;
+        const char* dot1 = strrchr(ver, '.');
+        if (!dot1)
+            minor = atoi(ver);
+        else if (strlen(dot1) > 1)
+        {
+            minor = atoi(dot1 + 1);
+            if(dot1 > ver)
+            {
+                const char* dot2 = dot1 - 1;
+
+                while(dot2 > ver && *dot2 != '.')
+                    dot2--;
+                if(*dot2 == '.')
+                    dot2++;
+                if(dot2 < dot1)
+                {
+                    StringBuffer majorstr;
+                    majorstr.append(dot1 - dot2, dot2);
+                    major = atoi(majorstr.str());
+                }
+            }
+        }
+
+        if(major > CUTOFF_MAJOR || (major == CUTOFF_MAJOR && minor >= CUTOFF_MINOR))
+        {
+            resp.setRetcode(0);
+            return true;
+        }
+
+        const char* build_ver = getBuildVersion();
+        if (build_ver && *build_ver)
+            throw MakeStringException(ECLWATCH_OLD_CLIENT_VERSION, "Client version %s (server %s) is out of date.", ver, build_ver);
+        else
+            throw MakeStringException(ECLWATCH_OLD_CLIENT_VERSION, "Client version %s is out of date.", ver);
+    }
+    catch(IException* e)
+    {
+        FORWARDEXCEPTION(e, ECLWATCH_INTERNAL_ERROR);
+    }
+
+    return true;
+}
 

+ 7 - 45
esp/services/ws_account/ws_accountService.hpp

@@ -19,28 +19,14 @@
 #ifndef _ESPWIZ_ws_account_HPP__
 #define _ESPWIZ_ws_account_HPP__
 
-#pragma warning( disable : 4786)
+#include "ws_account_esp.ipp"
 
-//JLib
-#include "jliball.hpp"
-
-//SCM Interfaces
-#include "esp.hpp"
-#include "soapesp.hpp"
-
-//ESP Bindings
-#include "SOAP/Platform/soapmessage.hpp"
-#include "SOAP/Platform/soapmacro.hpp"
-#include "SOAP/Platform/soapservice.hpp"
-#include "SOAP/Platform/soapparam.hpp"
-#include "SOAP/client/soapclient.hpp"
-
-class Cws_accountSoapBinding : public CHttpSoapBinding
+class Cws_accountSoapBindingEx : public Cws_accountSoapBinding
 {
-    StringBuffer m_authType, m_portalURL;
-    Owned<IXslProcessor> xslp;
+    StringBuffer m_portalURL;
+
 public:
-    Cws_accountSoapBinding(IPropertyTree *cfg, const char *name, const char *process, http_soap_log_level llevel=hsl_none) : CHttpSoapBinding(cfg, name, process, llevel)
+    Cws_accountSoapBindingEx(IPropertyTree *cfg, const char *name, const char *process, http_soap_log_level llevel=hsl_none) : Cws_accountSoapBinding(cfg, name, process, llevel)
     {
         StringBuffer xpath;
         xpath.appendf("Software/EspProcess[@name='%s']/@portalurl", process);
@@ -67,38 +53,14 @@ public:
             ensureNavLink(*folder, "Relogin", path.str(), "Relogin");
         ensureNavLink(*folder, "Who Am I", path.str(), "WhoAmI");
     }
-
-    int getQualifiedNames(IEspContext& ctx, MethodInfoArray & methods)
-    {
-        return methods.ordinality();
-    }
-    void setXslProcessor(IInterface *xslp_){xslp.set(dynamic_cast<IXslProcessor *>(xslp_));}
 };
 
-
-class Cws_account : public CInterface,
-    implements IEspService
+class Cws_accountEx : public Cws_account
 {
-private:
-    IEspContainer* m_container;
-
 public:
     IMPLEMENT_IINTERFACE;
 
-    virtual void init(IPropertyTree *cfg, const char *process, const char *service) {};
-    virtual bool init(const char * service, const char * type, IPropertyTree * cfg, const char * process)
-    {
-        return true;
-    }
-    virtual void setContainer(IEspContainer *c)
-    {
-        m_container = c;
-    }
-    virtual IEspContainer *queryContainer()
-    {
-        return m_container;
-    }
-    virtual const char* getServiceType(){return "ws_account";}
+    virtual bool onVerifyUser(IEspContext &context, IEspVerifyUserRequest &req, IEspVerifyUserResponse &resp);
 };
 
 #endif //_ESPWIZ_ws_account_HPP__