[mapguide-commits] r9130 - in trunk/MgDev: Common/PlatformBase/Services Server/src/Services/Resource

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Sun Feb 5 18:58:45 PST 2017


Author: christinebao
Date: 2017-02-05 18:58:45 -0800 (Sun, 05 Feb 2017)
New Revision: 9130

Modified:
   trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.cpp
   trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.h
   trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.cpp
   trunk/MgDev/Server/src/Services/Resource/TagManager.cpp
Log:
Fix ticket: MapGuide feature source data add supporting for proxy
https://trac.osgeo.org/mapguide/ticket/2761

Add support for proxy resource data. 

Modified: trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.cpp	2017-01-26 09:21:53 UTC (rev 9129)
+++ trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.cpp	2017-02-06 02:58:45 UTC (rev 9130)
@@ -1,5 +1,5 @@
 //
-//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//  Copyright (C) 2017 by Autodesk, Inc.
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -69,6 +69,10 @@
 const STRING MgResourceTag::LoginPassword           = L"%MG_LOGIN_PASSWORD%";
 const STRING MgResourceTag::Username                = L"%MG_USERNAME%";
 const STRING MgResourceTag::Password                = L"%MG_PASSWORD%";
+const STRING MgResourceTag::ProxyServer             = L"%MG_PROXY_SERVER%";
+const STRING MgResourceTag::ProxyPort               = L"%MG_PROXY_PORT%";
+const STRING MgResourceTag::ProxyUsername           = L"%MG_PROXY_USERNAME%";
+const STRING MgResourceTag::ProxyPassword           = L"%MG_PROXY_PASSWORD%";
 const STRING MgResourceTag::DataFilePath            = L"%MG_DATA_FILE_PATH%";
 const STRING MgResourceTag::TileCachePath           = L"%MG_TILE_CACHE_PATH%";
 const STRING MgResourceTag::DataPathAliasBegin      = L"%MG_DATA_PATH_ALIAS[";
@@ -79,6 +83,9 @@
 /// Resource data names
 ///
 const STRING MgResourceDataName::UserCredentials    = L"MG_USER_CREDENTIALS";
+const STRING MgResourceDataName::ProxyServerName    = L"MG_PROXY_SERVER";
+const STRING MgResourceDataName::ProxyServerPort    = L"MG_PROXY_PORT";
+const STRING MgResourceDataName::ProxyCredentials   = L"MG_PROXY_CREDENTIALS";
 
 
 ///////////////////////////////////////////////////////////////////////////////

Modified: trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.h
===================================================================
--- trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.h	2017-01-26 09:21:53 UTC (rev 9129)
+++ trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.h	2017-02-06 02:58:45 UTC (rev 9130)
@@ -1,5 +1,5 @@
 //
-//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//  Copyright (C) 2017 by Autodesk, Inc.
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -366,7 +366,30 @@
     ///
     static const STRING Password;       ///\if INTERNAL value("%MG_PASSWORD%") \endif
 
+	////////////////////////////////////////////////////////////////
+	/// \brief
+	/// Replaced with the proxy server name.
+	///
+	static const STRING ProxyServer;       ///\if INTERNAL value("%MG_PROXY_SERVER%") \endif
 
+	////////////////////////////////////////////////////////////////
+	/// \brief
+	/// Replaced with the proxy server port.
+	///
+	static const STRING ProxyPort;       ///\if INTERNAL value("%MG_PROXY_PORT%") \endif
+
+	////////////////////////////////////////////////////////////////
+	/// \brief
+	/// Replaced with the proxy server user name.
+	///
+	static const STRING ProxyUsername;       ///\if INTERNAL value("%MG_PROXY_USERNAME%") \endif
+
+	////////////////////////////////////////////////////////////////
+	/// \brief
+	/// Replaced with the proxy server password.
+	///
+	static const STRING ProxyPassword;       ///\if INTERNAL value("%MG_PROXY_PASSWORD%") \endif
+
     ////////////////////////////////////////////////////////////////
     /// \brief
     /// Replaced with the location of data files associated with the
@@ -404,16 +427,49 @@
 class MG_PLATFORMBASE_API MgResourceDataName
 {
 PUBLISHED_API:
+	/////////////////////////////////////////////////////////////////
+	/// \brief
+	/// Data name for adding default credentials to a resource.
+	///
+	/// \note1
+	///
+	/// \remarks
+	/// For an example, see \link MgResourceService::SetResourceData SetResourceData \endlink.
+	///
+	static const STRING UserCredentials;    ///\if INTERNAL value("MG_USER_CREDENTIALS") \endif
+
     /////////////////////////////////////////////////////////////////
     /// \brief
-    /// Data name for adding default credentials to a resource.
+    /// Data name for adding proxy server name to a resource.
     ///
     /// \note1
     ///
     /// \remarks
     /// For an example, see \link MgResourceService::SetResourceData SetResourceData \endlink.
     ///
-    static const STRING UserCredentials;    ///\if INTERNAL value("MG_USER_CREDENTIALS") \endif
+    static const STRING ProxyServerName;    ///\if INTERNAL value("MG_PROXY_SERVER") \endif
+
+    /////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Data name for adding proxy server port to a resource.
+    ///
+    /// \note1
+    ///
+    /// \remarks
+    /// For an example, see \link MgResourceService::SetResourceData SetResourceData \endlink.
+    ///
+	static const STRING ProxyServerPort;    ///\if INTERNAL value("MG_PROXY_PORT") \endif
+
+    /////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Data name for adding proxy credentials to a resource.
+    ///
+    /// \note1
+    ///
+    /// \remarks
+    /// For an example, see \link MgResourceService::SetResourceData SetResourceData \endlink.
+    ///
+	static const STRING ProxyCredentials;    ///\if INTERNAL value("MG_PROXY_CREDENTIALS") \endif
 };
 
 

Modified: trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.cpp	2017-01-26 09:21:53 UTC (rev 9129)
+++ trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.cpp	2017-02-06 02:58:45 UTC (rev 9130)
@@ -1,5 +1,5 @@
 //
-//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//  Copyright (C) 2017 by Autodesk, Inc.
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -945,7 +945,7 @@
     {
         dataValue = data->ToString();
 
-        if (MgResourceDataName::UserCredentials == dataName)
+        if (MgResourceDataName::UserCredentials == dataName || MgResourceDataName::ProxyCredentials == dataName)
         {
             MgCryptographyManager cryptoManager;
 
@@ -1221,7 +1221,7 @@
     {
         string data;
 
-        if (MgResourceDataName::UserCredentials == dataName)
+        if (MgResourceDataName::UserCredentials == dataName || MgResourceDataName::ProxyCredentials == dataName)
         {
             // For security purpose, only the decrypted username
             // (no decrypted password) is returned.

Modified: trunk/MgDev/Server/src/Services/Resource/TagManager.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Resource/TagManager.cpp	2017-01-26 09:21:53 UTC (rev 9129)
+++ trunk/MgDev/Server/src/Services/Resource/TagManager.cpp	2017-02-06 02:58:45 UTC (rev 9130)
@@ -1,5 +1,5 @@
 //
-//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//  Copyright (C) 2017 by Autodesk, Inc.
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -175,9 +175,9 @@
     }
 
     if ((MgResourceDataType::String != type
-            && MgResourceDataName::UserCredentials == name)
+            && ((MgResourceDataName::UserCredentials == name) || (MgResourceDataName::ProxyServerName == name) || (MgResourceDataName::ProxyServerPort == name) || (MgResourceDataName::ProxyCredentials == name)))
         || (MgResourceDataType::String == type
-                && MgResourceDataName::UserCredentials != name))
+                && ((MgResourceDataName::UserCredentials != name) && (MgResourceDataName::ProxyServerName != name) && (MgResourceDataName::ProxyServerPort != name) && (MgResourceDataName::ProxyCredentials != name))))
     {
         throw new MgInvalidResourceDataTypeException(
             L"MgTagManager.ValidateTag", __LINE__, __WFILE__, NULL, L"", NULL);
@@ -323,6 +323,46 @@
         MG_CRYPTOGRAPHY_CATCH_AND_THROW(L"MgTagManager.SubstituteTags")
     }
 
+	if (GetTag(MgResourceDataName::ProxyServerName, tagInfo, false))
+	{
+		CREFSTRING proxyServer = tagInfo.GetAttribute(MgTagInfo::TokenValue);
+		count += MgUtil::ReplaceString(
+            MgUtil::WideCharToMultiByte(MgResourceTag::ProxyServer),
+			MgUtil::WideCharToMultiByte(proxyServer),
+            doc, -1);
+	}
+
+    if (GetTag(MgResourceDataName::ProxyServerPort, tagInfo, false))
+    {
+        CREFSTRING proxyPort = tagInfo.GetAttribute(MgTagInfo::TokenValue);
+        count += MgUtil::ReplaceString(
+            MgUtil::WideCharToMultiByte(MgResourceTag::ProxyPort),
+            MgUtil::WideCharToMultiByte(proxyPort),
+            doc, -1);
+    }
+
+    if (GetTag(MgResourceDataName::ProxyCredentials, tagInfo, false))
+    {
+        MG_CRYPTOGRAPHY_TRY()
+
+            MgCryptographyUtil cryptoUtil;
+        string proxyUsername, proxyPassword;
+
+        cryptoUtil.DecryptCredentials(MgUtil::WideCharToMultiByte(
+            tagInfo.GetAttribute(MgTagInfo::TokenValue)), proxyUsername, proxyPassword);
+
+        count += MgUtil::ReplaceString(
+            MgUtil::WideCharToMultiByte(MgResourceTag::ProxyUsername),
+            proxyUsername,
+            doc, -1);
+        count += MgUtil::ReplaceString(
+            MgUtil::WideCharToMultiByte(MgResourceTag::ProxyPassword),
+            proxyPassword,
+            doc, -1);
+
+        MG_CRYPTOGRAPHY_CATCH_AND_THROW(L"MgTagManager.SubstituteTags")
+    }
+
     count += MgUtil::ReplaceString(
         MgUtil::WideCharToMultiByte(MgResourceTag::LoginUsername),
         MgUtil::WideCharToMultiByte(dataBindingInfo.GetLoginUsername()),



More information about the mapguide-commits mailing list