diff --git a/CASA.changes b/CASA.changes index 27a1149f..d922a812 100644 --- a/CASA.changes +++ b/CASA.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Feb 17 14:01:12 MST 2006 - jnorman@novell.com + +- Bug 135386: Linking secrets with colon in the name - FIXED + ------------------------------------------------------------------- Fri Feb 17 21:31:10 IST 2006 - smanojna@novell.com diff --git a/c_gui/MiCasa.cs b/c_gui/MiCasa.cs index 9994ec44..c4e88f27 100644 --- a/c_gui/MiCasa.cs +++ b/c_gui/MiCasa.cs @@ -1018,7 +1018,7 @@ public class MiCasa : Store while (ienum.MoveNext()) { LinkedKeyInfo lki = (LinkedKeyInfo) ienum.Value; - tsLinkedKeys.AppendValues(lki.GetLinkedSecretID(), lki.GetLinkedKeyID()); + tsLinkedKeys.AppendValues(lki.GetLinkedSecretID(true), lki.GetLinkedKeyID()); } } } @@ -1071,7 +1071,7 @@ public class MiCasa : Store //tsLinkedKeys.AppendValues(selectedSecret, selectedKey); // add a null terminator to the secretid - selectedSecret = selectedSecret + '\0'; + //selectedSecret = selectedSecret + '\0'; LinkedKeyInfo lki = new LinkedKeyInfo(selectedSecret, selectedKey); MiCasaRequestReply.Send(MiCasaRequestReply.VERB_SET_LINKED_KEY, null, labelLinkSecretID.Text, labelLinkKeyID.Text, lki); @@ -1093,7 +1093,7 @@ public class MiCasa : Store { selectedSecret = (string) model.GetValue(iter,0); // add NULL - selectedSecret = selectedSecret + '\0'; + selectedSecret = selectedSecret; selectedKey = (string) model.GetValue(iter,1); LinkedKeyInfo lki = new LinkedKeyInfo(selectedSecret, selectedKey); diff --git a/c_micasad/lib/common/LinkedKeyInfo.cs b/c_micasad/lib/common/LinkedKeyInfo.cs index bbf047af..1ef554a4 100644 --- a/c_micasad/lib/common/LinkedKeyInfo.cs +++ b/c_micasad/lib/common/LinkedKeyInfo.cs @@ -38,14 +38,35 @@ namespace Novell.CASA.MiCasa.Common public LinkedKeyInfo(string sDestSecretID, string sDestKey) { - if (sDestSecretID.StartsWith("SS_CredSet")) - m_sDestSecretID = sDestSecretID; - else - m_sDestSecretID = "SS_CredSet:" + sDestSecretID + '\0'; + if (sDestSecretID != null) + { + if (sDestSecretID.StartsWith("SS_CredSet")) + sDestSecretID = "SS_CredSet:" + Utils.EscapeReservedChars(sDestSecretID.Substring(11)) + '\0'; + else + sDestSecretID = "SS_CredSet:" + Utils.EscapeReservedChars(sDestSecretID) + '\0'; + } + m_sDestSecretID = sDestSecretID; m_sDestKeyID = sDestKey; } + public LinkedKeyInfo(string sDestSecretID, string sDestKey, bool bAlreadyEscaped) + { + if (!bAlreadyEscaped) + { + if (sDestSecretID != null) + { + if (sDestSecretID.StartsWith("SS_CredSet")) + sDestSecretID = "SS_CredSet:" + Utils.EscapeReservedChars(sDestSecretID.Substring(11)) + '\0'; + else + sDestSecretID = "SS_CredSet:" + Utils.EscapeReservedChars(sDestSecretID) + '\0'; + } + } + + m_sDestSecretID = sDestSecretID; + m_sDestKeyID = sDestKey; + } + public string GetLinkID() { return m_sDestSecretID + ":" + m_sDestKeyID; @@ -56,6 +77,19 @@ namespace Novell.CASA.MiCasa.Common return m_sDestSecretID; } + public string GetLinkedSecretID(bool bUnescape) + { + if (bUnescape) + { + if (m_sDestSecretID.StartsWith("SS_CredSet")) + return ("SS_CredSet:" + Utils.UnescapeString(m_sDestSecretID.Substring(11))); + else + return Utils.UnescapeString(m_sDestSecretID); + } + return m_sDestSecretID; + + } + public string GetLinkedKeyID() { return m_sDestKeyID; diff --git a/c_micasad/lib/common/Utils.cs b/c_micasad/lib/common/Utils.cs new file mode 100644 index 00000000..fb9a2315 --- /dev/null +++ b/c_micasad/lib/common/Utils.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Novell.CASA.MiCasa.Common +{ + class Utils + { + public static string EscapeReservedChars(string origString) + { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < origString.Length; i++) + { + switch (origString[i]) + { + case ':': + { + sb.Append("\\"); + break; + } + case '\\': + { + sb.Append("\\"); + break; + } + case '=': + { + sb.Append("\\"); + break; + } + + } + sb.Append(origString[i]); + } + return sb.ToString(); + } + + public static string UnescapeString(string sOrig) + { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < sOrig.Length; i++) + { + if (sOrig[i].Equals('\\')) + { + if (i + 1 < sOrig.Length) + { + if (sOrig[i + 1].Equals(':') + || sOrig[i + 1].Equals('\\') + || sOrig[i + 1].Equals('=')) + { + i++; + } + } + } + + sb.Append(sOrig[i]); + } + return sb.ToString(); + } + } +} diff --git a/c_micasad/lib/common/WrappedObject.cs b/c_micasad/lib/common/WrappedObject.cs index 87d2b658..8e9a9b6d 100644 --- a/c_micasad/lib/common/WrappedObject.cs +++ b/c_micasad/lib/common/WrappedObject.cs @@ -61,13 +61,13 @@ namespace Novell.CASA.MiCasa.Common if (sSecretID != null) { if (sSecretID.StartsWith("SS_CredSet")) - m_SecretID = "SS_CredSet:" + EscapeReservedChars(sSecretID.Substring(11)) + '\0'; + m_SecretID = "SS_CredSet:" + Utils.EscapeReservedChars(sSecretID.Substring(11)) + '\0'; else - m_SecretID = "SS_CredSet:" + EscapeReservedChars(sSecretID) + '\0'; + m_SecretID = "SS_CredSet:" + Utils.EscapeReservedChars(sSecretID) + '\0'; } if (sKeyID != null) - m_KeyID = EscapeReservedChars(sKeyID); // + '\0'; + m_KeyID = Utils.EscapeReservedChars(sKeyID); // + '\0'; // serialize the object m_object = theObject; @@ -118,34 +118,5 @@ namespace Novell.CASA.MiCasa.Common { return m_errorMsg; } - - private string EscapeReservedChars(string origString) - { - StringBuilder sb = new StringBuilder(); - for (int i=0; i