[mapguide-commits] r6893 - in branches/maestro-4.0.x: Maestro.Base/UI OSGeo.MapGuide.MaestroAPI/Properties OSGeo.MapGuide.MaestroAPI/Resource/Validation

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Jul 11 07:46:39 PDT 2012


Author: jng
Date: 2012-07-11 07:46:38 -0700 (Wed, 11 Jul 2012)
New Revision: 6893

Modified:
   branches/maestro-4.0.x/Maestro.Base/UI/ValidationResultsDialog.cs
   branches/maestro-4.0.x/Maestro.Base/UI/ValidationResultsDialog.designer.cs
   branches/maestro-4.0.x/Maestro.Base/UI/ValidationResultsDialog.resx
   branches/maestro-4.0.x/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs
   branches/maestro-4.0.x/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx
   branches/maestro-4.0.x/OSGeo.MapGuide.MaestroAPI/Resource/Validation/FeatureSourceValidator.cs
   branches/maestro-4.0.x/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ValidationStatusCode.cs
Log:
#2070: Backport to 4.0.x

Modified: branches/maestro-4.0.x/Maestro.Base/UI/ValidationResultsDialog.cs
===================================================================
--- branches/maestro-4.0.x/Maestro.Base/UI/ValidationResultsDialog.cs	2012-07-11 14:39:57 UTC (rev 6892)
+++ branches/maestro-4.0.x/Maestro.Base/UI/ValidationResultsDialog.cs	2012-07-11 14:46:38 UTC (rev 6893)
@@ -75,6 +75,7 @@
                             break;
                     }
                     lvi.SubItems.Add(issue.Message);
+                    lvi.SubItems.Add(issue.StatusCode.ToString());
                     listView1.Items.Add(lvi);
                 }
             }
@@ -105,7 +106,7 @@
                                 sw.WriteLine(new string('*', 80));
                                 sw.WriteLine(string.Format(Properties.Resources.ValidationProgressMessage, p.Key));
                                 foreach (ValidationIssue i in p.Value)
-                                    sw.WriteLine(string.Format(Properties.Resources.ValidationResultFormat, i.Status, i.Resource, i.Message));
+                                    sw.WriteLine(string.Format(Properties.Resources.ValidationResultFormat, i.Status, i.StatusCode, i.Message));
 
                                 sw.WriteLine();
                             }

Modified: branches/maestro-4.0.x/Maestro.Base/UI/ValidationResultsDialog.designer.cs
===================================================================
--- branches/maestro-4.0.x/Maestro.Base/UI/ValidationResultsDialog.designer.cs	2012-07-11 14:39:57 UTC (rev 6892)
+++ branches/maestro-4.0.x/Maestro.Base/UI/ValidationResultsDialog.designer.cs	2012-07-11 14:46:38 UTC (rev 6893)
@@ -38,6 +38,7 @@
             this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
             this.imageList1 = new System.Windows.Forms.ImageList(this.components);
             this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
+            this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
             this.panel1.SuspendLayout();
             this.SuspendLayout();
             // 
@@ -67,7 +68,8 @@
             // 
             this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
             this.columnHeader1,
-            this.columnHeader2});
+            this.columnHeader2,
+            this.columnHeader3});
             resources.ApplyResources(this.listView1, "listView1");
             this.listView1.GridLines = true;
             this.listView1.Name = "listView1";
@@ -96,6 +98,10 @@
             this.saveFileDialog.DefaultExt = "txt";
             resources.ApplyResources(this.saveFileDialog, "saveFileDialog");
             // 
+            // columnHeader3
+            // 
+            resources.ApplyResources(this.columnHeader3, "columnHeader3");
+            // 
             // ValidationResultsDialog
             // 
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@@ -120,5 +126,6 @@
         private System.Windows.Forms.ImageList imageList1;
         private System.Windows.Forms.Button SaveReportBtn;
         private System.Windows.Forms.SaveFileDialog saveFileDialog;
+        private System.Windows.Forms.ColumnHeader columnHeader3;
     }
 }
\ No newline at end of file

Modified: branches/maestro-4.0.x/Maestro.Base/UI/ValidationResultsDialog.resx
===================================================================
--- branches/maestro-4.0.x/Maestro.Base/UI/ValidationResultsDialog.resx	2012-07-11 14:39:57 UTC (rev 6892)
+++ branches/maestro-4.0.x/Maestro.Base/UI/ValidationResultsDialog.resx	2012-07-11 14:46:38 UTC (rev 6893)
@@ -204,12 +204,24 @@
   <data name="columnHeader1.Width" type="System.Int32, mscorlib">
     <value>240</value>
   </data>
+  <data name="columnHeader2.DisplayIndex" type="System.Int32, mscorlib">
+    <value>2</value>
+  </data>
   <data name="columnHeader2.Text" xml:space="preserve">
     <value>Message</value>
   </data>
   <data name="columnHeader2.Width" type="System.Int32, mscorlib">
     <value>324</value>
   </data>
+  <data name="columnHeader3.DisplayIndex" type="System.Int32, mscorlib">
+    <value>1</value>
+  </data>
+  <data name="columnHeader3.Text" xml:space="preserve">
+    <value>Code</value>
+  </data>
+  <data name="columnHeader3.Width" type="System.Int32, mscorlib">
+    <value>200</value>
+  </data>
   <data name="listView1.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
     <value>Fill</value>
   </data>
@@ -353,6 +365,12 @@
   <data name=">>saveFileDialog.Type" xml:space="preserve">
     <value>System.Windows.Forms.SaveFileDialog, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </data>
+  <data name=">>columnHeader3.Name" xml:space="preserve">
+    <value>columnHeader3</value>
+  </data>
+  <data name=">>columnHeader3.Type" xml:space="preserve">
+    <value>System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </data>
   <data name=">>$this.Name" xml:space="preserve">
     <value>ValidationResultsDialog</value>
   </data>

Modified: branches/maestro-4.0.x/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs
===================================================================
--- branches/maestro-4.0.x/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs	2012-07-11 14:39:57 UTC (rev 6892)
+++ branches/maestro-4.0.x/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs	2012-07-11 14:46:38 UTC (rev 6893)
@@ -1,6 +1,7 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
+//     Runtime Version:4.0.30319.225
 //     Runtime Version:2.0.50727.5448
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
@@ -477,6 +478,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Due to a limitation in the public APIs provided by MapGuide. This Feature Source cannot be packaged by Maestro's packager without discarding the MG_USER_CREDENTIALS element. The workaround is to either re-secure these Feature Sources after loading the Maestro-created package, or to use the official packaging method which will preserve MG_USER_CREDENTIALS in its encrypted state.
+        /// </summary>
+        internal static string FS_CannotPackageSecuredCredentials {
+            get {
+                return ResourceManager.GetString("FS_CannotPackageSecuredCredentials", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Connection test failed: {0}.
         /// </summary>
         internal static string FS_ConnectionTestFailed {
@@ -522,6 +532,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to This Feature Source uses plaintext credentials. This would happen if you are using an old version of Maestro (4.0.2 or older). This is not secure as such Feature Sources can be accessed by the Anonymous MapGuide user account. It is strongly advised that such Feature Sources can be re-secured with MapGuide/Infrastructure Studio or with Maestro 4.0.3 (or newer).
+        /// </summary>
+        internal static string FS_PlaintextCredentials {
+            get {
+                return ResourceManager.GetString("FS_PlaintextCredentials", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to No primary key defined for class: {0}, features will not be selectable and feature joins on this class may produce unexpected results.
         /// </summary>
         internal static string FS_PrimaryKeyMissingInformation {
@@ -558,6 +577,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Feature source content has the %MG_USERNAME% and %MG_PASSWORD% tokens, but does not have the MG_USER_CREDENTIALS resource data item.
+        /// </summary>
+        internal static string FS_SecuredCredentialTokensWithoutSecuredCredentialData {
+            get {
+                return ResourceManager.GetString("FS_SecuredCredentialTokensWithoutSecuredCredentialData", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Failed to read spatial context: {0}.
         /// </summary>
         internal static string FS_SpatialContextReadError {

Modified: branches/maestro-4.0.x/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx
===================================================================
--- branches/maestro-4.0.x/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx	2012-07-11 14:39:57 UTC (rev 6892)
+++ branches/maestro-4.0.x/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx	2012-07-11 14:46:38 UTC (rev 6893)
@@ -548,4 +548,13 @@
   <data name="BaseTemplate240_ApplicationDefinition" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\Resources\BaseTemplate.ApplicationDefinition1.xml;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
   </data>
+  <data name="FS_CannotPackageSecuredCredentials" xml:space="preserve">
+    <value>Due to a limitation in the public APIs provided by MapGuide. This Feature Source cannot be packaged by Maestro's packager without discarding the MG_USER_CREDENTIALS element. The workaround is to either re-secure these Feature Sources after loading the Maestro-created package, or to use the official packaging method which will preserve MG_USER_CREDENTIALS in its encrypted state</value>
+  </data>
+  <data name="FS_PlaintextCredentials" xml:space="preserve">
+    <value>This Feature Source uses plaintext credentials. This would happen if you are using an old version of Maestro (4.0.2 or older). This is not secure as such Feature Sources can be accessed by the Anonymous MapGuide user account. It is strongly advised that such Feature Sources can be re-secured with MapGuide/Infrastructure Studio or with Maestro 4.0.3 (or newer)</value>
+  </data>
+  <data name="FS_SecuredCredentialTokensWithoutSecuredCredentialData" xml:space="preserve">
+    <value>Feature source content has the %MG_USERNAME% and %MG_PASSWORD% tokens, but does not have the MG_USER_CREDENTIALS resource data item</value>
+  </data>
 </root>
\ No newline at end of file

Modified: branches/maestro-4.0.x/OSGeo.MapGuide.MaestroAPI/Resource/Validation/FeatureSourceValidator.cs
===================================================================
--- branches/maestro-4.0.x/OSGeo.MapGuide.MaestroAPI/Resource/Validation/FeatureSourceValidator.cs	2012-07-11 14:39:57 UTC (rev 6892)
+++ branches/maestro-4.0.x/OSGeo.MapGuide.MaestroAPI/Resource/Validation/FeatureSourceValidator.cs	2012-07-11 14:46:38 UTC (rev 6893)
@@ -58,10 +58,55 @@
 
             IFeatureSource feature = (IFeatureSource)resource;
             IFeatureService featSvc = feature.CurrentConnection.FeatureService;
+
+            //Plaintext credential check
+            string providerNameUpper = feature.Provider.ToUpper();
+            string fsXml = feature.Serialize().ToUpper();
+
+            //You'll get warnings either way
+            if (providerNameUpper == "OSGEO.SQLSERVERSPATIAL" ||
+                providerNameUpper == "OSGEO.MYSQL" ||
+                providerNameUpper == "OSGEO.POSTGRESQL" ||
+                providerNameUpper == "OSGEO.ARCSDE" ||
+                providerNameUpper == "OSGEO.WFS" ||
+                providerNameUpper == "OSGEO.WMS" ||
+                providerNameUpper == "KING.ORACLE" ||
+                providerNameUpper == "AUTODESK.ORACLE")
+            {
+                //Fortunately, all the above providers are universal in the naming choice of credential connection parameters
+                if ((fsXml.Contains("<NAME>USERNAME</NAME>") && !fsXml.Contains("%MG_USERNAME%")) || (fsXml.Contains("<NAME>PASSWORD</NAME>") && !fsXml.Contains("%MG_PASSWORD%")))
+                    issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, ValidationStatusCode.Warning_FeatureSource_Plaintext_Credentials, Properties.Resources.FS_PlaintextCredentials));
+                else
+                    issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, ValidationStatusCode.Warning_FeatureSource_Cannot_Package_Secured_Credentials, Properties.Resources.FS_CannotPackageSecuredCredentials));
+
+                //Has the placeholder token(s)
+                if (fsXml.Contains("%MG_USERNAME%") || fsXml.Contains("%MG_PASSWORD%"))
+                {
+                    //Find the MG_USER_CREDENTIALS resource data item
+                    bool bFound = false;
+                    var resData = feature.EnumerateResourceData();
+                    foreach (var data in resData)
+                    {
+                        if (data.Name == "MG_USER_CREDENTIALS")
+                        {
+                            bFound = true;
+                        }
+                    }
+
+                    if (!bFound)
+                    {
+                        issues.Add(new ValidationIssue(feature, ValidationStatus.Error, ValidationStatusCode.Error_FeatureSource_SecuredCredentialTokensWithoutSecuredCredentialData, Properties.Resources.FS_SecuredCredentialTokensWithoutSecuredCredentialData));
+                    }
+                }
+            }
+            
             //Note: Must be saved!
             string s = featSvc.TestConnection(feature.ResourceID);
             if (s.Trim().ToUpper() != true.ToString().ToUpper())
-                return new ValidationIssue[] { new ValidationIssue(feature, ValidationStatus.Error, ValidationStatusCode.Error_FeatureSource_ConnectionTestFailed, string.Format(Properties.Resources.FS_ConnectionTestFailed, s)) };
+            {
+                issues.Add(new ValidationIssue(feature, ValidationStatus.Error, ValidationStatusCode.Error_FeatureSource_ConnectionTestFailed, string.Format(Properties.Resources.FS_ConnectionTestFailed, s)));
+                return issues.ToArray();
+            }
 
             try
             {

Modified: branches/maestro-4.0.x/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ValidationStatusCode.cs
===================================================================
--- branches/maestro-4.0.x/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ValidationStatusCode.cs	2012-07-11 14:39:57 UTC (rev 6892)
+++ branches/maestro-4.0.x/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ValidationStatusCode.cs	2012-07-11 14:46:38 UTC (rev 6893)
@@ -99,6 +99,21 @@
         Warning_FeatureSource_NoSchemasFound,
 
         /// <summary>
+        /// Due to a limitation in the public APIs provided by MapGuide. Feature Sources with encrypted security credentials (MG_USER_CREDENTIALS)
+        /// cannot be packaged by Maestro's packager without discarding the MG_USER_CREDENTIALS element. The workaround is to either re-secure these
+        /// feature sources after loading the Maestro-created package, or to use the official packaging method which will preserve MG_USER_CREDENTIALS
+        /// in its encrypted state
+        /// </summary>
+        Warning_FeatureSource_Cannot_Package_Secured_Credentials,
+        
+        /// <summary>
+        /// A Feature Source whose provider contains username/password connection parameters contains login credentials in plaintext. This is not secure
+        /// as such Feature Sources can be accessed by the Anonymous MapGuide user account. It is strongly advised that such Feature Sources can be 
+        /// re-secured with MapGuide/Infrastructure Studio or with Maestro 4.0.3 (or newer)
+        /// </summary>
+        Warning_FeatureSource_Plaintext_Credentials,
+
+        /// <summary>
         /// DWG Load Procedures not supported. This is a limitation of Maestro
         /// </summary>
         Warning_LoadProcedure_DwgNotSupported = 3201,
@@ -215,6 +230,12 @@
         Error_FeatureSource_SchemaReadError,
 
         /// <summary>
+        /// The validator found the %MG_USERNAME% and %MG_PASSWORD% placeholder tokens in the Feature Source content, but could not find the
+        /// matching MG_USER_CREDENTIALS resource data item that contains the encrypted credentials
+        /// </summary>
+        Error_FeatureSource_SecuredCredentialTokensWithoutSecuredCredentialData,
+
+        /// <summary>
         /// No finite display scales defined for a map definition that contains tiled layers.
         /// </summary>
         Error_MapDefinition_NoFiniteDisplayScales = 5201,



More information about the mapguide-commits mailing list